diff options
Diffstat (limited to 'llvm/lib/MC')
-rw-r--r-- | llvm/lib/MC/ConstantPools.cpp | 13 | ||||
-rw-r--r-- | llvm/lib/MC/ELFObjectWriter.cpp | 34 | ||||
-rw-r--r-- | llvm/lib/MC/MCAsmInfoELF.cpp | 3 | ||||
-rw-r--r-- | llvm/lib/MC/MCAsmStreamer.cpp | 17 | ||||
-rw-r--r-- | llvm/lib/MC/MCAssembler.cpp | 10 | ||||
-rw-r--r-- | llvm/lib/MC/MCContext.cpp | 70 | ||||
-rw-r--r-- | llvm/lib/MC/MCDwarf.cpp | 18 | ||||
-rw-r--r-- | llvm/lib/MC/MCELFStreamer.cpp | 12 | ||||
-rw-r--r-- | llvm/lib/MC/MCExpr.cpp | 6 | ||||
-rw-r--r-- | llvm/lib/MC/MCMachOStreamer.cpp | 12 | ||||
-rw-r--r-- | llvm/lib/MC/MCNullStreamer.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/MC/MCObjectFileInfo.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/MC/MCObjectStreamer.cpp | 4 | ||||
-rw-r--r-- | llvm/lib/MC/MCParser/AsmParser.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/MC/MCParser/ELFAsmParser.cpp | 6 | ||||
-rw-r--r-- | llvm/lib/MC/MCSection.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/MC/MCStreamer.cpp | 11 | ||||
-rw-r--r-- | llvm/lib/MC/MCSymbol.cpp | 3 | ||||
-rw-r--r-- | llvm/lib/MC/MCWin64EH.cpp | 9 | ||||
-rw-r--r-- | llvm/lib/MC/MCWinEH.cpp | 19 | ||||
-rw-r--r-- | llvm/lib/MC/WinCOFFStreamer.cpp | 12 |
21 files changed, 131 insertions, 136 deletions
diff --git a/llvm/lib/MC/ConstantPools.cpp b/llvm/lib/MC/ConstantPools.cpp index 8011c799750..a723aa8fa40 100644 --- a/llvm/lib/MC/ConstantPools.cpp +++ b/llvm/lib/MC/ConstantPools.cpp @@ -48,8 +48,7 @@ bool ConstantPool::empty() { return Entries.empty(); } // // AssemblerConstantPools implementation // -ConstantPool * -AssemblerConstantPools::getConstantPool(const MCSection *Section) { +ConstantPool *AssemblerConstantPools::getConstantPool(MCSection *Section) { ConstantPoolMapTy::iterator CP = ConstantPools.find(Section); if (CP == ConstantPools.end()) return nullptr; @@ -58,11 +57,11 @@ AssemblerConstantPools::getConstantPool(const MCSection *Section) { } ConstantPool & -AssemblerConstantPools::getOrCreateConstantPool(const MCSection *Section) { +AssemblerConstantPools::getOrCreateConstantPool(MCSection *Section) { return ConstantPools[Section]; } -static void emitConstantPool(MCStreamer &Streamer, const MCSection *Section, +static void emitConstantPool(MCStreamer &Streamer, MCSection *Section, ConstantPool &CP) { if (!CP.empty()) { Streamer.SwitchSection(Section); @@ -75,7 +74,7 @@ void AssemblerConstantPools::emitAll(MCStreamer &Streamer) { for (ConstantPoolMapTy::iterator CPI = ConstantPools.begin(), CPE = ConstantPools.end(); CPI != CPE; ++CPI) { - const MCSection *Section = CPI->first; + MCSection *Section = CPI->first; ConstantPool &CP = CPI->second; emitConstantPool(Streamer, Section, CP); @@ -83,7 +82,7 @@ void AssemblerConstantPools::emitAll(MCStreamer &Streamer) { } void AssemblerConstantPools::emitForCurrentSection(MCStreamer &Streamer) { - const MCSection *Section = Streamer.getCurrentSection().first; + MCSection *Section = Streamer.getCurrentSection().first; if (ConstantPool *CP = getConstantPool(Section)) { emitConstantPool(Streamer, Section, *CP); } @@ -92,7 +91,7 @@ void AssemblerConstantPools::emitForCurrentSection(MCStreamer &Streamer) { const MCExpr *AssemblerConstantPools::addEntry(MCStreamer &Streamer, const MCExpr *Expr, unsigned Size) { - const MCSection *Section = Streamer.getCurrentSection().first; + MCSection *Section = Streamer.getCurrentSection().first; return getOrCreateConstantPool(Section).addEntry(Expr, Streamer.getContext(), Size); } diff --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp index c36da56f0ce..ff1c2a9ecc1 100644 --- a/llvm/lib/MC/ELFObjectWriter.cpp +++ b/llvm/lib/MC/ELFObjectWriter.cpp @@ -133,8 +133,8 @@ class ELFObjectWriter : public MCObjectWriter { unsigned ShstrtabIndex; // Sections in the order they are to be output in the section table. - std::vector<const MCSectionELF *> SectionTable; - unsigned addToSectionTable(const MCSectionELF *Sec); + std::vector<MCSectionELF *> SectionTable; + unsigned addToSectionTable(MCSectionELF *Sec); // TargetObjectWriter wrappers. bool is64Bit() const { return TargetObjectWriter->is64Bit(); } @@ -221,8 +221,8 @@ class ELFObjectWriter : public MCObjectWriter { const SectionIndexMapTy &SectionIndexMap, const RevGroupMapTy &RevGroupMap); - const MCSectionELF *createRelocationSection(MCAssembler &Asm, - const MCSectionELF &Sec); + MCSectionELF *createRelocationSection(MCAssembler &Asm, + const MCSectionELF &Sec); const MCSectionELF *createSectionHeaderStringTable(); const MCSectionELF *createStringTable(MCContext &Ctx); @@ -261,7 +261,7 @@ class ELFObjectWriter : public MCObjectWriter { }; } -unsigned ELFObjectWriter::addToSectionTable(const MCSectionELF *Sec) { +unsigned ELFObjectWriter::addToSectionTable(MCSectionELF *Sec) { SectionTable.push_back(Sec); ShStrTabBuilder.add(Sec->getSectionName()); return SectionTable.size(); @@ -549,7 +549,7 @@ void ELFObjectWriter::WriteSymbolTable(MCAssembler &Asm, unsigned EntrySize = is64Bit() ? ELF::SYMENTRY_SIZE64 : ELF::SYMENTRY_SIZE32; // Symbol table - const MCSectionELF *SymtabSection = + MCSectionELF *SymtabSection = Ctx.getELFSection(".symtab", ELF::SHT_SYMTAB, 0, EntrySize, ""); MCSectionData &SymtabSD = Asm.getOrCreateSectionData(*SymtabSection); SymtabSD.setAlignment(is64Bit() ? 8 : 4); @@ -608,7 +608,7 @@ void ELFObjectWriter::WriteSymbolTable(MCAssembler &Asm, return; SecStart = OS.tell(); - const MCSectionELF *SymtabShndxSection = + MCSectionELF *SymtabShndxSection = Ctx.getELFSection(".symtab_shndxr", ELF::SHT_SYMTAB_SHNDX, 0, 4, ""); addToSectionTable(SymtabShndxSection); MCSectionData *SymtabShndxSD = @@ -1064,7 +1064,7 @@ void ELFObjectWriter::computeSymbolTable( UndefinedSymbolData[i].Symbol->getData().setIndex(Index++); } -const MCSectionELF * +MCSectionELF * ELFObjectWriter::createRelocationSection(MCAssembler &Asm, const MCSectionELF &Sec) { if (Relocations[&Sec].empty()) @@ -1085,7 +1085,7 @@ ELFObjectWriter::createRelocationSection(MCAssembler &Asm, if (Sec.getFlags() & ELF::SHF_GROUP) Flags = ELF::SHF_GROUP; - const MCSectionELF *RelaSection = Ctx.createELFRelSection( + MCSectionELF *RelaSection = Ctx.createELFRelSection( RelaSectionName, hasRelocationAddend() ? ELF::SHT_RELA : ELF::SHT_REL, Flags, EntrySize, Sec.getGroup(), &Sec); MCSectionData &RelSD = Asm.getOrCreateSectionData(*RelaSection); @@ -1141,8 +1141,7 @@ prependCompressionHeader(uint64_t Size, void ELFObjectWriter::writeSectionData(const MCAssembler &Asm, const MCSectionData &SD, const MCAsmLayout &Layout) { - const MCSectionELF &Section = - static_cast<const MCSectionELF &>(SD.getSection()); + MCSectionELF &Section = static_cast<MCSectionELF &>(SD.getSection()); StringRef SectionName = Section.getSectionName(); // Compressing debug_frame requires handling alignment fragments which is @@ -1245,7 +1244,7 @@ const MCSectionELF *ELFObjectWriter::createSectionHeaderStringTable() { } const MCSectionELF *ELFObjectWriter::createStringTable(MCContext &Ctx) { - const MCSectionELF *StrtabSection = + MCSectionELF *StrtabSection = Ctx.getELFSection(".strtab", ELF::SHT_STRTAB, 0); StringTableIndex = addToSectionTable(StrtabSection); OS << StrTabBuilder.data(); @@ -1315,7 +1314,7 @@ void ELFObjectWriter::writeSectionHeader( (NumSections + 1) >= ELF::SHN_LORESERVE ? NumSections + 1 : 0; WriteSecHdrEntry(0, 0, 0, 0, 0, FirstSectionSize, 0, 0, 0, 0); - for (const MCSectionELF *Section : SectionTable) { + for (MCSectionELF *Section : SectionTable) { const MCSectionData &SD = Asm.getOrCreateSectionData(*Section); uint32_t GroupSymbolIndex; unsigned Type = Section->getType(); @@ -1337,7 +1336,7 @@ void ELFObjectWriter::writeSectionHeader( void ELFObjectWriter::WriteObject(MCAssembler &Asm, const MCAsmLayout &Layout) { MCContext &Ctx = Asm.getContext(); - const MCSectionELF *ShstrtabSection = + MCSectionELF *ShstrtabSection = Ctx.getELFSection(".shstrtab", ELF::SHT_STRTAB, 0); ShstrtabIndex = addToSectionTable(ShstrtabSection); @@ -1353,8 +1352,7 @@ void ELFObjectWriter::WriteObject(MCAssembler &Asm, SectionOffsetsTy SectionOffsets; bool ComputedSymtab = false; for (const MCSectionData &SD : Asm) { - const MCSectionELF &Section = - static_cast<const MCSectionELF &>(SD.getSection()); + MCSectionELF &Section = static_cast<MCSectionELF &>(SD.getSection()); uint64_t Padding = OffsetToAlignment(OS.tell(), SD.getAlignment()); WriteZeros(Padding); @@ -1388,13 +1386,13 @@ void ELFObjectWriter::WriteObject(MCAssembler &Asm, if (Type == ELF::SHT_GROUP || Type == ELF::SHT_REL || Type == ELF::SHT_RELA) continue; - const MCSectionELF *RelSection = createRelocationSection(Asm, Section); + MCSectionELF *RelSection = createRelocationSection(Asm, Section); if (SignatureSymbol) { Asm.getOrCreateSymbolData(*SignatureSymbol); unsigned &GroupIdx = RevGroupMap[SignatureSymbol]; if (!GroupIdx) { - const MCSectionELF *Group = Ctx.createELFGroupSection(SignatureSymbol); + MCSectionELF *Group = Ctx.createELFGroupSection(SignatureSymbol); GroupIdx = addToSectionTable(Group); MCSectionData *GroupD = &Asm.getOrCreateSectionData(*Group); GroupD->setAlignment(4); diff --git a/llvm/lib/MC/MCAsmInfoELF.cpp b/llvm/lib/MC/MCAsmInfoELF.cpp index cd61a43afc4..2bff6e05966 100644 --- a/llvm/lib/MC/MCAsmInfoELF.cpp +++ b/llvm/lib/MC/MCAsmInfoELF.cpp @@ -20,8 +20,7 @@ using namespace llvm; void MCAsmInfoELF::anchor() { } -const MCSection * -MCAsmInfoELF::getNonexecutableStackSection(MCContext &Ctx) const { +MCSection *MCAsmInfoELF::getNonexecutableStackSection(MCContext &Ctx) const { return Ctx.getELFSection(".note.GNU-stack", ELF::SHT_PROGBITS, 0); } diff --git a/llvm/lib/MC/MCAsmStreamer.cpp b/llvm/lib/MC/MCAsmStreamer.cpp index 2602718e615..e51cec1dad2 100644 --- a/llvm/lib/MC/MCAsmStreamer.cpp +++ b/llvm/lib/MC/MCAsmStreamer.cpp @@ -114,8 +114,7 @@ public: /// @name MCStreamer Interface /// @{ - void ChangeSection(const MCSection *Section, - const MCExpr *Subsection) override; + void ChangeSection(MCSection *Section, const MCExpr *Subsection) override; void EmitLOHDirective(MCLOHType Kind, const MCLOHArgs &Args) override; void EmitLabel(MCSymbol *Symbol) override; @@ -150,11 +149,11 @@ public: void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment) override; - void EmitZerofill(const MCSection *Section, MCSymbol *Symbol = nullptr, + void EmitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr, uint64_t Size = 0, unsigned ByteAlignment = 0) override; - void EmitTBSSSymbol (const MCSection *Section, MCSymbol *Symbol, - uint64_t Size, unsigned ByteAlignment = 0) override; + void EmitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size, + unsigned ByteAlignment = 0) override; void EmitBytes(StringRef Data) override; @@ -297,7 +296,7 @@ void MCAsmStreamer::emitRawComment(const Twine &T, bool TabPrefix) { EmitEOL(); } -void MCAsmStreamer::ChangeSection(const MCSection *Section, +void MCAsmStreamer::ChangeSection(MCSection *Section, const MCExpr *Subsection) { assert(Section && "Cannot switch to a null section!"); Section->PrintSwitchToSection(*MAI, OS, Subsection); @@ -542,7 +541,7 @@ void MCAsmStreamer::EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, EmitEOL(); } -void MCAsmStreamer::EmitZerofill(const MCSection *Section, MCSymbol *Symbol, +void MCAsmStreamer::EmitZerofill(MCSection *Section, MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment) { if (Symbol) AssignSection(Symbol, Section); @@ -565,7 +564,7 @@ void MCAsmStreamer::EmitZerofill(const MCSection *Section, MCSymbol *Symbol, // .tbss sym, size, align // This depends that the symbol has already been mangled from the original, // e.g. _a. -void MCAsmStreamer::EmitTBSSSymbol(const MCSection *Section, MCSymbol *Symbol, +void MCAsmStreamer::EmitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment) { AssignSection(Symbol, Section); @@ -1102,7 +1101,7 @@ void MCAsmStreamer::EmitWinEHHandlerData() { // We only do this so the section switch that terminates the handler // data block is visible. WinEH::FrameInfo *CurFrame = getCurrentWinFrameInfo(); - if (const MCSection *XData = WinEH::UnwindEmitter::getXDataSection( + if (MCSection *XData = WinEH::UnwindEmitter::getXDataSection( CurFrame->Function, getContext())) SwitchSectionNoChange(XData); diff --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp index 8f9320af2b1..c2ddb93880e 100644 --- a/llvm/lib/MC/MCAssembler.cpp +++ b/llvm/lib/MC/MCAssembler.cpp @@ -292,14 +292,20 @@ MCEncodedFragmentWithFixups::~MCEncodedFragmentWithFixups() { MCSectionData::MCSectionData() : Section(nullptr) {} -MCSectionData::MCSectionData(const MCSection &Section, MCAssembler *A) - : Section(&Section), Ordinal(~UINT32_C(0)), Alignment(1), +MCSectionData::MCSectionData(MCSection &Section, MCAssembler *A) + : Section(&Section), Ordinal(~UINT32_C(0)), BundleLockState(NotBundleLocked), BundleLockNestingDepth(0), BundleGroupBeforeFirstInst(false), HasInstructions(false) { if (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()) diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp index cbc130f6bfa..f3ea3cc1691 100644 --- a/llvm/lib/MC/MCContext.cpp +++ b/llvm/lib/MC/MCContext.cpp @@ -241,10 +241,10 @@ MCSymbol *MCContext::lookupSymbol(const Twine &Name) const { // Section Management //===----------------------------------------------------------------------===// -const MCSectionMachO * -MCContext::getMachOSection(StringRef Segment, StringRef Section, - unsigned TypeAndAttributes, unsigned Reserved2, - SectionKind Kind, const char *BeginSymName) { +MCSectionMachO *MCContext::getMachOSection(StringRef Segment, StringRef Section, + unsigned TypeAndAttributes, + unsigned Reserved2, SectionKind Kind, + const char *BeginSymName) { // We unique sections by their segment/section pair. The returned section // may not have the same flags as the requested section, if so this should be @@ -257,7 +257,7 @@ MCContext::getMachOSection(StringRef Segment, StringRef Section, Name += Section; // Do the lookup, if we have a hit, return it. - const MCSectionMachO *&Entry = MachOUniquingMap[Name]; + MCSectionMachO *&Entry = MachOUniquingMap[Name]; if (Entry) return Entry; @@ -270,7 +270,7 @@ MCContext::getMachOSection(StringRef Segment, StringRef Section, Reserved2, Kind, Begin); } -void MCContext::renameELFSection(const MCSectionELF *Section, StringRef Name) { +void MCContext::renameELFSection(MCSectionELF *Section, StringRef Name) { StringRef GroupName; if (const MCSymbol *Group = Section->getGroup()) GroupName = Group->getName(); @@ -286,10 +286,10 @@ void MCContext::renameELFSection(const MCSectionELF *Section, StringRef Name) { const_cast<MCSectionELF *>(Section)->setSectionName(CachedName); } -const MCSectionELF * -MCContext::createELFRelSection(StringRef Name, unsigned Type, unsigned Flags, - unsigned EntrySize, const MCSymbol *Group, - const MCSectionELF *Associated) { +MCSectionELF *MCContext::createELFRelSection(StringRef Name, unsigned Type, + unsigned Flags, unsigned EntrySize, + const MCSymbol *Group, + const MCSectionELF *Associated) { StringMap<bool>::iterator I; bool Inserted; std::tie(I, Inserted) = ELFRelSecNames.insert(std::make_pair(Name, true)); @@ -299,10 +299,10 @@ MCContext::createELFRelSection(StringRef Name, unsigned Type, unsigned Flags, EntrySize, Group, true, nullptr, Associated); } -const MCSectionELF *MCContext::getELFSection(StringRef Section, unsigned Type, - unsigned Flags, unsigned EntrySize, - StringRef Group, unsigned UniqueID, - const char *BeginSymName) { +MCSectionELF *MCContext::getELFSection(StringRef Section, unsigned Type, + unsigned Flags, unsigned EntrySize, + StringRef Group, unsigned UniqueID, + const char *BeginSymName) { MCSymbol *GroupSym = nullptr; if (!Group.empty()) GroupSym = getOrCreateSymbol(Group); @@ -311,12 +311,12 @@ const MCSectionELF *MCContext::getELFSection(StringRef Section, unsigned Type, BeginSymName, nullptr); } -const MCSectionELF *MCContext::getELFSection(StringRef Section, unsigned Type, - unsigned Flags, unsigned EntrySize, - const MCSymbol *GroupSym, - unsigned UniqueID, - const char *BeginSymName, - const MCSectionELF *Associated) { +MCSectionELF *MCContext::getELFSection(StringRef Section, unsigned Type, + unsigned Flags, unsigned EntrySize, + const MCSymbol *GroupSym, + unsigned UniqueID, + const char *BeginSymName, + const MCSectionELF *Associated) { StringRef Group = ""; if (GroupSym) Group = GroupSym->getName(); @@ -346,17 +346,18 @@ const MCSectionELF *MCContext::getELFSection(StringRef Section, unsigned Type, return Result; } -const MCSectionELF *MCContext::createELFGroupSection(const MCSymbol *Group) { +MCSectionELF *MCContext::createELFGroupSection(const MCSymbol *Group) { MCSectionELF *Result = new (*this) MCSectionELF(".group", ELF::SHT_GROUP, 0, SectionKind::getReadOnly(), 4, Group, ~0, nullptr, nullptr); return Result; } -const MCSectionCOFF * -MCContext::getCOFFSection(StringRef Section, unsigned Characteristics, - SectionKind Kind, StringRef COMDATSymName, - int Selection, const char *BeginSymName) { +MCSectionCOFF *MCContext::getCOFFSection(StringRef Section, + unsigned Characteristics, + SectionKind Kind, + StringRef COMDATSymName, int Selection, + const char *BeginSymName) { MCSymbol *COMDATSymbol = nullptr; if (!COMDATSymName.empty()) { COMDATSymbol = getOrCreateSymbol(COMDATSymName); @@ -382,14 +383,14 @@ MCContext::getCOFFSection(StringRef Section, unsigned Characteristics, return Result; } -const MCSectionCOFF *MCContext::getCOFFSection(StringRef Section, - unsigned Characteristics, - SectionKind Kind, - const char *BeginSymName) { +MCSectionCOFF *MCContext::getCOFFSection(StringRef Section, + unsigned Characteristics, + SectionKind Kind, + const char *BeginSymName) { return getCOFFSection(Section, Characteristics, Kind, "", 0, BeginSymName); } -const MCSectionCOFF *MCContext::getCOFFSection(StringRef Section) { +MCSectionCOFF *MCContext::getCOFFSection(StringRef Section) { COFFSectionKey T{Section, "", 0}; auto Iter = COFFUniquingMap.find(T); if (Iter == COFFUniquingMap.end()) @@ -397,9 +398,8 @@ const MCSectionCOFF *MCContext::getCOFFSection(StringRef Section) { return Iter->second; } -const MCSectionCOFF * -MCContext::getAssociativeCOFFSection(const MCSectionCOFF *Sec, - const MCSymbol *KeySym) { +MCSectionCOFF *MCContext::getAssociativeCOFFSection(MCSectionCOFF *Sec, + const MCSymbol *KeySym) { // Return the normal section if we don't have to be associative. if (!KeySym) return Sec; @@ -440,8 +440,8 @@ bool MCContext::isValidDwarfFileNumber(unsigned FileNumber, unsigned CUID) { /// Remove empty sections from SectionStartEndSyms, to avoid generating /// useless debug info for them. void MCContext::finalizeDwarfSections(MCStreamer &MCOS) { - std::vector<const MCSection *> Keep; - for (const MCSection *Sec : SectionsForRanges) { + std::vector<MCSection *> Keep; + for (MCSection *Sec : SectionsForRanges) { if (MCOS.mayHaveInstructions(*Sec)) Keep.push_back(Sec); } diff --git a/llvm/lib/MC/MCDwarf.cpp b/llvm/lib/MC/MCDwarf.cpp index ad70d61dccb..a7e83f61708 100644 --- a/llvm/lib/MC/MCDwarf.cpp +++ b/llvm/lib/MC/MCDwarf.cpp @@ -64,7 +64,7 @@ static inline uint64_t ScaleAddrDelta(MCContext &Context, uint64_t AddrDelta) { // and if there is information from the last .loc directive that has yet to have // a line entry made for it is made. // -void MCLineEntry::Make(MCObjectStreamer *MCOS, const MCSection *Section) { +void MCLineEntry::Make(MCObjectStreamer *MCOS, MCSection *Section) { if (!MCOS->getContext().getDwarfLocSeen()) return; @@ -115,7 +115,7 @@ static inline const MCExpr *MakeStartMinusEndExpr(const MCStreamer &MCOS, // in the LineSection. // static inline void -EmitDwarfLineTable(MCObjectStreamer *MCOS, const MCSection *Section, +EmitDwarfLineTable(MCObjectStreamer *MCOS, MCSection *Section, const MCLineSection::MCLineEntryCollection &LineEntries) { unsigned FileNum = 1; unsigned LastLine = 1; @@ -610,8 +610,8 @@ static void EmitGenDwarfAranges(MCStreamer *MCOS, // Now emit the table of pairs of PointerSize'ed values for the section // addresses and sizes. - for (const MCSection *Sec : Sections) { - MCSymbol *StartSymbol = Sec->getBeginSymbol(); + for (MCSection *Sec : Sections) { + const MCSymbol *StartSymbol = Sec->getBeginSymbol(); MCSymbol *EndSymbol = Sec->getEndSymbol(context); assert(StartSymbol && "StartSymbol must not be NULL"); assert(EndSymbol && "EndSymbol must not be NULL"); @@ -805,8 +805,8 @@ static void EmitGenDwarfRanges(MCStreamer *MCOS) { MCOS->SwitchSection(context.getObjectFileInfo()->getDwarfRangesSection()); - for (const MCSection *Sec : Sections) { - MCSymbol *StartSymbol = Sec->getBeginSymbol(); + for (MCSection *Sec : Sections) { + const MCSymbol *StartSymbol = Sec->getBeginSymbol(); MCSymbol *EndSymbol = Sec->getEndSymbol(context); assert(StartSymbol && "StartSymbol must not be NULL"); assert(EndSymbol && "EndSymbol must not be NULL"); @@ -1520,9 +1520,9 @@ void MCDwarfFrameEmitter::Emit(MCObjectStreamer &Streamer, MCAsmBackend *MAB, if (!NeedsEHFrameSection) return; - const MCSection &Section = - IsEH ? *const_cast<MCObjectFileInfo*>(MOFI)->getEHFrameSection() : - *MOFI->getDwarfFrameSection(); + MCSection &Section = + IsEH ? *const_cast<MCObjectFileInfo *>(MOFI)->getEHFrameSection() + : *MOFI->getDwarfFrameSection(); Streamer.SwitchSection(&Section); MCSymbol *SectionStart = Context.createTempSymbol(); diff --git a/llvm/lib/MC/MCELFStreamer.cpp b/llvm/lib/MC/MCELFStreamer.cpp index fe54dcbd83c..7b02f1a4528 100644 --- a/llvm/lib/MC/MCELFStreamer.cpp +++ b/llvm/lib/MC/MCELFStreamer.cpp @@ -141,7 +141,7 @@ static void setSectionAlignmentForBundling( Section->setAlignment(Assembler.getBundleAlignSize()); } -void MCELFStreamer::ChangeSection(const MCSection *Section, +void MCELFStreamer::ChangeSection(MCSection *Section, const MCExpr *Subsection) { MCSectionData *CurSection = getCurrentSectionData(); if (CurSection && CurSection->isBundleLocked()) @@ -314,7 +314,7 @@ void MCELFStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, MCELF::SetType(SD, ELF::STT_OBJECT); if (MCELF::GetBinding(SD) == ELF_STB_Local) { - const MCSection *Section = getAssembler().getContext().getELFSection( + MCSection *Section = getAssembler().getContext().getELFSection( ".bss", ELF::SHT_NOBITS, ELF::SHF_WRITE | ELF::SHF_ALLOC); AssignSection(Symbol, Section); @@ -369,7 +369,7 @@ void MCELFStreamer::EmitFileDirective(StringRef Filename) { } void MCELFStreamer::EmitIdent(StringRef IdentString) { - const MCSection *Comment = getAssembler().getContext().getELFSection( + MCSection *Comment = getAssembler().getContext().getELFSection( ".comment", ELF::SHT_PROGBITS, ELF::SHF_MERGE | ELF::SHF_STRINGS, 1, ""); PushSection(); SwitchSection(Comment); @@ -633,7 +633,7 @@ void MCELFStreamer::Flush() { const MCSymbol &Symbol = *i->Symbol; uint64_t Size = i->Size; unsigned ByteAlignment = i->ByteAlignment; - const MCSection &Section = Symbol.getSection(); + MCSection &Section = Symbol.getSection(); MCSectionData &SectData = getAssembler().getOrCreateSectionData(Section); new MCAlignFragment(ByteAlignment, 0, 1, ByteAlignment, &SectData); @@ -693,12 +693,12 @@ void MCELFStreamer::EndCOFFSymbolDef() { llvm_unreachable("ELF doesn't support this directive"); } -void MCELFStreamer::EmitZerofill(const MCSection *Section, MCSymbol *Symbol, +void MCELFStreamer::EmitZerofill(MCSection *Section, MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment) { llvm_unreachable("ELF doesn't support this directive"); } -void MCELFStreamer::EmitTBSSSymbol(const MCSection *Section, MCSymbol *Symbol, +void MCELFStreamer::EmitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment) { llvm_unreachable("ELF doesn't support this directive"); } diff --git a/llvm/lib/MC/MCExpr.cpp b/llvm/lib/MC/MCExpr.cpp index 3bb8d2f358e..b2c6965319f 100644 --- a/llvm/lib/MC/MCExpr.cpp +++ b/llvm/lib/MC/MCExpr.cpp @@ -755,7 +755,7 @@ bool MCExpr::EvaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm, llvm_unreachable("Invalid assembly expression kind!"); } -const MCSection *MCExpr::FindAssociatedSection() const { +MCSection *MCExpr::FindAssociatedSection() const { switch (getKind()) { case Target: // We never look through target specific expressions. @@ -779,8 +779,8 @@ const MCSection *MCExpr::FindAssociatedSection() const { case Binary: { const MCBinaryExpr *BE = cast<MCBinaryExpr>(this); - const MCSection *LHS_S = BE->getLHS()->FindAssociatedSection(); - const MCSection *RHS_S = BE->getRHS()->FindAssociatedSection(); + MCSection *LHS_S = BE->getLHS()->FindAssociatedSection(); + MCSection *RHS_S = BE->getRHS()->FindAssociatedSection(); // If either section is absolute, return the other. if (LHS_S == MCSymbol::AbsolutePseudoSection) diff --git a/llvm/lib/MC/MCMachOStreamer.cpp b/llvm/lib/MC/MCMachOStreamer.cpp index c0efc8e17bd..c9777809a7f 100644 --- a/llvm/lib/MC/MCMachOStreamer.cpp +++ b/llvm/lib/MC/MCMachOStreamer.cpp @@ -68,7 +68,7 @@ public: /// @name MCStreamer Interface /// @{ - void ChangeSection(const MCSection *Sect, const MCExpr *Subsect) override; + void ChangeSection(MCSection *Sect, const MCExpr *Subsect) override; void EmitLabel(MCSymbol *Symbol) override; void EmitEHSymAttributes(const MCSymbol *Symbol, MCSymbol *EHSymbol) override; void EmitAssemblerFlag(MCAssemblerFlag Flag) override; @@ -98,9 +98,9 @@ public: } void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment) override; - void EmitZerofill(const MCSection *Section, MCSymbol *Symbol = nullptr, + void EmitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr, uint64_t Size = 0, unsigned ByteAlignment = 0) override; - void EmitTBSSSymbol(const MCSection *Section, MCSymbol *Symbol, uint64_t Size, + void EmitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment = 0) override; void EmitFileDirective(StringRef Filename) override { @@ -149,7 +149,7 @@ static bool canGoAfterDWARF(const MCSectionMachO &MSec) { return false; } -void MCMachOStreamer::ChangeSection(const MCSection *Section, +void MCMachOStreamer::ChangeSection(MCSection *Section, const MCExpr *Subsection) { // Change the section normally. bool Created = MCObjectStreamer::changeSectionImpl(Section, Subsection); @@ -401,7 +401,7 @@ void MCMachOStreamer::EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, Symbol, Size, ByteAlignment); } -void MCMachOStreamer::EmitZerofill(const MCSection *Section, MCSymbol *Symbol, +void MCMachOStreamer::EmitZerofill(MCSection *Section, MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment) { MCSectionData &SectData = getAssembler().getOrCreateSectionData(*Section); @@ -432,7 +432,7 @@ void MCMachOStreamer::EmitZerofill(const MCSection *Section, MCSymbol *Symbol, // This should always be called with the thread local bss section. Like the // .zerofill directive this doesn't actually switch sections on us. -void MCMachOStreamer::EmitTBSSSymbol(const MCSection *Section, MCSymbol *Symbol, +void MCMachOStreamer::EmitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment) { EmitZerofill(Section, Symbol, Size, ByteAlignment); return; diff --git a/llvm/lib/MC/MCNullStreamer.cpp b/llvm/lib/MC/MCNullStreamer.cpp index fc56728f635..eb2d91254b3 100644 --- a/llvm/lib/MC/MCNullStreamer.cpp +++ b/llvm/lib/MC/MCNullStreamer.cpp @@ -31,7 +31,7 @@ namespace { void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment) override {} - void EmitZerofill(const MCSection *Section, MCSymbol *Symbol = nullptr, + void EmitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr, uint64_t Size = 0, unsigned ByteAlignment = 0) override {} void EmitGPRel32Value(const MCExpr *Value) override {} }; diff --git a/llvm/lib/MC/MCObjectFileInfo.cpp b/llvm/lib/MC/MCObjectFileInfo.cpp index 29f5a1d3752..e99f036af16 100644 --- a/llvm/lib/MC/MCObjectFileInfo.cpp +++ b/llvm/lib/MC/MCObjectFileInfo.cpp @@ -768,7 +768,7 @@ void MCObjectFileInfo::InitMCObjectFileInfo(StringRef T, Reloc::Model relocm, } } -const MCSection *MCObjectFileInfo::getDwarfTypesSection(uint64_t Hash) const { +MCSection *MCObjectFileInfo::getDwarfTypesSection(uint64_t Hash) const { return Ctx->getELFSection(".debug_types", ELF::SHT_PROGBITS, ELF::SHF_GROUP, 0, utostr(Hash)); } diff --git a/llvm/lib/MC/MCObjectStreamer.cpp b/llvm/lib/MC/MCObjectStreamer.cpp index 836b1ced5c5..b6d67a81771 100644 --- a/llvm/lib/MC/MCObjectStreamer.cpp +++ b/llvm/lib/MC/MCObjectStreamer.cpp @@ -201,12 +201,12 @@ void MCObjectStreamer::EmitWeakReference(MCSymbol *Alias, report_fatal_error("This file format doesn't support weak aliases."); } -void MCObjectStreamer::ChangeSection(const MCSection *Section, +void MCObjectStreamer::ChangeSection(MCSection *Section, const MCExpr *Subsection) { changeSectionImpl(Section, Subsection); } -bool MCObjectStreamer::changeSectionImpl(const MCSection *Section, +bool MCObjectStreamer::changeSectionImpl(MCSection *Section, const MCExpr *Subsection) { assert(Section && "Cannot switch to a null section!"); flushPendingLabels(nullptr); diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp index 85f463c2bd5..1e805fdfcf1 100644 --- a/llvm/lib/MC/MCParser/AsmParser.cpp +++ b/llvm/lib/MC/MCParser/AsmParser.cpp @@ -632,7 +632,7 @@ bool AsmParser::Run(bool NoInitialTextSection, bool NoFinalize) { if (getContext().getGenDwarfForAssembly()) { MCSymbol *SectionStartSym = getContext().createTempSymbol(); getStreamer().EmitLabel(SectionStartSym); - const MCSection *Sec = getStreamer().getCurrentSection().first; + MCSection *Sec = getStreamer().getCurrentSection().first; bool InsertResult = getContext().addGenDwarfSection(Sec); assert(InsertResult && ".text section should not have debug info yet"); (void)InsertResult; diff --git a/llvm/lib/MC/MCParser/ELFAsmParser.cpp b/llvm/lib/MC/MCParser/ELFAsmParser.cpp index 6b0a7785517..87b15ffe739 100644 --- a/llvm/lib/MC/MCParser/ELFAsmParser.cpp +++ b/llvm/lib/MC/MCParser/ELFAsmParser.cpp @@ -527,8 +527,8 @@ EndStmt: } } - const MCSection *ELFSection = getContext().getELFSection( - SectionName, Type, Flags, Size, GroupName, UniqueID); + MCSection *ELFSection = getContext().getELFSection(SectionName, Type, Flags, + Size, GroupName, UniqueID); getStreamer().SwitchSection(ELFSection, Subsection); if (getContext().getGenDwarfForAssembly()) { @@ -677,7 +677,7 @@ bool ELFAsmParser::ParseDirectiveVersion(StringRef, SMLoc) { Lex(); - const MCSection *Note = getContext().getELFSection(".note", ELF::SHT_NOTE, 0); + MCSection *Note = getContext().getELFSection(".note", ELF::SHT_NOTE, 0); getStreamer().PushSection(); getStreamer().SwitchSection(Note); diff --git a/llvm/lib/MC/MCSection.cpp b/llvm/lib/MC/MCSection.cpp index 7889f837b11..7204e6cba1f 100644 --- a/llvm/lib/MC/MCSection.cpp +++ b/llvm/lib/MC/MCSection.cpp @@ -18,7 +18,7 @@ using namespace llvm; // MCSection //===----------------------------------------------------------------------===// -MCSymbol *MCSection::getEndSymbol(MCContext &Ctx) const { +MCSymbol *MCSection::getEndSymbol(MCContext &Ctx) { if (!End) End = Ctx.createTempSymbol("sec_end", true); return End; diff --git a/llvm/lib/MC/MCStreamer.cpp b/llvm/lib/MC/MCStreamer.cpp index 31e93209842..9e0cc6b534c 100644 --- a/llvm/lib/MC/MCStreamer.cpp +++ b/llvm/lib/MC/MCStreamer.cpp @@ -188,7 +188,7 @@ void MCStreamer::InitSections(bool NoExecStack) { SwitchSection(getContext().getObjectFileInfo()->getTextSection()); } -void MCStreamer::AssignSection(MCSymbol *Symbol, const MCSection *Section) { +void MCStreamer::AssignSection(MCSymbol *Symbol, MCSection *Section) { if (Section) Symbol->setSection(*Section); else @@ -640,9 +640,9 @@ void MCStreamer::EmitCOFFSymbolType(int Type) {} void MCStreamer::EmitELFSize(MCSymbol *Symbol, const MCExpr *Value) {} void MCStreamer::EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment) {} -void MCStreamer::EmitTBSSSymbol(const MCSection *Section, MCSymbol *Symbol, +void MCStreamer::EmitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment) {} -void MCStreamer::ChangeSection(const MCSection *, const MCExpr *) {} +void MCStreamer::ChangeSection(MCSection *, const MCExpr *) {} void MCStreamer::EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) {} void MCStreamer::EmitBytes(StringRef Data) {} void MCStreamer::EmitValueImpl(const MCExpr *Value, unsigned Size, @@ -664,8 +664,7 @@ void MCStreamer::EmitBundleLock(bool AlignToEnd) {} void MCStreamer::FinishImpl() {} void MCStreamer::EmitBundleUnlock() {} -void MCStreamer::SwitchSection(const MCSection *Section, - const MCExpr *Subsection) { +void MCStreamer::SwitchSection(MCSection *Section, const MCExpr *Subsection) { assert(Section && "Cannot switch to a null section!"); MCSectionSubPair curSection = SectionStack.back().first; SectionStack.back().second = curSection; @@ -679,7 +678,7 @@ void MCStreamer::SwitchSection(const MCSection *Section, } } -MCSymbol *MCStreamer::endSection(const MCSection *Section) { +MCSymbol *MCStreamer::endSection(MCSection *Section) { // TODO: keep track of the last subsection so that this symbol appears in the // correct place. MCSymbol *Sym = Section->getEndSymbol(Context); diff --git a/llvm/lib/MC/MCSymbol.cpp b/llvm/lib/MC/MCSymbol.cpp index ccb9f8def9e..0009decef9b 100644 --- a/llvm/lib/MC/MCSymbol.cpp +++ b/llvm/lib/MC/MCSymbol.cpp @@ -14,8 +14,7 @@ using namespace llvm; // Sentinel value for the absolute pseudo section. -const MCSection *MCSymbol::AbsolutePseudoSection = - reinterpret_cast<const MCSection *>(1); +MCSection *MCSymbol::AbsolutePseudoSection = reinterpret_cast<MCSection *>(1); static bool isAcceptableChar(char C) { if ((C < 'a' || C > 'z') && diff --git a/llvm/lib/MC/MCWin64EH.cpp b/llvm/lib/MC/MCWin64EH.cpp index 7d38427e7c2..f87ea67ee46 100644 --- a/llvm/lib/MC/MCWin64EH.cpp +++ b/llvm/lib/MC/MCWin64EH.cpp @@ -224,16 +224,14 @@ void UnwindEmitter::Emit(MCStreamer &Streamer) const { // Emit the unwind info structs first. for (const auto &CFI : Streamer.getWinFrameInfos()) { - const MCSection *XData = - getXDataSection(CFI->Function, Context); + MCSection *XData = getXDataSection(CFI->Function, Context); Streamer.SwitchSection(XData); EmitUnwindInfo(Streamer, CFI); } // Now emit RUNTIME_FUNCTION entries. for (const auto &CFI : Streamer.getWinFrameInfos()) { - const MCSection *PData = - getPDataSection(CFI->Function, Context); + MCSection *PData = getPDataSection(CFI->Function, Context); Streamer.SwitchSection(PData); EmitRuntimeFunction(Streamer, CFI); } @@ -244,8 +242,7 @@ void UnwindEmitter::EmitUnwindInfo(MCStreamer &Streamer, // Switch sections (the static function above is meant to be called from // here and from Emit(). MCContext &context = Streamer.getContext(); - const MCSection *xdataSect = - getXDataSection(info->Function, context); + MCSection *xdataSect = getXDataSection(info->Function, context); Streamer.SwitchSection(xdataSect); llvm::EmitUnwindInfo(Streamer, info); diff --git a/llvm/lib/MC/MCWinEH.cpp b/llvm/lib/MC/MCWinEH.cpp index b1c95f800cf..d5d9eadf39a 100644 --- a/llvm/lib/MC/MCWinEH.cpp +++ b/llvm/lib/MC/MCWinEH.cpp @@ -25,9 +25,10 @@ namespace WinEH { /// associated with that comdat. If the code described is not in the main .text /// section, make a new section for it. Otherwise use the main unwind info /// section. -static const MCSection *getUnwindInfoSection( - StringRef SecName, const MCSectionCOFF *UnwindSec, const MCSymbol *Function, - MCContext &Context) { +static MCSection *getUnwindInfoSection(StringRef SecName, + MCSectionCOFF *UnwindSec, + const MCSymbol *Function, + MCContext &Context) { if (Function && Function->isInSection()) { // If Function is in a COMDAT, get or create an unwind info section in that // COMDAT group. @@ -59,16 +60,16 @@ static const MCSection *getUnwindInfoSection( } -const MCSection *UnwindEmitter::getPDataSection(const MCSymbol *Function, - MCContext &Context) { - const MCSectionCOFF *PData = +MCSection *UnwindEmitter::getPDataSection(const MCSymbol *Function, + MCContext &Context) { + MCSectionCOFF *PData = cast<MCSectionCOFF>(Context.getObjectFileInfo()->getPDataSection()); return getUnwindInfoSection(".pdata", PData, Function, Context); } -const MCSection *UnwindEmitter::getXDataSection(const MCSymbol *Function, - MCContext &Context) { - const MCSectionCOFF *XData = +MCSection *UnwindEmitter::getXDataSection(const MCSymbol *Function, + MCContext &Context) { + MCSectionCOFF *XData = cast<MCSectionCOFF>(Context.getObjectFileInfo()->getXDataSection()); return getUnwindInfoSection(".xdata", XData, Function, Context); } diff --git a/llvm/lib/MC/WinCOFFStreamer.cpp b/llvm/lib/MC/WinCOFFStreamer.cpp index eaddfa49832..d048f287593 100644 --- a/llvm/lib/MC/WinCOFFStreamer.cpp +++ b/llvm/lib/MC/WinCOFFStreamer.cpp @@ -219,7 +219,7 @@ void MCWinCOFFStreamer::EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment) { assert(!Symbol->isInSection() && "Symbol must not already have a section!"); - const MCSection *Section = getContext().getObjectFileInfo()->getBSSSection(); + MCSection *Section = getContext().getObjectFileInfo()->getBSSSection(); MCSectionData &SectionData = getAssembler().getOrCreateSectionData(*Section); if (SectionData.getAlignment() < ByteAlignment) SectionData.setAlignment(ByteAlignment); @@ -238,15 +238,13 @@ void MCWinCOFFStreamer::EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, SD.setFragment(Fragment); } -void MCWinCOFFStreamer::EmitZerofill(const MCSection *Section, - MCSymbol *Symbol, uint64_t Size, - unsigned ByteAlignment) { +void MCWinCOFFStreamer::EmitZerofill(MCSection *Section, MCSymbol *Symbol, + uint64_t Size, unsigned ByteAlignment) { llvm_unreachable("not implemented"); } -void MCWinCOFFStreamer::EmitTBSSSymbol(const MCSection *Section, - MCSymbol *Symbol, uint64_t Size, - unsigned ByteAlignment) { +void MCWinCOFFStreamer::EmitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, + uint64_t Size, unsigned ByteAlignment) { llvm_unreachable("not implemented"); } |