diff options
Diffstat (limited to 'llvm/lib/MC')
-rw-r--r-- | llvm/lib/MC/ELFObjectWriter.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/MC/MCAssembler.cpp | 9 | ||||
-rw-r--r-- | llvm/lib/MC/MCELFStreamer.cpp | 11 | ||||
-rw-r--r-- | llvm/lib/MC/MCMachOStreamer.cpp | 4 | ||||
-rw-r--r-- | llvm/lib/MC/MCObjectStreamer.cpp | 5 | ||||
-rw-r--r-- | llvm/lib/MC/MachObjectWriter.cpp | 13 | ||||
-rw-r--r-- | llvm/lib/MC/WinCOFFObjectWriter.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/MC/WinCOFFStreamer.cpp | 4 |
8 files changed, 22 insertions, 28 deletions
diff --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp index 0e764de7d8d..cdd6b173b67 100644 --- a/llvm/lib/MC/ELFObjectWriter.cpp +++ b/llvm/lib/MC/ELFObjectWriter.cpp @@ -1347,7 +1347,7 @@ void ELFObjectWriter::WriteObject(MCAssembler &Asm, 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. diff --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp index c2ddb93880e..481f91f2fb7 100644 --- a/llvm/lib/MC/MCAssembler.cpp +++ b/llvm/lib/MC/MCAssembler.cpp @@ -300,12 +300,6 @@ MCSectionData::MCSectionData(MCSection &Section, MCAssembler *A) 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(); diff --git a/llvm/lib/MC/MCELFStreamer.cpp b/llvm/lib/MC/MCELFStreamer.cpp index 7b02f1a4528..e666b554236 100644 --- a/llvm/lib/MC/MCELFStreamer.cpp +++ b/llvm/lib/MC/MCELFStreamer.cpp @@ -135,10 +135,9 @@ void MCELFStreamer::EmitAssemblerFlag(MCAssemblerFlag Flag) { // 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(); diff --git a/llvm/lib/MC/MCMachOStreamer.cpp b/llvm/lib/MC/MCMachOStreamer.cpp index c9777809a7f..3742a733d26 100644 --- a/llvm/lib/MC/MCMachOStreamer.cpp +++ b/llvm/lib/MC/MCMachOStreamer.cpp @@ -426,8 +426,8 @@ void MCMachOStreamer::EmitZerofill(MCSection *Section, MCSymbol *Symbol, 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 diff --git a/llvm/lib/MC/MCObjectStreamer.cpp b/llvm/lib/MC/MCObjectStreamer.cpp index b6d67a81771..3f32a36194f 100644 --- a/llvm/lib/MC/MCObjectStreamer.cpp +++ b/llvm/lib/MC/MCObjectStreamer.cpp @@ -380,8 +380,9 @@ void MCObjectStreamer::EmitValueToAlignment(unsigned ByteAlignment, 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, diff --git a/llvm/lib/MC/MachObjectWriter.cpp b/llvm/lib/MC/MachObjectWriter.cpp index 2799298d762..759b8c59568 100644 --- a/llvm/lib/MC/MachObjectWriter.cpp +++ b/llvm/lib/MC/MachObjectWriter.cpp @@ -115,7 +115,7 @@ uint64_t MachObjectWriter::getPaddingSize(const MCSectionData *SD, 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(const MCAssembler &Asm, 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(const MCAssembler &Asm, 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(const MCAssembler &Asm, 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::computeSectionAddresses(const MCAssembler &Asm, 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); diff --git a/llvm/lib/MC/WinCOFFObjectWriter.cpp b/llvm/lib/MC/WinCOFFObjectWriter.cpp index d5bffe93936..565bca3ee93 100644 --- a/llvm/lib/MC/WinCOFFObjectWriter.cpp +++ b/llvm/lib/MC/WinCOFFObjectWriter.cpp @@ -322,7 +322,7 @@ void WinCOFFObjectWriter::DefineSection(MCSectionData const &SectionData) { 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; diff --git a/llvm/lib/MC/WinCOFFStreamer.cpp b/llvm/lib/MC/WinCOFFStreamer.cpp index d048f287593..20c909db84a 100644 --- a/llvm/lib/MC/WinCOFFStreamer.cpp +++ b/llvm/lib/MC/WinCOFFStreamer.cpp @@ -221,8 +221,8 @@ void MCWinCOFFStreamer::EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, 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); |