Skip to content

Commit 007929b

Browse files
committed
[IR] improve hashing quality for ValueInfo
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.
1 parent 3086546 commit 007929b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

llvm/include/llvm/IR/ModuleSummaryIndex.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ template <> struct DenseMapInfo<ValueInfo> {
300300
assert(isSpecialKey(L) || isSpecialKey(R) || (L.haveGVs() == R.haveGVs()));
301301
return L.getRef() == R.getRef();
302302
}
303-
static unsigned getHashValue(ValueInfo I) { return (uintptr_t)I.getRef(); }
303+
static unsigned getHashValue(ValueInfo I) { return hash_value(I.getRef()); }
304304
};
305305

306306
// For optional hinted size reporting, holds a pair of the full stack id

0 commit comments

Comments
 (0)