1 ; RUN: opt -passes=inline < %s -S -o - -inline-threshold=8 | FileCheck %s
2 ; RUN: opt -passes='cgscc(inline)' < %s -S -o - -inline-threshold=8 | FileCheck %s
4 target datalayout = "p:32:32"
6 declare void @llvm.lifetime.start.p0(i64 %size, ptr nocapture %ptr)
8 @glbl = external global i32
10 define void @outer1() {
11 ; CHECK-LABEL: @outer1(
12 ; CHECK-NOT: call void @inner1
14 call void @inner1(ptr %ptr)
18 define void @inner1(ptr %ptr) {
19 %A = load i32, ptr %ptr
21 %D = getelementptr inbounds i32, ptr %ptr, i32 1
22 %F = select i1 false, ptr %ptr, ptr @glbl
23 call void @llvm.lifetime.start.p0(i64 0, ptr %ptr)
28 define void @outer2() {
29 ; CHECK-LABEL: @outer2(
30 ; CHECK: call void @inner2
32 call void @inner2(ptr %ptr)
36 ; %D poisons this call, scalar-repl can't handle that instruction.
37 define void @inner2(ptr %ptr) {
38 %A = load i32, ptr %ptr
40 %D = getelementptr inbounds i32, ptr %ptr, i32 %A
41 %F = select i1 false, ptr %ptr, ptr @glbl
42 call void @llvm.lifetime.start.p0(i64 0, ptr %ptr)
47 define void @outer3() {
48 ; CHECK-LABEL: @outer3(
49 ; CHECK-NOT: call void @inner3
51 call void @inner3(ptr %ptr, i1 undef)
55 define void @inner3(ptr %ptr, i1 %x) {
56 %A = icmp eq ptr %ptr, null
59 br i1 %A, label %bb.true, label %bb.false
61 ; This block musn't be counted in the inline cost.
62 %t1 = load i32, ptr %ptr
72 %t11 = add i32 %t10, 1
73 %t12 = add i32 %t11, 1
74 %t13 = add i32 %t12, 1
75 %t14 = add i32 %t13, 1
76 %t15 = add i32 %t14, 1
77 %t16 = add i32 %t15, 1
78 %t17 = add i32 %t16, 1
79 %t18 = add i32 %t17, 1
80 %t19 = add i32 %t18, 1
81 %t20 = add i32 %t19, 1
87 define void @outer4(i32 %A) {
88 ; CHECK-LABEL: @outer4(
89 ; CHECK-NOT: call void @inner4
91 call void @inner4(ptr %ptr, i32 %A)
95 ; %B poisons this call, scalar-repl can't handle that instruction. However, we
96 ; still want to detect that the icmp and branch *can* be handled.
97 define void @inner4(ptr %ptr, i32 %A) {
98 %B = getelementptr inbounds i32, ptr %ptr, i32 %A
99 %C = icmp eq ptr %ptr, null
101 br i1 %C, label %bb.true, label %bb.false
103 ; This block musn't be counted in the inline cost.
104 %t1 = load i32, ptr %ptr
113 %t10 = add i32 %t9, 1
114 %t11 = add i32 %t10, 1
115 %t12 = add i32 %t11, 1
116 %t13 = add i32 %t12, 1
117 %t14 = add i32 %t13, 1
118 %t15 = add i32 %t14, 1
119 %t16 = add i32 %t15, 1
120 %t17 = add i32 %t16, 1
121 %t18 = add i32 %t17, 1
122 %t19 = add i32 %t18, 1
123 %t20 = add i32 %t19, 1
129 define void @outer5() {
130 ; CHECK-LABEL: @outer5(
131 ; CHECK-NOT: call void @inner5
133 call void @inner5(i1 false, ptr %ptr)
137 ; %D poisons this call, scalar-repl can't handle that instruction. However, if
138 ; the flag is set appropriately, the poisoning instruction is inside of dead
139 ; code, and so shouldn't be counted.
140 define void @inner5(i1 %flag, ptr %ptr) {
141 %A = load i32, ptr %ptr
142 store i32 0, ptr %ptr
144 br i1 %flag, label %if.then, label %exit
147 %D = getelementptr inbounds i32, ptr %ptr, i32 %A
148 %F = select i1 false, ptr %ptr, ptr @glbl
149 call void @llvm.lifetime.start.p0(i64 0, ptr %ptr)
156 declare void @extern()