From 1c2827cd6a5456126b9a8041642148279456f71a Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Tue, 28 Jan 2014 00:49:26 +0000 Subject: [PATCH] Revert r199871 and replace it with a simple check in the debug info code to see if we're emitting a function into a non-default text section. This is still a less-than-ideal solution, but more contained than r199871 to determine whether or not we're emitting code into an array of comdat sections. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200269 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/TargetLoweringObjectFileImpl.h | 6 +++--- include/llvm/Target/TargetLoweringObjectFile.h | 8 ++++---- include/llvm/Target/TargetMachine.h | 4 ---- lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 9 ++++++++- lib/CodeGen/AsmPrinter/DwarfDebug.h | 4 ++++ lib/CodeGen/TargetLoweringObjectFileImpl.cpp | 8 +++----- lib/Target/Hexagon/HexagonTargetObjectFile.cpp | 2 +- lib/Target/Hexagon/HexagonTargetObjectFile.h | 7 ++++--- lib/Target/Mips/MipsTargetObjectFile.cpp | 2 +- lib/Target/Mips/MipsTargetObjectFile.h | 5 +++-- lib/Target/PowerPC/PPCTargetObjectFile.cpp | 2 +- lib/Target/PowerPC/PPCTargetObjectFile.h | 7 +++---- lib/Target/TargetLoweringObjectFile.cpp | 10 ++++++---- lib/Target/TargetMachine.cpp | 1 - lib/Target/XCore/XCoreTargetObjectFile.cpp | 2 +- lib/Target/XCore/XCoreTargetObjectFile.h | 7 +++---- 16 files changed, 45 insertions(+), 39 deletions(-) diff --git a/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h b/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h index 717ebdb2f71..4e90e141ce1 100644 --- a/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h +++ b/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h @@ -53,7 +53,7 @@ public: virtual const MCSection * SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, - Mangler *Mang, TargetMachine &TM) const; + Mangler *Mang, const TargetMachine &TM) const; /// getTTypeGlobalReference - Return an MCExpr to use for a reference to the /// specified type info global variable from exception handling information. @@ -92,7 +92,7 @@ public: virtual const MCSection * SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, - Mangler *Mang, TargetMachine &TM) const; + Mangler *Mang, const TargetMachine &TM) const; virtual const MCSection * getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind, @@ -131,7 +131,7 @@ public: virtual const MCSection * SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, - Mangler *Mang, TargetMachine &TM) const; + Mangler *Mang, const TargetMachine &TM) const; /// getDepLibFromLinkerOpt - Extract the dependent library name from a linker /// option string. Returns StringRef() if the option does not specify a library. diff --git a/include/llvm/Target/TargetLoweringObjectFile.h b/include/llvm/Target/TargetLoweringObjectFile.h index e7e16ace894..5bf9a13563e 100644 --- a/include/llvm/Target/TargetLoweringObjectFile.h +++ b/include/llvm/Target/TargetLoweringObjectFile.h @@ -38,7 +38,7 @@ class TargetLoweringObjectFile : public MCObjectFileInfo { const DataLayout *DL; TargetLoweringObjectFile( - const TargetLoweringObjectFile &) LLVM_DELETED_FUNCTION; + const TargetLoweringObjectFile&) LLVM_DELETED_FUNCTION; void operator=(const TargetLoweringObjectFile&) LLVM_DELETED_FUNCTION; public: @@ -91,14 +91,14 @@ public: /// be passed external (or available externally) globals. const MCSection *SectionForGlobal(const GlobalValue *GV, SectionKind Kind, Mangler *Mang, - TargetMachine &TM) const; + const TargetMachine &TM) const; /// 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 *SectionForGlobal(const GlobalValue *GV, Mangler *Mang, - TargetMachine &TM) const { + const TargetMachine &TM) const { return SectionForGlobal(GV, getKindForGlobal(GV, TM), Mang, TM); } @@ -167,7 +167,7 @@ public: protected: virtual const MCSection * SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, - Mangler *Mang, TargetMachine &TM) const; + Mangler *Mang, const TargetMachine &TM) const; }; } // end namespace llvm diff --git a/include/llvm/Target/TargetMachine.h b/include/llvm/Target/TargetMachine.h index 7cbc87d9a8b..c27ffdfcd77 100644 --- a/include/llvm/Target/TargetMachine.h +++ b/include/llvm/Target/TargetMachine.h @@ -88,7 +88,6 @@ protected: // Can only create subclasses. unsigned MCUseLoc : 1; unsigned MCUseCFI : 1; unsigned MCUseDwarfDirectory : 1; - unsigned DebugUseUniqueSections : 1; unsigned RequireStructuredCFG : 1; public: @@ -161,9 +160,6 @@ public: bool requiresStructuredCFG() const { return RequireStructuredCFG; } void setRequiresStructuredCFG(bool Value) { RequireStructuredCFG = Value; } - bool debugUseUniqueSections() const { return DebugUseUniqueSections; } - void setDebugUseUniqueSections(bool Value) { DebugUseUniqueSections = Value; } - /// hasMCRelaxAll - Check whether all machine code instructions should be /// relaxed. bool hasMCRelaxAll() const { return MCRelaxAll; } diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 72ce337b203..1d059d9f3c7 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -176,6 +176,7 @@ DwarfDebug::DwarfDebug(AsmPrinter *A, Module *M) : Asm(A), MMI(Asm->MMI), FirstCU(0), SourceIdMap(DIEValueAllocator), PrevLabel(NULL), GlobalRangeCount(0), InfoHolder(A, "info_string", DIEValueAllocator), HasCURanges(false), + UsedNonDefaultText(false), SkeletonHolder(A, "skel_string", DIEValueAllocator) { DwarfInfoSectionSym = DwarfAbbrevSectionSym = DwarfStrSectionSym = 0; @@ -1123,7 +1124,7 @@ void DwarfDebug::endSections() { // we have -ffunction-sections enabled, or we've emitted a function // into a unique section. At this point all sections should be finalized // except for dwarf sections. - HasCURanges = DwarfCURanges || Asm->TM.debugUseUniqueSections() || + HasCURanges = DwarfCURanges || UsedNonDefaultText || TargetMachine::getFunctionSections(); } @@ -1580,6 +1581,12 @@ void DwarfDebug::beginFunction(const MachineFunction *MF) { else Asm->OutStreamer.getContext().setDwarfCompileUnitID(TheCU->getUniqueID()); + // Check the current section against the standard text section. If different + // keep track so that we will know when we're emitting functions into multiple + // sections. + if (Asm->getObjFileLowering().getTextSection() != Asm->getCurrentSection()) + UsedNonDefaultText = true; + // Emit a label for the function so that we have a beginning address. FunctionBeginSym = Asm->GetTempSymbol("func_begin", Asm->getFunctionNumber()); // Assumes in correct section after the entry point. diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.h b/lib/CodeGen/AsmPrinter/DwarfDebug.h index 516def804d1..11695a5735d 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.h +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.h @@ -461,6 +461,10 @@ class DwarfDebug : public AsmPrinterHandler { // Whether or not to use AT_ranges for compilation units. bool HasCURanges; + // Whether we emitted a function into a section other than the default + // text. + bool UsedNonDefaultText; + // Version of dwarf we're emitting. unsigned DwarfVersion; diff --git a/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index 7f534acb70a..3621b582878 100644 --- a/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -232,7 +232,7 @@ static const char *getSectionPrefixForGlobal(SectionKind Kind) { const MCSection *TargetLoweringObjectFileELF:: SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, - Mangler *Mang, TargetMachine &TM) const { + Mangler *Mang, const TargetMachine &TM) const { // If we have -ffunction-section or -fdata-section then we should emit the // global value to a uniqued section specifically for it. bool EmitUniquedSection; @@ -258,8 +258,6 @@ SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, Flags |= ELF::SHF_GROUP; } - // Set that we've used a unique section name in the target machine. - TM.setDebugUseUniqueSections(true); return getContext().getELFSection(Name.str(), getELFSectionType(Name.str(), Kind), Flags, Kind, 0, Group); @@ -531,7 +529,7 @@ getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind, const MCSection *TargetLoweringObjectFileMachO:: SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, - Mangler *Mang, TargetMachine &TM) const { + Mangler *Mang, const TargetMachine &TM) const { // Handle thread local data. if (Kind.isThreadBSS()) return TLSBSSSection; @@ -756,7 +754,7 @@ static const char *getCOFFSectionNameForUniqueGlobal(SectionKind Kind) { const MCSection *TargetLoweringObjectFileCOFF:: SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, - Mangler *Mang, TargetMachine &TM) const { + Mangler *Mang, const TargetMachine &TM) const { // If this global is linkonce/weak and the target handles this by emitting it // into a 'uniqued' section name, create and return the section now. diff --git a/lib/Target/Hexagon/HexagonTargetObjectFile.cpp b/lib/Target/Hexagon/HexagonTargetObjectFile.cpp index a26b81de06c..7773cff2d21 100644 --- a/lib/Target/Hexagon/HexagonTargetObjectFile.cpp +++ b/lib/Target/Hexagon/HexagonTargetObjectFile.cpp @@ -87,7 +87,7 @@ IsGlobalInSmallSection(const GlobalValue *GV, const TargetMachine &TM, const MCSection *HexagonTargetObjectFile:: SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, - Mangler *Mang, TargetMachine &TM) const { + Mangler *Mang, const TargetMachine &TM) const { // Handle Small Section classification here. if (Kind.isBSS() && IsGlobalInSmallSection(GV, TM, Kind)) diff --git a/lib/Target/Hexagon/HexagonTargetObjectFile.h b/lib/Target/Hexagon/HexagonTargetObjectFile.h index ac87814b4b6..41f6792ca8e 100644 --- a/lib/Target/Hexagon/HexagonTargetObjectFile.h +++ b/lib/Target/Hexagon/HexagonTargetObjectFile.h @@ -30,9 +30,10 @@ namespace llvm { const TargetMachine &TM) const; bool IsSmallDataEnabled () const; - const MCSection *SelectSectionForGlobal(const GlobalValue *GV, - SectionKind Kind, Mangler *Mang, - TargetMachine &TM) const; + const MCSection* SelectSectionForGlobal(const GlobalValue *GV, + SectionKind Kind, + Mangler *Mang, + const TargetMachine &TM) const; }; } // namespace llvm diff --git a/lib/Target/Mips/MipsTargetObjectFile.cpp b/lib/Target/Mips/MipsTargetObjectFile.cpp index 90808bcb052..4c748c5b57c 100644 --- a/lib/Target/Mips/MipsTargetObjectFile.cpp +++ b/lib/Target/Mips/MipsTargetObjectFile.cpp @@ -103,7 +103,7 @@ IsGlobalInSmallSection(const GlobalValue *GV, const TargetMachine &TM, const MCSection *MipsTargetObjectFile:: SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, - Mangler *Mang, TargetMachine &TM) const { + Mangler *Mang, const TargetMachine &TM) const { // TODO: Could also support "weak" symbols as well with ".gnu.linkonce.s.*" // sections? diff --git a/lib/Target/Mips/MipsTargetObjectFile.h b/lib/Target/Mips/MipsTargetObjectFile.h index 9aaf7941abf..c0e9140c829 100644 --- a/lib/Target/Mips/MipsTargetObjectFile.h +++ b/lib/Target/Mips/MipsTargetObjectFile.h @@ -31,8 +31,9 @@ namespace llvm { const TargetMachine &TM) const; const MCSection *SelectSectionForGlobal(const GlobalValue *GV, - SectionKind Kind, Mangler *Mang, - TargetMachine &TM) const; + SectionKind Kind, + Mangler *Mang, + const TargetMachine &TM) const; // TODO: Classify globals as mips wishes. const MCSection *getReginfoSection() const { return ReginfoSection; } diff --git a/lib/Target/PowerPC/PPCTargetObjectFile.cpp b/lib/Target/PowerPC/PPCTargetObjectFile.cpp index b9cfe7c9a84..32678674f9a 100644 --- a/lib/Target/PowerPC/PPCTargetObjectFile.cpp +++ b/lib/Target/PowerPC/PPCTargetObjectFile.cpp @@ -24,7 +24,7 @@ Initialize(MCContext &Ctx, const TargetMachine &TM) { const MCSection * PPC64LinuxTargetObjectFile:: SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, - Mangler *Mang, TargetMachine &TM) const { + Mangler *Mang, const TargetMachine &TM) const { const MCSection *DefaultSection = TargetLoweringObjectFileELF::SelectSectionForGlobal(GV, Kind, Mang, TM); diff --git a/lib/Target/PowerPC/PPCTargetObjectFile.h b/lib/Target/PowerPC/PPCTargetObjectFile.h index 571954535db..262c52213d2 100644 --- a/lib/Target/PowerPC/PPCTargetObjectFile.h +++ b/lib/Target/PowerPC/PPCTargetObjectFile.h @@ -22,10 +22,9 @@ namespace llvm { virtual void Initialize(MCContext &Ctx, const TargetMachine &TM); - virtual const MCSection *SelectSectionForGlobal(const GlobalValue *GV, - SectionKind Kind, - Mangler *Mang, - TargetMachine &TM) const; + virtual const MCSection * + SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, + Mangler *Mang, const TargetMachine &TM) const; /// \brief Describe a TLS variable address within debug info. virtual const MCExpr *getDebugThreadLocalSymbol(const MCSymbol *Sym) const; diff --git a/lib/Target/TargetLoweringObjectFile.cpp b/lib/Target/TargetLoweringObjectFile.cpp index 8d73a3ab347..b62577e0801 100644 --- a/lib/Target/TargetLoweringObjectFile.cpp +++ b/lib/Target/TargetLoweringObjectFile.cpp @@ -265,7 +265,7 @@ SectionKind TargetLoweringObjectFile::getKindForGlobal(const GlobalValue *GV, /// be passed external (or available externally) globals. const MCSection *TargetLoweringObjectFile:: SectionForGlobal(const GlobalValue *GV, SectionKind Kind, Mangler *Mang, - TargetMachine &TM) const { + const TargetMachine &TM) const { // Select section name. if (GV->hasSection()) return getExplicitSectionGlobal(GV, Kind, Mang, TM); @@ -277,9 +277,11 @@ SectionForGlobal(const GlobalValue *GV, SectionKind Kind, Mangler *Mang, // Lame default implementation. Calculate the section name for global. -const MCSection *TargetLoweringObjectFile::SelectSectionForGlobal( - const GlobalValue *GV, SectionKind Kind, Mangler *Mang, - TargetMachine &TM) const { +const MCSection * +TargetLoweringObjectFile::SelectSectionForGlobal(const GlobalValue *GV, + SectionKind Kind, + Mangler *Mang, + const TargetMachine &TM) const{ assert(!Kind.isThreadLocal() && "Doesn't support TLS"); if (Kind.isText()) diff --git a/lib/Target/TargetMachine.cpp b/lib/Target/TargetMachine.cpp index 39ade0a2b85..a2350352071 100644 --- a/lib/Target/TargetMachine.cpp +++ b/lib/Target/TargetMachine.cpp @@ -55,7 +55,6 @@ TargetMachine::TargetMachine(const Target &T, MCUseLoc(true), MCUseCFI(true), MCUseDwarfDirectory(false), - DebugUseUniqueSections(false), RequireStructuredCFG(false), Options(Options) { } diff --git a/lib/Target/XCore/XCoreTargetObjectFile.cpp b/lib/Target/XCore/XCoreTargetObjectFile.cpp index fec79d759c8..61eb2b51f3e 100644 --- a/lib/Target/XCore/XCoreTargetObjectFile.cpp +++ b/lib/Target/XCore/XCoreTargetObjectFile.cpp @@ -130,7 +130,7 @@ getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind, const MCSection *XCoreTargetObjectFile:: SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, Mangler *Mang, - TargetMachine &TM) const{ + const TargetMachine &TM) const{ if (Kind.isText()) return TextSection; if (Kind.isMergeable1ByteCString()) return CStringSection; if (Kind.isMergeableConst4()) return MergeableConst4Section; diff --git a/lib/Target/XCore/XCoreTargetObjectFile.h b/lib/Target/XCore/XCoreTargetObjectFile.h index 127ff0704c1..bf9798d5085 100644 --- a/lib/Target/XCore/XCoreTargetObjectFile.h +++ b/lib/Target/XCore/XCoreTargetObjectFile.h @@ -27,10 +27,9 @@ static const unsigned CodeModelLargeSize = 256; getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind, Mangler *Mang, const TargetMachine &TM) const; - virtual const MCSection *SelectSectionForGlobal(const GlobalValue *GV, - SectionKind Kind, - Mangler *Mang, - TargetMachine &TM) const; + virtual const MCSection * + SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, + Mangler *Mang, const TargetMachine &TM) const; virtual const MCSection *getSectionForConstant(SectionKind Kind) const; };