mirror of
https://github.com/intel/llvm.git
synced 2026-02-06 06:31:50 +08:00
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:
@@ -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>;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user