Remove SymbolTable::getChunks.
authorRafael Espindola <rafael.espindola@gmail.com>
Tue, 4 Aug 2015 13:39:30 +0000 (13:39 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Tue, 4 Aug 2015 13:39:30 +0000 (13:39 +0000)
When we were using a std::sort over all the chunks we needed to put them in a
single storage.

Now that we just iterate over them and use a map to find the output section,
we can avoid allocating the temporary storage.

llvm-svn: 243980

lld/ELF/SymbolTable.cpp
lld/ELF/SymbolTable.h
lld/ELF/Writer.cpp

index 61001b1..5ea0030 100644 (file)
@@ -68,15 +68,6 @@ template <class ELFT> void SymbolTable<ELFT>::resolve(SymbolBody *New) {
     error(Twine("duplicate symbol: ") + Name);
 }
 
-template <class ELFT> std::vector<Chunk *> SymbolTable<ELFT>::getChunks() {
-  std::vector<Chunk *> Res;
-  for (std::unique_ptr<ObjectFile<ELFT>> &File : ObjectFiles) {
-    ArrayRef<Chunk *> V = File->getChunks();
-    Res.insert(Res.end(), V.begin(), V.end());
-  }
-  return Res;
-}
-
 namespace lld {
 namespace elf2 {
 template class SymbolTable<object::ELF32LE>;
index 5fea407..98416a1 100644 (file)
@@ -38,9 +38,6 @@ public:
   // Print an error message on undefined symbols.
   void reportRemainingUndefines();
 
-  // Returns a list of chunks of selected symbols.
-  std::vector<Chunk *> getChunks();
-
   // The writer needs to infer the machine type from the object files.
   std::vector<std::unique_ptr<ObjectFile<ELFT>>> ObjectFiles;
 
index f702bc5..0f66e40 100644 (file)
@@ -81,13 +81,15 @@ void OutputSection::writeHeaderTo(Elf_Shdr_Impl<ELFT> *SHdr) {
 // Create output section objects and add them to OutputSections.
 template <class ELFT> void Writer<ELFT>::createSections() {
   SmallDenseMap<StringRef, OutputSection *> Map;
-  for (Chunk *C : Symtab->getChunks()) {
-    OutputSection *&Sec = Map[C->getSectionName()];
-    if (!Sec) {
-      Sec = new (CAlloc.Allocate()) OutputSection(C->getSectionName());
-      OutputSections.push_back(Sec);
+  for (std::unique_ptr<ObjectFile<ELFT>> &File : Symtab->ObjectFiles) {
+    for (Chunk *C : File->getChunks()) {
+      OutputSection *&Sec = Map[C->getSectionName()];
+      if (!Sec) {
+        Sec = new (CAlloc.Allocate()) OutputSection(C->getSectionName());
+        OutputSections.push_back(Sec);
+      }
+      Sec->addChunk<ELFT>(C);
     }
-    Sec->addChunk<ELFT>(C);
   }
 }