[llvm] [memprof] Construct MemProfReader with IndexedMemProfData (PR #117022)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 20 10:40:04 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-pgo
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/117022.diff
2 Files Affected:
- (modified) llvm/include/llvm/ProfileData/MemProfReader.h (+2)
- (modified) llvm/unittests/ProfileData/MemProfTest.cpp (+10-10)
``````````diff
diff --git a/llvm/include/llvm/ProfileData/MemProfReader.h b/llvm/include/llvm/ProfileData/MemProfReader.h
index 9a0857fee6cc2a..57ddcbf350060c 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<FrameId, Frame> FrameIdMap,
llvm::MapVector<GlobalValue::GUID, IndexedMemProfRecord> ProfData);
diff --git a/llvm/unittests/ProfileData/MemProfTest.cpp b/llvm/unittests/ProfileData/MemProfTest.cpp
index e68cc094338736..79b644dc5a528d 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) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/117022
More information about the llvm-commits
mailing list