[llvm] r200269 - Revert r199871 and replace it with a simple check in the debug info

Eric Christopher echristo at gmail.com
Mon Jan 27 16:49:26 PST 2014


Author: echristo
Date: Mon Jan 27 18:49:26 2014
New Revision: 200269

URL: http://llvm.org/viewvc/llvm-project?rev=200269&view=rev
Log:
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.

Modified:
    llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
    llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h
    llvm/trunk/include/llvm/Target/TargetMachine.h
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
    llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
    llvm/trunk/lib/Target/Hexagon/HexagonTargetObjectFile.cpp
    llvm/trunk/lib/Target/Hexagon/HexagonTargetObjectFile.h
    llvm/trunk/lib/Target/Mips/MipsTargetObjectFile.cpp
    llvm/trunk/lib/Target/Mips/MipsTargetObjectFile.h
    llvm/trunk/lib/Target/PowerPC/PPCTargetObjectFile.cpp
    llvm/trunk/lib/Target/PowerPC/PPCTargetObjectFile.h
    llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp
    llvm/trunk/lib/Target/TargetMachine.cpp
    llvm/trunk/lib/Target/XCore/XCoreTargetObjectFile.cpp
    llvm/trunk/lib/Target/XCore/XCoreTargetObjectFile.h

Modified: llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h?rev=200269&r1=200268&r2=200269&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h (original)
+++ llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h Mon Jan 27 18:49:26 2014
@@ -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.

Modified: llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h?rev=200269&r1=200268&r2=200269&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h (original)
+++ llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h Mon Jan 27 18:49:26 2014
@@ -38,7 +38,7 @@ class TargetLoweringObjectFile : public
   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

Modified: llvm/trunk/include/llvm/Target/TargetMachine.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetMachine.h?rev=200269&r1=200268&r2=200269&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Target/TargetMachine.h (original)
+++ llvm/trunk/include/llvm/Target/TargetMachine.h Mon Jan 27 18:49:26 2014
@@ -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; }

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=200269&r1=200268&r2=200269&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon Jan 27 18:49:26 2014
@@ -176,6 +176,7 @@ DwarfDebug::DwarfDebug(AsmPrinter *A, Mo
     : 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 Mac
   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.

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=200269&r1=200268&r2=200269&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Mon Jan 27 18:49:26 2014
@@ -461,6 +461,10 @@ class DwarfDebug : public AsmPrinterHand
   // 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;
 

Modified: llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp?rev=200269&r1=200268&r2=200269&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp (original)
+++ llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp Mon Jan 27 18:49:26 2014
@@ -232,7 +232,7 @@ static const char *getSectionPrefixForGl
 
 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
       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 GlobalVal
 
 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 *getCOFFSectionNameFor
 
 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.

Modified: llvm/trunk/lib/Target/Hexagon/HexagonTargetObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonTargetObjectFile.cpp?rev=200269&r1=200268&r2=200269&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Hexagon/HexagonTargetObjectFile.cpp (original)
+++ llvm/trunk/lib/Target/Hexagon/HexagonTargetObjectFile.cpp Mon Jan 27 18:49:26 2014
@@ -87,7 +87,7 @@ IsGlobalInSmallSection(const GlobalValue
 
 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))

Modified: llvm/trunk/lib/Target/Hexagon/HexagonTargetObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonTargetObjectFile.h?rev=200269&r1=200268&r2=200269&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Hexagon/HexagonTargetObjectFile.h (original)
+++ llvm/trunk/lib/Target/Hexagon/HexagonTargetObjectFile.h Mon Jan 27 18:49:26 2014
@@ -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

Modified: llvm/trunk/lib/Target/Mips/MipsTargetObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsTargetObjectFile.cpp?rev=200269&r1=200268&r2=200269&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MipsTargetObjectFile.cpp (original)
+++ llvm/trunk/lib/Target/Mips/MipsTargetObjectFile.cpp Mon Jan 27 18:49:26 2014
@@ -103,7 +103,7 @@ IsGlobalInSmallSection(const GlobalValue
 
 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?
 

Modified: llvm/trunk/lib/Target/Mips/MipsTargetObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsTargetObjectFile.h?rev=200269&r1=200268&r2=200269&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MipsTargetObjectFile.h (original)
+++ llvm/trunk/lib/Target/Mips/MipsTargetObjectFile.h Mon Jan 27 18:49:26 2014
@@ -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; }

Modified: llvm/trunk/lib/Target/PowerPC/PPCTargetObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCTargetObjectFile.cpp?rev=200269&r1=200268&r2=200269&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCTargetObjectFile.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCTargetObjectFile.cpp Mon Jan 27 18:49:26 2014
@@ -24,7 +24,7 @@ Initialize(MCContext &Ctx, const TargetM
 
 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);

Modified: llvm/trunk/lib/Target/PowerPC/PPCTargetObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCTargetObjectFile.h?rev=200269&r1=200268&r2=200269&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCTargetObjectFile.h (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCTargetObjectFile.h Mon Jan 27 18:49:26 2014
@@ -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;

Modified: llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp?rev=200269&r1=200268&r2=200269&view=diff
==============================================================================
--- llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp (original)
+++ llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Mon Jan 27 18:49:26 2014
@@ -265,7 +265,7 @@ SectionKind TargetLoweringObjectFile::ge
 /// 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,
 
 
 // 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())

Modified: llvm/trunk/lib/Target/TargetMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetMachine.cpp?rev=200269&r1=200268&r2=200269&view=diff
==============================================================================
--- llvm/trunk/lib/Target/TargetMachine.cpp (original)
+++ llvm/trunk/lib/Target/TargetMachine.cpp Mon Jan 27 18:49:26 2014
@@ -55,7 +55,6 @@ TargetMachine::TargetMachine(const Targe
     MCUseLoc(true),
     MCUseCFI(true),
     MCUseDwarfDirectory(false),
-    DebugUseUniqueSections(false),
     RequireStructuredCFG(false),
     Options(Options) {
 }

Modified: llvm/trunk/lib/Target/XCore/XCoreTargetObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreTargetObjectFile.cpp?rev=200269&r1=200268&r2=200269&view=diff
==============================================================================
--- llvm/trunk/lib/Target/XCore/XCoreTargetObjectFile.cpp (original)
+++ llvm/trunk/lib/Target/XCore/XCoreTargetObjectFile.cpp Mon Jan 27 18:49:26 2014
@@ -130,7 +130,7 @@ getExplicitSectionGlobal(const GlobalVal
 
 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;

Modified: llvm/trunk/lib/Target/XCore/XCoreTargetObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreTargetObjectFile.h?rev=200269&r1=200268&r2=200269&view=diff
==============================================================================
--- llvm/trunk/lib/Target/XCore/XCoreTargetObjectFile.h (original)
+++ llvm/trunk/lib/Target/XCore/XCoreTargetObjectFile.h Mon Jan 27 18:49:26 2014
@@ -27,10 +27,9 @@ static const unsigned CodeModelLargeSize
     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;
   };





More information about the llvm-commits mailing list