[llvm] [memprof] Use BLAKE for FrameId (PR #109501)
    Anton Korobeynikov via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Fri Sep 20 19:47:50 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>
----------------
asl wrote:
What is the performance implication of using a cryptographic hash function?
https://github.com/llvm/llvm-project/pull/109501
    
    
More information about the llvm-commits
mailing list