[LLD] [COFF] Avoid doing repeated fuzzy symbol lookup for each iteration. NFC.
authorMartin Storsjö <martin@martin.st>
Thu, 17 Jun 2021 13:28:47 +0000 (16:28 +0300)
committerMartin Storsjö <martin@martin.st>
Sat, 19 Jun 2021 19:32:37 +0000 (22:32 +0300)
This is run every time around in the main linker loop. Once a match
has been found, stop trying to rematch such a symbol.

Not sure if this has any actual measurable performance impact though
(SymbolTable::findMangle() iterates over the whole symbol table for
each call and does fuzzy matching on top of that) but this makes the
code more reassuring to read at least. (This is in practice run for def
files listing undecorated stdcall functions to be exported.)

Differential Revision: https://reviews.llvm.org/D104529

lld/COFF/Driver.cpp

index 97b3c90..5eab3fb 100644 (file)
@@ -549,7 +549,7 @@ Symbol *LinkerDriver::addUndefined(StringRef name) {
 StringRef LinkerDriver::mangleMaybe(Symbol *s) {
   // If the plain symbol name has already been resolved, do nothing.
   Undefined *unmangled = dyn_cast<Undefined>(s);
-  if (!unmangled)
+  if (!unmangled || unmangled->getWeakAlias())
     return "";
 
   // Otherwise, see if a similar, mangled symbol exists in the symbol table.