@@ -323,21 +323,6 @@ struct Frame {
323
323
<< " Column: " << Column << " \n "
324
324
<< " Inline: " << IsInlineFrame << " \n " ;
325
325
}
326
-
327
- // Return a hash value based on the contents of the frame. Here we use a
328
- // cryptographic hash function to minimize the chance of hash collisions. We
329
- // do persist FrameIds as part of memprof formats up to Version 2, inclusive.
330
- // However, the deserializer never calls this function; it uses FrameIds
331
- // merely as keys to look up Frames proper.
332
- inline FrameId hash () const {
333
- llvm::HashBuilder<llvm::TruncatedBLAKE3<8 >, llvm::endianness::little>
334
- HashBuilder;
335
- HashBuilder.add (Function, LineOffset, Column, IsInlineFrame);
336
- llvm::BLAKE3Result<8 > Hash = HashBuilder.final ();
337
- FrameId Id;
338
- std::memcpy (&Id, Hash.data (), sizeof (Hash));
339
- return Id;
340
- }
341
326
};
342
327
343
328
// A type representing the index into the table of call stacks.
@@ -775,9 +760,6 @@ class CallStackLookupTrait {
775
760
}
776
761
};
777
762
778
- // Compute a CallStackId for a given call stack.
779
- CallStackId hashCallStack (ArrayRef<FrameId> CS);
780
-
781
763
namespace detail {
782
764
// "Dereference" the iterator from DenseMap or OnDiskChainedHashTable. We have
783
765
// to do so in one of two different ways depending on the type of the hash
@@ -1011,7 +993,7 @@ struct IndexedMemProfData {
1011
993
llvm::MapVector<CallStackId, llvm::SmallVector<FrameId>> CallStacks;
1012
994
1013
995
FrameId addFrame (const Frame &F) {
1014
- const FrameId Id = F. hash ( );
996
+ const FrameId Id = hashFrame (F );
1015
997
Frames.try_emplace (Id, F);
1016
998
return Id;
1017
999
}
@@ -1027,6 +1009,25 @@ struct IndexedMemProfData {
1027
1009
CallStacks.try_emplace (CSId, std::move (CS));
1028
1010
return CSId;
1029
1011
}
1012
+
1013
+ private:
1014
+ // Return a hash value based on the contents of the frame. Here we use a
1015
+ // cryptographic hash function to minimize the chance of hash collisions. We
1016
+ // do persist FrameIds as part of memprof formats up to Version 2, inclusive.
1017
+ // However, the deserializer never calls this function; it uses FrameIds
1018
+ // merely as keys to look up Frames proper.
1019
+ FrameId hashFrame (const Frame &F) const {
1020
+ llvm::HashBuilder<llvm::TruncatedBLAKE3<8 >, llvm::endianness::little>
1021
+ HashBuilder;
1022
+ HashBuilder.add (F.Function , F.LineOffset , F.Column , F.IsInlineFrame );
1023
+ llvm::BLAKE3Result<8 > Hash = HashBuilder.final ();
1024
+ FrameId Id;
1025
+ std::memcpy (&Id, Hash.data (), sizeof (Hash));
1026
+ return Id;
1027
+ }
1028
+
1029
+ // Compute a CallStackId for a given call stack.
1030
+ CallStackId hashCallStack (ArrayRef<FrameId> CS) const ;
1030
1031
};
1031
1032
1032
1033
struct FrameStat {
0 commit comments