[lld] r231549 - Resolver: Reduce number of hash function call.

Rui Ueyama ruiu at google.com
Fri Mar 6 19:22:38 PST 2015


Author: ruiu
Date: Fri Mar  6 21:22:37 2015
New Revision: 231549

URL: http://llvm.org/viewvc/llvm-project?rev=231549&view=rev
Log:
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.

Modified:
    lld/trunk/lib/Core/Resolver.cpp

Modified: lld/trunk/lib/Core/Resolver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/Resolver.cpp?rev=231549&r1=231548&r2=231549&view=diff
==============================================================================
--- lld/trunk/lib/Core/Resolver.cpp (original)
+++ lld/trunk/lib/Core/Resolver.cpp Fri Mar  6 21:22:37 2015
@@ -54,8 +54,8 @@ void Resolver::forEachUndefines(File &fi
       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;





More information about the llvm-commits mailing list