-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[memprof] Report an error when buildid and profile do not match #132504
base: main
Are you sure you want to change the base?
Conversation
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
@llvm/pr-subscribers-pgo Author: None (zcfh) ChangesProblemWhen the build ids of the profile and binary do not match, the error reported by llvm-profdata is Trigger scenarioFor example, when performing ChangedCurrently, 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. Full diff: https://github.com/llvm/llvm-project/pull/132504.diff 2 Files Affected:
diff --git a/llvm/lib/ProfileData/MemProfReader.cpp b/llvm/lib/ProfileData/MemProfReader.cpp
index 16502a4f1e8af..c57f9b22273d4 100644
--- a/llvm/lib/ProfileData/MemProfReader.cpp
+++ b/llvm/lib/ProfileData/MemProfReader.cpp
@@ -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 "
diff --git a/llvm/test/tools/llvm-profdata/memprof-buildid.test b/llvm/test/tools/llvm-profdata/memprof-buildid.test
index a5abe6ea7dcb6..d604d18df61ad 100644
--- a/llvm/test/tools/llvm-profdata/memprof-buildid.test
+++ b/llvm/test/tools/llvm-profdata/memprof-buildid.test
@@ -14,3 +14,9 @@ CHECK: Build ID: [[ID:[[:xdigit:]]+]]
COM: Then match it with the profdata output.
CHECK-COUNT-1: BuildId: {{.*}}[[ID]]
+
+Test that profile build id does not match build id in the 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
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm - thanks for the fix!
caaaafc
to
12a5154
Compare
…nvocations and the earlier preexisting ones
f0e4c33
to
bf832a1
Compare
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 onclang
,rawprofile
is collected throughninja clang
. In addition to running clang, some other programs will also be executed, and these programs will also generate rawprofile. Whenno entries in callstack map after symbolization
appears duringllvm-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.