[llvm] ab07c51 - [memprof] Don't use Frame::hash() (NFC) (#119828)

via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 13 13:58:52 PST 2024


Author: Kazu Hirata
Date: 2024-12-13T13:58:48-08:00
New Revision: ab07c51534b904bab55bcaaf950823fc72719b11

URL: https://github.com/llvm/llvm-project/commit/ab07c51534b904bab55bcaaf950823fc72719b11
DIFF: https://github.com/llvm/llvm-project/commit/ab07c51534b904bab55bcaaf950823fc72719b11.diff

LOG: [memprof] Don't use Frame::hash() (NFC) (#119828)

In these tests, we just want to add one instance of
IndexedMemProfRecord to MemProfData.Records and retrieve it from
MemProfReader.  There is no particular reason to associate F1.hash()
with the IndexedMemProfRecord instance.  A fake value suffices.

While I am at it, I'm switching to try_emplace so that I can move
FakeRecord.

Added: 
    

Modified: 
    llvm/unittests/ProfileData/MemProfTest.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/unittests/ProfileData/MemProfTest.cpp b/llvm/unittests/ProfileData/MemProfTest.cpp
index af801d0ff5e1e2..2cb4725ab89e38 100644
--- a/llvm/unittests/ProfileData/MemProfTest.cpp
+++ b/llvm/unittests/ProfileData/MemProfTest.cpp
@@ -422,7 +422,7 @@ TEST(MemProf, BaseMemProfReader) {
   Block.AllocCount = 1U, Block.TotalAccessDensity = 4,
   Block.TotalLifetime = 200001;
   FakeRecord.AllocSites.emplace_back(/*CSId=*/CSId, /*MB=*/Block);
-  MemProfData.Records.insert({F1.hash(), FakeRecord});
+  MemProfData.Records.try_emplace(0x1234, std::move(FakeRecord));
 
   MemProfReader Reader(std::move(MemProfData));
 
@@ -454,7 +454,7 @@ TEST(MemProf, BaseMemProfReaderWithCSIdMap) {
   Block.AllocCount = 1U, Block.TotalAccessDensity = 4,
   Block.TotalLifetime = 200001;
   FakeRecord.AllocSites.emplace_back(/*CSId=*/CSId, /*MB=*/Block);
-  MemProfData.Records.insert({F1.hash(), FakeRecord});
+  MemProfData.Records.try_emplace(0x1234, std::move(FakeRecord));
 
   MemProfReader Reader(std::move(MemProfData));
 


        


More information about the llvm-commits mailing list