Skip to content

Commit 59575eb

Browse files
committed
[memprof] Report an error when buildid and profile do not match
1 parent 616737c commit 59575eb

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

llvm/lib/ProfileData/MemProfReader.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,11 @@ Error RawMemProfReader::setupForSymbolization() {
444444
ProfiledTextSegmentEnd = Entry.End;
445445
}
446446
}
447-
assert(NumMatched != 0 && "No matching executable segments in segment info.");
447+
if (NumMatched == 0)
448+
return make_error<StringError>(
449+
Twine("No matching executable segments found in binary ") +
450+
Binary.getBinary()->getFileName(),
451+
inconvertibleErrorCode());
448452
assert((PreferredTextSegmentAddress == 0 ||
449453
(PreferredTextSegmentAddress == ProfiledTextSegmentStart)) &&
450454
"Expect text segment address to be 0 or equal to profiled text "

llvm/test/tools/llvm-profdata/memprof-buildid.test

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,11 @@ CHECK: Build ID: [[ID:[[:xdigit:]]+]]
1414

1515
COM: Then match it with the profdata output.
1616
CHECK-COUNT-1: BuildId: {{.*}}[[ID]]
17+
18+
Test that profile build id does not match build id in the binary
19+
RUN: not llvm-profdata show --memory %p/Inputs/buildid.memprofraw --profiled-binary %p/Inputs/basic.memprofexe -o - 2>&1 | FileCheck %s -check-prefix=BUILDID-NOT-MATCH
20+
21+
Test error message when profile build id does not match build id in a different binary.
22+
RUN: not llvm-profdata merge %p/Inputs/buildid.memprofraw %p/Inputs/basic.memprofraw --profiled-binary %p/Inputs/basic.memprofexe -o %t4.prof 2>&1 | FileCheck %s -check-prefix=BUILDID-NOT-MATCH
23+
24+
BUILDID-NOT-MATCH: No matching executable segments found in binary

0 commit comments

Comments
 (0)