[lld] r231552 - Resolver: optimize fallback atoms.
Rui Ueyama
ruiu at google.com
Fri Mar 6 20:23:46 PST 2015
Author: ruiu
Date: Fri Mar 6 22:23:46 2015
New Revision: 231552
URL: http://llvm.org/viewvc/llvm-project?rev=231552&view=rev
Log:
Resolver: optimize fallback atoms.
Atoms with fallback atoms are never be added to the symbol table.
However, we added such atoms to _undefines array. We had to call
isCoalescedAway to identify and skip them. We should just stop
adding them in the first place.
This seems to make the linker ~1% faster in my test case.
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=231552&r1=231551&r2=231552&view=diff
==============================================================================
--- lld/trunk/lib/Core/Resolver.cpp (original)
+++ lld/trunk/lib/Core/Resolver.cpp Fri Mar 6 22:23:46 2015
@@ -54,8 +54,7 @@ void Resolver::forEachUndefines(File &fi
StringRef undefName = _undefines[i];
if (undefName.empty())
continue;
- const Atom *atom = _symbolTable.findByName(undefName);
- if (!isa<UndefinedAtom>(atom) || _symbolTable.isCoalescedAway(atom)) {
+ if (_symbolTable.isDefined(undefName)) {
// The symbol was resolved by some other file. Cache the result.
_undefines[i] = "";
continue;
@@ -119,18 +118,18 @@ bool Resolver::doUndefinedAtom(const Und
// tell symbol table
bool newUndefAdded = _symbolTable.add(atom);
- if (newUndefAdded)
- _undefines.push_back(atom.name());
// If the undefined symbol has an alternative name, try to resolve the
// symbol with the name to give it a second chance. This feature is used
// for COFF "weak external" symbol.
if (newUndefAdded || !_symbolTable.isDefined(atom.name())) {
if (const UndefinedAtom *fallbackAtom = atom.fallback()) {
- doUndefinedAtom(*fallbackAtom);
_symbolTable.addReplacement(&atom, fallbackAtom);
+ return doUndefinedAtom(*fallbackAtom);
}
}
+ if (newUndefAdded)
+ _undefines.push_back(atom.name());
return newUndefAdded;
}
More information about the llvm-commits
mailing list