1 ; RUN: opt -inline < %s -S -o - -inline-threshold=8 | FileCheck %s
3 target datalayout = "p:32:32"
5 declare void @llvm.lifetime.start(i64 %size, i8* nocapture %ptr)
7 @glbl = external global i32
9 define void @outer1() {
10 ; CHECK-LABEL: @outer1(
11 ; CHECK-NOT: call void @inner1
13 call void @inner1(i32* %ptr)
17 define void @inner1(i32 *%ptr) {
18 %A = load i32, i32* %ptr
19 store i32 0, i32* %ptr
20 %C = getelementptr inbounds i32, i32* %ptr, i32 0
21 %D = getelementptr inbounds i32, i32* %ptr, i32 1
22 %E = bitcast i32* %ptr to i8*
23 %F = select i1 false, i32* %ptr, i32* @glbl
24 call void @llvm.lifetime.start(i64 0, i8* %E)
28 define void @outer2() {
29 ; CHECK-LABEL: @outer2(
30 ; CHECK: call void @inner2
32 call void @inner2(i32* %ptr)
36 ; %D poisons this call, scalar-repl can't handle that instruction.
37 define void @inner2(i32 *%ptr) {
38 %A = load i32, i32* %ptr
39 store i32 0, i32* %ptr
40 %C = getelementptr inbounds i32, i32* %ptr, i32 0
41 %D = getelementptr inbounds i32, i32* %ptr, i32 %A
42 %E = bitcast i32* %ptr to i8*
43 %F = select i1 false, i32* %ptr, i32* @glbl
44 call void @llvm.lifetime.start(i64 0, i8* %E)
48 define void @outer3() {
49 ; CHECK-LABEL: @outer3(
50 ; CHECK-NOT: call void @inner3
52 call void @inner3(i32* %ptr, i1 undef)
56 define void @inner3(i32 *%ptr, i1 %x) {
57 %A = icmp eq i32* %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, i32* %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(i32* %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(i32 *%ptr, i32 %A) {
98 %B = getelementptr inbounds i32, i32* %ptr, i32 %A
99 %C = icmp eq i32* %ptr, null
100 br i1 %C, label %bb.true, label %bb.false
102 ; This block musn't be counted in the inline cost.
103 %t1 = load i32, i32* %ptr
112 %t10 = add i32 %t9, 1
113 %t11 = add i32 %t10, 1
114 %t12 = add i32 %t11, 1
115 %t13 = add i32 %t12, 1
116 %t14 = add i32 %t13, 1
117 %t15 = add i32 %t14, 1
118 %t16 = add i32 %t15, 1
119 %t17 = add i32 %t16, 1
120 %t18 = add i32 %t17, 1
121 %t19 = add i32 %t18, 1
122 %t20 = add i32 %t19, 1
128 define void @outer5() {
129 ; CHECK-LABEL: @outer5(
130 ; CHECK-NOT: call void @inner5
132 call void @inner5(i1 false, i32* %ptr)
136 ; %D poisons this call, scalar-repl can't handle that instruction. However, if
137 ; the flag is set appropriately, the poisoning instruction is inside of dead
138 ; code, and so shouldn't be counted.
139 define void @inner5(i1 %flag, i32 *%ptr) {
140 %A = load i32, i32* %ptr
141 store i32 0, i32* %ptr
142 %C = getelementptr inbounds i32, i32* %ptr, i32 0
143 br i1 %flag, label %if.then, label %exit
146 %D = getelementptr inbounds i32, i32* %ptr, i32 %A
147 %E = bitcast i32* %ptr to i8*
148 %F = select i1 false, i32* %ptr, i32* @glbl
149 call void @llvm.lifetime.start(i64 0, i8* %E)