diff options
author | Bill Wendling <isanbard@gmail.com> | 2013-11-21 07:05:41 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2013-11-21 07:05:41 +0000 |
commit | 8ae03404a3a38e34474d29f20bf5cd6b7088ada8 (patch) | |
tree | b3996260c849cd4bd838580c871ef32621e73bd8 /test | |
parent | 3099edd7304fb1b7e1a3a72bcfb466dbeb5b72fd (diff) | |
download | external_llvm-8ae03404a3a38e34474d29f20bf5cd6b7088ada8.zip external_llvm-8ae03404a3a38e34474d29f20bf5cd6b7088ada8.tar.gz external_llvm-8ae03404a3a38e34474d29f20bf5cd6b7088ada8.tar.bz2 |
Merging r195318:
------------------------------------------------------------------------
r195318 | void | 2013-11-20 23:04:30 -0800 (Wed, 20 Nov 2013) | 29 lines
The basic problem is that some mainstream programs cannot deal with the way
clang optimizes tail calls, as in this example:
int foo(void);
int bar(void) {
return foo();
}
where the call is transformed to:
calll .L0$pb
.L0$pb:
popl %eax
.Ltmp0:
addl $_GLOBAL_OFFSET_TABLE_+(.Ltmp0-.L0$pb), %eax
movl foo@GOT(%eax), %eax
popl %ebp
jmpl *%eax # TAILCALL
However, the GOT references must all be resolved at dlopen() time, and so this
approach cannot be used with lazy dynamic linking (e.g. using RTLD_LAZY), which
usually populates the PLT with stubs that perform the actual resolving.
This patch changes X86TargetLowering::LowerCall() to skip tail call
optimization, if the called function is a global or external symbol.
Patch by Dimitry Andric!
PR15086
------------------------------------------------------------------------
git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_34@195319 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r-- | test/CodeGen/X86/tail-call-got.ll | 6 | ||||
-rw-r--r-- | test/CodeGen/X86/tailcallpic2.ll | 4 |
2 files changed, 4 insertions, 6 deletions
diff --git a/test/CodeGen/X86/tail-call-got.ll b/test/CodeGen/X86/tail-call-got.ll index 84d561d..bdfdeb5 100644 --- a/test/CodeGen/X86/tail-call-got.ll +++ b/test/CodeGen/X86/tail-call-got.ll @@ -5,8 +5,7 @@ target triple = "i386-unknown-freebsd9.0" 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 @@ declare double @foo(double) readnone 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 } diff --git a/test/CodeGen/X86/tailcallpic2.ll b/test/CodeGen/X86/tailcallpic2.ll index 1b6bdb7..c35cee3 100644 --- a/test/CodeGen/X86/tailcallpic2.ll +++ b/test/CodeGen/X86/tailcallpic2.ll @@ -9,7 +9,7 @@ define fastcc i32 @tailcaller(i32 %in1, i32 %in2) { entry: %tmp11 = tail call fastcc i32 @tailcallee( i32 %in1, i32 %in2, i32 %in1, i32 %in2 ) ; <i32> [#uses=1] ret i32 %tmp11 -; CHECK: movl tailcallee@GOT -; CHECK: jmpl +; Note that this call via PLT could be further optimized into a direct call (no GOT, no PLT): +; CHECK: calll tailcallee@PLT } |