[lld] r361802 - [ELF] Replace two addSymbol() call sites with Symbol::resolve(). NFC

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Tue May 28 03:12:06 PDT 2019


Author: maskray
Date: Tue May 28 03:12:06 2019
New Revision: 361802

URL: http://llvm.org/viewvc/llvm-project?rev=361802&view=rev
Log:
[ELF] Replace two addSymbol() call sites with Symbol::resolve(). NFC

If we have a handle of the symbol, insert() called by addSymbol() is
redundant. Just call resolve().

Modified:
    lld/trunk/ELF/Writer.cpp

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=361802&r1=361801&r2=361802&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Tue May 28 03:12:06 2019
@@ -180,9 +180,9 @@ static Defined *addOptionalRegular(Strin
   if (!S || S->isDefined())
     return nullptr;
 
-  return cast<Defined>(Symtab->addSymbol(
-      Defined{/*File=*/nullptr, Name, Binding, StOther, STT_NOTYPE, Val,
-              /*Size=*/0, Sec}));
+  S->resolve(Defined{/*File=*/nullptr, Name, Binding, StOther, STT_NOTYPE, Val,
+                     /*Size=*/0, Sec});
+  return cast<Defined>(S);
 }
 
 static Defined *addAbsolute(StringRef Name) {
@@ -239,9 +239,8 @@ void elf::addReservedSymbols() {
     if (Config->EMachine == EM_PPC || Config->EMachine == EM_PPC64)
       GotOff = 0x8000;
 
-    Symtab->addSymbol(Defined{/*File=*/nullptr, GotSymName, STB_GLOBAL,
-                              STV_HIDDEN, STT_NOTYPE, GotOff, /*Size=*/0,
-                              Out::ElfHeader});
+    S->resolve(Defined{/*File=*/nullptr, GotSymName, STB_GLOBAL, STV_HIDDEN,
+                       STT_NOTYPE, GotOff, /*Size=*/0, Out::ElfHeader});
     ElfSym::GlobalOffsetTable = cast<Defined>(S);
   }
 




More information about the llvm-commits mailing list