Skip to content

Commit 5883989

Browse files
committedNov 13, 2017
Remove a std::map and std::set that show up in LLD profiles
For GC roots, add a bit to SymbolBody to ensure that we don't add the same root twice, and switch to a vector. In addition to being faster, this may also fix some latent non-determinism. We iterate the GCRoot list later and it the order should be deterministic. For fixupExports, we can just use DenseMap. This is a simple string uniquing task, and we don't iterate the map. Reviewers: ruiu Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D39609 llvm-svn: 318072
1 parent c2dcdd8 commit 5883989

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed
 

‎lld/COFF/Config.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ struct Configuration {
9494
std::vector<llvm::StringRef> Argv;
9595

9696
// Symbols in this set are considered as live by the garbage collector.
97-
std::set<Symbol *> GCRoot;
97+
std::vector<Symbol *> GCRoot;
9898

9999
std::set<StringRef> NoDefaultLibs;
100100
bool NoDefaultLibAll = false;

‎lld/COFF/Driver.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,10 @@ void LinkerDriver::addLibSearchPaths() {
355355

356356
Symbol *LinkerDriver::addUndefined(StringRef Name) {
357357
Symbol *B = Symtab->addUndefined(Name);
358-
Config->GCRoot.insert(B);
358+
if (!B->IsGCRoot) {
359+
B->IsGCRoot = true;
360+
Config->GCRoot.push_back(B);
361+
}
359362
return B;
360363
}
361364

‎lld/COFF/Symbols.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ class Symbol {
7777
friend SymbolTable;
7878
explicit Symbol(Kind K, StringRef N = "")
7979
: SymbolKind(K), IsExternal(true), IsCOMDAT(false),
80-
WrittenToSymtab(false), Name(N) {}
80+
WrittenToSymtab(false), PendingArchiveLoad(false), IsGCRoot(false),
81+
Name(N) {}
8182

8283
const unsigned SymbolKind : 8;
8384
unsigned IsExternal : 1;
@@ -98,6 +99,9 @@ class Symbol {
9899
// not load any more archive members to resolve the same symbol.
99100
unsigned PendingArchiveLoad : 1;
100101

102+
/// True if we've already added this symbol to the list of GC roots.
103+
unsigned IsGCRoot : 1;
104+
101105
protected:
102106
StringRef Name;
103107
};

0 commit comments

Comments
 (0)
Please sign in to comment.