- Emit subsections_via_symbols for Darwin.
- 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
diff --git a/lib/Target/X86/X86AsmPrinter.cpp b/lib/Target/X86/X86AsmPrinter.cpp
index edc2397..a5e7008 100644
--- a/lib/Target/X86/X86AsmPrinter.cpp
+++ b/lib/Target/X86/X86AsmPrinter.cpp
@@ -75,8 +75,10 @@
   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 @@
       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