[PATCH] D25643: [IR] Add DenseMapInfo<CallSite>.

Justin Lebar via llvm-commits llvm-commits at lists.llvm.org
Sat Oct 15 15:06:35 PDT 2016


jlebar created this revision.
jlebar added a reviewer: timshen.
jlebar added a subscriber: llvm-commits.

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.


https://reviews.llvm.org/D25643

Files:
  llvm/include/llvm/IR/CallSite.h


Index: llvm/include/llvm/IR/CallSite.h
===================================================================
--- llvm/include/llvm/IR/CallSite.h
+++ llvm/include/llvm/IR/CallSite.h
@@ -623,9 +623,31 @@
   }
 
 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:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25643.74771.patch
Type: text/x-patch
Size: 980 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161015/733c4746/attachment.bin>


More information about the llvm-commits mailing list