[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.
This commit is contained in:
Zhaoxuan Jiang 2025-04-09 21:44:35 +08:00 committed by GitHub
parent 4f64da1495
commit e24c9e7a0c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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