]> granicus.if.org Git - llvm/commitdiff
[IR] Add DenseMapInfo<CallSite>.
authorJustin Lebar <jlebar@google.com>
Fri, 21 Oct 2016 20:10:44 +0000 (20:10 +0000)
committerJustin Lebar <jlebar@google.com>
Fri, 21 Oct 2016 20:10:44 +0000 (20:10 +0000)
Summary:
A CallSite is basically an Instruction*, and you can put Instruction*s
into DenseMaps, so you should be able to do the same with CallSites.

This is used in a later patch.

Reviewers: timshen

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D25643

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284870 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/IR/CallSite.h

index f8f31f6608e4754ef9d5f15d2a7ee05157f306c3..4078499274318988587b208aed9d83e00d95efe2 100644 (file)
@@ -623,9 +623,31 @@ public:
   }
 
 private:
+  friend struct DenseMapInfo<CallSite>;
   User::op_iterator getCallee() const;
 };
 
+template <> struct DenseMapInfo<CallSite> {
+  using BaseInfo = llvm::DenseMapInfo<decltype(CallSite::I)>;
+
+  static CallSite getEmptyKey() {
+    CallSite CS;
+    CS.I = BaseInfo::getEmptyKey();
+    return CS;
+  }
+  static CallSite getTombstoneKey() {
+    CallSite CS;
+    CS.I = BaseInfo::getTombstoneKey();
+    return CS;
+  }
+  static unsigned getHashValue(const CallSite &CS) {
+    return BaseInfo::getHashValue(CS.I);
+  }
+  static bool isEqual(const CallSite &LHS, const CallSite &RHS) {
+    return LHS == RHS;
+  }
+};
+
 /// ImmutableCallSite - establish a view to a call site for examination
 class ImmutableCallSite : public CallSiteBase<> {
 public: