[llvm] c9a3d29 - [memprof] Update the frame is inline logic and unittests.

Snehasish Kumar via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 21 10:41:56 PDT 2022


Author: Snehasish Kumar
Date: 2022-03-21T10:41:05-07:00
New Revision: c9a3d29613dbf3b011c2660356fa482cc10b9160

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

LOG: [memprof] Update the frame is inline logic and unittests.

Since DI frames are enumerated with the leaf function at index 0, this
patch fixes the logic when IsInlineFrame is set. Also update the
unittests to check that only the last frame is marked as non-inline from
a set of DI Frames for a PC address.

Differential Revision: https://reviews.llvm.org/D121830

Added: 
    

Modified: 
    llvm/lib/ProfileData/RawMemProfReader.cpp
    llvm/unittests/ProfileData/MemProfTest.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/ProfileData/RawMemProfReader.cpp b/llvm/lib/ProfileData/RawMemProfReader.cpp
index 71e6629856807..a87410f6e5099 100644
--- a/llvm/lib/ProfileData/RawMemProfReader.cpp
+++ b/llvm/lib/ProfileData/RawMemProfReader.cpp
@@ -325,7 +325,8 @@ Error RawMemProfReader::symbolizeAndFilterStackFrames() {
         continue;
       }
 
-      for (size_t I = 0; I < DI.getNumberOfFrames(); I++) {
+      for (size_t I = 0, NumFrames = DI.getNumberOfFrames(); I < NumFrames;
+           I++) {
         const auto &Frame = DI.getFrame(I);
         LLVM_DEBUG(
             // Print out the name to guid mapping for debugging.
@@ -340,8 +341,8 @@ Error RawMemProfReader::symbolizeAndFilterStackFrames() {
             // these suffixes will not be present.
             Function::getGUID(trimSuffix(Frame.FunctionName)),
             Frame.Line - Frame.StartLine, Frame.Column,
-            // Only the first entry is not an inlined location.
-            I != 0);
+            // Only the last entry is not an inlined location.
+            I != NumFrames - 1);
       }
     }
 

diff  --git a/llvm/unittests/ProfileData/MemProfTest.cpp b/llvm/unittests/ProfileData/MemProfTest.cpp
index 8134ac6e696a8..8921235d063fb 100644
--- a/llvm/unittests/ProfileData/MemProfTest.cpp
+++ b/llvm/unittests/ProfileData/MemProfTest.cpp
@@ -169,13 +169,13 @@ TEST(MemProf, FillsValue) {
 
   EXPECT_EQ(Records[0].Info.getAllocCount(), 1U);
   EXPECT_EQ(Records[1].Info.getAllocCount(), 2U);
-  EXPECT_THAT(Records[0].CallStack[0], FrameContains("foo", 5U, 30U, false));
-  EXPECT_THAT(Records[0].CallStack[1], FrameContains("bar", 51U, 20U, true));
+  EXPECT_THAT(Records[0].CallStack[0], FrameContains("foo", 5U, 30U, true));
+  EXPECT_THAT(Records[0].CallStack[1], FrameContains("bar", 51U, 20U, false));
 
-  EXPECT_THAT(Records[1].CallStack[0], FrameContains("baz", 5U, 30U, false));
-  EXPECT_THAT(Records[1].CallStack[1], FrameContains("qux", 5U, 10U, true));
-  EXPECT_THAT(Records[1].CallStack[2], FrameContains("foo", 5U, 30U, false));
-  EXPECT_THAT(Records[1].CallStack[3], FrameContains("bar", 51U, 20U, true));
+  EXPECT_THAT(Records[1].CallStack[0], FrameContains("baz", 5U, 30U, true));
+  EXPECT_THAT(Records[1].CallStack[1], FrameContains("qux", 5U, 10U, false));
+  EXPECT_THAT(Records[1].CallStack[2], FrameContains("foo", 5U, 30U, true));
+  EXPECT_THAT(Records[1].CallStack[3], FrameContains("bar", 51U, 20U, false));
 }
 
 TEST(MemProf, PortableWrapper) {


        


More information about the llvm-commits mailing list