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

Chuanqi Xu via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 20 04:05:55 PDT 2024


================
@@ -137,7 +137,10 @@ template<> struct DenseMapInfo<unsigned long> {
   static inline unsigned long getTombstoneKey() { return ~0UL - 1L; }
 
   static unsigned getHashValue(const unsigned long& Val) {
-    return (unsigned)(Val * 37UL);
+    if constexpr (sizeof(Val) == 4)
+      return DenseMapInfo<unsigned>::getHashValue(Val);
+    else
+      return detail::combineHashValue(Val >> 32, Val);
----------------
ChuanqiXu9 wrote:

Thanks. You can land that directly to make the build green. But I don't understand in what cases it is a problem. I think I've already handled the case for its size is 4. I don't feel it is possible that `sizeof(Val)` may evaluate to `2` here.

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


More information about the llvm-commits mailing list