diff options
author | Hans Wennborg <hans@hanshq.net> | 2016-09-30 20:07:35 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2016-09-30 20:07:35 +0000 |
commit | b5643b47b6d2c07b2fd30b077e5fac3a0753c2ff (patch) | |
tree | ee252dcaf37043c0c1cd4d6dc99381bf239811c4 /llvm/test/CodeGen/X86/conditional-tailcall.ll | |
parent | 2cd87a0cf2008d74de5c1ed5b061d57bdd527481 (diff) | |
download | bcm5719-llvm-b5643b47b6d2c07b2fd30b077e5fac3a0753c2ff.tar.gz bcm5719-llvm-b5643b47b6d2c07b2fd30b077e5fac3a0753c2ff.zip |
X86: Allow conditional tail calls in Win64 "leaf" functions (PR26302)
We can't use Jcc to leave a Win64 function in general, because that
confuses the unwinder. However, for "leaf" functions, that is, functions
where the return address is always on top of the stack and which don't
have unwind info, it's OK.
Differential Revision: https://reviews.llvm.org/D24836
llvm-svn: 282920
Diffstat (limited to 'llvm/test/CodeGen/X86/conditional-tailcall.ll')
-rw-r--r-- | llvm/test/CodeGen/X86/conditional-tailcall.ll | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/llvm/test/CodeGen/X86/conditional-tailcall.ll b/llvm/test/CodeGen/X86/conditional-tailcall.ll index 502643d9a91..331697c0515 100644 --- a/llvm/test/CodeGen/X86/conditional-tailcall.ll +++ b/llvm/test/CodeGen/X86/conditional-tailcall.ll @@ -1,5 +1,6 @@ -; RUN: llc < %s -mtriple=i686-linux -show-mc-encoding | FileCheck %s -; RUN: llc < %s -mtriple=x86_64-linux -show-mc-encoding | FileCheck %s +; RUN: llc < %s -mtriple=i686-linux -show-mc-encoding | FileCheck -check-prefix=CHECK %s +; RUN: llc < %s -mtriple=x86_64-linux -show-mc-encoding | FileCheck -check-prefix=CHECK %s +; RUN: llc < %s -mtriple=x86_64-win32 -show-mc-encoding | FileCheck -check-prefix=CHECK -check-prefix=WIN64 %s declare void @foo() declare void @bar() @@ -23,6 +24,28 @@ bb2: ; CHECK: jmp foo } +define void @f_non_leaf(i32 %x, i32 %y) optsize { +entry: + ; Force %ebx to be spilled on the stack, turning this into + ; not a "leaf" function for Win64. + tail call void asm sideeffect "", "~{ebx}"() + + %p = icmp eq i32 %x, %y + br i1 %p, label %bb1, label %bb2 +bb1: + tail call void @foo() + ret void +bb2: + tail call void @bar() + ret void + +; CHECK-LABEL: f_non_leaf: +; WIN64-NOT: je foo +; WIN64-NOT: jne bar +; WIN64: jne +; WIN64: jmp foo +; WIN64: jmp bar +} declare x86_thiscallcc zeroext i1 @baz(i8*, i32) define x86_thiscallcc zeroext i1 @BlockPlacementTest(i8* %this, i32 %x) optsize { |