[PATCH] Disable x86 tail call optimization under PIC mode
Chih-Hung Hsieh
chh at google.com
Fri May 22 17:02:39 PDT 2015
Keep IsMustTail working as before.
http://reviews.llvm.org/D9799
Files:
lib/Target/X86/X86ISelLowering.cpp
test/CodeGen/X86/pic.ll
test/CodeGen/X86/tail-call-got.ll
test/CodeGen/X86/tailcallpic1.ll
test/CodeGen/X86/tailcallpic2.ll
Index: lib/Target/X86/X86ISelLowering.cpp
===================================================================
--- lib/Target/X86/X86ISelLowering.cpp
+++ lib/Target/X86/X86ISelLowering.cpp
@@ -2752,11 +2752,15 @@
if (MF.getTarget().Options.DisableTailCalls)
isTailCall = false;
+ // Cannot jump to address through GOT, see https://llvm.org/bugs/show_bug.cgi?id=15086
+ if (Subtarget->isPICStyleGOT())
+ isTailCall = false;
+
bool IsMustTail = CLI.CS && CLI.CS->isMustTailCall();
if (IsMustTail) {
// Force this to be a tail call. The verifier rules are enough to ensure
// that we can lower this successfully without moving the return address
- // around.
+ // around. User should be aware of lazy dynamic linking issue in bug 15086.
isTailCall = true;
} else if (isTailCall) {
// Check if it's really possible to do a tail call.
Index: test/CodeGen/X86/pic.ll
===================================================================
--- test/CodeGen/X86/pic.ll
+++ test/CodeGen/X86/pic.ll
@@ -196,9 +196,11 @@
; LINUX-NEXT: .LJTI7_0:
; LINUX: .long .LBB7_2 at GOTOFF
; LINUX: .long .LBB7_8 at GOTOFF
-; LINUX: .long .LBB7_14 at GOTOFF
-; LINUX: .long .LBB7_9 at GOTOFF
-; LINUX: .long .LBB7_10 at GOTOFF
+; LINUX: .long .LBB7_4 at GOTOFF
+; LINUX: .long .LBB7_6 at GOTOFF
+; LINUX: .long .LBB7_5 at GOTOFF
+; LINUX: .long .LBB7_8 at GOTOFF
+; LINUX: .long .LBB7_7 at GOTOFF
}
declare void @foo1(...)
Index: test/CodeGen/X86/tail-call-got.ll
===================================================================
--- test/CodeGen/X86/tail-call-got.ll
+++ test/CodeGen/X86/tail-call-got.ll
@@ -5,18 +5,16 @@
define double @test1(double %x) nounwind readnone {
; CHECK-LABEL: test1:
-; CHECK: movl foo at GOT
-; CHECK-NEXT: jmpl
+; CHECK: calll foo at PLT
%1 = tail call double @foo(double %x) nounwind readnone
ret double %1
}
declare double @foo(double) readnone
define double @test2(double %x) nounwind readnone {
; CHECK-LABEL: test2:
-; CHECK: movl sin at GOT
-; CHECK-NEXT: jmpl
+; CHECK: calll sin at PLT
%1 = tail call double @sin(double %x) nounwind readnone
ret double %1
}
Index: test/CodeGen/X86/tailcallpic1.ll
===================================================================
--- test/CodeGen/X86/tailcallpic1.ll
+++ test/CodeGen/X86/tailcallpic1.ll
@@ -9,5 +9,5 @@
entry:
%tmp11 = tail call fastcc i32 @tailcallee( i32 %in1, i32 %in2, i32 %in1, i32 %in2 ) ; <i32> [#uses=1]
ret i32 %tmp11
-; CHECK: jmp tailcallee
+; CHECK: calll tailcallee
}
Index: test/CodeGen/X86/tailcallpic2.ll
===================================================================
--- test/CodeGen/X86/tailcallpic2.ll
+++ test/CodeGen/X86/tailcallpic2.ll
@@ -9,7 +9,6 @@
entry:
%tmp11 = tail call fastcc i32 @tailcallee( i32 %in1, i32 %in2, i32 %in1, i32 %in2 ) ; <i32> [#uses=1]
ret i32 %tmp11
-; CHECK: movl tailcallee at GOT
-; CHECK: jmpl
+; CHECK: calll tailcallee at PLT
}
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9799.26363.patch
Type: text/x-patch
Size: 2938 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150523/bcdd027c/attachment.bin>
More information about the llvm-commits
mailing list