- Emit subsections_via_symbols for Darwin.
authorEvan Cheng <evan.cheng@apple.com>
Tue, 7 Mar 2006 02:23:26 +0000 (02:23 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Tue, 7 Mar 2006 02:23:26 +0000 (02:23 +0000)
- Conditionalize Dwarf debugging output (Darwin only for now).

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

lib/Target/X86/X86ATTAsmPrinter.cpp
lib/Target/X86/X86AsmPrinter.cpp
lib/Target/X86/X86AsmPrinter.h
lib/Target/X86/X86IntelAsmPrinter.cpp

index e50100e7528ad7f79ff71150076e793386c517e2..f1b53fd7ea334fe9f0624a411514ff6f1a3771d0 100755 (executable)
@@ -27,15 +27,19 @@ using namespace x86;
 /// method to print assembly for each instruction.
 ///
 bool X86ATTAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
-  // Let PassManager know we need debug information and relay
-  // the MachineDebugInfo address on to DwarfWriter.
-  DW.SetDebugInfo(&getAnalysis<MachineDebugInfo>());
+  //  if (forDarwin) {
+    // Let PassManager know we need debug information and relay
+    // the MachineDebugInfo address on to DwarfWriter.
+    DW.SetDebugInfo(&getAnalysis<MachineDebugInfo>());
+    //  }
 
   SetupMachineFunction(MF);
   O << "\n\n";
 
-  // Emit pre-function debug information.
-  DW.BeginFunction(MF);
+  if (forDarwin) {
+    // Emit pre-function debug information.
+    DW.BeginFunction(MF);
+  }
 
   // Print out constants referenced by the function
   EmitConstantPool(MF.getConstantPool());
@@ -88,8 +92,10 @@ bool X86ATTAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
   if (HasDotTypeDotSizeDirective)
     O << "\t.size " << CurrentFnName << ", .-" << CurrentFnName << "\n";
 
-  // Emit post-function debug information.
-  DW.EndFunction(MF);
+  if (forDarwin) {
+    // Emit post-function debug information.
+    DW.EndFunction(MF);
+  }
 
   // We didn't modify anything.
   return false;
index edc2397e604ad3e57223f033cd79a9aa01095bd7..a5e7008bc0be3d39e02b9f3f9c57ddef0a4b6d1c 100644 (file)
@@ -75,8 +75,10 @@ bool X86SharedAsmPrinter::doInitialization(Module &M) {
   default: break;
   }
   
-  // Emit initial debug information.
-  DW.BeginModule(M);
+  if (forDarwin) {
+    // Emit initial debug information.
+    DW.BeginModule(M);
+  }
 
   return AsmPrinter::doInitialization(M);
 }
@@ -188,10 +190,17 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) {
       O << "\t.indirect_symbol " << *i << "\n";
       O << "\t.long\t0\n";
     }
-  }
 
-  // Emit initial debug information.
-  DW.EndModule(M);
+    // Emit initial debug information.
+    DW.EndModule(M);
+
+    // Funny Darwin hack: This flag tells the linker that no global symbols
+    // contain code that falls through to other global symbols (e.g. the obvious
+    // implementation of multiple entry points).  If this doesn't occur, the
+    // linker can safely perform dead code stripping.  Since LLVM never generates
+    // code that does this, it is always safe to set.
+    O << "\t.subsections_via_symbols\n";
+  }
 
   AsmPrinter::doFinalization(M);
   return false; // success
index 5b27c564577bc382067a628b75c0e0d79f43f74c..ed0fdbed27dbffb01b41a6a54a177bbd07f2f296 100755 (executable)
@@ -68,7 +68,7 @@ struct X86SharedAsmPrinter : public AsmPrinter {
     MachineFunctionPass::getAnalysisUsage(AU);
   }
 
-    bool forDarwin;  // FIXME: eliminate.
+  bool forDarwin;  // FIXME: eliminate.
 
   // Necessary for Darwin to print out the apprioriate types of linker stubs
   std::set<std::string> FnStubs, GVStubs, LinkOnceStubs;
index 5bc8b243723cd08e0a7be1220dc4c0f647ebd111..a04dfca854594cfddf9525ac7a804fb4895031bf 100755 (executable)
@@ -26,15 +26,19 @@ using namespace x86;
 /// method to print assembly for each instruction.
 ///
 bool X86IntelAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
-  // Let PassManager know we need debug information and relay
-  // the MachineDebugInfo address on to DwarfWriter.
-  DW.SetDebugInfo(&getAnalysis<MachineDebugInfo>());
+  if (forDarwin) {
+    // Let PassManager know we need debug information and relay
+    // the MachineDebugInfo address on to DwarfWriter.
+    DW.SetDebugInfo(&getAnalysis<MachineDebugInfo>());
+  }
 
   SetupMachineFunction(MF);
   O << "\n\n";
 
-  // Emit pre-function debug information.
-  DW.BeginFunction(MF);
+  if (forDarwin) {
+    // Emit pre-function debug information.
+    DW.BeginFunction(MF);
+  }
 
   // Print out constants referenced by the function
   EmitConstantPool(MF.getConstantPool());
@@ -63,8 +67,10 @@ bool X86IntelAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
     }
   }
 
-  // Emit post-function debug information.
-  DW.EndFunction(MF);
+  if (forDarwin) {
+    // Emit post-function debug information.
+    DW.EndFunction(MF);
+  }
 
   // We didn't modify anything.
   return false;