[llvm] e24c9e7 - [IR] improve hashing quality for ValueInfo (#132917)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 9 06:44:39 PDT 2025
Author: Zhaoxuan Jiang
Date: 2025-04-09T06:44:35-07:00
New Revision: e24c9e7a0c61ed49e79433d405cb5157483ce691
URL: https://github.com/llvm/llvm-project/commit/e24c9e7a0c61ed49e79433d405cb5157483ce691
DIFF: https://github.com/llvm/llvm-project/commit/e24c9e7a0c61ed49e79433d405cb5157483ce691.diff
LOG: [IR] improve hashing quality for ValueInfo (#132917)
The current hashing quality for `ValueInfo` is poor because it uses
pointers as the hash value, which can negatively impact performance in
various places that use a `DenseSet`/`Map` of `ValueInfo`. In one
observed case, `ModuleSummaryIndex::propagateAttributes()` was taking
about 25 minutes to complete on a ThinLTO application. Profiling
revealed that the majority of this time was spent operating on the
`MarkedNonReadWriteOnly` set.
With the improved hashing, the execution time for `propagateAttributes`
is dramatically reduced to less than 10 seconds.
Added:
Modified:
llvm/include/llvm/IR/ModuleSummaryIndex.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/IR/ModuleSummaryIndex.h b/llvm/include/llvm/IR/ModuleSummaryIndex.h
index 2650456c49841..7aa36345268cd 100644
--- a/llvm/include/llvm/IR/ModuleSummaryIndex.h
+++ b/llvm/include/llvm/IR/ModuleSummaryIndex.h
@@ -300,7 +300,7 @@ template <> struct DenseMapInfo<ValueInfo> {
assert(isSpecialKey(L) || isSpecialKey(R) || (L.haveGVs() == R.haveGVs()));
return L.getRef() == R.getRef();
}
- static unsigned getHashValue(ValueInfo I) { return (uintptr_t)I.getRef(); }
+ static unsigned getHashValue(ValueInfo I) { return hash_value(I.getRef()); }
};
// For optional hinted size reporting, holds a pair of the full stack id
More information about the llvm-commits
mailing list