[llvm] r275041 - Allow BasicBlockEdge to be used in DenseMap

Daniel Berlin via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 10 21:37:53 PDT 2016


Author: dannyb
Date: Sun Jul 10 23:37:53 2016
New Revision: 275041

URL: http://llvm.org/viewvc/llvm-project?rev=275041&view=rev
Log:
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

Modified:
    llvm/trunk/include/llvm/IR/Dominators.h

Modified: llvm/trunk/include/llvm/IR/Dominators.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Dominators.h?rev=275041&r1=275040&r2=275041&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Dominators.h (original)
+++ llvm/trunk/include/llvm/IR/Dominators.h Sun Jul 10 23:37:53 2016
@@ -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.
 ///




More information about the llvm-commits mailing list