[lld] r267822 - Do not lookup the symbol table twice for each --wrap.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 27 17:03:38 PDT 2016


Author: ruiu
Date: Wed Apr 27 19:03:38 2016
New Revision: 267822

URL: http://llvm.org/viewvc/llvm-project?rev=267822&view=rev
Log:
Do not lookup the symbol table twice for each --wrap.

Modified:
    lld/trunk/ELF/SymbolTable.cpp

Modified: lld/trunk/ELF/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.cpp?rev=267822&r1=267821&r2=267822&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.cpp (original)
+++ lld/trunk/ELF/SymbolTable.cpp Wed Apr 27 19:03:38 2016
@@ -188,10 +188,11 @@ DefinedRegular<ELFT> *SymbolTable<ELFT>:
 // Rename SYM as __wrap_SYM. The original symbol is preserved as __real_SYM.
 // Used to implement --wrap.
 template <class ELFT> void SymbolTable<ELFT>::wrap(StringRef Name) {
-  if (Symtab.count(Name) == 0)
+  SymbolBody *B = find(Name);
+  if (!B)
     return;
   StringSaver Saver(Alloc);
-  Symbol *Sym = addUndefined(Name)->Backref;
+  Symbol *Sym = B->Backref;
   Symbol *Real = addUndefined(Saver.save("__real_" + Name))->Backref;
   Symbol *Wrap = addUndefined(Saver.save("__wrap_" + Name))->Backref;
   Real->Body = Sym->Body;




More information about the llvm-commits mailing list