Skip to content

Commit

Permalink
[memprof] Update the frame is inline logic and unittests.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
snehasish committed Mar 21, 2022
1 parent 69a7759 commit c9a3d29
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
7 changes: 4 additions & 3 deletions llvm/lib/ProfileData/RawMemProfReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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);
}
}

Expand Down
12 changes: 6 additions & 6 deletions llvm/unittests/ProfileData/MemProfTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit c9a3d29

Please sign in to comment.