[llvm] Use MapVector to fix lld thinLTO bep issue. (PR #117551)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 25 05:13:28 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-binary-utilities
Author: None (llvmssh)
<details>
<summary>Changes</summary>
When the ModuleSymbolTable is generated, the binary consistency problem occurs due to the
unorder of the data structure when collecting asm symbols.
Use MapVector to fix lld thinLTO bep issue.
---
Full diff: https://github.com/llvm/llvm-project/pull/117551.diff
2 Files Affected:
- (modified) llvm/lib/Object/ModuleSymbolTable.cpp (+1-1)
- (modified) llvm/lib/Object/RecordStreamer.h (+4-3)
``````````diff
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();
``````````
</details>
https://github.com/llvm/llvm-project/pull/117551
More information about the llvm-commits
mailing list