diff options
author | Kazu Hirata <kazu@google.com> | 2024-11-20 10:52:17 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-20 10:52:17 -0800 |
commit | b170ab21c3cd16c1fc1917d91092b221b4163442 (patch) | |
tree | 4f2ae1118f1d566d9ef04e79d5f4d2671b9656f6 /llvm/unittests/ProfileData/MemProfTest.cpp | |
parent | d5032b9f4b6aa415e7fd39701f29edb93028d8b3 (diff) | |
download | llvm-b170ab21c3cd16c1fc1917d91092b221b4163442.zip llvm-b170ab21c3cd16c1fc1917d91092b221b4163442.tar.gz llvm-b170ab21c3cd16c1fc1917d91092b221b4163442.tar.bz2 |
[memprof] Construct MemProfReader with IndexedMemProfData (#117022)
This patch updates a unit test to construct MemProfReader with
IndexedMemProfData, a complete package of MemProf profile.
With this change, nobody in the LLVM codebase is using the
MemProfReader constructor that takes individual components of the
MemProf profile, so this patch deprecates the constructor.
Diffstat (limited to 'llvm/unittests/ProfileData/MemProfTest.cpp')
-rw-r--r-- | llvm/unittests/ProfileData/MemProfTest.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/llvm/unittests/ProfileData/MemProfTest.cpp b/llvm/unittests/ProfileData/MemProfTest.cpp index e68cc09..79b644d 100644 --- a/llvm/unittests/ProfileData/MemProfTest.cpp +++ b/llvm/unittests/ProfileData/MemProfTest.cpp @@ -454,26 +454,26 @@ TEST(MemProf, SymbolizationFilter) { } TEST(MemProf, BaseMemProfReader) { - llvm::DenseMap<FrameId, Frame> FrameIdMap; + llvm::memprof::IndexedMemProfData MemProfData; Frame F1(/*Hash=*/IndexedMemProfRecord::getGUID("foo"), /*LineOffset=*/20, /*Column=*/5, /*IsInlineFrame=*/true); Frame F2(/*Hash=*/IndexedMemProfRecord::getGUID("bar"), /*LineOffset=*/10, /*Column=*/2, /*IsInlineFrame=*/false); - FrameIdMap.insert({F1.hash(), F1}); - FrameIdMap.insert({F2.hash(), F2}); + MemProfData.Frames.insert({F1.hash(), F1}); + MemProfData.Frames.insert({F2.hash(), F2}); + + llvm::SmallVector<FrameId> CallStack{F1.hash(), F2.hash()}; + CallStackId CSId = llvm::memprof::hashCallStack(CallStack); + MemProfData.CallStacks.try_emplace(CSId, CallStack); - llvm::MapVector<llvm::GlobalValue::GUID, IndexedMemProfRecord> ProfData; IndexedMemProfRecord FakeRecord; MemInfoBlock Block; Block.AllocCount = 1U, Block.TotalAccessDensity = 4, Block.TotalLifetime = 200001; - std::array<FrameId, 2> CallStack{F1.hash(), F2.hash()}; - FakeRecord.AllocSites.emplace_back( - /*CS=*/CallStack, /*CSId=*/llvm::memprof::hashCallStack(CallStack), - /*MB=*/Block); - ProfData.insert({F1.hash(), FakeRecord}); + FakeRecord.AllocSites.emplace_back(/*CSId=*/CSId, /*MB=*/Block); + MemProfData.Records.insert({F1.hash(), FakeRecord}); - MemProfReader Reader(FrameIdMap, ProfData); + MemProfReader Reader(MemProfData); llvm::SmallVector<MemProfRecord, 1> Records; for (const auto &KeyRecordPair : Reader) { |