From 9b21ded6c8a615b8a5e9f822d40f632795675633 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Sat, 7 Mar 2015 04:23:46 +0000 Subject: [PATCH] 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 --- lld/lib/Core/Resolver.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lld/lib/Core/Resolver.cpp b/lld/lib/Core/Resolver.cpp index 2f24e47ef8f4..b9c26f040a16 100644 --- a/lld/lib/Core/Resolver.cpp +++ b/lld/lib/Core/Resolver.cpp @@ -54,8 +54,7 @@ void Resolver::forEachUndefines(File &file, bool searchForOverrides, StringRef undefName = _undefines[i]; if (undefName.empty()) continue; - const Atom *atom = _symbolTable.findByName(undefName); - if (!isa(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 UndefinedAtom &atom) { // 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; } -- 2.34.1