-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[memprof] Report an error when buildid and profile do not match #132504
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
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
Excuse me, when will this PR be merged? This is my first PR. I am looking forward to it being merged. |
I'll take a look soon. |
@zcfh Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR. Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues. How to do this, and the rest of the post-merge process, is covered in detail here. If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! |
I didn't see a request for it to be merged - if you don't have commit access please ask for PRs to be merged for you after they are approved. |
Thanks for your reply. I thought it would be merged after all the comments were resolved. I know how to do it next time submit pr(hopefully there will be a next time soon). |
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.