diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2015-05-21 19:20:38 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2015-05-21 19:20:38 +0000 |
commit | 0709a7bd1a75191a13580ca2a505fa0f7c4326bd (patch) | |
tree | d77dc6bcc145992fbd6a9deebe5e82c4aa553cae /llvm/lib/Target | |
parent | 85d1965abd5e1d452e68e70473d856373c6ca845 (diff) | |
download | bcm5719-llvm-0709a7bd1a75191a13580ca2a505fa0f7c4326bd.tar.gz bcm5719-llvm-0709a7bd1a75191a13580ca2a505fa0f7c4326bd.zip |
Move alignment from MCSectionData to MCSection.
This starts merging MCSection and MCSectionData.
There are a few issues with the current split between MCSection and
MCSectionData.
* It optimizes the the not as important case. We want the production
of .o files to be really fast, but the split puts the information used
for .o emission in a separate data structure.
* The ELF/COFF/MachO hierarchy is not represented in MCSectionData,
leading to some ad-hoc ways to represent the various flags.
* It makes it harder to remember where each item is.
The attached patch starts merging the two by moving the alignment from
MCSectionData to MCSection.
Most of the patch is actually just dropping 'const', since
MCSectionData is mutable, but MCSection was not.
llvm-svn: 237936
Diffstat (limited to 'llvm/lib/Target')
30 files changed, 117 insertions, 125 deletions
diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp index 38c859bc1b3..473ffbe6bce 100644 --- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp +++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp @@ -96,8 +96,7 @@ public: ~AArch64ELFStreamer() override {} - void ChangeSection(const MCSection *Section, - const MCExpr *Subsection) override { + void ChangeSection(MCSection *Section, const MCExpr *Subsection) override { // We have to keep track of the mapping symbol state of any sections we // use. Each one should start off as EMS_None, which is provided as the // default constructor by DenseMap::lookup. diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCExpr.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCExpr.cpp index 9e31508bfb0..74b81af2cb4 100644 --- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCExpr.cpp +++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCExpr.cpp @@ -86,7 +86,7 @@ void AArch64MCExpr::visitUsedExpr(MCStreamer &Streamer) const { Streamer.visitUsedExpr(*getSubExpr()); } -const MCSection *AArch64MCExpr::FindAssociatedSection() const { +MCSection *AArch64MCExpr::FindAssociatedSection() const { llvm_unreachable("FIXME: what goes here?"); } diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCExpr.h b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCExpr.h index 499b3f50354..95d22775736 100644 --- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCExpr.h +++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCExpr.h @@ -149,7 +149,7 @@ public: void visitUsedExpr(MCStreamer &Streamer) const override; - const MCSection *FindAssociatedSection() const override; + MCSection *FindAssociatedSection() const override; bool EvaluateAsRelocatableImpl(MCValue &Res, const MCAsmLayout *Layout, diff --git a/llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp b/llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp index 2f5559a16b2..71cc516237f 100644 --- a/llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp +++ b/llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp @@ -275,7 +275,7 @@ private: unsigned EmittedArch; SmallVector<AttributeItem, 64> Contents; - const MCSection *AttributeSection; + MCSection *AttributeSection; AttributeItem *getAttributeItem(unsigned Attribute) { for (size_t i = 0; i < Contents.size(); ++i) @@ -431,8 +431,7 @@ public: void emitRegSave(const SmallVectorImpl<unsigned> &RegList, bool isVector); void emitUnwindRaw(int64_t Offset, const SmallVectorImpl<uint8_t> &Opcodes); - void ChangeSection(const MCSection *Section, - const MCExpr *Subsection) override { + void ChangeSection(MCSection *Section, const MCExpr *Subsection) override { // We have to keep track of the mapping symbol state of any sections we // use. Each one should start off as EMS_None, which is provided as the // default constructor by DenseMap::lookup. @@ -1028,7 +1027,7 @@ inline void ARMELFStreamer::SwitchToEHSection(const char *Prefix, const MCSymbol *Group = FnSection.getGroup(); if (Group) Flags |= ELF::SHF_GROUP; - const MCSectionELF *EHSection = + MCSectionELF *EHSection = getContext().getELFSection(EHSecName, Type, Flags, 0, Group, FnSection.getUniqueID(), nullptr, &FnSection); diff --git a/llvm/lib/Target/ARM/MCTargetDesc/ARMMCExpr.h b/llvm/lib/Target/ARM/MCTargetDesc/ARMMCExpr.h index 2be98d2e9e7..a52abe7760d 100644 --- a/llvm/lib/Target/ARM/MCTargetDesc/ARMMCExpr.h +++ b/llvm/lib/Target/ARM/MCTargetDesc/ARMMCExpr.h @@ -62,8 +62,8 @@ public: const MCFixup *Fixup) const override { return false; } - void visitUsedExpr(MCStreamer &Streamer) const override; - const MCSection *FindAssociatedSection() const override { + void visitUsedExpr(MCStreamer &Streamer) const override; + MCSection *FindAssociatedSection() const override { return getSubExpr()->FindAssociatedSection(); } diff --git a/llvm/lib/Target/Hexagon/HexagonTargetObjectFile.cpp b/llvm/lib/Target/Hexagon/HexagonTargetObjectFile.cpp index d8660d3138e..4ea0e0d1199 100644 --- a/llvm/lib/Target/Hexagon/HexagonTargetObjectFile.cpp +++ b/llvm/lib/Target/Hexagon/HexagonTargetObjectFile.cpp @@ -81,7 +81,7 @@ IsGlobalInSmallSection(const GlobalValue *GV, const TargetMachine &TM, return false; } -const MCSection * +MCSection * HexagonTargetObjectFile::SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, Mangler &Mang, const TargetMachine &TM) const { diff --git a/llvm/lib/Target/Hexagon/HexagonTargetObjectFile.h b/llvm/lib/Target/Hexagon/HexagonTargetObjectFile.h index c9742042724..da0eeeb3fd2 100644 --- a/llvm/lib/Target/Hexagon/HexagonTargetObjectFile.h +++ b/llvm/lib/Target/Hexagon/HexagonTargetObjectFile.h @@ -16,8 +16,9 @@ namespace llvm { class HexagonTargetObjectFile : public TargetLoweringObjectFileELF { - const MCSectionELF *SmallDataSection; - const MCSectionELF *SmallBSSSection; + MCSectionELF *SmallDataSection; + MCSectionELF *SmallBSSSection; + public: void Initialize(MCContext &Ctx, const TargetMachine &TM) override; @@ -30,9 +31,9 @@ namespace llvm { const TargetMachine &TM) const; bool IsSmallDataEnabled () const; - const MCSection *SelectSectionForGlobal(const GlobalValue *GV, - SectionKind Kind, Mangler &Mang, - const TargetMachine &TM) const override; + MCSection *SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, + Mangler &Mang, + const TargetMachine &TM) const override; }; } // namespace llvm diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsELFStreamer.cpp b/llvm/lib/Target/Mips/MCTargetDesc/MipsELFStreamer.cpp index 6d1d9f4f223..d2b51831245 100644 --- a/llvm/lib/Target/Mips/MCTargetDesc/MipsELFStreamer.cpp +++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsELFStreamer.cpp @@ -58,7 +58,7 @@ void MipsELFStreamer::EmitLabel(MCSymbol *Symbol) { Labels.push_back(Symbol); } -void MipsELFStreamer::SwitchSection(const MCSection * Section, +void MipsELFStreamer::SwitchSection(MCSection *Section, const MCExpr *Subsection) { MCELFStreamer::SwitchSection(Section, Subsection); Labels.clear(); diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsELFStreamer.h b/llvm/lib/Target/Mips/MCTargetDesc/MipsELFStreamer.h index 4e3090171e3..af9311fa428 100644 --- a/llvm/lib/Target/Mips/MCTargetDesc/MipsELFStreamer.h +++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsELFStreamer.h @@ -55,7 +55,7 @@ public: /// Overriding this function allows us to dismiss all labels that are /// candidates for marking as microMIPS when .section directive is processed. - void SwitchSection(const MCSection *Section, + void SwitchSection(MCSection *Section, const MCExpr *Subsection = nullptr) override; /// Overriding this function allows us to dismiss all labels that are diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsMCExpr.h b/llvm/lib/Target/Mips/MCTargetDesc/MipsMCExpr.h index 2b8f0c89a2e..ee11461ef17 100644 --- a/llvm/lib/Target/Mips/MCTargetDesc/MipsMCExpr.h +++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsMCExpr.h @@ -51,7 +51,7 @@ public: const MCAsmLayout *Layout, const MCFixup *Fixup) const override; void visitUsedExpr(MCStreamer &Streamer) const override; - const MCSection *FindAssociatedSection() const override { + MCSection *FindAssociatedSection() const override { return getSubExpr()->FindAssociatedSection(); } diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsOptionRecord.cpp b/llvm/lib/Target/Mips/MCTargetDesc/MipsOptionRecord.cpp index 188e3e8e1db..272186240ba 100644 --- a/llvm/lib/Target/Mips/MCTargetDesc/MipsOptionRecord.cpp +++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsOptionRecord.cpp @@ -28,7 +28,7 @@ void MipsRegInfoRecord::EmitMipsOptionRecord() { if (MTS->getABI().IsN64()) { // The EntrySize value of 1 seems strange since the records are neither // 1-byte long nor fixed length but it matches the value GAS emits. - const MCSectionELF *Sec = + MCSectionELF *Sec = Context.getELFSection(".MIPS.options", ELF::SHT_MIPS_OPTIONS, ELF::SHF_ALLOC | ELF::SHF_MIPS_NOSTRIP, 1, ""); MCA.getOrCreateSectionData(*Sec).setAlignment(8); @@ -46,8 +46,8 @@ void MipsRegInfoRecord::EmitMipsOptionRecord() { Streamer->EmitIntValue(ri_cprmask[3], 4); Streamer->EmitIntValue(ri_gp_value, 8); } else { - const MCSectionELF *Sec = Context.getELFSection( - ".reginfo", ELF::SHT_MIPS_REGINFO, ELF::SHF_ALLOC, 24, ""); + MCSectionELF *Sec = Context.getELFSection(".reginfo", ELF::SHT_MIPS_REGINFO, + ELF::SHF_ALLOC, 24, ""); MCA.getOrCreateSectionData(*Sec) .setAlignment(MTS->getABI().IsN32() ? 8 : 4); Streamer->SwitchSection(Sec); diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp b/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp index 289959be47e..0bb04c58520 100644 --- a/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp +++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp @@ -564,8 +564,8 @@ void MipsTargetELFStreamer::emitDirectiveEnd(StringRef Name) { MCContext &Context = MCA.getContext(); MCStreamer &OS = getStreamer(); - const MCSectionELF *Sec = Context.getELFSection( - ".pdr", ELF::SHT_PROGBITS, ELF::SHF_ALLOC | ELF::SHT_REL); + MCSectionELF *Sec = Context.getELFSection(".pdr", ELF::SHT_PROGBITS, + ELF::SHF_ALLOC | ELF::SHT_REL); const MCSymbolRefExpr *ExprRef = MCSymbolRefExpr::Create(Name, MCSymbolRefExpr::VK_None, Context); @@ -786,7 +786,7 @@ void MipsTargetELFStreamer::emitMipsAbiFlags() { MCAssembler &MCA = getStreamer().getAssembler(); MCContext &Context = MCA.getContext(); MCStreamer &OS = getStreamer(); - const MCSectionELF *Sec = Context.getELFSection( + MCSectionELF *Sec = Context.getELFSection( ".MIPS.abiflags", ELF::SHT_MIPS_ABIFLAGS, ELF::SHF_ALLOC, 24, ""); MCSectionData &ABIShndxSD = MCA.getOrCreateSectionData(*Sec); ABIShndxSD.setAlignment(8); diff --git a/llvm/lib/Target/Mips/MipsAsmPrinter.cpp b/llvm/lib/Target/Mips/MipsAsmPrinter.cpp index 7d5377aaf9d..ae33867f4d3 100644 --- a/llvm/lib/Target/Mips/MipsAsmPrinter.cpp +++ b/llvm/lib/Target/Mips/MipsAsmPrinter.cpp @@ -963,7 +963,7 @@ void MipsAsmPrinter::EmitFPCallStub( // // .section mips16.call.fpxxxx,"ax",@progbits // - const MCSectionELF *M = OutContext.getELFSection( + MCSectionELF *M = OutContext.getELFSection( ".mips16.call.fp." + std::string(Symbol), ELF::SHT_PROGBITS, ELF::SHF_ALLOC | ELF::SHF_EXECINSTR); OutStreamer->SwitchSection(M, nullptr); diff --git a/llvm/lib/Target/Mips/MipsTargetObjectFile.cpp b/llvm/lib/Target/Mips/MipsTargetObjectFile.cpp index 723b63bb41c..0f2db6039b6 100644 --- a/llvm/lib/Target/Mips/MipsTargetObjectFile.cpp +++ b/llvm/lib/Target/Mips/MipsTargetObjectFile.cpp @@ -110,9 +110,10 @@ IsGlobalInSmallSectionImpl(const GlobalValue *GV, return IsInSmallSection(TM.getDataLayout()->getTypeAllocSize(Ty)); } -const MCSection *MipsTargetObjectFile:: -SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, - Mangler &Mang, const TargetMachine &TM) const { +MCSection * +MipsTargetObjectFile::SelectSectionForGlobal(const GlobalValue *GV, + SectionKind Kind, Mangler &Mang, + const TargetMachine &TM) const { // TODO: Could also support "weak" symbols as well with ".gnu.linkonce.s.*" // sections? @@ -136,8 +137,9 @@ IsConstantInSmallSection(const Constant *CN, const TargetMachine &TM) const { CN->getType()))); } -const MCSection *MipsTargetObjectFile:: -getSectionForConstant(SectionKind Kind, const Constant *C) const { +MCSection * +MipsTargetObjectFile::getSectionForConstant(SectionKind Kind, + const Constant *C) const { if (IsConstantInSmallSection(C, *TM)) return SmallDataSection; diff --git a/llvm/lib/Target/Mips/MipsTargetObjectFile.h b/llvm/lib/Target/Mips/MipsTargetObjectFile.h index 45ed9d05f9c..725f2ffd93d 100644 --- a/llvm/lib/Target/Mips/MipsTargetObjectFile.h +++ b/llvm/lib/Target/Mips/MipsTargetObjectFile.h @@ -15,8 +15,8 @@ namespace llvm { class MipsTargetMachine; class MipsTargetObjectFile : public TargetLoweringObjectFileELF { - const MCSection *SmallDataSection; - const MCSection *SmallBSSSection; + MCSection *SmallDataSection; + MCSection *SmallBSSSection; const MipsTargetMachine *TM; public: @@ -31,16 +31,16 @@ class MipsTargetMachine; bool IsGlobalInSmallSectionImpl(const GlobalValue *GV, const TargetMachine &TM) const; - const MCSection *SelectSectionForGlobal(const GlobalValue *GV, - SectionKind Kind, Mangler &Mang, - const TargetMachine &TM) const override; + MCSection *SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, + Mangler &Mang, + const TargetMachine &TM) const override; /// Return true if this constant should be placed into small data section. bool IsConstantInSmallSection(const Constant *CN, const TargetMachine &TM) const; - const MCSection *getSectionForConstant(SectionKind Kind, - const Constant *C) const override; + MCSection *getSectionForConstant(SectionKind Kind, + const Constant *C) const override; }; } // end namespace llvm diff --git a/llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp b/llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp index 162dc55cd80..805847a581f 100644 --- a/llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp +++ b/llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp @@ -4520,7 +4520,7 @@ NVPTXTargetObjectFile::~NVPTXTargetObjectFile() { delete DwarfRangesSection; } -const MCSection * +MCSection * NVPTXTargetObjectFile::SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, Mangler &Mang, const TargetMachine &TM) const { diff --git a/llvm/lib/Target/NVPTX/NVPTXMCExpr.h b/llvm/lib/Target/NVPTX/NVPTXMCExpr.h index fcec11165af..8c6b219abd1 100644 --- a/llvm/lib/Target/NVPTX/NVPTXMCExpr.h +++ b/llvm/lib/Target/NVPTX/NVPTXMCExpr.h @@ -68,9 +68,7 @@ public: return false; } void visitUsedExpr(MCStreamer &Streamer) const override {}; - const MCSection *FindAssociatedSection() const override { - return nullptr; - } + MCSection *FindAssociatedSection() const override { return nullptr; } // There are no TLS NVPTXMCExprs at the moment. void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override {} @@ -112,9 +110,7 @@ public: return false; } void visitUsedExpr(MCStreamer &Streamer) const override {}; - const MCSection *FindAssociatedSection() const override { - return nullptr; - } + MCSection *FindAssociatedSection() const override { return nullptr; } // There are no TLS NVPTXMCExprs at the moment. void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override {} diff --git a/llvm/lib/Target/NVPTX/NVPTXTargetObjectFile.h b/llvm/lib/Target/NVPTX/NVPTXTargetObjectFile.h index 5d9ab0d511f..5ecdc874883 100644 --- a/llvm/lib/Target/NVPTX/NVPTXTargetObjectFile.h +++ b/llvm/lib/Target/NVPTX/NVPTXTargetObjectFile.h @@ -84,20 +84,20 @@ public: new NVPTXSection(MCSection::SV_ELF, SectionKind::getMetadata()); } - const MCSection *getSectionForConstant(SectionKind Kind, - const Constant *C) const override { + MCSection *getSectionForConstant(SectionKind Kind, + const Constant *C) const override { return ReadOnlySection; } - const MCSection *getExplicitSectionGlobal(const GlobalValue *GV, - SectionKind Kind, Mangler &Mang, - const TargetMachine &TM) const override { + MCSection *getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind, + Mangler &Mang, + const TargetMachine &TM) const override { return DataSection; } - const MCSection * - SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, Mangler &Mang, - const TargetMachine &TM) const override; + MCSection *SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, + Mangler &Mang, + const TargetMachine &TM) const override; }; } // end namespace llvm diff --git a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCExpr.h b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCExpr.h index 1c840d998e0..ca72ccf0f76 100644 --- a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCExpr.h +++ b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCExpr.h @@ -82,7 +82,7 @@ public: const MCAsmLayout *Layout, const MCFixup *Fixup) const override; void visitUsedExpr(MCStreamer &Streamer) const override; - const MCSection *FindAssociatedSection() const override { + MCSection *FindAssociatedSection() const override { return getSubExpr()->FindAssociatedSection(); } diff --git a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp index 4fd96145fb2..4f1c3c73e71 100644 --- a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp +++ b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp @@ -1054,7 +1054,7 @@ void PPCLinuxAsmPrinter::EmitFunctionEntryLabel() { // Emit an official procedure descriptor. MCSectionSubPair Current = OutStreamer->getCurrentSection(); - const MCSectionELF *Section = OutStreamer->getContext().getELFSection( + MCSectionELF *Section = OutStreamer->getContext().getELFSection( ".opd", ELF::SHT_PROGBITS, ELF::SHF_WRITE | ELF::SHF_ALLOC); OutStreamer->SwitchSection(Section); OutStreamer->EmitLabel(CurrentFnSym); @@ -1084,8 +1084,8 @@ bool PPCLinuxAsmPrinter::doFinalization(Module &M) { static_cast<PPCTargetStreamer &>(*OutStreamer->getTargetStreamer()); if (!TOC.empty()) { - const MCSectionELF *Section; - + MCSectionELF *Section; + if (isPPC64) Section = OutStreamer->getContext().getELFSection( ".toc", ELF::SHT_PROGBITS, ELF::SHF_WRITE | ELF::SHF_ALLOC); @@ -1285,15 +1285,14 @@ EmitFunctionStubs(const MachineModuleInfoMachO::SymbolListTy &Stubs) { static_cast<const TargetLoweringObjectFileMachO &>(getObjFileLowering()); // .lazy_symbol_pointer - const MCSection *LSPSection = TLOFMacho.getLazySymbolPointerSection(); - + MCSection *LSPSection = TLOFMacho.getLazySymbolPointerSection(); + // Output stubs for dynamically-linked functions if (TM.getRelocationModel() == Reloc::PIC_) { - const MCSection *StubSection = - OutContext.getMachOSection("__TEXT", "__picsymbolstub1", - MachO::S_SYMBOL_STUBS | - MachO::S_ATTR_PURE_INSTRUCTIONS, - 32, SectionKind::getText()); + MCSection *StubSection = OutContext.getMachOSection( + "__TEXT", "__picsymbolstub1", + MachO::S_SYMBOL_STUBS | MachO::S_ATTR_PURE_INSTRUCTIONS, 32, + SectionKind::getText()); for (unsigned i = 0, e = Stubs.size(); i != e; ++i) { OutStreamer->SwitchSection(StubSection); EmitAlignment(4); @@ -1356,12 +1355,11 @@ EmitFunctionStubs(const MachineModuleInfoMachO::SymbolListTy &Stubs) { OutStreamer->AddBlankLine(); return; } - - const MCSection *StubSection = - OutContext.getMachOSection("__TEXT","__symbol_stub1", - MachO::S_SYMBOL_STUBS | - MachO::S_ATTR_PURE_INSTRUCTIONS, - 16, SectionKind::getText()); + + MCSection *StubSection = OutContext.getMachOSection( + "__TEXT", "__symbol_stub1", + MachO::S_SYMBOL_STUBS | MachO::S_ATTR_PURE_INSTRUCTIONS, 16, + SectionKind::getText()); for (unsigned i = 0, e = Stubs.size(); i != e; ++i) { MCSymbol *Stub = Stubs[i].first; MCSymbol *RawSym = Stubs[i].second.getPointer(); diff --git a/llvm/lib/Target/PowerPC/PPCTargetObjectFile.cpp b/llvm/lib/Target/PowerPC/PPCTargetObjectFile.cpp index 2903cc192aa..9ad13407008 100644 --- a/llvm/lib/Target/PowerPC/PPCTargetObjectFile.cpp +++ b/llvm/lib/Target/PowerPC/PPCTargetObjectFile.cpp @@ -22,7 +22,7 @@ Initialize(MCContext &Ctx, const TargetMachine &TM) { InitializeELF(TM.Options.UseInitArray); } -const MCSection *PPC64LinuxTargetObjectFile::SelectSectionForGlobal( +MCSection *PPC64LinuxTargetObjectFile::SelectSectionForGlobal( const GlobalValue *GV, SectionKind Kind, Mangler &Mang, const TargetMachine &TM) const { // Here override ReadOnlySection to DataRelROSection for PPC64 SVR4 ABI diff --git a/llvm/lib/Target/PowerPC/PPCTargetObjectFile.h b/llvm/lib/Target/PowerPC/PPCTargetObjectFile.h index cd84da22275..d248791f2ca 100644 --- a/llvm/lib/Target/PowerPC/PPCTargetObjectFile.h +++ b/llvm/lib/Target/PowerPC/PPCTargetObjectFile.h @@ -22,9 +22,9 @@ namespace llvm { void Initialize(MCContext &Ctx, const TargetMachine &TM) override; - const MCSection *SelectSectionForGlobal(const GlobalValue *GV, - SectionKind Kind, Mangler &Mang, - const TargetMachine &TM) const override; + MCSection *SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, + Mangler &Mang, + const TargetMachine &TM) const override; /// \brief Describe a TLS variable address within debug info. const MCExpr *getDebugThreadLocalSymbol(const MCSymbol *Sym) const override; diff --git a/llvm/lib/Target/R600/AMDGPUAsmPrinter.cpp b/llvm/lib/Target/R600/AMDGPUAsmPrinter.cpp index 9f09b42d11f..56b50a9c159 100644 --- a/llvm/lib/Target/R600/AMDGPUAsmPrinter.cpp +++ b/llvm/lib/Target/R600/AMDGPUAsmPrinter.cpp @@ -107,7 +107,7 @@ bool AMDGPUAsmPrinter::runOnMachineFunction(MachineFunction &MF) { SetupMachineFunction(MF); MCContext &Context = getObjFileLowering().getContext(); - const MCSectionELF *ConfigSection = + MCSectionELF *ConfigSection = Context.getELFSection(".AMDGPU.config", ELF::SHT_PROGBITS, 0); OutStreamer->SwitchSection(ConfigSection); @@ -131,7 +131,7 @@ bool AMDGPUAsmPrinter::runOnMachineFunction(MachineFunction &MF) { EmitFunctionBody(); if (isVerbose()) { - const MCSectionELF *CommentSection = + MCSectionELF *CommentSection = Context.getELFSection(".AMDGPU.csdata", ELF::SHT_PROGBITS, 0); OutStreamer->SwitchSection(CommentSection); @@ -509,7 +509,7 @@ void AMDGPUAsmPrinter::EmitAmdKernelCodeT(const MachineFunction &MF, header.wavefront_size = STM.getWavefrontSize(); - const MCSectionELF *VersionSection = + MCSectionELF *VersionSection = OutContext.getELFSection(".hsa.version", ELF::SHT_PROGBITS, 0); OutStreamer->SwitchSection(VersionSection); OutStreamer->EmitBytes(Twine("HSA Code Unit:" + diff --git a/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCExpr.h b/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCExpr.h index 3a6f508da72..116e10406a7 100644 --- a/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCExpr.h +++ b/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCExpr.h @@ -90,7 +90,7 @@ public: const MCAsmLayout *Layout, const MCFixup *Fixup) const override; void visitUsedExpr(MCStreamer &Streamer) const override; - const MCSection *FindAssociatedSection() const override { + MCSection *FindAssociatedSection() const override { return getSubExpr()->FindAssociatedSection(); } diff --git a/llvm/lib/Target/TargetLoweringObjectFile.cpp b/llvm/lib/Target/TargetLoweringObjectFile.cpp index 1b02a1c60bb..a184b92d3c9 100644 --- a/llvm/lib/Target/TargetLoweringObjectFile.cpp +++ b/llvm/lib/Target/TargetLoweringObjectFile.cpp @@ -255,12 +255,13 @@ SectionKind TargetLoweringObjectFile::getKindForGlobal(const GlobalValue *GV, llvm_unreachable("Invalid relocation"); } -/// SectionForGlobal - This method computes the appropriate section to emit -/// the specified global variable or function definition. This should not -/// be passed external (or available externally) globals. -const MCSection *TargetLoweringObjectFile:: -SectionForGlobal(const GlobalValue *GV, SectionKind Kind, Mangler &Mang, - const TargetMachine &TM) const { +/// This method computes the appropriate section to emit the specified global +/// variable or function definition. This should not be passed external (or +/// available externally) globals. +MCSection * +TargetLoweringObjectFile::SectionForGlobal(const GlobalValue *GV, + SectionKind Kind, Mangler &Mang, + const TargetMachine &TM) const { // Select section name. if (GV->hasSection()) return getExplicitSectionGlobal(GV, Kind, Mang, TM); @@ -270,7 +271,7 @@ SectionForGlobal(const GlobalValue *GV, SectionKind Kind, Mangler &Mang, return SelectSectionForGlobal(GV, Kind, Mang, TM); } -const MCSection *TargetLoweringObjectFile::getSectionForJumpTable( +MCSection *TargetLoweringObjectFile::getSectionForJumpTable( const Function &F, Mangler &Mang, const TargetMachine &TM) const { return getSectionForConstant(SectionKind::getReadOnly(), /*C=*/nullptr); } @@ -293,10 +294,9 @@ bool TargetLoweringObjectFile::shouldPutJumpTableInFunctionSection( return false; } -/// getSectionForConstant - Given a mergable constant with the -/// specified size and relocation information, return a section that it -/// should be placed in. -const MCSection * +/// Given a mergable constant with the specified size and relocation +/// information, return a section that it should be placed in. +MCSection * TargetLoweringObjectFile::getSectionForConstant(SectionKind Kind, const Constant *C) const { if (Kind.isReadOnly() && ReadOnlySection != nullptr) diff --git a/llvm/lib/Target/X86/X86AsmPrinter.cpp b/llvm/lib/Target/X86/X86AsmPrinter.cpp index c7ac0bd7721..f97557e5c60 100644 --- a/llvm/lib/Target/X86/X86AsmPrinter.cpp +++ b/llvm/lib/Target/X86/X86AsmPrinter.cpp @@ -615,12 +615,11 @@ void X86AsmPrinter::EmitEndOfAsmFile(Module &M) { Stubs = MMIMacho.GetFnStubList(); if (!Stubs.empty()) { - const MCSection *TheSection = - OutContext.getMachOSection("__IMPORT", "__jump_table", - MachO::S_SYMBOL_STUBS | - MachO::S_ATTR_SELF_MODIFYING_CODE | - MachO::S_ATTR_PURE_INSTRUCTIONS, - 5, SectionKind::getMetadata()); + MCSection *TheSection = OutContext.getMachOSection( + "__IMPORT", "__jump_table", + MachO::S_SYMBOL_STUBS | MachO::S_ATTR_SELF_MODIFYING_CODE | + MachO::S_ATTR_PURE_INSTRUCTIONS, + 5, SectionKind::getMetadata()); OutStreamer->SwitchSection(TheSection); for (const auto &Stub : Stubs) { @@ -641,10 +640,9 @@ void X86AsmPrinter::EmitEndOfAsmFile(Module &M) { // Output stubs for external and common global variables. Stubs = MMIMacho.GetGVStubList(); if (!Stubs.empty()) { - const MCSection *TheSection = - OutContext.getMachOSection("__IMPORT", "__pointers", - MachO::S_NON_LAZY_SYMBOL_POINTERS, - SectionKind::getMetadata()); + MCSection *TheSection = OutContext.getMachOSection( + "__IMPORT", "__pointers", MachO::S_NON_LAZY_SYMBOL_POINTERS, + SectionKind::getMetadata()); OutStreamer->SwitchSection(TheSection); for (auto &Stub : Stubs) @@ -656,10 +654,9 @@ void X86AsmPrinter::EmitEndOfAsmFile(Module &M) { Stubs = MMIMacho.GetHiddenGVStubList(); if (!Stubs.empty()) { - const MCSection *TheSection = - OutContext.getMachOSection("__IMPORT", "__pointers", - MachO::S_NON_LAZY_SYMBOL_POINTERS, - SectionKind::getMetadata()); + MCSection *TheSection = OutContext.getMachOSection( + "__IMPORT", "__pointers", MachO::S_NON_LAZY_SYMBOL_POINTERS, + SectionKind::getMetadata()); OutStreamer->SwitchSection(TheSection); for (auto &Stub : Stubs) diff --git a/llvm/lib/Target/X86/X86TargetObjectFile.cpp b/llvm/lib/Target/X86/X86TargetObjectFile.cpp index d65d3b0cbf7..6bf45c37e38 100644 --- a/llvm/lib/Target/X86/X86TargetObjectFile.cpp +++ b/llvm/lib/Target/X86/X86TargetObjectFile.cpp @@ -149,7 +149,7 @@ static std::string scalarConstantToHexString(const Constant *C) { return APIntToHexString(AI); } -const MCSection * +MCSection * X86WindowsTargetObjectFile::getSectionForConstant(SectionKind Kind, const Constant *C) const { if (Kind.isReadOnly()) { diff --git a/llvm/lib/Target/X86/X86TargetObjectFile.h b/llvm/lib/Target/X86/X86TargetObjectFile.h index 2e25fb2b849..66366b2373c 100644 --- a/llvm/lib/Target/X86/X86TargetObjectFile.h +++ b/llvm/lib/Target/X86/X86TargetObjectFile.h @@ -58,8 +58,8 @@ namespace llvm { /// \brief Given a mergeable constant with the specified size and relocation /// information, return a section that it should be placed in. - const MCSection *getSectionForConstant(SectionKind Kind, - const Constant *C) const override; + MCSection *getSectionForConstant(SectionKind Kind, + const Constant *C) const override; }; } // end namespace llvm diff --git a/llvm/lib/Target/XCore/XCoreTargetObjectFile.cpp b/llvm/lib/Target/XCore/XCoreTargetObjectFile.cpp index c435b36fae1..b5a99058f46 100644 --- a/llvm/lib/Target/XCore/XCoreTargetObjectFile.cpp +++ b/llvm/lib/Target/XCore/XCoreTargetObjectFile.cpp @@ -95,7 +95,7 @@ static unsigned getXCoreSectionFlags(SectionKind K, bool IsCPRel) { return Flags; } -const MCSection * +MCSection * XCoreTargetObjectFile::getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind, Mangler &Mang, const TargetMachine &TM) const { @@ -108,9 +108,10 @@ XCoreTargetObjectFile::getExplicitSectionGlobal(const GlobalValue *GV, getXCoreSectionFlags(Kind, IsCPRel)); } -const MCSection *XCoreTargetObjectFile:: -SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, Mangler &Mang, - const TargetMachine &TM) const{ +MCSection * +XCoreTargetObjectFile::SelectSectionForGlobal(const GlobalValue *GV, + SectionKind Kind, Mangler &Mang, + const TargetMachine &TM) const { bool UseCPRel = GV->isLocalLinkage(GV->getLinkage()); @@ -141,7 +142,7 @@ SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, Mangler &Mang, report_fatal_error("Target does not support TLS or Common sections"); } -const MCSection * +MCSection * XCoreTargetObjectFile::getSectionForConstant(SectionKind Kind, const Constant *C) const { if (Kind.isMergeableConst4()) return MergeableConst4Section; diff --git a/llvm/lib/Target/XCore/XCoreTargetObjectFile.h b/llvm/lib/Target/XCore/XCoreTargetObjectFile.h index 7d3f49d222d..2a5ac238a44 100644 --- a/llvm/lib/Target/XCore/XCoreTargetObjectFile.h +++ b/llvm/lib/Target/XCore/XCoreTargetObjectFile.h @@ -17,25 +17,24 @@ namespace llvm { static const unsigned CodeModelLargeSize = 256; class XCoreTargetObjectFile : public TargetLoweringObjectFileELF { - const MCSection *BSSSectionLarge; - const MCSection *DataSectionLarge; - const MCSection *ReadOnlySectionLarge; - const MCSection *DataRelROSectionLarge; + MCSection *BSSSectionLarge; + MCSection *DataSectionLarge; + MCSection *ReadOnlySectionLarge; + MCSection *DataRelROSectionLarge; + public: void Initialize(MCContext &Ctx, const TargetMachine &TM) override; - const MCSection * - getExplicitSectionGlobal(const GlobalValue *GV, - SectionKind Kind, Mangler &Mang, - const TargetMachine &TM) const override; + MCSection *getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind, + Mangler &Mang, + const TargetMachine &TM) const override; - const MCSection * - SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, - Mangler &Mang, - const TargetMachine &TM) const override; + MCSection *SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, + Mangler &Mang, + const TargetMachine &TM) const override; - const MCSection *getSectionForConstant(SectionKind Kind, - const Constant *C) const override; + MCSection *getSectionForConstant(SectionKind Kind, + const Constant *C) const override; }; } // end namespace llvm |