summaryrefslogtreecommitdiffstats
path: root/lld/lib/Core/Resolver.cpp
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2015-03-07 03:22:37 +0000
committerRui Ueyama <ruiu@google.com>2015-03-07 03:22:37 +0000
commit923147b95448476478297b30af7645b910da2dbe (patch)
tree4cea2c6c499bb1842db944d5d4301c895c0512d3 /lld/lib/Core/Resolver.cpp
parent80fce4e7da95876ffc26ba7114933a15787ae66d (diff)
downloadbcm5719-llvm-923147b95448476478297b30af7645b910da2dbe.tar.gz
bcm5719-llvm-923147b95448476478297b30af7645b910da2dbe.zip
Resolver: Reduce number of hash function call.
This is yet another optimization patch. Previously we called SymbolTable::isDefined() and SymbolTable::findByName() from a very frequently executed function. Because isDefined calls findByName, findByName is called twice on each iteration. findByName is not a cheap function. It computes a hash value for a given symbol name. When linking C++ programs, it can be expensive because of C++ mangled long symbols. This patch reduces the number of call from 2 to 1. Performance improvements by this patch was larger than I expected. Linking time of chrome.dll gets almost 5% shorter. llvm-svn: 231549
Diffstat (limited to 'lld/lib/Core/Resolver.cpp')
-rw-r--r--lld/lib/Core/Resolver.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/lld/lib/Core/Resolver.cpp b/lld/lib/Core/Resolver.cpp
index fbfffb5aa8c..bb942f54b70 100644
--- a/lld/lib/Core/Resolver.cpp
+++ b/lld/lib/Core/Resolver.cpp
@@ -54,8 +54,8 @@ void Resolver::forEachUndefines(File &file, bool searchForOverrides,
StringRef undefName = _undefines[i];
if (undefName.empty())
continue;
- if (_symbolTable.isDefined(undefName) ||
- _symbolTable.isCoalescedAway(_symbolTable.findByName(undefName))) {
+ const Atom *atom = _symbolTable.findByName(undefName);
+ if (!isa<UndefinedAtom>(atom) || _symbolTable.isCoalescedAway(atom)) {
// The symbol was resolved by some other file. Cache the result.
_undefines[i] = "";
continue;
OpenPOWER on IntegriCloud