From: Rafael Espindola Date: Tue, 4 Aug 2015 13:39:30 +0000 (+0000) Subject: Remove SymbolTable::getChunks. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b89951457de7f5ba4e23fd1dc2d5c5a4aedf461d;p=platform%2Fupstream%2Fllvm.git Remove SymbolTable::getChunks. 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 --- diff --git a/lld/ELF/SymbolTable.cpp b/lld/ELF/SymbolTable.cpp index 61001b1..5ea0030 100644 --- a/lld/ELF/SymbolTable.cpp +++ b/lld/ELF/SymbolTable.cpp @@ -68,15 +68,6 @@ template void SymbolTable::resolve(SymbolBody *New) { error(Twine("duplicate symbol: ") + Name); } -template std::vector SymbolTable::getChunks() { - std::vector Res; - for (std::unique_ptr> &File : ObjectFiles) { - ArrayRef V = File->getChunks(); - Res.insert(Res.end(), V.begin(), V.end()); - } - return Res; -} - namespace lld { namespace elf2 { template class SymbolTable; diff --git a/lld/ELF/SymbolTable.h b/lld/ELF/SymbolTable.h index 5fea407..98416a1 100644 --- a/lld/ELF/SymbolTable.h +++ b/lld/ELF/SymbolTable.h @@ -38,9 +38,6 @@ public: // Print an error message on undefined symbols. void reportRemainingUndefines(); - // Returns a list of chunks of selected symbols. - std::vector getChunks(); - // The writer needs to infer the machine type from the object files. std::vector>> ObjectFiles; diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index f702bc5..0f66e40 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -81,13 +81,15 @@ void OutputSection::writeHeaderTo(Elf_Shdr_Impl *SHdr) { // Create output section objects and add them to OutputSections. template void Writer::createSections() { SmallDenseMap 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> &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(C); } - Sec->addChunk(C); } }