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.
llvm-svn: 231552
diff --git a/lld/lib/Core/Resolver.cpp b/lld/lib/Core/Resolver.cpp
index 2f24e47..b9c26f0 100644
--- a/lld/lib/Core/Resolver.cpp
+++ b/lld/lib/Core/Resolver.cpp
@@ -54,8 +54,7 @@
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 @@
// 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;
}