[llvm] [memprof] Use BLAKE for FrameId (PR #109501)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 24 15:29:31 PDT 2024


================
@@ -312,20 +314,13 @@ struct Frame {
   // hashing from llvm ADT since we are going to persist the hash id, the hash
   // combine algorithm in ADT uses a new randomized seed each time.
   inline FrameId hash() const {
-    auto HashCombine = [](auto Value, size_t Seed) {
-      std::hash<decltype(Value)> Hasher;
-      // The constant used below is the 64 bit representation of the fractional
-      // part of the golden ratio. Used here for the randomness in their bit
-      // pattern.
-      return Hasher(Value) + 0x9e3779b97f4a7c15 + (Seed << 6) + (Seed >> 2);
-    };
-
-    size_t Result = 0;
-    Result ^= HashCombine(Function, Result);
-    Result ^= HashCombine(LineOffset, Result);
-    Result ^= HashCombine(Column, Result);
-    Result ^= HashCombine(IsInlineFrame, Result);
-    return static_cast<FrameId>(Result);
+    llvm::HashBuilder<llvm::TruncatedBLAKE3<8>, llvm::endianness::little>
----------------
kazutakahirata wrote:

Thanks!  As I noted in https://github.com/llvm/llvm-project/pull/109501#issuecomment-2370345195, I'm planning to use BLAKE as a short-term solution.  I'm going to replace it with something else in the long term.

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


More information about the llvm-commits mailing list