Skip to content

Commit 5bf017c

Browse files
[memprof] Use LineLocation in a unit test (NFC) (#116917)
This patch uses LineLocation in preference to FieldsAre to improve the readability. The change makes the unit test a little more consistent because we already use LineLocation in other tests in the same file.
1 parent 1b7f690 commit 5bf017c

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

llvm/unittests/Transforms/Instrumentation/MemProfUseTest.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,12 @@ declare !dbg !19 void @_Z2f3v()
107107

108108
// Verify that call sites show up in the ascending order of their source
109109
// locations.
110-
EXPECT_THAT(CallSites[0],
111-
Pair(FieldsAre(1U, 3U), IndexedMemProfRecord::getGUID("_Z2f1v")));
112-
EXPECT_THAT(CallSites[1],
113-
Pair(FieldsAre(2U, 3U), IndexedMemProfRecord::getGUID("_Z2f2v")));
114-
EXPECT_THAT(CallSites[2],
115-
Pair(FieldsAre(2U, 9U), IndexedMemProfRecord::getGUID("_Z2f3v")));
110+
EXPECT_THAT(CallSites[0], Pair(LineLocation(1, 3),
111+
IndexedMemProfRecord::getGUID("_Z2f1v")));
112+
EXPECT_THAT(CallSites[1], Pair(LineLocation(2, 3),
113+
IndexedMemProfRecord::getGUID("_Z2f2v")));
114+
EXPECT_THAT(CallSites[2], Pair(LineLocation(2, 9),
115+
IndexedMemProfRecord::getGUID("_Z2f3v")));
116116
}
117117

118118
TEST(MemProf, ExtractDirectCallsFromIRInline) {
@@ -207,36 +207,36 @@ declare !dbg !25 void @_Z2g2v() local_unnamed_addr
207207
const auto &[FooCallerGUID, FooCallSites] = *FooIt;
208208
EXPECT_EQ(FooCallerGUID, IndexedMemProfRecord::getGUID("_Z3foov"));
209209
ASSERT_THAT(FooCallSites, SizeIs(2));
210-
EXPECT_THAT(FooCallSites[0], Pair(FieldsAre(1U, 3U),
210+
EXPECT_THAT(FooCallSites[0], Pair(LineLocation(1, 3),
211211
IndexedMemProfRecord::getGUID("_ZL2f3v")));
212-
EXPECT_THAT(FooCallSites[1], Pair(FieldsAre(2U, 9U),
212+
EXPECT_THAT(FooCallSites[1], Pair(LineLocation(2, 9),
213213
IndexedMemProfRecord::getGUID("_ZL2g3v")));
214214

215215
auto F2It = Calls.find(IndexedMemProfRecord::getGUID("_ZL2f2v"));
216216
ASSERT_NE(F2It, Calls.end());
217217
const auto &[F2CallerGUID, F2CallSites] = *F2It;
218218
EXPECT_EQ(F2CallerGUID, IndexedMemProfRecord::getGUID("_ZL2f2v"));
219219
ASSERT_THAT(F2CallSites, SizeIs(1));
220-
EXPECT_THAT(F2CallSites[0],
221-
Pair(FieldsAre(2U, 3U), IndexedMemProfRecord::getGUID("_Z2f1v")));
220+
EXPECT_THAT(F2CallSites[0], Pair(LineLocation(2, 3),
221+
IndexedMemProfRecord::getGUID("_Z2f1v")));
222222

223223
auto F3It = Calls.find(IndexedMemProfRecord::getGUID("_ZL2f3v"));
224224
ASSERT_NE(F3It, Calls.end());
225225
const auto &[F3CallerGUID, F3CallSites] = *F3It;
226226
EXPECT_EQ(F3CallerGUID, IndexedMemProfRecord::getGUID("_ZL2f3v"));
227227
ASSERT_THAT(F3CallSites, SizeIs(1));
228-
EXPECT_THAT(F3CallSites[0], Pair(FieldsAre(1U, 10U),
228+
EXPECT_THAT(F3CallSites[0], Pair(LineLocation(1, 10),
229229
IndexedMemProfRecord::getGUID("_ZL2f2v")));
230230

231231
auto G3It = Calls.find(IndexedMemProfRecord::getGUID("_ZL2g3v"));
232232
ASSERT_NE(G3It, Calls.end());
233233
const auto &[G3CallerGUID, G3CallSites] = *G3It;
234234
EXPECT_EQ(G3CallerGUID, IndexedMemProfRecord::getGUID("_ZL2g3v"));
235235
ASSERT_THAT(G3CallSites, SizeIs(2));
236-
EXPECT_THAT(G3CallSites[0],
237-
Pair(FieldsAre(1U, 8U), IndexedMemProfRecord::getGUID("_Z2g1v")));
238-
EXPECT_THAT(G3CallSites[1],
239-
Pair(FieldsAre(2U, 3U), IndexedMemProfRecord::getGUID("_Z2g2v")));
236+
EXPECT_THAT(G3CallSites[0], Pair(LineLocation(1, 8),
237+
IndexedMemProfRecord::getGUID("_Z2g1v")));
238+
EXPECT_THAT(G3CallSites[1], Pair(LineLocation(2, 3),
239+
IndexedMemProfRecord::getGUID("_Z2g2v")));
240240
}
241241

242242
TEST(MemProf, ExtractDirectCallsFromIRCallingNew) {
@@ -302,7 +302,7 @@ attributes #2 = { builtin allocsize(0) }
302302
const auto &[FooCallerGUID, FooCallSites] = *FooIt;
303303
EXPECT_EQ(FooCallerGUID, IndexedMemProfRecord::getGUID("_Z3foov"));
304304
ASSERT_THAT(FooCallSites, SizeIs(1));
305-
EXPECT_THAT(FooCallSites[0], Pair(FieldsAre(1U, 10U), 0));
305+
EXPECT_THAT(FooCallSites[0], Pair(LineLocation(1, 10), 0));
306306
}
307307

308308
// Populate those fields returned by getHotColdSchema.

0 commit comments

Comments
 (0)