[llvm] r237956 - Stop forwarding (get|set)Aligment from MCSectionData to MCSection.

Rafael Espindola rafael.espindola at gmail.com
Thu May 21 14:02:36 PDT 2015


Author: rafael
Date: Thu May 21 16:02:35 2015
New Revision: 237956

URL: http://llvm.org/viewvc/llvm-project?rev=237956&view=rev
Log:
Stop forwarding (get|set)Aligment from MCSectionData to MCSection.

Modified:
    llvm/trunk/include/llvm/MC/MCAssembler.h
    llvm/trunk/lib/MC/ELFObjectWriter.cpp
    llvm/trunk/lib/MC/MCAssembler.cpp
    llvm/trunk/lib/MC/MCELFStreamer.cpp
    llvm/trunk/lib/MC/MCMachOStreamer.cpp
    llvm/trunk/lib/MC/MCObjectStreamer.cpp
    llvm/trunk/lib/MC/MachObjectWriter.cpp
    llvm/trunk/lib/MC/WinCOFFObjectWriter.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=237956&r1=237955&r2=237956&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCAssembler.h (original)
+++ llvm/trunk/include/llvm/MC/MCAssembler.h Thu May 21 16:02:35 2015
@@ -597,9 +597,6 @@ public:
 
   MCSection &getSection() const { return *Section; }
 
-  unsigned getAlignment() const;
-  void setAlignment(unsigned Value);
-
   bool hasInstructions() const { return HasInstructions; }
   void setHasInstructions(bool Value) { HasInstructions = Value; }
 

Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ELFObjectWriter.cpp?rev=237956&r1=237955&r2=237956&view=diff
==============================================================================
--- llvm/trunk/lib/MC/ELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/ELFObjectWriter.cpp Thu May 21 16:02:35 2015
@@ -1347,7 +1347,7 @@ void ELFObjectWriter::WriteObject(MCAsse
   for (const MCSectionData &SD : Asm) {
     MCSectionELF &Section = static_cast<MCSectionELF &>(SD.getSection());
 
-    uint64_t Padding = OffsetToAlignment(OS.tell(), SD.getAlignment());
+    uint64_t Padding = OffsetToAlignment(OS.tell(), Section.getAlignment());
     WriteZeros(Padding);
 
     // Remember the offset into the file for this section.

Modified: llvm/trunk/lib/MC/MCAssembler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAssembler.cpp?rev=237956&r1=237955&r2=237956&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCAssembler.cpp (original)
+++ llvm/trunk/lib/MC/MCAssembler.cpp Thu May 21 16:02:35 2015
@@ -300,12 +300,6 @@ MCSectionData::MCSectionData(MCSection &
     A->getSectionList().push_back(this);
 }
 
-unsigned MCSectionData::getAlignment() const { return Section->getAlignment(); }
-
-void MCSectionData::setAlignment(unsigned Value) {
-  Section->setAlignment(Value);
-}
-
 MCSectionData::iterator
 MCSectionData::getSubsectionInsertionPoint(unsigned Subsection) {
   if (Subsection == 0 && SubsectionFragmentMap.empty())
@@ -1259,8 +1253,7 @@ void MCSectionData::dump() {
   raw_ostream &OS = llvm::errs();
 
   OS << "<MCSectionData";
-  OS << " Alignment:" << getAlignment()
-     << " Fragments:[\n      ";
+  OS << " Fragments:[\n      ";
   for (iterator it = begin(), ie = end(); it != ie; ++it) {
     if (it != begin()) OS << ",\n      ";
     it->dump();

Modified: llvm/trunk/lib/MC/MCELFStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCELFStreamer.cpp?rev=237956&r1=237955&r2=237956&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCELFStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCELFStreamer.cpp Thu May 21 16:02:35 2015
@@ -135,10 +135,9 @@ void MCELFStreamer::EmitAssemblerFlag(MC
 // needs to be aligned to at least the bundle size.
 static void setSectionAlignmentForBundling(
     const MCAssembler &Assembler, MCSectionData *Section) {
-  if (Assembler.isBundlingEnabled() && Section &&
-      Section->hasInstructions() &&
-      Section->getAlignment() < Assembler.getBundleAlignSize())
-    Section->setAlignment(Assembler.getBundleAlignSize());
+  if (Assembler.isBundlingEnabled() && Section && Section->hasInstructions() &&
+      Section->getSection().getAlignment() < Assembler.getBundleAlignSize())
+    Section->getSection().setAlignment(Assembler.getBundleAlignSize());
 }
 
 void MCELFStreamer::ChangeSection(MCSection *Section,
@@ -642,8 +641,8 @@ void MCELFStreamer::Flush() {
     Symbol.getData().setFragment(F);
 
     // Update the maximum alignment of the section if necessary.
-    if (ByteAlignment > SectData.getAlignment())
-      SectData.setAlignment(ByteAlignment);
+    if (ByteAlignment > Section.getAlignment())
+      Section.setAlignment(ByteAlignment);
   }
 
   LocalCommons.clear();

Modified: llvm/trunk/lib/MC/MCMachOStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCMachOStreamer.cpp?rev=237956&r1=237955&r2=237956&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCMachOStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCMachOStreamer.cpp Thu May 21 16:02:35 2015
@@ -426,8 +426,8 @@ void MCMachOStreamer::EmitZerofill(MCSec
   AssignSection(Symbol, Section);
 
   // Update the maximum alignment on the zero fill section if necessary.
-  if (ByteAlignment > SectData.getAlignment())
-    SectData.setAlignment(ByteAlignment);
+  if (ByteAlignment > Section->getAlignment())
+    Section->setAlignment(ByteAlignment);
 }
 
 // This should always be called with the thread local bss section.  Like the

Modified: llvm/trunk/lib/MC/MCObjectStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCObjectStreamer.cpp?rev=237956&r1=237955&r2=237956&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCObjectStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCObjectStreamer.cpp Thu May 21 16:02:35 2015
@@ -380,8 +380,9 @@ void MCObjectStreamer::EmitValueToAlignm
   insert(new MCAlignFragment(ByteAlignment, Value, ValueSize, MaxBytesToEmit));
 
   // Update the maximum alignment on the current section if necessary.
-  if (ByteAlignment > getCurrentSectionData()->getAlignment())
-    getCurrentSectionData()->setAlignment(ByteAlignment);
+  MCSection *CurSec = getCurrentSection().first;
+  if (ByteAlignment > CurSec->getAlignment())
+    CurSec->setAlignment(ByteAlignment);
 }
 
 void MCObjectStreamer::EmitCodeAlignment(unsigned ByteAlignment,

Modified: llvm/trunk/lib/MC/MachObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MachObjectWriter.cpp?rev=237956&r1=237955&r2=237956&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MachObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/MachObjectWriter.cpp Thu May 21 16:02:35 2015
@@ -115,7 +115,7 @@ uint64_t MachObjectWriter::getPaddingSiz
   const MCSectionData &NextSD = *Layout.getSectionOrder()[Next];
   if (NextSD.getSection().isVirtualSection())
     return 0;
-  return OffsetToAlignment(EndAddr, NextSD.getAlignment());
+  return OffsetToAlignment(EndAddr, NextSD.getSection().getAlignment());
 }
 
 void MachObjectWriter::WriteHeader(unsigned NumLoadCommands,
@@ -199,9 +199,10 @@ void MachObjectWriter::WriteSection(cons
                                     uint64_t RelocationsStart,
                                     unsigned NumRelocations) {
   uint64_t SectionSize = Layout.getSectionAddressSize(&SD);
+  const MCSectionMachO &Section = cast<MCSectionMachO>(SD.getSection());
 
   // The offset is unused for virtual sections.
-  if (SD.getSection().isVirtualSection()) {
+  if (Section.isVirtualSection()) {
     assert(Layout.getSectionFileSize(&SD) == 0 && "Invalid file size!");
     FileOffset = 0;
   }
@@ -212,7 +213,6 @@ void MachObjectWriter::WriteSection(cons
   uint64_t Start = OS.tell();
   (void) Start;
 
-  const MCSectionMachO &Section = cast<MCSectionMachO>(SD.getSection());
   WriteBytes(Section.getSectionName(), 16);
   WriteBytes(Section.getSegmentName(), 16);
   if (is64Bit()) {
@@ -228,8 +228,8 @@ void MachObjectWriter::WriteSection(cons
   if (SD.hasInstructions())
     Flags |= MachO::S_ATTR_SOME_INSTRUCTIONS;
 
-  assert(isPowerOf2_32(SD.getAlignment()) && "Invalid alignment!");
-  Write32(Log2_32(SD.getAlignment()));
+  assert(isPowerOf2_32(Section.getAlignment()) && "Invalid alignment!");
+  Write32(Log2_32(Section.getAlignment()));
   Write32(NumRelocations ? RelocationsStart : 0);
   Write32(NumRelocations);
   Write32(Flags);
@@ -645,7 +645,8 @@ void MachObjectWriter::computeSectionAdd
   const SmallVectorImpl<MCSectionData*> &Order = Layout.getSectionOrder();
   for (int i = 0, n = Order.size(); i != n ; ++i) {
     const MCSectionData *SD = Order[i];
-    StartAddress = RoundUpToAlignment(StartAddress, SD->getAlignment());
+    StartAddress =
+        RoundUpToAlignment(StartAddress, SD->getSection().getAlignment());
     SectionAddress[SD] = StartAddress;
     StartAddress += Layout.getSectionAddressSize(SD);
 

Modified: llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp?rev=237956&r1=237955&r2=237956&view=diff
==============================================================================
--- llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp Thu May 21 16:02:35 2015
@@ -322,7 +322,7 @@ void WinCOFFObjectWriter::DefineSection(
   coff_section->Header.Characteristics = Sec.getCharacteristics();
 
   uint32_t &Characteristics = coff_section->Header.Characteristics;
-  switch (SectionData.getAlignment()) {
+  switch (Sec.getAlignment()) {
   case 1:    Characteristics |= COFF::IMAGE_SCN_ALIGN_1BYTES;    break;
   case 2:    Characteristics |= COFF::IMAGE_SCN_ALIGN_2BYTES;    break;
   case 4:    Characteristics |= COFF::IMAGE_SCN_ALIGN_4BYTES;    break;

Modified: llvm/trunk/lib/MC/WinCOFFStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/WinCOFFStreamer.cpp?rev=237956&r1=237955&r2=237956&view=diff
==============================================================================
--- llvm/trunk/lib/MC/WinCOFFStreamer.cpp (original)
+++ llvm/trunk/lib/MC/WinCOFFStreamer.cpp Thu May 21 16:02:35 2015
@@ -221,8 +221,8 @@ void MCWinCOFFStreamer::EmitLocalCommonS
 
   MCSection *Section = getContext().getObjectFileInfo()->getBSSSection();
   MCSectionData &SectionData = getAssembler().getOrCreateSectionData(*Section);
-  if (SectionData.getAlignment() < ByteAlignment)
-    SectionData.setAlignment(ByteAlignment);
+  if (Section->getAlignment() < ByteAlignment)
+    Section->setAlignment(ByteAlignment);
 
   MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol);
   SD.setExternal(false);

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=237956&r1=237955&r2=237956&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsOptionRecord.cpp (original)
+++ llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsOptionRecord.cpp Thu May 21 16:02:35 2015
@@ -31,7 +31,8 @@ void MipsRegInfoRecord::EmitMipsOptionRe
     MCSectionELF *Sec =
         Context.getELFSection(".MIPS.options", ELF::SHT_MIPS_OPTIONS,
                               ELF::SHF_ALLOC | ELF::SHF_MIPS_NOSTRIP, 1, "");
-    MCA.getOrCreateSectionData(*Sec).setAlignment(8);
+    MCA.getOrCreateSectionData(*Sec);
+    Sec->setAlignment(8);
     Streamer->SwitchSection(Sec);
 
     Streamer->EmitIntValue(ELF::ODK_REGINFO, 1);  // kind
@@ -48,8 +49,8 @@ void MipsRegInfoRecord::EmitMipsOptionRe
   } else {
     MCSectionELF *Sec = Context.getELFSection(".reginfo", ELF::SHT_MIPS_REGINFO,
                                               ELF::SHF_ALLOC, 24, "");
-    MCA.getOrCreateSectionData(*Sec)
-        .setAlignment(MTS->getABI().IsN32() ? 8 : 4);
+    MCA.getOrCreateSectionData(*Sec);
+    Sec->setAlignment(MTS->getABI().IsN32() ? 8 : 4);
     Streamer->SwitchSection(Sec);
 
     Streamer->EmitIntValue(ri_gprmask, 4);

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=237956&r1=237955&r2=237956&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp (original)
+++ llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp Thu May 21 16:02:35 2015
@@ -459,16 +459,16 @@ void MipsTargetELFStreamer::finish() {
   const MCObjectFileInfo &OFI = *MCA.getContext().getObjectFileInfo();
 
   // .bss, .text and .data are always at least 16-byte aligned.
-  MCSectionData &TextSectionData =
-      MCA.getOrCreateSectionData(*OFI.getTextSection());
-  MCSectionData &DataSectionData =
-      MCA.getOrCreateSectionData(*OFI.getDataSection());
-  MCSectionData &BSSSectionData =
-      MCA.getOrCreateSectionData(*OFI.getBSSSection());
-
-  TextSectionData.setAlignment(std::max(16u, TextSectionData.getAlignment()));
-  DataSectionData.setAlignment(std::max(16u, DataSectionData.getAlignment()));
-  BSSSectionData.setAlignment(std::max(16u, BSSSectionData.getAlignment()));
+  MCSection &TextSection = *OFI.getTextSection();
+  MCA.getOrCreateSectionData(TextSection);
+  MCSection &DataSection = *OFI.getDataSection();
+  MCA.getOrCreateSectionData(DataSection);
+  MCSection &BSSSection = *OFI.getBSSSection();
+  MCA.getOrCreateSectionData(BSSSection);
+
+  TextSection.setAlignment(std::max(16u, TextSection.getAlignment()));
+  DataSection.setAlignment(std::max(16u, DataSection.getAlignment()));
+  BSSSection.setAlignment(std::max(16u, BSSSection.getAlignment()));
 
   uint64_t Features = STI.getFeatureBits();
 
@@ -570,8 +570,8 @@ void MipsTargetELFStreamer::emitDirectiv
   const MCSymbolRefExpr *ExprRef =
       MCSymbolRefExpr::Create(Name, MCSymbolRefExpr::VK_None, Context);
 
-  MCSectionData &SecData = MCA.getOrCreateSectionData(*Sec);
-  SecData.setAlignment(4);
+  MCA.getOrCreateSectionData(*Sec);
+  Sec->setAlignment(4);
 
   OS.PushSection();
 
@@ -788,8 +788,8 @@ void MipsTargetELFStreamer::emitMipsAbiF
   MCStreamer &OS = getStreamer();
   MCSectionELF *Sec = Context.getELFSection(
       ".MIPS.abiflags", ELF::SHT_MIPS_ABIFLAGS, ELF::SHF_ALLOC, 24, "");
-  MCSectionData &ABIShndxSD = MCA.getOrCreateSectionData(*Sec);
-  ABIShndxSD.setAlignment(8);
+  MCA.getOrCreateSectionData(*Sec);
+  Sec->setAlignment(8);
   OS.SwitchSection(Sec);
 
   OS << ABIFlagsSection;





More information about the llvm-commits mailing list