Skip to content

Commit de57b7a

Browse files
committed
Use MapVector to fix lld thinLTO bep issue.
When the ModuleSymbolTable is generated, the binary consistency problem occurs due to the unorder of the data structure when collecting asm symbols.
1 parent ceaf6e9 commit de57b7a

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

llvm/lib/Object/ModuleSymbolTable.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ void ModuleSymbolTable::CollectAsmSymbols(
144144
Streamer.flushSymverDirectives();
145145

146146
for (auto &KV : Streamer) {
147-
StringRef Key = KV.first();
147+
StringRef Key = KV.first;
148148
RecordStreamer::State Value = KV.second;
149149
// FIXME: For now we just assume that all asm symbols are executable.
150150
uint32_t Res = BasicSymbolRef::SF_Executable;

llvm/lib/Object/RecordStreamer.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "llvm/MC/MCDirectives.h"
1515
#include "llvm/MC/MCStreamer.h"
1616
#include "llvm/Support/SMLoc.h"
17+
#include "llvm/ADT/MapVector.h"
1718
#include <vector>
1819

1920
namespace llvm {
@@ -28,11 +29,11 @@ class RecordStreamer : public MCStreamer {
2829

2930
private:
3031
const Module &M;
31-
StringMap<State> Symbols;
32+
MapVector<StringRef, State> Symbols;
3233
// Map of aliases created by .symver directives, saved so we can update
3334
// their symbol binding after parsing complete. This maps from each
3435
// aliasee to its list of aliases.
35-
DenseMap<const MCSymbol *, std::vector<StringRef>> SymverAliasMap;
36+
MapVector<const MCSymbol *, std::vector<StringRef>> SymverAliasMap;
3637

3738
/// Get the state recorded for the given symbol.
3839
State getSymbolState(const MCSymbol *Sym);
@@ -70,7 +71,7 @@ class RecordStreamer : public MCStreamer {
7071
void flushSymverDirectives();
7172

7273
// Symbols iterators
73-
using const_iterator = StringMap<State>::const_iterator;
74+
using const_iterator = MapVector<StringRef, State>::const_iterator;
7475
const_iterator begin();
7576
const_iterator end();
7677

0 commit comments

Comments
 (0)