1; RUN: opt -S < %s -inline -argpromotion | FileCheck %s
2; RUN: opt -S < %s -passes=inline,argpromotion | FileCheck %s
3
4%S = type { %S* }
5
6; Inlining should nuke the invoke (and any inlined calls) here even with
7; argument promotion running along with it.
8define void @zot() personality i32 (...)* @wibble {
9; CHECK-LABEL: define void @zot() personality i32 (...)* @wibble
10; CHECK-NOT: call
11; CHECK-NOT: invoke
12bb:
13  invoke void @hoge()
14          to label %bb1 unwind label %bb2
15
16bb1:
17  unreachable
18
19bb2:
20  %tmp = landingpad { i8*, i32 }
21          cleanup
22  unreachable
23}
24
25define internal void @hoge() {
26bb:
27  %tmp = call fastcc i8* @spam(i1 (i8*)* @eggs)
28  %tmp1 = call fastcc i8* @spam(i1 (i8*)* @barney)
29  unreachable
30}
31
32define internal fastcc i8* @spam(i1 (i8*)* %arg) {
33bb:
34  unreachable
35}
36
37define internal i1 @eggs(i8* %arg) {
38bb:
39  %tmp = call zeroext i1 @barney(i8* %arg)
40  unreachable
41}
42
43define internal i1 @barney(i8* %arg) {
44bb:
45  ret i1 undef
46}
47
48define i32 @test_inf_promote_caller(i32 %arg) {
49; CHECK-LABEL: define i32 @test_inf_promote_caller(
50bb:
51  %tmp = alloca %S
52  %tmp1 = alloca %S
53  %tmp2 = call i32 @test_inf_promote_callee(%S* %tmp, %S* %tmp1)
54; CHECK: call i32 @test_inf_promote_callee(%S* %{{.*}}, %S* %{{.*}})
55
56  ret i32 0
57}
58
59define internal i32 @test_inf_promote_callee(%S* %arg, %S* %arg1) {
60; CHECK-LABEL: define internal i32 @test_inf_promote_callee(
61; CHECK: %S* %{{.*}}, %S* %{{.*}})
62bb:
63  %tmp = getelementptr %S, %S* %arg1, i32 0, i32 0
64  %tmp2 = load %S*, %S** %tmp
65  %tmp3 = getelementptr %S, %S* %arg, i32 0, i32 0
66  %tmp4 = load %S*, %S** %tmp3
67  %tmp5 = call i32 @test_inf_promote_callee(%S* %tmp4, %S* %tmp2)
68; CHECK: call i32 @test_inf_promote_callee(%S* %{{.*}}, %S* %{{.*}})
69
70  ret i32 0
71}
72
73declare i32 @wibble(...)
74