[llvm] r238208 - Replace getOrCreateSectionData with registerSection.

Rafael Espindola rafael.espindola at gmail.com
Tue May 26 08:07:26 PDT 2015


Author: rafael
Date: Tue May 26 10:07:25 2015
New Revision: 238208

URL: http://llvm.org/viewvc/llvm-project?rev=238208&view=rev
Log:
Replace getOrCreateSectionData with registerSection.

There is now no SectionData to be created.

Modified:
    llvm/trunk/include/llvm/MC/MCAssembler.h
    llvm/trunk/lib/MC/MCELFStreamer.cpp
    llvm/trunk/lib/MC/MCMachOStreamer.cpp
    llvm/trunk/lib/MC/MCObjectStreamer.cpp
    llvm/trunk/lib/MC/WinCOFFStreamer.cpp
    llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsOptionRecord.cpp
    llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp

Modified: llvm/trunk/include/llvm/MC/MCAssembler.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAssembler.h?rev=238208&r1=238207&r2=238208&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCAssembler.h (original)
+++ llvm/trunk/include/llvm/MC/MCAssembler.h Tue May 26 10:07:25 2015
@@ -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(); }
 

Modified: llvm/trunk/lib/MC/MCELFStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCELFStreamer.cpp?rev=238208&r1=238207&r2=238208&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCELFStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCELFStreamer.cpp Tue May 26 10:07:25 2015
@@ -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.

Modified: llvm/trunk/lib/MC/MCMachOStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCMachOStreamer.cpp?rev=238208&r1=238207&r2=238208&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCMachOStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCMachOStreamer.cpp Tue May 26 10:07:25 2015
@@ -403,7 +403,7 @@ void MCMachOStreamer::EmitLocalCommonSym
 
 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(MCSec
 
   // 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);

Modified: llvm/trunk/lib/MC/MCObjectStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCObjectStreamer.cpp?rev=238208&r1=238207&r2=238208&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCObjectStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCObjectStreamer.cpp Tue May 26 10:07:25 2015
@@ -211,8 +211,7 @@ bool MCObjectStreamer::changeSectionImpl
   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;

Modified: llvm/trunk/lib/MC/WinCOFFStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/WinCOFFStreamer.cpp?rev=238208&r1=238207&r2=238208&view=diff
==============================================================================
--- llvm/trunk/lib/MC/WinCOFFStreamer.cpp (original)
+++ llvm/trunk/lib/MC/WinCOFFStreamer.cpp Tue May 26 10:07:25 2015
@@ -220,7 +220,7 @@ void MCWinCOFFStreamer::EmitLocalCommonS
   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::EmitLocalCommonS
 
   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);
 }
 

Modified: llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsOptionRecord.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsOptionRecord.cpp?rev=238208&r1=238207&r2=238208&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsOptionRecord.cpp (original)
+++ llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsOptionRecord.cpp Tue May 26 10:07:25 2015
@@ -31,7 +31,7 @@ void MipsRegInfoRecord::EmitMipsOptionRe
     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::EmitMipsOptionRe
   } 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);
 

Modified: llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp?rev=238208&r1=238207&r2=238208&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp (original)
+++ llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp Tue May 26 10:07:25 2015
@@ -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::emitDirectiv
   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::emitMipsAbiF
   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);
 





More information about the llvm-commits mailing list