diff options
| author | Fedor Indutny <fedor@indutny.com> | 2018-03-03 21:40:14 +0000 |
|---|---|---|
| committer | Fedor Indutny <fedor@indutny.com> | 2018-03-03 21:40:14 +0000 |
| commit | f9e09c1dd06c3d277b16ce9e3e06c6882bc26efd (patch) | |
| tree | 716ac15c418e9faa39be264daae0cb5eb11e3878 /llvm/test/Transforms | |
| parent | 1a3901c69fdd34ad979e6c1e65dfd05fe3c34826 (diff) | |
| download | bcm5719-llvm-f9e09c1dd06c3d277b16ce9e3e06c6882bc26efd.tar.gz bcm5719-llvm-f9e09c1dd06c3d277b16ce9e3e06c6882bc26efd.zip | |
[CallSiteSplitting] properly split musttail calls
Summary:
`musttail` calls can't be naively splitted. The split blocks must
include not only the call instruction itself, but also (optional)
`bitcast` and `return` instructions that follow it.
Clone `bitcast` and `ret`, place them into the split blocks, and
remove the tail block when done.
Reviewers: junbuml, mcrosier, davidxl, davide, fhahn
Reviewed By: fhahn
Subscribers: JDevlieghere, llvm-commits
Differential Revision: https://reviews.llvm.org/D43729
llvm-svn: 326666
Diffstat (limited to 'llvm/test/Transforms')
| -rw-r--r-- | llvm/test/Transforms/CallSiteSplitting/musttail.ll | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/llvm/test/Transforms/CallSiteSplitting/musttail.ll b/llvm/test/Transforms/CallSiteSplitting/musttail.ll new file mode 100644 index 00000000000..faa352dd5bf --- /dev/null +++ b/llvm/test/Transforms/CallSiteSplitting/musttail.ll @@ -0,0 +1,75 @@ +; RUN: opt < %s -callsite-splitting -S | FileCheck %s + +;CHECK-LABEL: @caller +;CHECK-LABEL: Top.split: +;CHECK: %ca1 = musttail call i8* @callee(i8* null, i8* %b) +;CHECK: %cb2 = bitcast i8* %ca1 to i8* +;CHECK: ret i8* %cb2 +;CHECK-LABEL: TBB.split +;CHECK: %ca3 = musttail call i8* @callee(i8* nonnull %a, i8* null) +;CHECK: %cb4 = bitcast i8* %ca3 to i8* +;CHECK: ret i8* %cb4 +define i8* @caller(i8* %a, i8* %b) { +Top: + %c = icmp eq i8* %a, null + br i1 %c, label %Tail, label %TBB +TBB: + %c2 = icmp eq i8* %b, null + br i1 %c2, label %Tail, label %End +Tail: + %ca = musttail call i8* @callee(i8* %a, i8* %b) + %cb = bitcast i8* %ca to i8* + ret i8* %cb +End: + ret i8* null +} + +define i8* @callee(i8* %a, i8* %b) noinline { + ret i8* %a +} + +;CHECK-LABEL: @no_cast_caller +;CHECK-LABEL: Top.split: +;CHECK: %ca1 = musttail call i8* @callee(i8* null, i8* %b) +;CHECK: ret i8* %ca1 +;CHECK-LABEL: TBB.split +;CHECK: %ca2 = musttail call i8* @callee(i8* nonnull %a, i8* null) +;CHECK: ret i8* %ca2 +define i8* @no_cast_caller(i8* %a, i8* %b) { +Top: + %c = icmp eq i8* %a, null + br i1 %c, label %Tail, label %TBB +TBB: + %c2 = icmp eq i8* %b, null + br i1 %c2, label %Tail, label %End +Tail: + %ca = musttail call i8* @callee(i8* %a, i8* %b) + ret i8* %ca +End: + ret i8* null +} + +;CHECK-LABEL: @void_caller +;CHECK-LABEL: Top.split: +;CHECK: musttail call void @void_callee(i8* null, i8* %b) +;CHECK: ret void +;CHECK-LABEL: TBB.split +;CHECK: musttail call void @void_callee(i8* nonnull %a, i8* null) +;CHECK: ret void +define void @void_caller(i8* %a, i8* %b) { +Top: + %c = icmp eq i8* %a, null + br i1 %c, label %Tail, label %TBB +TBB: + %c2 = icmp eq i8* %b, null + br i1 %c2, label %Tail, label %End +Tail: + musttail call void @void_callee(i8* %a, i8* %b) + ret void +End: + ret void +} + +define void @void_callee(i8* %a, i8* %b) noinline { + ret void +} |

