[llvm] 8eb5baf - [memprof] Use IndexedMemProfData in a unit test (NFC) (#119062)

via llvm-commits llvm-commits at lists.llvm.org
Sat Dec 7 10:41:58 PST 2024


Author: Kazu Hirata
Date: 2024-12-07T10:41:55-08:00
New Revision: 8eb5baf5ea52edd0b8df38ffca2a65e21610f3ad

URL: https://github.com/llvm/llvm-project/commit/8eb5baf5ea52edd0b8df38ffca2a65e21610f3ad
DIFF: https://github.com/llvm/llvm-project/commit/8eb5baf5ea52edd0b8df38ffca2a65e21610f3ad.diff

LOG: [memprof] Use IndexedMemProfData in a unit test (NFC) (#119062)

IndexedMemProfData eliminates the need for the "using" directives.
Also, we do not need to declare maps for individual components of the
MemProf profile.

Added: 
    

Modified: 
    llvm/unittests/ProfileData/MemProfTest.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/unittests/ProfileData/MemProfTest.cpp b/llvm/unittests/ProfileData/MemProfTest.cpp
index 04e914189c9db9..5e24579baccd37 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<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);
@@ -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);


        


More information about the llvm-commits mailing list