[llvm] 78daab0 - [Attributor][NFCI] Compute ReachabilityQueryInfo hash once and on demand
Johannes Doerfert via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 3 00:13:09 PDT 2023
Author: Johannes Doerfert
Date: 2023-08-03T00:12:46-07:00
New Revision: 78daab0a85a9d1055d0060897779d1caada37df4
URL: https://github.com/llvm/llvm-project/commit/78daab0a85a9d1055d0060897779d1caada37df4
DIFF: https://github.com/llvm/llvm-project/commit/78daab0a85a9d1055d0060897779d1caada37df4.diff
LOG: [Attributor][NFCI] Compute ReachabilityQueryInfo hash once and on demand
Added:
Modified:
llvm/lib/Transforms/IPO/AttributorAttributes.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
index 0774b9880590da..15dada6f854bde 100644
--- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -3441,6 +3441,18 @@ template <typename ToTy> struct ReachabilityQueryInfo {
/// and remember if it worked:
Reachable Result = Reachable::No;
+ /// Precomputed hash for this RQI.
+ unsigned Hash = 0;
+
+ unsigned computeHashValue() const {
+ assert(Hash == 0 && "Computed hash twice!");
+ using InstSetDMI = DenseMapInfo<const AA::InstExclusionSetTy *>;
+ using PairDMI = DenseMapInfo<std::pair<const Instruction *, const ToTy *>>;
+ return const_cast<ReachabilityQueryInfo<ToTy> *>(this)->Hash =
+ detail::combineHashValue(PairDMI ::getHashValue({From, To}),
+ InstSetDMI::getHashValue(ExclusionSet));
+ }
+
ReachabilityQueryInfo(const Instruction *From, const ToTy *To)
: From(From), To(To) {}
@@ -3474,9 +3486,7 @@ template <typename ToTy> struct DenseMapInfo<ReachabilityQueryInfo<ToTy> *> {
return &TombstoneKey;
}
static unsigned getHashValue(const ReachabilityQueryInfo<ToTy> *RQI) {
- unsigned H = PairDMI ::getHashValue({RQI->From, RQI->To});
- H += InstSetDMI::getHashValue(RQI->ExclusionSet);
- return H;
+ return RQI->Hash ? RQI->Hash : RQI->computeHashValue();
}
static bool isEqual(const ReachabilityQueryInfo<ToTy> *LHS,
const ReachabilityQueryInfo<ToTy> *RHS) {
More information about the llvm-commits
mailing list