[llvm] [ADT] Update hash function of uint64_t for DenseMap (PR #95734)

Ilya Biryukov via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 18 09:27:46 PDT 2024


================
@@ -151,7 +151,7 @@ template<> struct DenseMapInfo<unsigned long long> {
   static inline unsigned long long getTombstoneKey() { return ~0ULL - 1ULL; }
 
   static unsigned getHashValue(const unsigned long long& Val) {
-    return (unsigned)(Val * 37ULL);
+    return DenseMapInfo<unsigned>(Val) ^ DenseMapInfo<unsigned>(Val >> 32);
----------------
ilya-biryukov wrote:

Maybe we should switch all `DenseMapInfo` for all integer types to  `llvm::hash_value`?
@chandlerc suggested to use it in his response and he does not expect this to cause any problems.
The code would be simple and we will get to reuse it in more places.

I am not sure how much worse the build times will get, but this should be easy to address by having declarations with functions hashing integers in a separate header.
I feel it should not be a blocker to using the hash function that we feel is better otherwise.

https://github.com/llvm/llvm-project/pull/95734


More information about the llvm-commits mailing list