Disable x86 tail call optimizations that jump through GOT
For x86 targets, do not do sibling call optimization when materializing
the callee's address would require a GOT relocation. We can still do
tail calls to internal functions, hidden functions, and protected
functions, because they do not require this kind of relocation. It is
still possible to get GOT relocations when the user explicitly asks for
it with musttail or -tailcallopt, both of which are supposed to
guarantee TCO.
Based on a patch by Chih-hung Hsieh.
Reviewers: srhines, timmurray, danalbert, enh, void, nadav, rnk
Subscribers: joerg, davidxl, llvm-commits
Differential Revision: http://reviews.llvm.org/D9799
llvm-svn: 238487
2015-05-29 04:44:28 +08:00
|
|
|
; RUN: llc < %s -mtriple=i686-pc-linux-gnu -relocation-model=pic | FileCheck %s
|
|
|
|
|
|
|
|
; While many of these could be tail called, we don't do it because it forces
|
|
|
|
; early binding.
|
|
|
|
|
|
|
|
declare void @external()
|
|
|
|
|
|
|
|
define hidden void @tailcallee_hidden() {
|
|
|
|
entry:
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @tailcall_hidden() {
|
|
|
|
entry:
|
|
|
|
tail call void @tailcallee_hidden()
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
; CHECK: tailcall_hidden:
|
2020-08-14 06:58:40 +08:00
|
|
|
; CHECK: jmp tailcallee_hidden
|
Disable x86 tail call optimizations that jump through GOT
For x86 targets, do not do sibling call optimization when materializing
the callee's address would require a GOT relocation. We can still do
tail calls to internal functions, hidden functions, and protected
functions, because they do not require this kind of relocation. It is
still possible to get GOT relocations when the user explicitly asks for
it with musttail or -tailcallopt, both of which are supposed to
guarantee TCO.
Based on a patch by Chih-hung Hsieh.
Reviewers: srhines, timmurray, danalbert, enh, void, nadav, rnk
Subscribers: joerg, davidxl, llvm-commits
Differential Revision: http://reviews.llvm.org/D9799
llvm-svn: 238487
2015-05-29 04:44:28 +08:00
|
|
|
|
|
|
|
define internal void @tailcallee_internal() {
|
|
|
|
entry:
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @tailcall_internal() {
|
|
|
|
entry:
|
|
|
|
tail call void @tailcallee_internal()
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
; CHECK: tailcall_internal:
|
|
|
|
; CHECK: jmp tailcallee_internal
|
|
|
|
|
|
|
|
define default void @tailcallee_default() {
|
|
|
|
entry:
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @tailcall_default() {
|
|
|
|
entry:
|
|
|
|
tail call void @tailcallee_default()
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
; CHECK: tailcall_default:
|
|
|
|
; CHECK: calll tailcallee_default@PLT
|
|
|
|
|
|
|
|
define void @tailcallee_default_implicit() {
|
|
|
|
entry:
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @tailcall_default_implicit() {
|
|
|
|
entry:
|
|
|
|
tail call void @tailcallee_default_implicit()
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
; CHECK: tailcall_default_implicit:
|
|
|
|
; CHECK: calll tailcallee_default_implicit@PLT
|
|
|
|
|
|
|
|
define void @tailcall_external() {
|
|
|
|
tail call void @external()
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
; CHECK: tailcall_external:
|
|
|
|
; CHECK: calll external@PLT
|
|
|
|
|
|
|
|
define void @musttail_external() {
|
|
|
|
musttail call void @external()
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
; CHECK: musttail_external:
|
|
|
|
; CHECK: movl external@GOT
|
|
|
|
; CHECK: jmpl
|