Emit sections/directives in the proper order. This fixes PR1376. Also,
authorAnton Korobeynikov <asl@math.spbu.ru>
Sat, 5 May 2007 09:04:50 +0000 (09:04 +0000)
committerAnton Korobeynikov <asl@math.spbu.ru>
Sat, 5 May 2007 09:04:50 +0000 (09:04 +0000)
some small cleanup was made.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36780 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Target/TargetAsmInfo.h
lib/CodeGen/DwarfWriter.cpp
lib/Target/TargetAsmInfo.cpp
lib/Target/X86/X86ATTAsmPrinter.cpp
lib/Target/X86/X86AsmPrinter.cpp
lib/Target/X86/X86TargetAsmInfo.cpp

index 0a9047beec015ebd16dd1f9d0f18c81e7d8567a4..7e96c095da3047f2172c68c28e350538f2194e75 100644 (file)
@@ -282,8 +282,13 @@ namespace llvm {
     /// HasDotFile - True if target asm supports .file directives.
     ///
     bool HasDotFile; // Defaults to false.
-    
-    /// SupportsExceptionHandling - True if target supports exception handling.
+
+    /// SupportsDebugInformation - True if target supports emission of debugging
+    /// information.
+    bool SupportsDebugInformation;
+        
+    /// SupportsExceptionHandling - True if target supports
+    /// exception handling.
     ///
     bool SupportsExceptionHandling; // Defaults to false.
     
@@ -549,10 +554,13 @@ namespace llvm {
     bool hasDotFile() const {
       return HasDotFile;
     }
-    bool getSupportsExceptionHandling() const {
+    bool doesSupportDebugInformation() const {
+      return SupportsDebugInformation;
+    }
+    bool doesSupportExceptionHandling() const {
       return SupportsExceptionHandling;
     }
-    bool getDwarfRequiresFrameSection() const {
+    bool doesDwarfRequireFrameSection() const {
       return DwarfRequiresFrameSection;
     }
     const char *getDwarfSectionOffsetDirective() const {
index 55c2b0984900526cdc3fa98ce08a13d2292c160a..8b6edac307985e3de62e64e57fd63fc7c4f09765 100644 (file)
@@ -1955,7 +1955,7 @@ private:
     didInitial = true;
     
     // Dwarf sections base addresses.
-    if (TAI->getDwarfRequiresFrameSection()) {
+    if (TAI->doesDwarfRequireFrameSection()) {
       Asm->SwitchToDataSection(TAI->getDwarfFrameSection());
       EmitLabel("section_frame", 0);
     }
@@ -2324,7 +2324,7 @@ private:
   /// EmitInitialDebugFrame - Emit common frame info into a debug frame section.
   ///
   void EmitInitialDebugFrame() {
-    if (!TAI->getDwarfRequiresFrameSection())
+    if (!TAI->doesDwarfRequireFrameSection())
       return;
 
     int stackGrowth =
@@ -2367,7 +2367,7 @@ private:
   /// EmitFunctionDebugFrame - Emit per function frame info into a debug frame
   /// section.
   void EmitFunctionDebugFrame() {
-    if (!TAI->getDwarfRequiresFrameSection())
+    if (!TAI->doesDwarfRequireFrameSection())
       return;
        
     // Start the dwarf frame section.
@@ -3124,7 +3124,7 @@ public:
     
     if (MMI &&
         ExceptionHandling &&
-        TAI->getSupportsExceptionHandling()) {
+        TAI->doesSupportExceptionHandling()) {
       shouldEmit = true;
       // Assumes in correct section after the entry point.
       EmitLabel("eh_func_begin", ++SubprogramCount);
index 8f85366b78cced205ea8a0a293e0b53cfc560a4e..79186789ba0f0dbd29182e0ec28a35bd3aa4fbee 100644 (file)
@@ -80,6 +80,7 @@ TargetAsmInfo::TargetAsmInfo() :
   HasLEB128(false),
   HasDotLoc(false),
   HasDotFile(false),
+  SupportsDebugInformation(false),
   SupportsExceptionHandling(false),
   DwarfRequiresFrameSection(true),
   DwarfSectionOffsetDirective(0),
index 634f41b9200abfe51e6b1252d322a1e03dd69ffb..17de05300786b82abae51898907e96d993f08d2d 100755 (executable)
@@ -71,9 +71,7 @@ std::string X86ATTAsmPrinter::getSectionForFunction(const Function &F) const {
 /// method to print assembly for each instruction.
 ///
 bool X86ATTAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
-  if (Subtarget->isTargetDarwin() ||
-      Subtarget->isTargetELF() ||
-      Subtarget->isTargetCygMing()) {
+  if (TAI->doesSupportDebugInformation()) {
     // Let PassManager know we need debug information and relay
     // the MachineModuleInfo address on to DwarfWriter.
     DW.SetModuleInfo(&getAnalysis<MachineModuleInfo>());
@@ -150,9 +148,7 @@ bool X86ATTAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
        F->getLinkage() == Function::WeakLinkage))
     O << "Lllvm$workaround$fake$stub$" << CurrentFnName << ":\n";
 
-  if (Subtarget->isTargetDarwin() ||
-      Subtarget->isTargetELF() ||
-      Subtarget->isTargetCygMing()) {
+  if (TAI->doesSupportDebugInformation()) {
     // Emit pre-function debug information.
     DW.BeginFunction(&MF);
   }
@@ -173,22 +169,17 @@ bool X86ATTAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
     }
   }
 
-  // Print out jump tables referenced by the function.
-  
-  // Mac OS X requires that the jump table follow the function, so that the jump
-  // table is part of the same atom that the function is in.
-  EmitJumpTableInfo(MF.getJumpTableInfo(), MF);
-  
   if (TAI->hasDotTypeDotSizeDirective())
     O << "\t.size " << CurrentFnName << ", .-" << CurrentFnName << "\n";
 
-  if (Subtarget->isTargetDarwin() ||
-      Subtarget->isTargetELF() ||
-      Subtarget->isTargetCygMing()) {
+  if (TAI->doesSupportDebugInformation()) {
     // Emit post-function debug information.
     DW.EndFunction();
   }
 
+  // Print out jump tables referenced by the function.
+  EmitJumpTableInfo(MF.getJumpTableInfo(), MF);
+  
   // We didn't modify anything.
   return false;
 }
index 7e7dc8861a7c48206d41ebd03ea3a43a754f1906..3a5889d73167a87bc64bd7a04f750dfc33f7a677 100644 (file)
@@ -115,9 +115,7 @@ void X86SharedAsmPrinter::decorateName(std::string &Name,
 
 /// doInitialization
 bool X86SharedAsmPrinter::doInitialization(Module &M) {
-  if (Subtarget->isTargetELF() ||
-      Subtarget->isTargetCygMing() ||
-      Subtarget->isTargetDarwin()) {
+  if (TAI->doesSupportDebugInformation()) {
     // Emit initial debug information.
     DW.BeginModule(&M);
   }
index 67196b6f8fe46f96cd4864f60e53458dc73b1ba4..8734ecd677358be7de8b5f6eb79ab6bfb31b0afd 100644 (file)
@@ -81,7 +81,8 @@ X86TargetAsmInfo::X86TargetAsmInfo(const X86TargetMachine &TM) {
       // Emit a local label that is preserved until the linker runs.
       JumpTableSpecialLabelPrefix = "l";
     }
-    
+
+    SupportsDebugInformation = true;
     NeedsSet = true;
     DwarfAbbrevSection = ".section __DWARF,__debug_abbrev,regular,debug";
     DwarfInfoSection = ".section __DWARF,__debug_info,regular,debug";
@@ -97,26 +98,21 @@ X86TargetAsmInfo::X86TargetAsmInfo(const X86TargetMachine &TM) {
     break;
 
   case X86Subtarget::isELF:
-    // Set up DWARF directives
-    HasLEB128 = true;  // Target asm supports leb128 directives (little-endian)
-    AbsoluteDebugSectionOffsets = true;
-    AbsoluteEHSectionOffsets = false;
-    // bool HasLEB128; // Defaults to false.
-    // hasDotLoc - True if target asm supports .loc directives.
-    // bool HasDotLoc; // Defaults to false.
-    // HasDotFile - True if target asm supports .file directives.
-    // bool HasDotFile; // Defaults to false.
     ReadOnlySection = "\t.section\t.rodata\n";
     FourByteConstantSection = "\t.section\t.rodata.cst4,\"aM\",@progbits,4";
     EightByteConstantSection = "\t.section\t.rodata.cst8,\"aM\",@progbits,8";
-    SixteenByteConstantSection =
-                             "\t.section\t.rodata.cst16,\"aM\",@progbits,16";
+    SixteenByteConstantSection = "\t.section\t.rodata.cst16,\"aM\",@progbits,16";
     CStringSection = "\t.section\t.rodata.str1.1,\"aMS\",@progbits,1";
     PrivateGlobalPrefix = ".L";
     WeakRefDirective = "\t.weak\t";
     SetDirective = "\t.set\t";
     PCSymbol = ".";
-    
+
+    // Set up DWARF directives
+    HasLEB128 = true;  // Target asm supports leb128 directives (little-endian)
+    AbsoluteDebugSectionOffsets = true;
+    AbsoluteEHSectionOffsets = false;
+    SupportsDebugInformation = true;
     DwarfRequiresFrameSection = false;
     DwarfAbbrevSection =  "\t.section\t.debug_abbrev,\"\",@progbits";
     DwarfInfoSection =    "\t.section\t.debug_info,\"\",@progbits";
@@ -144,14 +140,15 @@ X86TargetAsmInfo::X86TargetAsmInfo(const X86TargetMachine &TM) {
     StaticCtorsSection = "\t.section .ctors,\"aw\"";
     StaticDtorsSection = "\t.section .dtors,\"aw\"";
     HiddenDirective = NULL;
+    PrivateGlobalPrefix = "L";  // Prefix for private global symbols
+    WeakRefDirective = "\t.weak\t";
+    SetDirective = "\t.set\t";
 
     // Set up DWARF directives
     HasLEB128 = true;  // Target asm supports leb128 directives (little-endian)
     AbsoluteDebugSectionOffsets = true;
     AbsoluteEHSectionOffsets = false;
-    PrivateGlobalPrefix = "L";  // Prefix for private global symbols
-    WeakRefDirective = "\t.weak\t";
-    SetDirective = "\t.set\t";
+    SupportsDebugInformation = true;
     DwarfRequiresFrameSection = false;
     DwarfSectionOffsetDirective = "\t.secrel32\t";
     DwarfAbbrevSection =  "\t.section\t.debug_abbrev,\"dr\"";