From: Rafael Espindola Date: Tue, 26 May 2015 15:07:25 +0000 (+0000) Subject: Replace getOrCreateSectionData with registerSection. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=b14ebd6a1da4acaaf6a1b7f6916ff3b94e3d45a8;p=oota-llvm.git Replace getOrCreateSectionData with registerSection. There is now no SectionData to be created. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238208 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/MC/MCAssembler.h b/include/llvm/MC/MCAssembler.h index 38c8b9c01d2..593504ce060 100644 --- a/include/llvm/MC/MCAssembler.h +++ b/include/llvm/MC/MCAssembler.h @@ -40,7 +40,6 @@ class MCExpr; class MCFragment; class MCObjectWriter; class MCSection; -class MCSectionData; class MCSubtargetInfo; class MCValue; class MCAsmBackend; @@ -884,13 +883,7 @@ public: /// \name Backend Data Access /// @{ - MCSectionData &getOrCreateSectionData(MCSection &Section, - bool *Created = nullptr) { - bool C = Sections.insert(&Section); - if (Created) - *Created = C; - return Section.getSectionData(); - } + bool registerSection(MCSection &Section) { return Sections.insert(&Section); } bool hasSymbolData(const MCSymbol &Symbol) const { return Symbol.hasData(); } diff --git a/lib/MC/MCELFStreamer.cpp b/lib/MC/MCELFStreamer.cpp index 8854866bca7..653a1d2b3a5 100644 --- a/lib/MC/MCELFStreamer.cpp +++ b/lib/MC/MCELFStreamer.cpp @@ -637,11 +637,10 @@ void MCELFStreamer::Flush() { unsigned ByteAlignment = i->ByteAlignment; MCSection &Section = Symbol.getSection(); - MCSectionData &SectData = getAssembler().getOrCreateSectionData(Section); - new MCAlignFragment(ByteAlignment, 0, 1, ByteAlignment, - &SectData.getSection()); + getAssembler().registerSection(Section); + new MCAlignFragment(ByteAlignment, 0, 1, ByteAlignment, &Section); - MCFragment *F = new MCFillFragment(0, 0, Size, &SectData.getSection()); + MCFragment *F = new MCFillFragment(0, 0, Size, &Section); Symbol.getData().setFragment(F); // Update the maximum alignment of the section if necessary. diff --git a/lib/MC/MCMachOStreamer.cpp b/lib/MC/MCMachOStreamer.cpp index 2db463c86b5..011db484751 100644 --- a/lib/MC/MCMachOStreamer.cpp +++ b/lib/MC/MCMachOStreamer.cpp @@ -403,7 +403,7 @@ void MCMachOStreamer::EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, void MCMachOStreamer::EmitZerofill(MCSection *Section, MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment) { - MCSectionData &SectData = getAssembler().getOrCreateSectionData(*Section); + getAssembler().registerSection(*Section); // The symbol may not be present, which only creates the section. if (!Symbol) @@ -418,10 +418,9 @@ void MCMachOStreamer::EmitZerofill(MCSection *Section, MCSymbol *Symbol, // Emit an align fragment if necessary. if (ByteAlignment != 1) - new MCAlignFragment(ByteAlignment, 0, 0, ByteAlignment, - &SectData.getSection()); + new MCAlignFragment(ByteAlignment, 0, 0, ByteAlignment, Section); - MCFragment *F = new MCFillFragment(0, 0, Size, &SectData.getSection()); + MCFragment *F = new MCFillFragment(0, 0, Size, Section); SD.setFragment(F); AssignSection(Symbol, Section); diff --git a/lib/MC/MCObjectStreamer.cpp b/lib/MC/MCObjectStreamer.cpp index f5a282d603c..c1b20717db3 100644 --- a/lib/MC/MCObjectStreamer.cpp +++ b/lib/MC/MCObjectStreamer.cpp @@ -211,8 +211,7 @@ bool MCObjectStreamer::changeSectionImpl(MCSection *Section, assert(Section && "Cannot switch to a null section!"); flushPendingLabels(nullptr); - bool Created; - getAssembler().getOrCreateSectionData(*Section, &Created); + bool Created = getAssembler().registerSection(*Section); CurSectionData = Section; int64_t IntSubsection = 0; diff --git a/lib/MC/WinCOFFStreamer.cpp b/lib/MC/WinCOFFStreamer.cpp index eb98eba1711..d2fbd37499f 100644 --- a/lib/MC/WinCOFFStreamer.cpp +++ b/lib/MC/WinCOFFStreamer.cpp @@ -220,7 +220,7 @@ void MCWinCOFFStreamer::EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, assert(!Symbol->isInSection() && "Symbol must not already have a section!"); MCSection *Section = getContext().getObjectFileInfo()->getBSSSection(); - MCSectionData &SectionData = getAssembler().getOrCreateSectionData(*Section); + getAssembler().registerSection(*Section); if (Section->getAlignment() < ByteAlignment) Section->setAlignment(ByteAlignment); @@ -231,10 +231,10 @@ void MCWinCOFFStreamer::EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, if (ByteAlignment != 1) new MCAlignFragment(ByteAlignment, /*Value=*/0, /*ValueSize=*/0, - ByteAlignment, &SectionData.getSection()); + ByteAlignment, Section); MCFillFragment *Fragment = new MCFillFragment( - /*Value=*/0, /*ValueSize=*/0, Size, &SectionData.getSection()); + /*Value=*/0, /*ValueSize=*/0, Size, Section); SD.setFragment(Fragment); } diff --git a/lib/Target/Mips/MCTargetDesc/MipsOptionRecord.cpp b/lib/Target/Mips/MCTargetDesc/MipsOptionRecord.cpp index 076beedfa66..49116326139 100644 --- a/lib/Target/Mips/MCTargetDesc/MipsOptionRecord.cpp +++ b/lib/Target/Mips/MCTargetDesc/MipsOptionRecord.cpp @@ -31,7 +31,7 @@ void MipsRegInfoRecord::EmitMipsOptionRecord() { MCSectionELF *Sec = Context.getELFSection(".MIPS.options", ELF::SHT_MIPS_OPTIONS, ELF::SHF_ALLOC | ELF::SHF_MIPS_NOSTRIP, 1, ""); - MCA.getOrCreateSectionData(*Sec); + MCA.registerSection(*Sec); Sec->setAlignment(8); Streamer->SwitchSection(Sec); @@ -49,7 +49,7 @@ void MipsRegInfoRecord::EmitMipsOptionRecord() { } else { MCSectionELF *Sec = Context.getELFSection(".reginfo", ELF::SHT_MIPS_REGINFO, ELF::SHF_ALLOC, 24, ""); - MCA.getOrCreateSectionData(*Sec); + MCA.registerSection(*Sec); Sec->setAlignment(MTS->getABI().IsN32() ? 8 : 4); Streamer->SwitchSection(Sec); diff --git a/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp b/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp index a59f353c7eb..8e6f047450e 100644 --- a/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp +++ b/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp @@ -460,11 +460,11 @@ void MipsTargetELFStreamer::finish() { // .bss, .text and .data are always at least 16-byte aligned. MCSection &TextSection = *OFI.getTextSection(); - MCA.getOrCreateSectionData(TextSection); + MCA.registerSection(TextSection); MCSection &DataSection = *OFI.getDataSection(); - MCA.getOrCreateSectionData(DataSection); + MCA.registerSection(DataSection); MCSection &BSSSection = *OFI.getBSSSection(); - MCA.getOrCreateSectionData(BSSSection); + MCA.registerSection(BSSSection); TextSection.setAlignment(std::max(16u, TextSection.getAlignment())); DataSection.setAlignment(std::max(16u, DataSection.getAlignment())); @@ -570,7 +570,7 @@ void MipsTargetELFStreamer::emitDirectiveEnd(StringRef Name) { const MCSymbolRefExpr *ExprRef = MCSymbolRefExpr::Create(Name, MCSymbolRefExpr::VK_None, Context); - MCA.getOrCreateSectionData(*Sec); + MCA.registerSection(*Sec); Sec->setAlignment(4); OS.PushSection(); @@ -788,7 +788,7 @@ void MipsTargetELFStreamer::emitMipsAbiFlags() { MCStreamer &OS = getStreamer(); MCSectionELF *Sec = Context.getELFSection( ".MIPS.abiflags", ELF::SHT_MIPS_ABIFLAGS, ELF::SHF_ALLOC, 24, ""); - MCA.getOrCreateSectionData(*Sec); + MCA.registerSection(*Sec); Sec->setAlignment(8); OS.SwitchSection(Sec);