From 4b84baa77e53905136d9356d3f08af8ab9ac0cbe Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Sat, 7 Dec 2024 00:29:47 -0800 Subject: [PATCH] [memprof] Use IndexedMemProfData in a unit test (NFC) IndexedMemProfData eliminates the need for the "using" directives. Also, we do not need to declare maps for individual components of the MemProf profile. --- llvm/unittests/ProfileData/MemProfTest.cpp | 32 ++++++++-------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/llvm/unittests/ProfileData/MemProfTest.cpp b/llvm/unittests/ProfileData/MemProfTest.cpp index 04e914189c9db..5e24579baccd3 100644 --- a/llvm/unittests/ProfileData/MemProfTest.cpp +++ b/llvm/unittests/ProfileData/MemProfTest.cpp @@ -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; @@ -575,12 +569,11 @@ TEST(MemProf, MissingCallStackId) { IndexedMR.AllocSites.push_back(AI); // Create empty maps. - const FrameIdMapTy IdToFrameMap; - const CallStackIdMapTy CSIdToCallStackMap; - llvm::memprof::FrameIdConverter FrameIdConv( - IdToFrameMap); - llvm::memprof::CallStackIdConverter CSIdConv( - CSIdToCallStackMap, FrameIdConv); + IndexedMemProfData MemProfData; + llvm::memprof::FrameIdConverter FrameIdConv( + MemProfData.Frames); + llvm::memprof::CallStackIdConverter + CSIdConv(MemProfData.CallStacks, FrameIdConv); // We are only interested in errors, not the return value. (void)IndexedMR.toMemProfRecord(CSIdConv); @@ -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 FrameIdConv( - IdToFrameMap); - llvm::memprof::CallStackIdConverter CSIdConv( - CSIdToCallStackMap, FrameIdConv); + llvm::memprof::FrameIdConverter FrameIdConv( + MemProfData.Frames); + llvm::memprof::CallStackIdConverter + CSIdConv(MemProfData.CallStacks, FrameIdConv); // We are only interested in errors, not the return value. (void)IndexedMR.toMemProfRecord(CSIdConv);