[lld] r318072 - Remove a std::map and std::set that show up in LLD profiles
Reid Kleckner via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 13 10:38:53 PST 2017
Author: rnk
Date: Mon Nov 13 10:38:53 2017
New Revision: 318072
URL: http://llvm.org/viewvc/llvm-project?rev=318072&view=rev
Log:
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
Modified:
lld/trunk/COFF/Config.h
lld/trunk/COFF/Driver.cpp
lld/trunk/COFF/Symbols.h
Modified: lld/trunk/COFF/Config.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Config.h?rev=318072&r1=318071&r2=318072&view=diff
==============================================================================
--- lld/trunk/COFF/Config.h (original)
+++ lld/trunk/COFF/Config.h Mon Nov 13 10:38:53 2017
@@ -94,7 +94,7 @@ struct Configuration {
std::vector<llvm::StringRef> Argv;
// Symbols in this set are considered as live by the garbage collector.
- std::set<Symbol *> GCRoot;
+ std::vector<Symbol *> GCRoot;
std::set<StringRef> NoDefaultLibs;
bool NoDefaultLibAll = false;
Modified: lld/trunk/COFF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Driver.cpp?rev=318072&r1=318071&r2=318072&view=diff
==============================================================================
--- lld/trunk/COFF/Driver.cpp (original)
+++ lld/trunk/COFF/Driver.cpp Mon Nov 13 10:38:53 2017
@@ -355,7 +355,10 @@ void LinkerDriver::addLibSearchPaths() {
Symbol *LinkerDriver::addUndefined(StringRef Name) {
Symbol *B = Symtab->addUndefined(Name);
- Config->GCRoot.insert(B);
+ if (!B->IsGCRoot) {
+ B->IsGCRoot = true;
+ Config->GCRoot.push_back(B);
+ }
return B;
}
Modified: lld/trunk/COFF/Symbols.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Symbols.h?rev=318072&r1=318071&r2=318072&view=diff
==============================================================================
--- lld/trunk/COFF/Symbols.h (original)
+++ lld/trunk/COFF/Symbols.h Mon Nov 13 10:38:53 2017
@@ -77,7 +77,8 @@ protected:
friend SymbolTable;
explicit Symbol(Kind K, StringRef N = "")
: SymbolKind(K), IsExternal(true), IsCOMDAT(false),
- WrittenToSymtab(false), Name(N) {}
+ WrittenToSymtab(false), PendingArchiveLoad(false), IsGCRoot(false),
+ Name(N) {}
const unsigned SymbolKind : 8;
unsigned IsExternal : 1;
@@ -98,6 +99,9 @@ public:
// not load any more archive members to resolve the same symbol.
unsigned PendingArchiveLoad : 1;
+ /// True if we've already added this symbol to the list of GC roots.
+ unsigned IsGCRoot : 1;
+
protected:
StringRef Name;
};
More information about the llvm-commits
mailing list