From b89275550c9615d2bc94c9591bc952606883a3d3 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Tue, 28 Apr 2015 22:26:19 +0000 Subject: [PATCH] Remove redundant temporary std::vector. New sections are added to the end of the list, so the RelSections array was redundant. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236053 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/MC/ELFObjectWriter.cpp | 32 +++++++------------------------- 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/lib/MC/ELFObjectWriter.cpp b/lib/MC/ELFObjectWriter.cpp index 185b66332be..201b1a40f39 100644 --- a/lib/MC/ELFObjectWriter.cpp +++ b/lib/MC/ELFObjectWriter.cpp @@ -239,8 +239,7 @@ class ELFObjectWriter : public MCObjectWriter { SectionIndexMapTy &SectionIndexMap, const RevGroupMapTy &RevGroupMap); - MCSectionData *createRelocationSection(MCAssembler &Asm, - const MCSectionData &SD); + void createRelocationSection(MCAssembler &Asm, const MCSectionData &SD); void CompressDebugSections(MCAssembler &Asm, MCAsmLayout &Layout); @@ -957,32 +956,16 @@ void ELFObjectWriter::maybeAddToGroup(MCAssembler &Asm, void ELFObjectWriter::computeIndexMap( MCAssembler &Asm, std::vector &Sections, SectionIndexMapTy &SectionIndexMap, const RevGroupMapTy &RevGroupMap) { - std::vector RelSections; for (const MCSectionData &SD : Asm) { const MCSectionELF &Section = static_cast(SD.getSection()); - if (Section.getType() == ELF::SHT_GROUP || - Section.getType() == ELF::SHT_REL || - Section.getType() == ELF::SHT_RELA) + if (Section.getType() == ELF::SHT_GROUP) continue; Sections.push_back(&Section); unsigned Index = Sections.size(); SectionIndexMap[&Section] = Index; maybeAddToGroup(Asm, RevGroupMap, Section, Index); - - if (MCSectionData *RelSD = createRelocationSection(Asm, SD)) { - const MCSectionELF *RelSection = - static_cast(&RelSD->getSection()); - RelSections.push_back(RelSection); - } - } - - // Put relocation sections close together. The linker reads them - // first, so this improves cache locality. - for (const MCSectionELF *Sec : RelSections) { - Sections.push_back(Sec); - unsigned Index = Sections.size(); - maybeAddToGroup(Asm, RevGroupMap, *Sec, Index); + createRelocationSection(Asm, SD); } } @@ -1131,11 +1114,10 @@ void ELFObjectWriter::computeSymbolTable( UndefinedSymbolData[i].SymbolData->setIndex(Index++); } -MCSectionData * -ELFObjectWriter::createRelocationSection(MCAssembler &Asm, - const MCSectionData &SD) { +void ELFObjectWriter::createRelocationSection(MCAssembler &Asm, + const MCSectionData &SD) { if (Relocations[&SD].empty()) - return nullptr; + return; MCContext &Ctx = Asm.getContext(); const MCSectionELF &Section = @@ -1158,7 +1140,7 @@ ELFObjectWriter::createRelocationSection(MCAssembler &Asm, const MCSectionELF *RelaSection = Ctx.createELFRelSection( RelaSectionName, hasRelocationAddend() ? ELF::SHT_RELA : ELF::SHT_REL, Flags, EntrySize, Section.getGroup(), &Section); - return &Asm.getOrCreateSectionData(*RelaSection); + Asm.getOrCreateSectionData(*RelaSection); } static SmallVector -- 2.34.1