Skip to content

Commit 77d02bb

Browse files
Address more comments.
1 parent 26ff649 commit 77d02bb

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

llvm/lib/Transforms/Instrumentation/MemProfiler.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,7 @@ memprof::extractCallsFromIR(Module &M) {
819819

820820
auto *CB = dyn_cast<CallBase>(&I);
821821
auto *CalledFunction = CB->getCalledFunction();
822+
// Disregard indirect calls and intrinsics.
822823
if (!CalledFunction || CalledFunction->isIntrinsic())
823824
continue;
824825

llvm/unittests/Transforms/Instrumentation/MemProfUseTest.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818

1919
namespace {
2020
using namespace llvm;
21+
using namespace llvm::memprof;
22+
using testing::FieldsAre;
23+
using testing::Pair;
24+
using testing::SizeIs;
2125

2226
TEST(MemProf, ExtractDirectCallsFromIR) {
2327
// The following IR is generated from:
@@ -76,28 +80,25 @@ declare !dbg !19 void @_Z2f3v()
7680
std::unique_ptr<Module> M = parseAssemblyString(IR, Err, Ctx);
7781
ASSERT_TRUE(M);
7882

79-
auto Calls = memprof::extractCallsFromIR(*M);
83+
auto Calls = extractCallsFromIR(*M);
8084

8185
// Expect exactly one caller.
82-
ASSERT_THAT(Calls, testing::SizeIs(1));
86+
ASSERT_THAT(Calls, SizeIs(1));
8387

8488
auto It = Calls.begin();
8589
ASSERT_NE(It, Calls.end());
8690

8791
const auto &[CallerGUID, CallSites] = *It;
88-
EXPECT_EQ(CallerGUID, memprof::IndexedMemProfRecord::getGUID("_Z3foov"));
89-
ASSERT_THAT(CallSites, testing::SizeIs(3));
92+
EXPECT_EQ(CallerGUID, IndexedMemProfRecord::getGUID("_Z3foov"));
93+
ASSERT_THAT(CallSites, SizeIs(3));
9094

9195
// Verify that call sites show up in the ascending order of their source
9296
// locations.
9397
EXPECT_THAT(CallSites[0],
94-
testing::Pair(testing::FieldsAre(1U, 3U),
95-
memprof::IndexedMemProfRecord::getGUID("_Z2f1v")));
98+
Pair(FieldsAre(1U, 3U), IndexedMemProfRecord::getGUID("_Z2f1v")));
9699
EXPECT_THAT(CallSites[1],
97-
testing::Pair(testing::FieldsAre(2U, 3U),
98-
memprof::IndexedMemProfRecord::getGUID("_Z2f2v")));
100+
Pair(FieldsAre(2U, 3U), IndexedMemProfRecord::getGUID("_Z2f2v")));
99101
EXPECT_THAT(CallSites[2],
100-
testing::Pair(testing::FieldsAre(2U, 9U),
101-
memprof::IndexedMemProfRecord::getGUID("_Z2f3v")));
102+
Pair(FieldsAre(2U, 9U), IndexedMemProfRecord::getGUID("_Z2f3v")));
102103
}
103104
} // namespace

0 commit comments

Comments
 (0)