Transforms: reapply SVN r219899
[oota-llvm.git] / test / Transforms / Inline / inlined-allocas.ll
1 ; RUN: opt -dse -inline -S %s | FileCheck %s
2
3 declare void @external(i32* byval)
4 declare i32 @identity(i32* byval)
5
6 ; An alloca in the inlinee should not force the tail to be stripped
7
8 define void @inlinee_with_alloca() {
9   %local = alloca i32
10   store i32 42, i32* %local, align 4
11   tail call void @external(i32* byval %local)
12   ret void
13 }
14
15 define void @inliner_without_alloca() {
16   tail call void @inlinee_with_alloca()
17   ret void
18 }
19
20 ; CHECK-LABEL: inliner_without_alloca
21 ; CHECK-NEXT: %local.i = alloca i32
22 ; CHECK: store i32 42, i32* %local.i
23 ; CHECK: tail call void @external
24 ; CHECK: ret
25
26 ; An alloca in the inliner should not force the tail to be stripped
27
28 define i32 @inliner_with_alloca() {
29   %local = alloca i32
30   store i32 42, i32* %local, align 4
31   %1 = tail call i32 @identity(i32* byval %local)
32   ret i32 %1
33 }
34
35 ; CHECK-LABEL: inliner_with_alloca
36 ; CHECK: %local = alloca i32
37 ; CHECK: store i32 42, i32* %local
38 ; CHECK: %1 = tail call i32 @identity
39 ; CHECK: ret i32 %1
40
41 ; Force the synthesis of the value through the byval parameter.
42 ; The alloca should force the tail to be stripped
43
44 define void @inlinee_with_passthru(i32* byval %value) {
45   tail call void @external(i32* byval %value)
46   ret void
47 }
48
49 define void @strip_tail(i32* %value) {
50   tail call void @inlinee_with_passthru(i32* %value)
51   ret void
52 }
53
54 ; CHECK-LABEL: strip_tail
55 ; CHECK: %value1 = alloca i32
56 ; CHECK: {{^ *}}call void @external
57 ; CHECK: ret void
58