mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-18 12:26:50 +00:00
[memprof] Report an error when buildid and profile do not match (#132504)
## Problem When the build ids of the profile and binary do not match, the error reported by llvm-profdata is `no entries in callstack map after symbolization`, but the root cause of this problem is the **build id mismatch**. ## Trigger scenario For example, when performing `memprof` optimization on `clang`, `rawprofile` is collected through `ninja clang`. In addition to running clang, some other programs will also be executed, and these programs will also generate rawprofile. When `no entries in callstack map after symbolization` appears during `llvm-profdata merge`, users may mistakenly think that the **instrumentation failed or other reasons**, and will **not directly realize that the binary and profile do not match**. ## Changed Currently, when the build id does not match, an assert error is triggered only in debug mode. Change it to directly return an error when the build id does not match.
This commit is contained in:
parent
7288f1bc32
commit
229ca7dbcb
@ -444,7 +444,11 @@ Error RawMemProfReader::setupForSymbolization() {
|
||||
ProfiledTextSegmentEnd = Entry.End;
|
||||
}
|
||||
}
|
||||
assert(NumMatched != 0 && "No matching executable segments in segment info.");
|
||||
if (NumMatched == 0)
|
||||
return make_error<StringError>(
|
||||
Twine("No matching executable segments found in binary ") +
|
||||
Binary.getBinary()->getFileName(),
|
||||
inconvertibleErrorCode());
|
||||
assert((PreferredTextSegmentAddress == 0 ||
|
||||
(PreferredTextSegmentAddress == ProfiledTextSegmentStart)) &&
|
||||
"Expect text segment address to be 0 or equal to profiled text "
|
||||
|
@ -14,3 +14,9 @@ CHECK: Build ID: [[ID:[[:xdigit:]]+]]
|
||||
|
||||
COM: Then match it with the profdata output.
|
||||
CHECK-COUNT-1: BuildId: {{.*}}[[ID]]
|
||||
|
||||
Test error message when profile build id does not match build id in a different binary.
|
||||
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
|
||||
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
|
||||
|
||||
BUILDID-NOT-MATCH: No matching executable segments found in binary
|
||||
|
Loading…
x
Reference in New Issue
Block a user