[lld] r248572 - Inline function into only use.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 25 08:08:44 PDT 2015


Author: rafael
Date: Fri Sep 25 10:08:44 2015
New Revision: 248572

URL: http://llvm.org/viewvc/llvm-project?rev=248572&view=rev
Log:
Inline function into only use.

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=248572&r1=248571&r2=248572&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Fri Sep 25 10:08:44 2015
@@ -295,18 +295,6 @@ template <class ELFT> void Writer<ELFT>:
   OutputSections.push_back(&BssSec);
   Map[{BssSec.getName(), BssSec.getType(), BssSec.getFlags()}] = &BssSec;
 
-  auto getSection = [&](StringRef Name, uint32_t sh_type,
-                        uintX_t sh_flags) -> OutputSection<ELFT> * {
-    SectionKey<ELFT::Is64Bits> Key{Name, sh_type, sh_flags};
-    OutputSection<ELFT> *&Sec = Map[Key];
-    if (!Sec) {
-      Sec = new (CAlloc.Allocate()) OutputSection<ELFT>(
-          PltSec, GotSec, BssSec, Key.Name, Key.sh_type, Key.sh_flags);
-      OutputSections.push_back(Sec);
-    }
-    return Sec;
-  };
-
   const SymbolTable &Symtab = SymTabSec.getSymTable();
   for (const std::unique_ptr<ObjectFileBase> &FileB : Symtab.getObjectFiles()) {
     auto &File = cast<ObjectFile<ELFT>>(*FileB);
@@ -322,8 +310,14 @@ template <class ELFT> void Writer<ELFT>:
       if (!C)
         continue;
       const Elf_Shdr *H = C->getSectionHdr();
-      OutputSection<ELFT> *Sec =
-          getSection(C->getSectionName(), H->sh_type, H->sh_flags);
+      SectionKey<ELFT::Is64Bits> Key{C->getSectionName(), H->sh_type,
+                                     H->sh_flags};
+      OutputSection<ELFT> *&Sec = Map[Key];
+      if (!Sec) {
+        Sec = new (CAlloc.Allocate()) OutputSection<ELFT>(
+            PltSec, GotSec, BssSec, Key.Name, Key.sh_type, Key.sh_flags);
+        OutputSections.push_back(Sec);
+      }
       Sec->addSection(C);
       scanRelocs(*C);
     }




More information about the llvm-commits mailing list