Skip to content

Commit

Permalink
[memprof] Use IndexedMemProfData in a unit test (NFC) (llvm#119062)
Browse files Browse the repository at this point in the history
IndexedMemProfData eliminates the need for the "using" directives.
Also, we do not need to declare maps for individual components of the
MemProf profile.
  • Loading branch information
kazutakahirata authored Dec 7, 2024
1 parent 4cf0bd8 commit 8eb5baf
Showing 1 changed file with 12 additions and 20 deletions.
32 changes: 12 additions & 20 deletions llvm/unittests/ProfileData/MemProfTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -549,12 +549,6 @@ TEST(MemProf, IndexedMemProfRecordToMemProfRecord) {
EXPECT_EQ(Record.CallSites[1][1].hash(), F4.hash());
}

using FrameIdMapTy =
llvm::DenseMap<::llvm::memprof::FrameId, ::llvm::memprof::Frame>;
using CallStackIdMapTy =
llvm::DenseMap<::llvm::memprof::CallStackId,
::llvm::SmallVector<::llvm::memprof::FrameId>>;

// Populate those fields returned by getHotColdSchema.
MemInfoBlock makePartialMIB() {
MemInfoBlock MIB;
Expand All @@ -575,12 +569,11 @@ TEST(MemProf, MissingCallStackId) {
IndexedMR.AllocSites.push_back(AI);

// Create empty maps.
const FrameIdMapTy IdToFrameMap;
const CallStackIdMapTy CSIdToCallStackMap;
llvm::memprof::FrameIdConverter<decltype(IdToFrameMap)> FrameIdConv(
IdToFrameMap);
llvm::memprof::CallStackIdConverter<decltype(CSIdToCallStackMap)> CSIdConv(
CSIdToCallStackMap, FrameIdConv);
IndexedMemProfData MemProfData;
llvm::memprof::FrameIdConverter<decltype(MemProfData.Frames)> FrameIdConv(
MemProfData.Frames);
llvm::memprof::CallStackIdConverter<decltype(MemProfData.CallStacks)>
CSIdConv(MemProfData.CallStacks, FrameIdConv);

// We are only interested in errors, not the return value.
(void)IndexedMR.toMemProfRecord(CSIdConv);
Expand All @@ -597,15 +590,14 @@ TEST(MemProf, MissingFrameId) {
IndexedMemProfRecord IndexedMR;
IndexedMR.AllocSites.push_back(AI);

// An empty map to trigger a mapping error.
const FrameIdMapTy IdToFrameMap;
CallStackIdMapTy CSIdToCallStackMap;
CSIdToCallStackMap.insert({0x222, {2, 3}});
// An empty Frame map to trigger a mapping error.
IndexedMemProfData MemProfData;
MemProfData.CallStacks.insert({0x222, {2, 3}});

llvm::memprof::FrameIdConverter<decltype(IdToFrameMap)> FrameIdConv(
IdToFrameMap);
llvm::memprof::CallStackIdConverter<decltype(CSIdToCallStackMap)> CSIdConv(
CSIdToCallStackMap, FrameIdConv);
llvm::memprof::FrameIdConverter<decltype(MemProfData.Frames)> FrameIdConv(
MemProfData.Frames);
llvm::memprof::CallStackIdConverter<decltype(MemProfData.CallStacks)>
CSIdConv(MemProfData.CallStacks, FrameIdConv);

// We are only interested in errors, not the return value.
(void)IndexedMR.toMemProfRecord(CSIdConv);
Expand Down

0 comments on commit 8eb5baf

Please sign in to comment.