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

Snehasish Kumar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 16 10:34:44 PDT 2022


snehasish created this revision.
snehasish added a reviewer: tejohnson.
Herald added a subscriber: hiraditya.
Herald added a project: All.
snehasish requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121830

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


Index: llvm/unittests/ProfileData/MemProfTest.cpp
===================================================================
--- llvm/unittests/ProfileData/MemProfTest.cpp
+++ llvm/unittests/ProfileData/MemProfTest.cpp
@@ -169,13 +169,13 @@
 
   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) {
Index: llvm/lib/ProfileData/RawMemProfReader.cpp
===================================================================
--- llvm/lib/ProfileData/RawMemProfReader.cpp
+++ llvm/lib/ProfileData/RawMemProfReader.cpp
@@ -325,7 +325,8 @@
         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 @@
             // 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);
       }
     }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D121830.415900.patch
Type: text/x-patch
Size: 2269 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220316/fd7e0c9e/attachment.bin>


More information about the llvm-commits mailing list