@@ -323,21 +323,6 @@ struct Frame {
323323 << " Column: " << Column << " \n "
324324 << " Inline: " << IsInlineFrame << " \n " ;
325325 }
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- }
341326};
342327
343328// A type representing the index into the table of call stacks.
@@ -775,9 +760,6 @@ class CallStackLookupTrait {
775760 }
776761};
777762
778- // Compute a CallStackId for a given call stack.
779- CallStackId hashCallStack (ArrayRef<FrameId> CS);
780-
781763namespace detail {
782764// "Dereference" the iterator from DenseMap or OnDiskChainedHashTable. We have
783765// to do so in one of two different ways depending on the type of the hash
@@ -1011,7 +993,7 @@ struct IndexedMemProfData {
1011993 llvm::MapVector<CallStackId, llvm::SmallVector<FrameId>> CallStacks;
1012994
1013995 FrameId addFrame (const Frame &F) {
1014- const FrameId Id = F. hash ( );
996+ const FrameId Id = hashFrame (F );
1015997 Frames.try_emplace (Id, F);
1016998 return Id;
1017999 }
@@ -1027,6 +1009,25 @@ struct IndexedMemProfData {
10271009 CallStacks.try_emplace (CSId, std::move (CS));
10281010 return CSId;
10291011 }
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 ;
10301031};
10311032
10321033struct FrameStat {
0 commit comments