diff --git a/llvm/include/llvm/ProfileData/MemProfReader.h b/llvm/include/llvm/ProfileData/MemProfReader.h index 9a0857fee6cc2..57ddcbf350060 100644 --- a/llvm/include/llvm/ProfileData/MemProfReader.h +++ b/llvm/include/llvm/ProfileData/MemProfReader.h @@ -117,6 +117,8 @@ class MemProfReader { virtual ~MemProfReader() = default; // Initialize the MemProfReader with the frame mappings and profile contents. + LLVM_DEPRECATED("Construct MemProfReader with IndexedMemProfData", + "MemProfReader") MemProfReader( llvm::DenseMap FrameIdMap, llvm::MapVector ProfData); diff --git a/llvm/unittests/ProfileData/MemProfTest.cpp b/llvm/unittests/ProfileData/MemProfTest.cpp index e68cc09433873..79b644dc5a528 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 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 CallStack{F1.hash(), F2.hash()}; + CallStackId CSId = llvm::memprof::hashCallStack(CallStack); + MemProfData.CallStacks.try_emplace(CSId, CallStack); - llvm::MapVector ProfData; IndexedMemProfRecord FakeRecord; MemInfoBlock Block; Block.AllocCount = 1U, Block.TotalAccessDensity = 4, Block.TotalLifetime = 200001; - std::array 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 Records; for (const auto &KeyRecordPair : Reader) {