From e346694a81cbead3289d11057111fba46aa30aae Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 27 Jul 2009 06:17:14 +0000 Subject: [PATCH] Eliminate getNamed/getUnnamedSection, adding a new and unified getOrCreateSection instead. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77186 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Target/TargetAsmInfo.h | 7 ++- lib/Target/ARM/ARMTargetAsmInfo.cpp | 2 +- lib/Target/CellSPU/SPUTargetAsmInfo.cpp | 2 +- lib/Target/DarwinTargetAsmInfo.cpp | 34 ++++++------- lib/Target/ELFTargetAsmInfo.cpp | 42 ++++++++-------- lib/Target/MSP430/MSP430TargetAsmInfo.cpp | 2 +- lib/Target/Mips/MipsTargetAsmInfo.cpp | 2 +- lib/Target/PIC16/PIC16AsmPrinter.cpp | 4 +- lib/Target/PIC16/PIC16TargetAsmInfo.cpp | 54 ++++++++++++--------- lib/Target/PowerPC/PPCTargetAsmInfo.cpp | 2 +- lib/Target/Sparc/SparcTargetAsmInfo.cpp | 2 +- lib/Target/SystemZ/SystemZTargetAsmInfo.cpp | 2 +- lib/Target/TargetAsmInfo.cpp | 29 +++-------- lib/Target/X86/X86TargetAsmInfo.cpp | 23 ++++----- lib/Target/XCore/XCoreTargetAsmInfo.cpp | 12 +++-- 15 files changed, 108 insertions(+), 111 deletions(-) diff --git a/include/llvm/Target/TargetAsmInfo.h b/include/llvm/Target/TargetAsmInfo.h index d4a368e3e89..9ddaf29f465 100644 --- a/include/llvm/Target/TargetAsmInfo.h +++ b/include/llvm/Target/TargetAsmInfo.h @@ -639,10 +639,9 @@ namespace llvm { explicit TargetAsmInfo(const TargetMachine &TM); virtual ~TargetAsmInfo(); - const Section* getNamedSection(const char *Name, - SectionKind::Kind K) const; - const Section* getUnnamedSection(const char *Directive, - SectionKind::Kind K) const; + const Section *getOrCreateSection(const char *Name, + bool isDirective, + SectionKind::Kind K) const; /// Measure the specified inline asm to determine an approximation of its /// length. diff --git a/lib/Target/ARM/ARMTargetAsmInfo.cpp b/lib/Target/ARM/ARMTargetAsmInfo.cpp index 983a609b74c..87f8a685640 100644 --- a/lib/Target/ARM/ARMTargetAsmInfo.cpp +++ b/lib/Target/ARM/ARMTargetAsmInfo.cpp @@ -59,7 +59,7 @@ ARMELFTargetAsmInfo::ARMELFTargetAsmInfo(const ARMBaseTargetMachine &TM): ARMTargetAsmInfo(TM) { Subtarget = &TM.getSubtarget(); - BSSSection_ = getUnnamedSection("\t.bss", SectionKind::BSS); + BSSSection_ = getOrCreateSection("\t.bss", true, SectionKind::BSS); NeedsSet = false; HasLEB128 = true; diff --git a/lib/Target/CellSPU/SPUTargetAsmInfo.cpp b/lib/Target/CellSPU/SPUTargetAsmInfo.cpp index 2dcd37bfa79..534d18e60fc 100644 --- a/lib/Target/CellSPU/SPUTargetAsmInfo.cpp +++ b/lib/Target/CellSPU/SPUTargetAsmInfo.cpp @@ -35,7 +35,7 @@ SPULinuxTargetAsmInfo::SPULinuxTargetAsmInfo(const SPUTargetMachine &TM) : // BSS section needs to be emitted as ".section" BSSSection = "\t.section\t.bss"; - BSSSection_ = getUnnamedSection("\t.section\t.bss", SectionKind::BSS); + BSSSection_ = getOrCreateSection("\t.bss", false, SectionKind::BSS); SupportsDebugInformation = true; NeedsSet = true; diff --git a/lib/Target/DarwinTargetAsmInfo.cpp b/lib/Target/DarwinTargetAsmInfo.cpp index b3bcf4b3a19..4ac9eae94bc 100644 --- a/lib/Target/DarwinTargetAsmInfo.cpp +++ b/lib/Target/DarwinTargetAsmInfo.cpp @@ -28,30 +28,30 @@ using namespace llvm; DarwinTargetAsmInfo::DarwinTargetAsmInfo(const TargetMachine &TM) : TargetAsmInfo(TM) { - CStringSection_ = getUnnamedSection("\t.cstring", - SectionKind::MergeableCString); - FourByteConstantSection = getUnnamedSection("\t.literal4\n", - SectionKind::MergeableConst4); - EightByteConstantSection = getUnnamedSection("\t.literal8\n", - SectionKind::MergeableConst8); + CStringSection_ = getOrCreateSection("\t.cstring", true, + SectionKind::MergeableCString); + FourByteConstantSection = getOrCreateSection("\t.literal4\n", true, + SectionKind::MergeableConst4); + EightByteConstantSection = getOrCreateSection("\t.literal8\n", true, + SectionKind::MergeableConst8); // Note: 16-byte constant section is subtarget specific and should be provided // there, if needed. SixteenByteConstantSection = 0; - ReadOnlySection = getUnnamedSection("\t.const", SectionKind::ReadOnly); + ReadOnlySection = getOrCreateSection("\t.const", true, SectionKind::ReadOnly); TextCoalSection = - getNamedSection("\t__TEXT,__textcoal_nt,coalesced,pure_instructions", - SectionKind::Text); - ConstTextCoalSection = getNamedSection("\t__TEXT,__const_coal,coalesced", - SectionKind::Text); - ConstDataCoalSection = getNamedSection("\t__DATA,__const_coal,coalesced", - SectionKind::Text); - ConstDataSection = getUnnamedSection("\t.const_data", - SectionKind::ReadOnlyWithRel); - DataCoalSection = getNamedSection("\t__DATA,__datacoal_nt,coalesced", - SectionKind::DataRel); + getOrCreateSection("\t__TEXT,__textcoal_nt,coalesced,pure_instructions", + false, SectionKind::Text); + ConstTextCoalSection = getOrCreateSection("\t__TEXT,__const_coal,coalesced", + false, SectionKind::Text); + ConstDataCoalSection = getOrCreateSection("\t__DATA,__const_coal,coalesced", + false, SectionKind::Text); + ConstDataSection = getOrCreateSection("\t.const_data", true, + SectionKind::ReadOnlyWithRel); + DataCoalSection = getOrCreateSection("\t__DATA,__datacoal_nt,coalesced", + false, SectionKind::DataRel); // Common settings for all Darwin targets. diff --git a/lib/Target/ELFTargetAsmInfo.cpp b/lib/Target/ELFTargetAsmInfo.cpp index cefcb5d21c1..de0150fdf9d 100644 --- a/lib/Target/ELFTargetAsmInfo.cpp +++ b/lib/Target/ELFTargetAsmInfo.cpp @@ -26,25 +26,28 @@ using namespace llvm; ELFTargetAsmInfo::ELFTargetAsmInfo(const TargetMachine &TM) : TargetAsmInfo(TM) { - - ReadOnlySection = getNamedSection("\t.rodata", SectionKind::ReadOnly); - TLSDataSection = getNamedSection("\t.tdata", SectionKind::ThreadData); - TLSBSSSection = getNamedSection("\t.tbss", SectionKind::ThreadBSS); - - DataRelSection = getNamedSection("\t.data.rel", SectionKind::DataRel); - DataRelLocalSection = getNamedSection("\t.data.rel.local", - SectionKind::DataRelLocal); - DataRelROSection = getNamedSection("\t.data.rel.ro", - SectionKind::ReadOnlyWithRel); - DataRelROLocalSection = getNamedSection("\t.data.rel.ro.local", - SectionKind::ReadOnlyWithRelLocal); + ReadOnlySection = + getOrCreateSection("\t.rodata", false, SectionKind::ReadOnly); + TLSDataSection = + getOrCreateSection("\t.tdata", false, SectionKind::ThreadData); + TLSBSSSection = getOrCreateSection("\t.tbss", false, SectionKind::ThreadBSS); + + DataRelSection = getOrCreateSection("\t.data.rel", false, + SectionKind::DataRel); + DataRelLocalSection = getOrCreateSection("\t.data.rel.local", false, + SectionKind::DataRelLocal); + DataRelROSection = getOrCreateSection("\t.data.rel.ro", false, + SectionKind::ReadOnlyWithRel); + DataRelROLocalSection = + getOrCreateSection("\t.data.rel.ro.local", false, + SectionKind::ReadOnlyWithRelLocal); - MergeableConst4Section = getNamedSection(".rodata.cst4", - SectionKind::MergeableConst4); - MergeableConst8Section = getNamedSection(".rodata.cst8", - SectionKind::MergeableConst8); - MergeableConst16Section = getNamedSection(".rodata.cst16", - SectionKind::MergeableConst16); + MergeableConst4Section = getOrCreateSection(".rodata.cst4", false, + SectionKind::MergeableConst4); + MergeableConst8Section = getOrCreateSection(".rodata.cst8", false, + SectionKind::MergeableConst8); + MergeableConst16Section = getOrCreateSection(".rodata.cst16", false, + SectionKind::MergeableConst16); } @@ -158,7 +161,8 @@ ELFTargetAsmInfo::MergeableStringSection(const GlobalVariable *GV) const { Align = Size; std::string Name = getCStringSection() + utostr(Size) + '.' + utostr(Align); - return getNamedSection(Name.c_str(), SectionKind::MergeableCString); + return getOrCreateSection(Name.c_str(), false, + SectionKind::MergeableCString); } return getReadOnlySection(); diff --git a/lib/Target/MSP430/MSP430TargetAsmInfo.cpp b/lib/Target/MSP430/MSP430TargetAsmInfo.cpp index 65d2f39a697..cd3cdcff06d 100644 --- a/lib/Target/MSP430/MSP430TargetAsmInfo.cpp +++ b/lib/Target/MSP430/MSP430TargetAsmInfo.cpp @@ -18,5 +18,5 @@ MSP430TargetAsmInfo::MSP430TargetAsmInfo(const TargetMachine &TM) : ELFTargetAsmInfo(TM) { AlignmentIsInBytes = false; - BSSSection_ = getUnnamedSection("\t.bss", SectionKind::BSS); + BSSSection_ = getOrCreateSection("\t.bss", true, SectionKind::BSS); } diff --git a/lib/Target/Mips/MipsTargetAsmInfo.cpp b/lib/Target/Mips/MipsTargetAsmInfo.cpp index 9c90ff0c74f..26f4b3b9ee1 100644 --- a/lib/Target/Mips/MipsTargetAsmInfo.cpp +++ b/lib/Target/Mips/MipsTargetAsmInfo.cpp @@ -30,7 +30,7 @@ MipsTargetAsmInfo::MipsTargetAsmInfo(const MipsTargetMachine &TM) BSSSection = "\t.section\t.bss"; CStringSection = ".rodata.str"; - BSSSection_ = getUnnamedSection("\t.bss", SectionKind::BSS); + BSSSection_ = getOrCreateSection("\t.bss", true, SectionKind::BSS); if (!TM.getSubtarget().hasABICall()) JumpTableDirective = "\t.word\t"; diff --git a/lib/Target/PIC16/PIC16AsmPrinter.cpp b/lib/Target/PIC16/PIC16AsmPrinter.cpp index a72b8e5e500..443ced0c184 100644 --- a/lib/Target/PIC16/PIC16AsmPrinter.cpp +++ b/lib/Target/PIC16/PIC16AsmPrinter.cpp @@ -62,7 +62,7 @@ bool PIC16AsmPrinter::runOnMachineFunction(MachineFunction &MF) { const char *codeSection = PAN::getCodeSectionName(CurrentFnName).c_str(); const Section *fCodeSection = - TAI->getNamedSection(codeSection, SectionKind::Text); + TAI->getOrCreateSection(codeSection, false, SectionKind::Text); // Start the Code Section. O << "\n"; SwitchToSection(fCodeSection); @@ -292,7 +292,7 @@ void PIC16AsmPrinter::EmitFunctionFrame(MachineFunction &MF) { const char *SectionName = PAN::getFrameSectionName(CurrentFnName).c_str(); const Section *fPDataSection = - TAI->getNamedSection(SectionName, SectionKind::DataRel); + TAI->getOrCreateSection(SectionName, false, SectionKind::DataRel); SwitchToSection(fPDataSection); // Emit function frame label diff --git a/lib/Target/PIC16/PIC16TargetAsmInfo.cpp b/lib/Target/PIC16/PIC16TargetAsmInfo.cpp index c855632d9f5..5a4387ae253 100644 --- a/lib/Target/PIC16/PIC16TargetAsmInfo.cpp +++ b/lib/Target/PIC16/PIC16TargetAsmInfo.cpp @@ -37,21 +37,24 @@ PIC16TargetAsmInfo(const PIC16TargetMachine &TM) ZeroDirective = NULL; AsciiDirective = " dt "; AscizDirective = NULL; - BSSSection_ = getNamedSection("udata.# UDATA", SectionKind::BSS); - ReadOnlySection = getNamedSection("romdata.# ROMDATA", SectionKind::ReadOnly); - DataSection = getNamedSection("idata.# IDATA", SectionKind::DataRel); + BSSSection_ = getOrCreateSection("udata.# UDATA", false, SectionKind::BSS); + ReadOnlySection = getOrCreateSection("romdata.# ROMDATA", false, + SectionKind::ReadOnly); + DataSection = getOrCreateSection("idata.# IDATA", false,SectionKind::DataRel); SwitchToSectionDirective = ""; // Need because otherwise a .text symbol is emitted by DwarfWriter // in BeginModule, and gpasm cribbs for that .text symbol. - TextSection = getUnnamedSection("", SectionKind::Text); + TextSection = getOrCreateSection("", true, SectionKind::Text); PIC16Section *ROSection = new PIC16Section(getReadOnlySection()); ROSections.push_back(ROSection); // FIXME: I don't know what the classification of these sections really is. - ExternalVarDecls = new PIC16Section(getNamedSection("ExternalVarDecls", - SectionKind::Metadata)); - ExternalVarDefs = new PIC16Section(getNamedSection("ExternalVarDefs", - SectionKind::Metadata)); + ExternalVarDecls = new PIC16Section(getOrCreateSection("ExternalVarDecls", + false, + SectionKind::Metadata)); + ExternalVarDefs = new PIC16Section(getOrCreateSection("ExternalVarDefs", + false, + SectionKind::Metadata)); // Set it to false because we weed to generate c file name and not bc file // name. HasSingleParameterDotFile = false; @@ -98,9 +101,9 @@ PIC16TargetAsmInfo::getBSSSectionForGlobal(const GlobalVariable *GV) const { // No BSS section spacious enough was found. Crate a new one. if (!FoundBSS) { std::string name = PAN::getUdataSectionName(BSSSections.size()); - const Section *NewSection = getNamedSection(name.c_str(), - // FIXME. - SectionKind::Metadata); + const Section *NewSection = getOrCreateSection(name.c_str(), false, + // FIXME. + SectionKind::Metadata); FoundBSS = new PIC16Section(NewSection); @@ -140,9 +143,10 @@ PIC16TargetAsmInfo::getIDATASectionForGlobal(const GlobalVariable *GV) const { // No IDATA section spacious enough was found. Crate a new one. if (!FoundIDATA) { std::string name = PAN::getIdataSectionName(IDATASections.size()); - const Section *NewSection = getNamedSection(name.c_str(), - // FIXME. - SectionKind::Metadata); + const Section *NewSection = getOrCreateSection(name.c_str(), + false, + // FIXME. + SectionKind::Metadata); FoundIDATA = new PIC16Section(NewSection); @@ -175,9 +179,10 @@ PIC16TargetAsmInfo::getSectionForAuto(const GlobalVariable *GV) const { // No Auto section was found. Crate a new one. if (!FoundAutoSec) { - const Section *NewSection = getNamedSection(name.c_str(), - // FIXME. - SectionKind::Metadata); + const Section *NewSection = getOrCreateSection(name.c_str(), + // FIXME. + false, + SectionKind::Metadata); FoundAutoSec = new PIC16Section(NewSection); @@ -325,7 +330,8 @@ PIC16TargetAsmInfo::CreateBSSSectionForGlobal(const GlobalVariable *GV, PIC16Section *NewBSS = FoundBSS; if (NewBSS == NULL) { - const Section *NewSection = getNamedSection(Name.c_str(), SectionKind::BSS); + const Section *NewSection = getOrCreateSection(Name.c_str(), + false, SectionKind::BSS); NewBSS = new PIC16Section(NewSection); BSSSections.push_back(NewBSS); } @@ -376,9 +382,10 @@ PIC16TargetAsmInfo::CreateIDATASectionForGlobal(const GlobalVariable *GV, PIC16Section *NewIDATASec = FoundIDATASec; if (NewIDATASec == NULL) { - const Section *NewSection = getNamedSection(Name.c_str(), - // FIXME: - SectionKind::Metadata); + const Section *NewSection = getOrCreateSection(Name.c_str(), + false, + // FIXME: + SectionKind::Metadata); NewIDATASec = new PIC16Section(NewSection); IDATASections.push_back(NewIDATASec); } @@ -416,8 +423,9 @@ PIC16TargetAsmInfo::CreateROSectionForGlobal(const GlobalVariable *GV, PIC16Section *NewRomSec = FoundROSec; if (NewRomSec == NULL) { - const Section *NewSection = getNamedSection(Name.c_str(), - SectionKind::ReadOnly); + const Section *NewSection = getOrCreateSection(Name.c_str(), + false, + SectionKind::ReadOnly); NewRomSec = new PIC16Section(NewSection); ROSections.push_back(NewRomSec); } diff --git a/lib/Target/PowerPC/PPCTargetAsmInfo.cpp b/lib/Target/PowerPC/PPCTargetAsmInfo.cpp index d56a92147ce..a56f965857f 100644 --- a/lib/Target/PowerPC/PPCTargetAsmInfo.cpp +++ b/lib/Target/PowerPC/PPCTargetAsmInfo.cpp @@ -71,7 +71,7 @@ PPCLinuxTargetAsmInfo::PPCLinuxTargetAsmInfo(const PPCTargetMachine &TM) : BSSSection = "\t.section\t\".sbss\",\"aw\",@nobits"; // PPC/Linux normally uses named section for BSS. - BSSSection_ = getNamedSection("\t.bss", SectionKind::BSS); + BSSSection_ = getOrCreateSection("\t.bss", true, SectionKind::BSS); // Debug Information AbsoluteDebugSectionOffsets = true; diff --git a/lib/Target/Sparc/SparcTargetAsmInfo.cpp b/lib/Target/Sparc/SparcTargetAsmInfo.cpp index 4bcaec00053..59897e65e81 100644 --- a/lib/Target/Sparc/SparcTargetAsmInfo.cpp +++ b/lib/Target/Sparc/SparcTargetAsmInfo.cpp @@ -27,7 +27,7 @@ SparcELFTargetAsmInfo::SparcELFTargetAsmInfo(const TargetMachine &TM) CStringSection=".rodata.str"; // Sparc normally uses named section for BSS. - BSSSection_ = getNamedSection("\t.bss", SectionKind::BSS); + BSSSection_ = getOrCreateSection("\t.bss", true, SectionKind::BSS); } diff --git a/lib/Target/SystemZ/SystemZTargetAsmInfo.cpp b/lib/Target/SystemZ/SystemZTargetAsmInfo.cpp index 1f9d34f02bc..0079586dc40 100644 --- a/lib/Target/SystemZ/SystemZTargetAsmInfo.cpp +++ b/lib/Target/SystemZ/SystemZTargetAsmInfo.cpp @@ -28,5 +28,5 @@ SystemZTargetAsmInfo::SystemZTargetAsmInfo(const SystemZTargetMachine &TM) NonexecutableStackDirective = "\t.section\t.note.GNU-stack,\"\",@progbits"; - BSSSection_ = getUnnamedSection("\t.bss", SectionKind::BSS); + BSSSection_ = getOrCreateSection("\t.bss", true, SectionKind::BSS); } diff --git a/lib/Target/TargetAsmInfo.cpp b/lib/Target/TargetAsmInfo.cpp index 604c54ecf07..de333a81d18 100644 --- a/lib/Target/TargetAsmInfo.cpp +++ b/lib/Target/TargetAsmInfo.cpp @@ -122,8 +122,8 @@ TargetAsmInfo::TargetAsmInfo(const TargetMachine &tm) : TM(tm) { DwarfEHFrameSection = ".eh_frame"; DwarfExceptionSection = ".gcc_except_table"; AsmTransCBE = 0; - TextSection = getUnnamedSection("\t.text", SectionKind::Text); - DataSection = getUnnamedSection("\t.data", SectionKind::DataRel); + TextSection = getOrCreateSection("\t.text", true, SectionKind::Text); + DataSection = getOrCreateSection("\t.data", true, SectionKind::DataRel); } TargetAsmInfo::~TargetAsmInfo() { @@ -314,7 +314,7 @@ const Section *TargetAsmInfo::SectionForGlobal(const GlobalValue *GV) const { // section and still get the appropriate section flags printed. GVKind = getKindForNamedSection(GV->getSection().c_str(), GVKind); - return getNamedSection(GV->getSection().c_str(), GVKind); + return getOrCreateSection(GV->getSection().c_str(), false, GVKind); } // If this global is linkonce/weak and the target handles this by emitting it @@ -323,7 +323,7 @@ const Section *TargetAsmInfo::SectionForGlobal(const GlobalValue *GV) const { if (const char *Prefix = getSectionPrefixForUniqueGlobal(Kind)) { // FIXME: Use mangler interface (PR4584). std::string Name = Prefix+GV->getNameStr(); - return getNamedSection(Name.c_str(), GVKind); + return getOrCreateSection(Name.c_str(), false, GVKind); } } @@ -364,33 +364,20 @@ TargetAsmInfo::getSectionForMergeableConstant(SectionKind Kind) const { } -const Section *TargetAsmInfo::getNamedSection(const char *Name, - SectionKind::Kind Kind) const { +const Section *TargetAsmInfo::getOrCreateSection(const char *Name, + bool isDirective, + SectionKind::Kind Kind) const { Section &S = Sections[Name]; // This is newly-created section, set it up properly. if (S.Name.empty()) { - S.Kind = SectionKind::get(Kind, false /*weak*/, true /*Named*/); + S.Kind = SectionKind::get(Kind, false /*weak*/, !isDirective); S.Name = Name; } return &S; } -const Section* -TargetAsmInfo::getUnnamedSection(const char *Directive, - SectionKind::Kind Kind) const { - Section& S = Sections[Directive]; - - // This is newly-created section, set it up properly. - if (S.Name.empty()) { - S.Kind = SectionKind::get(Kind, false /*weak*/, false /*Named*/); - S.Name = Directive; - } - - return &S; -} - unsigned TargetAsmInfo::getULEB128Size(unsigned Value) { unsigned Size = 0; do { diff --git a/lib/Target/X86/X86TargetAsmInfo.cpp b/lib/Target/X86/X86TargetAsmInfo.cpp index 04de225a400..c2ac9f2ff4c 100644 --- a/lib/Target/X86/X86TargetAsmInfo.cpp +++ b/lib/Target/X86/X86TargetAsmInfo.cpp @@ -57,8 +57,8 @@ X86DarwinTargetAsmInfo::X86DarwinTargetAsmInfo(const X86TargetMachine &TM): ConstantPoolSection = "\t.const\n"; // FIXME: Why don't we always use this section? if (is64Bit) - SixteenByteConstantSection = getUnnamedSection("\t.literal16\n", - SectionKind::MergeableConst16); + SixteenByteConstantSection = + getOrCreateSection("\t.literal16\n", true, SectionKind::MergeableConst16); LCOMMDirective = "\t.lcomm\t"; // Leopard and above support aligned common symbols. @@ -100,23 +100,20 @@ X86DarwinTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason, bool Global) const { if (Reason == DwarfEncoding::Functions && Global) return (DW_EH_PE_pcrel | DW_EH_PE_indirect | DW_EH_PE_sdata4); - else if (Reason == DwarfEncoding::CodeLabels || !Global) + if (Reason == DwarfEncoding::CodeLabels || !Global) return DW_EH_PE_pcrel; - else - return DW_EH_PE_absptr; + return DW_EH_PE_absptr; } const char * -X86DarwinTargetAsmInfo::getEHGlobalPrefix() const -{ +X86DarwinTargetAsmInfo::getEHGlobalPrefix() const { const X86Subtarget* Subtarget = &TM.getSubtarget(); if (Subtarget->getDarwinVers() > 9) return PrivateGlobalPrefix; - else - return ""; + return ""; } -X86ELFTargetAsmInfo::X86ELFTargetAsmInfo(const X86TargetMachine &TM): +X86ELFTargetAsmInfo::X86ELFTargetAsmInfo(const X86TargetMachine &TM) : X86TargetAsmInfo(TM) { CStringSection = ".rodata.str"; @@ -128,7 +125,7 @@ X86ELFTargetAsmInfo::X86ELFTargetAsmInfo(const X86TargetMachine &TM): // Set up DWARF directives HasLEB128 = true; // Target asm supports leb128 directives (little-endian) - BSSSection_ = getUnnamedSection("\t.bss", SectionKind::BSS); + BSSSection_ = getOrCreateSection("\t.bss", true, SectionKind::BSS); // Debug Information AbsoluteDebugSectionOffsets = true; @@ -314,8 +311,8 @@ X86WinTargetAsmInfo::X86WinTargetAsmInfo(const X86TargetMachine &TM): AlignmentIsInBytes = true; - TextSection = getUnnamedSection("_text", SectionKind::Text); - DataSection = getUnnamedSection("_data", SectionKind::DataRel); + TextSection = getOrCreateSection("_text", true, SectionKind::Text); + DataSection = getOrCreateSection("_data", true, SectionKind::DataRel); JumpTableDataSection = NULL; SwitchToSectionDirective = ""; diff --git a/lib/Target/XCore/XCoreTargetAsmInfo.cpp b/lib/Target/XCore/XCoreTargetAsmInfo.cpp index 4c8786a4d47..fee0a2244ce 100644 --- a/lib/Target/XCore/XCoreTargetAsmInfo.cpp +++ b/lib/Target/XCore/XCoreTargetAsmInfo.cpp @@ -24,9 +24,9 @@ using namespace llvm; XCoreTargetAsmInfo::XCoreTargetAsmInfo(const XCoreTargetMachine &TM) : ELFTargetAsmInfo(TM) { SupportsDebugInformation = true; - TextSection = getUnnamedSection("\t.text", SectionKind::Text); - DataSection = getNamedSection("\t.dp.data", SectionKind::DataRel); - BSSSection_ = getNamedSection("\t.dp.bss", SectionKind::BSS); + TextSection = getOrCreateSection("\t.text", true, SectionKind::Text); + DataSection = getOrCreateSection("\t.dp.data", false, SectionKind::DataRel); + BSSSection_ = getOrCreateSection("\t.dp.bss", false, SectionKind::BSS); // TLS globals are lowered in the backend to arrays indexed by the current // thread id. After lowering they require no special handling by the linker @@ -36,9 +36,11 @@ XCoreTargetAsmInfo::XCoreTargetAsmInfo(const XCoreTargetMachine &TM) if (TM.getSubtargetImpl()->isXS1A()) // FIXME: Why is this writable??? - ReadOnlySection = getNamedSection("\t.dp.rodata", SectionKind::DataRel); + ReadOnlySection = getOrCreateSection("\t.dp.rodata", false, + SectionKind::DataRel); else - ReadOnlySection = getNamedSection("\t.cp.rodata", SectionKind::ReadOnly); + ReadOnlySection = getOrCreateSection("\t.cp.rodata", false, + SectionKind::ReadOnly); Data16bitsDirective = "\t.short\t"; Data32bitsDirective = "\t.long\t"; Data64bitsDirective = 0; -- 2.34.1