-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Use MapVector to fix lld thinLTO "nondeterminism" issue. #117551
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-llvm-binary-utilities Author: None (llvmssh) ChangesWhen the ModuleSymbolTable is generated, the binary consistency problem occurs due to the Full diff: https://github.com/llvm/llvm-project/pull/117551.diff 2 Files Affected:
diff --git a/llvm/lib/Object/ModuleSymbolTable.cpp b/llvm/lib/Object/ModuleSymbolTable.cpp
index 54e654a0d121cb..dc8ba00d3c91c7 100644
--- a/llvm/lib/Object/ModuleSymbolTable.cpp
+++ b/llvm/lib/Object/ModuleSymbolTable.cpp
@@ -144,7 +144,7 @@ void ModuleSymbolTable::CollectAsmSymbols(
Streamer.flushSymverDirectives();
for (auto &KV : Streamer) {
- StringRef Key = KV.first();
+ StringRef Key = KV.first;
RecordStreamer::State Value = KV.second;
// FIXME: For now we just assume that all asm symbols are executable.
uint32_t Res = BasicSymbolRef::SF_Executable;
diff --git a/llvm/lib/Object/RecordStreamer.h b/llvm/lib/Object/RecordStreamer.h
index 70b41f270720b4..946578ef06d11e 100644
--- a/llvm/lib/Object/RecordStreamer.h
+++ b/llvm/lib/Object/RecordStreamer.h
@@ -14,6 +14,7 @@
#include "llvm/MC/MCDirectives.h"
#include "llvm/MC/MCStreamer.h"
#include "llvm/Support/SMLoc.h"
+#include "llvm/ADT/MapVector.h"
#include <vector>
namespace llvm {
@@ -28,11 +29,11 @@ class RecordStreamer : public MCStreamer {
private:
const Module &M;
- StringMap<State> Symbols;
+ MapVector<StringRef, State> Symbols;
// Map of aliases created by .symver directives, saved so we can update
// their symbol binding after parsing complete. This maps from each
// aliasee to its list of aliases.
- DenseMap<const MCSymbol *, std::vector<StringRef>> SymverAliasMap;
+ MapVector<const MCSymbol *, std::vector<StringRef>> SymverAliasMap;
/// Get the state recorded for the given symbol.
State getSymbolState(const MCSymbol *Sym);
@@ -70,7 +71,7 @@ class RecordStreamer : public MCStreamer {
void flushSymverDirectives();
// Symbols iterators
- using const_iterator = StringMap<State>::const_iterator;
+ using const_iterator = MapVector<StringRef, State>::const_iterator;
const_iterator begin();
const_iterator end();
|
I don't know who filed this PR, but the author is listed as "None". I think whoever did this has messed up their commit email/author details? |
✅ With the latest revision this PR passed the C/C++ code formatter. |
fa5890f
to
86e55de
Compare
Thank you for your comment. I should have modified the information. |
86e55de
to
de57b7a
Compare
Thanks for the update. Is there a GitHub issue associated with the problem you're trying to fix? If so, please include "Fixes #####" in your PR description. Just so you know, I'm not familiar with the area, so somebody who is will need to perform the review. Take a look through past contributors to this file and try pinging them on here/adding them as reviewers. |
Thanks, I have a problem, it seems that I can't add reviewers. |
From the automated greeting post above:
|
@vitalybuka Hi,I see you have modified this file before, I have made a little modification, can you help review it? |
@pcc,@vitalybuka Hi, can you help review my code? thank you. |
Can you add a few reviewers for me? |
What is "bep issue"? |
Thanks for your reply. When a compiler of the same version builds the same project twice, the generated binary files are different, which is reflected in the inconsistent sequence in the symbol table. For example: |
Sorry, out of curiosity are there definition of "bep"? Regardless of definition, can we please just call it "nondeterminism" in title and description? I guess that's how we usually call it in LLVM. |
@teresajohnson who added the loop in https://reviews.llvm.org/D30485 |
When the ModuleSymbolTable is generated, the binary consistency problem occurs due to the unorder of the data structure when collecting asm symbols.
de57b7a
to
56e28a9
Compare
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
I will land when buildkite is done. |
@llvmssh 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! |
Thanks for improving consistency! |
The Buildbot has detected a new failure on builder sanitizer-x86_64-linux-android while building llvm. Full details are available at: Worker for this Build: sanitizer-buildbot-android BUILD FAILED: failed 'python ../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py' (failure) Step 2 (annotate) failure: 'python ../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py' (failure) ... |
Probably a flake. |
Okay, thanks for your reply. Is it necessary to confirm this? |
Multiple following builds have no this error and the patch is still there. https://lab.llvm.org/buildbot/#/builders/186 |
Ok, thanks. |
When the ModuleSymbolTable is generated, the binary consistency problem occurs due to the
data structure for collecting asm symbols was ordered by memory pointers.
Use MapVector to fix lld thinLTO "nondeterminism" issue.