Skip to content

Commit 6c062af

Browse files
[memprof] Compare Frames instead of FrameIds in a unit test (#119111)
When we call IndexedMemProfRecord::toMemProfRecord, we care about getting the original (that is, non-indexed) MemProfRecord back, so we should just verify that, not the hash values, which are intermediaries. There is a remote possibility of hash collisions where call stack {F1, F2} might come back as {F1, F1} if F1.hash() == F2.hash() for example. However, since FrameId uses BLAKE, the hash values should be consistent across architectures. That is, if this test case works on one architecture, it should work on others as well.
1 parent fc2cc01 commit 6c062af

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

llvm/unittests/ProfileData/MemProfTest.cpp

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -534,19 +534,10 @@ TEST(MemProf, IndexedMemProfRecordToMemProfRecord) {
534534

535535
// Verify the contents of Record.
536536
ASSERT_THAT(Record.AllocSites, SizeIs(2));
537-
ASSERT_THAT(Record.AllocSites[0].CallStack, SizeIs(2));
538-
EXPECT_EQ(Record.AllocSites[0].CallStack[0].hash(), F1.hash());
539-
EXPECT_EQ(Record.AllocSites[0].CallStack[1].hash(), F2.hash());
540-
ASSERT_THAT(Record.AllocSites[1].CallStack, SizeIs(2));
541-
EXPECT_EQ(Record.AllocSites[1].CallStack[0].hash(), F1.hash());
542-
EXPECT_EQ(Record.AllocSites[1].CallStack[1].hash(), F3.hash());
543-
ASSERT_THAT(Record.CallSites, SizeIs(2));
544-
ASSERT_THAT(Record.CallSites[0], SizeIs(2));
545-
EXPECT_EQ(Record.CallSites[0][0].hash(), F2.hash());
546-
EXPECT_EQ(Record.CallSites[0][1].hash(), F3.hash());
547-
ASSERT_THAT(Record.CallSites[1], SizeIs(2));
548-
EXPECT_EQ(Record.CallSites[1][0].hash(), F2.hash());
549-
EXPECT_EQ(Record.CallSites[1][1].hash(), F4.hash());
537+
EXPECT_THAT(Record.AllocSites[0].CallStack, ElementsAre(F1, F2));
538+
EXPECT_THAT(Record.AllocSites[1].CallStack, ElementsAre(F1, F3));
539+
EXPECT_THAT(Record.CallSites,
540+
ElementsAre(ElementsAre(F2, F3), ElementsAre(F2, F4)));
550541
}
551542

552543
// Populate those fields returned by getHotColdSchema.

0 commit comments

Comments
 (0)