[llvm-commits] [llvm] r56378 - in /llvm/trunk: lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp test/CodeGen/X86/darwin-stub.ll

Evan Cheng evan.cheng at apple.com
Fri Sep 19 17:13:45 PDT 2008


Author: evancheng
Date: Fri Sep 19 19:13:45 2008
New Revision: 56378

URL: http://llvm.org/viewvc/llvm-project?rev=56378&view=rev
Log:
No need to print function stubs for Mac OS X 10.5 and up. Linker will handle it.

Added:
    llvm/trunk/test/CodeGen/X86/darwin-stub.ll
Modified:
    llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp

Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp?rev=56378&r1=56377&r2=56378&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Fri Sep 19 19:13:45 2008
@@ -392,8 +392,13 @@
       if (GV->isDeclaration() || GV->isWeakForLinker()) {
         // Dynamically-resolved functions need a stub for the function.
         if (isCallOp && isa<Function>(GV)) {
-          FnStubs.insert(Name);
-          printSuffixedName(Name, "$stub");
+          // Function stubs are no longer needed for Mac OS X 10.5 and up.
+          if (Subtarget->isTargetDarwin() && Subtarget->getDarwinVers() >= 9) {
+            O << Name;
+          } else {
+            FnStubs.insert(Name);
+            printSuffixedName(Name, "$stub");
+          }
         } else {
           GVStubs.insert(Name);
           printSuffixedName(Name, "$non_lazy_ptr");
@@ -475,7 +480,9 @@
     bool needCloseParen = false;
     std::string Name(TAI->getGlobalPrefix());
     Name += MO.getSymbolName();
-    if (isCallOp && shouldPrintStub(TM, Subtarget)) {
+    // Print function stub suffix unless it's Mac OS X 10.5 and up.
+    if (isCallOp && shouldPrintStub(TM, Subtarget) && 
+        !(Subtarget->isTargetDarwin() && Subtarget->getDarwinVers() >= 9)) {
       FnStubs.insert(Name);
       printSuffixedName(Name, "$stub");
       return;

Added: llvm/trunk/test/CodeGen/X86/darwin-stub.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/darwin-stub.ll?rev=56378&view=auto

==============================================================================
--- llvm/trunk/test/CodeGen/X86/darwin-stub.ll (added)
+++ llvm/trunk/test/CodeGen/X86/darwin-stub.ll Fri Sep 19 19:13:45 2008
@@ -0,0 +1,12 @@
+; RUN: llvm-as < %s | llc -mtriple=i386-apple-darwin  |     grep stub
+; RUN: llvm-as < %s | llc -mtriple=i386-apple-darwin9 | not grep stub
+
+@"\01LC" = internal constant [13 x i8] c"Hello World!\00"		; <[13 x i8]*> [#uses=1]
+
+define i32 @main() nounwind {
+entry:
+	%0 = tail call i32 @puts(i8* getelementptr ([13 x i8]* @"\01LC", i32 0, i32 0)) nounwind		; <i32> [#uses=0]
+	ret i32 0
+}
+
+declare i32 @puts(i8*)





More information about the llvm-commits mailing list