aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/ProfileData/MemProfTest.cpp
diff options
context:
space:
mode:
authorKazu Hirata <kazu@google.com>2024-11-20 08:35:54 -0800
committerGitHub <noreply@github.com>2024-11-20 08:35:54 -0800
commitf88c913f8aa1c2bb8e8636ccd9defcb7755a8a40 (patch)
tree1db86ba9686bd8ae4dab4828f653a398b546246c /llvm/unittests/ProfileData/MemProfTest.cpp
parent5bf017ca0c158316d9b060154a1e80304de970f3 (diff)
downloadllvm-f88c913f8aa1c2bb8e8636ccd9defcb7755a8a40.zip
llvm-f88c913f8aa1c2bb8e8636ccd9defcb7755a8a40.tar.gz
llvm-f88c913f8aa1c2bb8e8636ccd9defcb7755a8a40.tar.bz2
[memprof] Add a new constructor to MemProfReader (NFC) (#116918)
This patch adds a new constructor to MemProfReader that takes IndexedMemProfData, a complete package of MemProf profile. To showcase its usage, I'm updating one of the unit tests to use the new constructor. Because of type mismatches between DenseMap and MapVector, I'm copying Frames and CallStacks for now. Once we remove the methods and old constructors that take or return individual components (frames, call stacks, and records), we will drop the copying, and the new constructor will collapse down to: MemProfReader(IndexedMemProfData MemProfData) : MemProfData(std::move(MemProfData)) {} Since nobody in the LLVM codebase uses the constructor that takes the three indivdual components, I'm deprecating the old constructor.
Diffstat (limited to 'llvm/unittests/ProfileData/MemProfTest.cpp')
-rw-r--r--llvm/unittests/ProfileData/MemProfTest.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/llvm/unittests/ProfileData/MemProfTest.cpp b/llvm/unittests/ProfileData/MemProfTest.cpp
index 5097dbd..e5d41db 100644
--- a/llvm/unittests/ProfileData/MemProfTest.cpp
+++ b/llvm/unittests/ProfileData/MemProfTest.cpp
@@ -490,20 +490,18 @@ TEST(MemProf, BaseMemProfReader) {
}
TEST(MemProf, BaseMemProfReaderWithCSIdMap) {
- 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::DenseMap<CallStackId, llvm::SmallVector<FrameId>> CSIdMap;
llvm::SmallVector<FrameId> CallStack = {F1.hash(), F2.hash()};
CallStackId CSId = llvm::memprof::hashCallStack(CallStack);
- CSIdMap.insert({CSId, CallStack});
+ MemProfData.CallStacks.insert({CSId, CallStack});
- llvm::MapVector<llvm::GlobalValue::GUID, IndexedMemProfRecord> ProfData;
IndexedMemProfRecord FakeRecord;
MemInfoBlock Block;
Block.AllocCount = 1U, Block.TotalAccessDensity = 4,
@@ -511,9 +509,9 @@ TEST(MemProf, BaseMemProfReaderWithCSIdMap) {
FakeRecord.AllocSites.emplace_back(
/*CSId=*/llvm::memprof::hashCallStack(CallStack),
/*MB=*/Block);
- ProfData.insert({F1.hash(), FakeRecord});
+ MemProfData.Records.insert({F1.hash(), FakeRecord});
- MemProfReader Reader(FrameIdMap, CSIdMap, ProfData);
+ MemProfReader Reader(MemProfData);
llvm::SmallVector<MemProfRecord, 1> Records;
for (const auto &KeyRecordPair : Reader) {