Skip to content

Commit b170ab2

Browse files
[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.
1 parent d5032b9 commit b170ab2

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

llvm/include/llvm/ProfileData/MemProfReader.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ class MemProfReader {
117117
virtual ~MemProfReader() = default;
118118

119119
// Initialize the MemProfReader with the frame mappings and profile contents.
120+
LLVM_DEPRECATED("Construct MemProfReader with IndexedMemProfData",
121+
"MemProfReader")
120122
MemProfReader(
121123
llvm::DenseMap<FrameId, Frame> FrameIdMap,
122124
llvm::MapVector<GlobalValue::GUID, IndexedMemProfRecord> ProfData);

llvm/unittests/ProfileData/MemProfTest.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -454,26 +454,26 @@ TEST(MemProf, SymbolizationFilter) {
454454
}
455455

456456
TEST(MemProf, BaseMemProfReader) {
457-
llvm::DenseMap<FrameId, Frame> FrameIdMap;
457+
llvm::memprof::IndexedMemProfData MemProfData;
458458
Frame F1(/*Hash=*/IndexedMemProfRecord::getGUID("foo"), /*LineOffset=*/20,
459459
/*Column=*/5, /*IsInlineFrame=*/true);
460460
Frame F2(/*Hash=*/IndexedMemProfRecord::getGUID("bar"), /*LineOffset=*/10,
461461
/*Column=*/2, /*IsInlineFrame=*/false);
462-
FrameIdMap.insert({F1.hash(), F1});
463-
FrameIdMap.insert({F2.hash(), F2});
462+
MemProfData.Frames.insert({F1.hash(), F1});
463+
MemProfData.Frames.insert({F2.hash(), F2});
464+
465+
llvm::SmallVector<FrameId> CallStack{F1.hash(), F2.hash()};
466+
CallStackId CSId = llvm::memprof::hashCallStack(CallStack);
467+
MemProfData.CallStacks.try_emplace(CSId, CallStack);
464468

465-
llvm::MapVector<llvm::GlobalValue::GUID, IndexedMemProfRecord> ProfData;
466469
IndexedMemProfRecord FakeRecord;
467470
MemInfoBlock Block;
468471
Block.AllocCount = 1U, Block.TotalAccessDensity = 4,
469472
Block.TotalLifetime = 200001;
470-
std::array<FrameId, 2> CallStack{F1.hash(), F2.hash()};
471-
FakeRecord.AllocSites.emplace_back(
472-
/*CS=*/CallStack, /*CSId=*/llvm::memprof::hashCallStack(CallStack),
473-
/*MB=*/Block);
474-
ProfData.insert({F1.hash(), FakeRecord});
473+
FakeRecord.AllocSites.emplace_back(/*CSId=*/CSId, /*MB=*/Block);
474+
MemProfData.Records.insert({F1.hash(), FakeRecord});
475475

476-
MemProfReader Reader(FrameIdMap, ProfData);
476+
MemProfReader Reader(MemProfData);
477477

478478
llvm::SmallVector<MemProfRecord, 1> Records;
479479
for (const auto &KeyRecordPair : Reader) {

0 commit comments

Comments
 (0)