Skip to content

Commit ec5b729

Browse files
[memprof] Upgrade a unit test to MemProf Version 3 (#117063)
This patch upgrades a unit test to MemProf Version 3 while removing those bits that cannot be upgraded to Version 3. The bits being removed expect instrprof_error::hash_mismatch from a broken MemProf profile that references a frame that doesn't actually exist. Now, Version 3 no longer issues instrprof_error::hash_mismatch. Even if it still issued instrprof_error::hash_mismatch, we would have a couple of hurdles: - InstrProfWriter::addMemProfData will soon require all (or none) of the fields (frames, call stacks, and records) be populated. That is, it won't accept an instance of IndexedMemProfData with frames missing. - writeMemProfV3 asserts that every frame occurs at least once: assert(MemProfData.Frames.size() == FrameHistogram.size()); This patch gives up on instrprof_error::hash_mismatch and tries to trigger instrprof_error::unknown_function with the empty profile.
1 parent 9be475a commit ec5b729

File tree

1 file changed

+3
-19
lines changed

1 file changed

+3
-19
lines changed

llvm/unittests/ProfileData/InstrProfTest.cpp

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -640,29 +640,13 @@ TEST_F(InstrProfTest, test_memprof_getrecord_error) {
640640
ASSERT_THAT_ERROR(Writer.mergeProfileKind(InstrProfKind::MemProf),
641641
Succeeded());
642642

643-
const IndexedMemProfRecord IndexedMR = makeRecord(
644-
/*AllocFrames=*/
645-
{
646-
{0, 1},
647-
{2, 3},
648-
},
649-
/*CallSiteFrames=*/{
650-
{4, 5},
651-
});
652-
// We skip adding the frame mappings here unlike the test_memprof unit test
653-
// above to exercise the failure path when getMemProfRecord is invoked.
654-
Writer.addMemProfRecord(/*Id=*/0x9999, IndexedMR);
655-
643+
Writer.setMemProfVersionRequested(memprof::Version3);
644+
// Generate an empty profile.
656645
auto Profile = Writer.writeBuffer();
657646
readProfile(std::move(Profile));
658647

659-
// Missing frames give a hash_mismatch error.
660-
auto RecordOr = Reader->getMemProfRecord(0x9999);
661-
ASSERT_TRUE(
662-
ErrorEquals(instrprof_error::hash_mismatch, RecordOr.takeError()));
663-
664648
// Missing functions give a unknown_function error.
665-
RecordOr = Reader->getMemProfRecord(0x1111);
649+
auto RecordOr = Reader->getMemProfRecord(0x1111);
666650
ASSERT_TRUE(
667651
ErrorEquals(instrprof_error::unknown_function, RecordOr.takeError()));
668652
}

0 commit comments

Comments
 (0)