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
This commit is contained in:
Rafael Espindola
2015-08-04 13:39:30 +00:00
parent c9ba1bd20a
commit b89951457d
3 changed files with 8 additions and 18 deletions

View 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>;

View 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;

View 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);
}
}