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@GOTOFF ; LINUX: .long .LBB7_8@GOTOFF -; LINUX: .long .LBB7_14@GOTOFF -; LINUX: .long .LBB7_9@GOTOFF -; LINUX: .long .LBB7_10@GOTOFF +; LINUX: .long .LBB7_4@GOTOFF +; LINUX: .long .LBB7_6@GOTOFF +; LINUX: .long .LBB7_5@GOTOFF +; LINUX: .long .LBB7_8@GOTOFF +; LINUX: .long .LBB7_7@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,8 +5,7 @@ define double @test1(double %x) nounwind readnone { ; CHECK-LABEL: test1: -; CHECK: movl foo@GOT -; CHECK-NEXT: jmpl +; CHECK: calll foo@PLT %1 = tail call double @foo(double %x) nounwind readnone ret double %1 } @@ -15,8 +14,7 @@ define double @test2(double %x) nounwind readnone { ; CHECK-LABEL: test2: -; CHECK: movl sin@GOT -; CHECK-NEXT: jmpl +; CHECK: calll sin@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 ) ; [#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 ) ; [#uses=1] ret i32 %tmp11 -; CHECK: movl tailcallee@GOT -; CHECK: jmpl +; CHECK: calll tailcallee@PLT }