[llvm] r284870 - [IR] Add DenseMapInfo<CallSite>.

Justin Lebar via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 21 13:10:44 PDT 2016


Author: jlebar
Date: Fri Oct 21 15:10:44 2016
New Revision: 284870

URL: http://llvm.org/viewvc/llvm-project?rev=284870&view=rev
Log:
[IR] Add DenseMapInfo<CallSite>.

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

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

Modified: llvm/trunk/include/llvm/IR/CallSite.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/CallSite.h?rev=284870&r1=284869&r2=284870&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/CallSite.h (original)
+++ llvm/trunk/include/llvm/IR/CallSite.h Fri Oct 21 15:10:44 2016
@@ -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:




More information about the llvm-commits mailing list