From 86b7255776646e6a185ccf1dca5a07ec14ca0dd2 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. llvm-svn: 77186 --- llvm/include/llvm/Target/TargetAsmInfo.h | 7 ++- llvm/lib/Target/ARM/ARMTargetAsmInfo.cpp | 2 +- llvm/lib/Target/CellSPU/SPUTargetAsmInfo.cpp | 2 +- llvm/lib/Target/DarwinTargetAsmInfo.cpp | 34 +++++++-------- llvm/lib/Target/ELFTargetAsmInfo.cpp | 42 +++++++++--------- llvm/lib/Target/MSP430/MSP430TargetAsmInfo.cpp | 2 +- llvm/lib/Target/Mips/MipsTargetAsmInfo.cpp | 2 +- llvm/lib/Target/PIC16/PIC16AsmPrinter.cpp | 4 +- llvm/lib/Target/PIC16/PIC16TargetAsmInfo.cpp | 54 ++++++++++++++---------- llvm/lib/Target/PowerPC/PPCTargetAsmInfo.cpp | 2 +- llvm/lib/Target/Sparc/SparcTargetAsmInfo.cpp | 2 +- llvm/lib/Target/SystemZ/SystemZTargetAsmInfo.cpp | 2 +- llvm/lib/Target/TargetAsmInfo.cpp | 29 ++++--------- llvm/lib/Target/X86/X86TargetAsmInfo.cpp | 23 +++++----- llvm/lib/Target/XCore/XCoreTargetAsmInfo.cpp | 12 +++--- 15 files changed, 108 insertions(+), 111 deletions(-) diff --git a/llvm/include/llvm/Target/TargetAsmInfo.h b/llvm/include/llvm/Target/TargetAsmInfo.h index d4a368e..9ddaf29 100644 --- a/llvm/include/llvm/Target/TargetAsmInfo.h +++ b/llvm/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/llvm/lib/Target/ARM/ARMTargetAsmInfo.cpp b/llvm/lib/Target/ARM/ARMTargetAsmInfo.cpp index 983a609..87f8a68 100644 --- a/llvm/lib/Target/ARM/ARMTargetAsmInfo.cpp +++ b/llvm/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/llvm/lib/Target/CellSPU/SPUTargetAsmInfo.cpp b/llvm/lib/Target/CellSPU/SPUTargetAsmInfo.cpp index 2dcd37b..534d18e 100644 --- a/llvm/lib/Target/CellSPU/SPUTargetAsmInfo.cpp +++ b/llvm/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/llvm/lib/Target/DarwinTargetAsmInfo.cpp b/llvm/lib/Target/DarwinTargetAsmInfo.cpp index b3bcf4b..4ac9eae 100644 --- a/llvm/lib/Target/DarwinTargetAsmInfo.cpp +++ b/llvm/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/llvm/lib/Target/ELFTargetAsmInfo.cpp b/llvm/lib/Target/ELFTargetAsmInfo.cpp index cefcb5d..de0150f 100644 --- a/llvm/lib/Target/ELFTargetAsmInfo.cpp +++ b/llvm/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/llvm/lib/Target/MSP430/MSP430TargetAsmInfo.cpp b/llvm/lib/Target/MSP430/MSP430TargetAsmInfo.cpp index 65d2f39..cd3cdcf 100644 --- a/llvm/lib/Target/MSP430/MSP430TargetAsmInfo.cpp +++ b/llvm/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/llvm/lib/Target/Mips/MipsTargetAsmInfo.cpp b/llvm/lib/Target/Mips/MipsTargetAsmInfo.cpp index 9c90ff0..26f4b3b 100644 --- a/llvm/lib/Target/Mips/MipsTargetAsmInfo.cpp +++ b/llvm/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/llvm/lib/Target/PIC16/PIC16AsmPrinter.cpp b/llvm/lib/Target/PIC16/PIC16AsmPrinter.cpp index a72b8e5..443ced0 100644 --- a/llvm/lib/Target/PIC16/PIC16AsmPrinter.cpp +++ b/llvm/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/llvm/lib/Target/PIC16/PIC16TargetAsmInfo.cpp b/llvm/lib/Target/PIC16/PIC16TargetAsmInfo.cpp index c855632..5a4387a 100644 --- a/llvm/lib/Target/PIC16/PIC16TargetAsmInfo.cpp +++ b/llvm/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/llvm/lib/Target/PowerPC/PPCTargetAsmInfo.cpp b/llvm/lib/Target/PowerPC/PPCTargetAsmInfo.cpp index d56a921..a56f965 100644 --- a/llvm/lib/Target/PowerPC/PPCTargetAsmInfo.cpp +++ b/llvm/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/llvm/lib/Target/Sparc/SparcTargetAsmInfo.cpp b/llvm/lib/Target/Sparc/SparcTargetAsmInfo.cpp index 4bcaec0..59897e6 100644 --- a/llvm/lib/Target/Sparc/SparcTargetAsmInfo.cpp +++ b/llvm/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/llvm/lib/Target/SystemZ/SystemZTargetAsmInfo.cpp b/llvm/lib/Target/SystemZ/SystemZTargetAsmInfo.cpp index 1f9d34f..0079586 100644 --- a/llvm/lib/Target/SystemZ/SystemZTargetAsmInfo.cpp +++ b/llvm/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/llvm/lib/Target/TargetAsmInfo.cpp b/llvm/lib/Target/TargetAsmInfo.cpp index 604c54e..de333a8 100644 --- a/llvm/lib/Target/TargetAsmInfo.cpp +++ b/llvm/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/llvm/lib/Target/X86/X86TargetAsmInfo.cpp b/llvm/lib/Target/X86/X86TargetAsmInfo.cpp index 04de225..c2ac9f2 100644 --- a/llvm/lib/Target/X86/X86TargetAsmInfo.cpp +++ b/llvm/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/llvm/lib/Target/XCore/XCoreTargetAsmInfo.cpp b/llvm/lib/Target/XCore/XCoreTargetAsmInfo.cpp index 4c8786a..fee0a22 100644 --- a/llvm/lib/Target/XCore/XCoreTargetAsmInfo.cpp +++ b/llvm/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.7.4