Index: llvm/include/llvm/IR/ValueHandle.h =================================================================== --- llvm/include/llvm/IR/ValueHandle.h +++ llvm/include/llvm/IR/ValueHandle.h @@ -307,30 +307,10 @@ ValueTy &operator*() const { return *getValPtr(); } }; -// Specialize DenseMapInfo to allow AssertingVH to participate in DenseMap. +// Treat AssertingVH like T* inside maps. This also allows using find_by() +// to look up a value without constructing a value handle. template -struct DenseMapInfo> { - static inline AssertingVH getEmptyKey() { - AssertingVH Res; - Res.setRawValPtr(DenseMapInfo::getEmptyKey()); - return Res; - } - - static inline AssertingVH getTombstoneKey() { - AssertingVH Res; - Res.setRawValPtr(DenseMapInfo::getTombstoneKey()); - return Res; - } - - static unsigned getHashValue(const AssertingVH &Val) { - return DenseMapInfo::getHashValue(Val.getRawValPtr()); - } - - static bool isEqual(const AssertingVH &LHS, const AssertingVH &RHS) { - return DenseMapInfo::isEqual(LHS.getRawValPtr(), - RHS.getRawValPtr()); - } -}; +struct DenseMapInfo> : public DenseMapInfo {}; /// Value handle that tracks a Value across RAUW. /// @@ -562,6 +542,17 @@ return DenseMapInfo::isEqual(LHS.getRawValPtr(), RHS.getRawValPtr()); } + + // Allow lookup by T* via find_by(), without constructing a temporary + // value handle. + + static unsigned getHashValue(const T *Val) { + return DenseMapInfo::getHashValue(Val); + } + + static bool isEqual(const T *LHS, const PoisoningVH &RHS) { + return DenseMapInfo::isEqual(LHS, RHS.getRawValPtr()); + } }; } // end namespace llvm