Allow BasicBlockEdge to be used in DenseMap

Summary: Add a DenseMapInfo specialization for BasicBlockEdge

Reviewers: hfinkel, chandlerc, majnemer

Differential Revision: http://reviews.llvm.org/D22207

llvm-svn: 275041
This commit is contained in:
Daniel Berlin 2016-07-11 04:37:53 +00:00
parent 60e5bdc470
commit e64985fc94
1 changed files with 21 additions and 0 deletions

View File

@ -15,6 +15,7 @@
#ifndef LLVM_IR_DOMINATORS_H
#define LLVM_IR_DOMINATORS_H
#include "llvm/ADT/DenseMapInfo.h"
#include "llvm/ADT/GraphTraits.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/IR/CFG.h"
@ -54,6 +55,26 @@ public:
bool isSingleEdge() const;
};
template <> struct DenseMapInfo<BasicBlockEdge> {
static unsigned getHashValue(const BasicBlockEdge *V);
typedef DenseMapInfo<const BasicBlock *> BBInfo;
static inline BasicBlockEdge getEmptyKey() {
return BasicBlockEdge(BBInfo::getEmptyKey(), BBInfo::getEmptyKey());
}
static inline BasicBlockEdge getTombstoneKey() {
return BasicBlockEdge(BBInfo::getTombstoneKey(), BBInfo::getTombstoneKey());
}
static unsigned getHashValue(const BasicBlockEdge &Edge) {
return hash_combine(BBInfo::getHashValue(Edge.getStart()),
BBInfo::getHashValue(Edge.getEnd()));
}
static bool isEqual(const BasicBlockEdge &LHS, const BasicBlockEdge &RHS) {
return BBInfo::isEqual(LHS.getStart(), RHS.getStart()) &&
BBInfo::isEqual(LHS.getEnd(), RHS.getEnd());
}
};
/// \brief Concrete subclass of DominatorTreeBase that is used to compute a
/// normal dominator tree.
///