1 ; RUN: llc -mcpu=corei7 -no-stack-coloring=false < %s | FileCheck %s --check-prefix=YESCOLOR --check-prefix=CHECK
2 ; RUN: llc -mcpu=corei7 -no-stack-coloring=false -stackcoloring-lifetime-start-on-first-use=false < %s | FileCheck %s --check-prefix=NOFIRSTUSE --check-prefix=CHECK
3 ; RUN: llc -mcpu=corei7 -no-stack-coloring=true < %s | FileCheck %s --check-prefix=NOCOLOR --check-prefix=CHECK
5 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
6 target triple = "x86_64-apple-macosx10.8.0"
8 ;CHECK-LABEL: myCall_w2:
9 ;YESCOLOR: subq $144, %rsp
10 ;NOCOLOR: subq $272, %rsp
12 define i32 @myCall_w2(i32 %in) {
14 %a = alloca [17 x i8*], align 8
15 %a2 = alloca [16 x i8*], align 8
16 %b = bitcast [17 x i8*]* %a to i8*
17 %b2 = bitcast [16 x i8*]* %a2 to i8*
18 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %b)
19 %t1 = call i32 @foo(i32 %in, i8* %b)
20 %t2 = call i32 @foo(i32 %in, i8* %b)
21 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %b)
22 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %b2)
23 %t3 = call i32 @foo(i32 %in, i8* %b2)
24 %t4 = call i32 @foo(i32 %in, i8* %b2)
25 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %b2)
26 %t5 = add i32 %t1, %t2
27 %t6 = add i32 %t3, %t4
28 %t7 = add i32 %t5, %t6
33 ;CHECK-LABEL: myCall2_no_merge
34 ;YESCOLOR: subq $272, %rsp
35 ;NOCOLOR: subq $272, %rsp
37 define i32 @myCall2_no_merge(i32 %in, i1 %d) {
39 %a = alloca [17 x i8*], align 8
40 %a2 = alloca [16 x i8*], align 8
41 %b = bitcast [17 x i8*]* %a to i8*
42 %b2 = bitcast [16 x i8*]* %a2 to i8*
43 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %b)
44 %t1 = call i32 @foo(i32 %in, i8* %b)
45 %t2 = call i32 @foo(i32 %in, i8* %b)
46 br i1 %d, label %bb2, label %bb3
48 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %b2)
49 %t3 = call i32 @foo(i32 %in, i8* %b2)
50 %t4 = call i32 @foo(i32 %in, i8* %b2)
51 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %b2)
52 %t5 = add i32 %t1, %t2
53 %t6 = add i32 %t3, %t4
54 %t7 = add i32 %t5, %t6
55 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %b)
58 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %b)
62 ;CHECK-LABEL: myCall2_w2
63 ;YESCOLOR: subq $144, %rsp
64 ;NOCOLOR: subq $272, %rsp
66 define i32 @myCall2_w2(i32 %in, i1 %d) {
68 %a = alloca [17 x i8*], align 8
69 %a2 = alloca [16 x i8*], align 8
70 %b = bitcast [17 x i8*]* %a to i8*
71 %b2 = bitcast [16 x i8*]* %a2 to i8*
72 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %b)
73 %t1 = call i32 @foo(i32 %in, i8* %b)
74 %t2 = call i32 @foo(i32 %in, i8* %b)
75 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %b)
76 br i1 %d, label %bb2, label %bb3
78 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %b2)
79 %t3 = call i32 @foo(i32 %in, i8* %b2)
80 %t4 = call i32 @foo(i32 %in, i8* %b2)
81 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %b2)
82 %t5 = add i32 %t1, %t2
83 %t6 = add i32 %t3, %t4
84 %t7 = add i32 %t5, %t6
90 ;CHECK-LABEL: myCall_w4:
91 ;YESCOLOR: subq $120, %rsp
92 ;NOFIRSTUSE: subq $200, %rsp
93 ;NOCOLOR: subq $408, %rsp
95 define i32 @myCall_w4(i32 %in) {
97 %a1 = alloca [14 x i8*], align 8
98 %a2 = alloca [13 x i8*], align 8
99 %a3 = alloca [12 x i8*], align 8
100 %a4 = alloca [11 x i8*], align 8
101 %b1 = bitcast [14 x i8*]* %a1 to i8*
102 %b2 = bitcast [13 x i8*]* %a2 to i8*
103 %b3 = bitcast [12 x i8*]* %a3 to i8*
104 %b4 = bitcast [11 x i8*]* %a4 to i8*
105 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %b4)
106 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %b1)
107 %t1 = call i32 @foo(i32 %in, i8* %b1)
108 %t2 = call i32 @foo(i32 %in, i8* %b1)
109 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %b1)
110 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %b2)
111 %t9 = call i32 @foo(i32 %in, i8* %b2)
112 %t8 = call i32 @foo(i32 %in, i8* %b2)
113 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %b2)
114 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %b3)
115 %t3 = call i32 @foo(i32 %in, i8* %b3)
116 %t4 = call i32 @foo(i32 %in, i8* %b3)
117 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %b3)
118 %t11 = call i32 @foo(i32 %in, i8* %b4)
119 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %b4)
120 %t5 = add i32 %t1, %t2
121 %t6 = add i32 %t3, %t4
122 %t7 = add i32 %t5, %t6
126 ;CHECK-LABEL: myCall2_w4:
127 ;YESCOLOR: subq $112, %rsp
128 ;NOCOLOR: subq $400, %rsp
130 define i32 @myCall2_w4(i32 %in) {
132 %a1 = alloca [14 x i8*], align 8
133 %a2 = alloca [13 x i8*], align 8
134 %a3 = alloca [12 x i8*], align 8
135 %a4 = alloca [11 x i8*], align 8
136 %b1 = bitcast [14 x i8*]* %a1 to i8*
137 %b2 = bitcast [13 x i8*]* %a2 to i8*
138 %b3 = bitcast [12 x i8*]* %a3 to i8*
139 %b4 = bitcast [11 x i8*]* %a4 to i8*
140 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %b1)
141 %t1 = call i32 @foo(i32 %in, i8* %b1)
142 %t2 = call i32 @foo(i32 %in, i8* %b1)
143 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %b1)
144 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %b2)
145 %t9 = call i32 @foo(i32 %in, i8* %b2)
146 %t8 = call i32 @foo(i32 %in, i8* %b2)
147 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %b2)
148 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %b3)
149 %t3 = call i32 @foo(i32 %in, i8* %b3)
150 %t4 = call i32 @foo(i32 %in, i8* %b3)
151 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %b3)
152 br i1 undef, label %bb2, label %bb3
154 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %b4)
155 %t11 = call i32 @foo(i32 %in, i8* %b4)
156 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %b4)
157 %t5 = add i32 %t1, %t2
158 %t6 = add i32 %t3, %t4
159 %t7 = add i32 %t5, %t6
166 ;CHECK-LABEL: myCall2_noend:
167 ;YESCOLOR: subq $144, %rsp
168 ;NOCOLOR: subq $272, %rsp
171 define i32 @myCall2_noend(i32 %in, i1 %d) {
173 %a = alloca [17 x i8*], align 8
174 %a2 = alloca [16 x i8*], align 8
175 %b = bitcast [17 x i8*]* %a to i8*
176 %b2 = bitcast [16 x i8*]* %a2 to i8*
177 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %b)
178 %t1 = call i32 @foo(i32 %in, i8* %b)
179 %t2 = call i32 @foo(i32 %in, i8* %b)
180 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %b)
181 br i1 %d, label %bb2, label %bb3
183 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %b2)
184 %t3 = call i32 @foo(i32 %in, i8* %b2)
185 %t4 = call i32 @foo(i32 %in, i8* %b2)
186 %t5 = add i32 %t1, %t2
187 %t6 = add i32 %t3, %t4
188 %t7 = add i32 %t5, %t6
194 ;CHECK-LABEL: myCall2_noend2:
195 ;YESCOLOR: subq $144, %rsp
196 ;NOCOLOR: subq $272, %rsp
197 define i32 @myCall2_noend2(i32 %in, i1 %d) {
199 %a = alloca [17 x i8*], align 8
200 %a2 = alloca [16 x i8*], align 8
201 %b = bitcast [17 x i8*]* %a to i8*
202 %b2 = bitcast [16 x i8*]* %a2 to i8*
203 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %b)
204 %t1 = call i32 @foo(i32 %in, i8* %b)
205 %t2 = call i32 @foo(i32 %in, i8* %b)
206 br i1 %d, label %bb2, label %bb3
208 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %b)
209 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %b2)
210 %t3 = call i32 @foo(i32 %in, i8* %b2)
211 %t4 = call i32 @foo(i32 %in, i8* %b2)
212 %t5 = add i32 %t1, %t2
213 %t6 = add i32 %t3, %t4
214 %t7 = add i32 %t5, %t6
221 ;CHECK-LABEL: myCall2_nostart:
222 ;YESCOLOR: subq $272, %rsp
223 ;NOCOLOR: subq $272, %rsp
224 define i32 @myCall2_nostart(i32 %in, i1 %d) {
226 %a = alloca [17 x i8*], align 8
227 %a2 = alloca [16 x i8*], align 8
228 %b = bitcast [17 x i8*]* %a to i8*
229 %b2 = bitcast [16 x i8*]* %a2 to i8*
230 %t1 = call i32 @foo(i32 %in, i8* %b)
231 %t2 = call i32 @foo(i32 %in, i8* %b)
232 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %b)
233 br i1 %d, label %bb2, label %bb3
235 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %b2)
236 %t3 = call i32 @foo(i32 %in, i8* %b2)
237 %t4 = call i32 @foo(i32 %in, i8* %b2)
238 %t5 = add i32 %t1, %t2
239 %t6 = add i32 %t3, %t4
240 %t7 = add i32 %t5, %t6
246 ; Adopt the test from Transforms/Inline/array_merge.ll'
247 ;CHECK-LABEL: array_merge:
248 ;YESCOLOR: subq $808, %rsp
249 ;NOCOLOR: subq $1608, %rsp
250 define void @array_merge() nounwind ssp {
252 %A.i1 = alloca [100 x i32], align 4
253 %B.i2 = alloca [100 x i32], align 4
254 %A.i = alloca [100 x i32], align 4
255 %B.i = alloca [100 x i32], align 4
256 %0 = bitcast [100 x i32]* %A.i to i8*
257 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %0) nounwind
258 %1 = bitcast [100 x i32]* %B.i to i8*
259 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %1) nounwind
260 call void @bar([100 x i32]* %A.i, [100 x i32]* %B.i) nounwind
261 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %0) nounwind
262 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %1) nounwind
263 %2 = bitcast [100 x i32]* %A.i1 to i8*
264 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %2) nounwind
265 %3 = bitcast [100 x i32]* %B.i2 to i8*
266 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %3) nounwind
267 call void @bar([100 x i32]* %A.i1, [100 x i32]* %B.i2) nounwind
268 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %2) nounwind
269 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %3) nounwind
273 ;CHECK-LABEL: func_phi_lifetime:
274 ;YESCOLOR: subq $272, %rsp
275 ;NOCOLOR: subq $272, %rsp
276 define i32 @func_phi_lifetime(i32 %in, i1 %d) {
278 %a = alloca [17 x i8*], align 8
279 %a2 = alloca [16 x i8*], align 8
280 %b = bitcast [17 x i8*]* %a to i8*
281 %b2 = bitcast [16 x i8*]* %a2 to i8*
282 %t1 = call i32 @foo(i32 %in, i8* %b)
283 %t2 = call i32 @foo(i32 %in, i8* %b)
284 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %b)
285 br i1 %d, label %bb0, label %bb1
288 %I1 = bitcast [17 x i8*]* %a to i8*
292 %I2 = bitcast [16 x i8*]* %a2 to i8*
296 %split = phi i8* [ %I1, %bb0 ], [ %I2, %bb1 ]
297 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %split)
298 %t3 = call i32 @foo(i32 %in, i8* %b2)
299 %t4 = call i32 @foo(i32 %in, i8* %b2)
300 %t5 = add i32 %t1, %t2
301 %t6 = add i32 %t3, %t4
302 %t7 = add i32 %t5, %t6
303 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %split)
310 ;CHECK-LABEL: multi_region_bb:
311 ;YESCOLOR: subq $272, %rsp
312 ;NOCOLOR: subq $272, %rsp
314 define void @multi_region_bb() nounwind ssp {
316 %A.i1 = alloca [100 x i32], align 4
317 %B.i2 = alloca [100 x i32], align 4
318 %A.i = alloca [100 x i32], align 4
319 %B.i = alloca [100 x i32], align 4
320 %0 = bitcast [100 x i32]* %A.i to i8*
321 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %0) nounwind ; <---- start #1
322 %1 = bitcast [100 x i32]* %B.i to i8*
323 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %1) nounwind
324 call void @bar([100 x i32]* %A.i, [100 x i32]* %B.i) nounwind
325 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %0) nounwind
326 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %1) nounwind
327 %2 = bitcast [100 x i32]* %A.i1 to i8*
328 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %2) nounwind
329 %3 = bitcast [100 x i32]* %B.i2 to i8*
330 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %3) nounwind
331 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %0) nounwind ; <---- start #2
332 call void @bar([100 x i32]* %A.i1, [100 x i32]* %B.i2) nounwind
333 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %2) nounwind
334 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %0) nounwind
335 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %3) nounwind
339 define i32 @myCall_end_before_begin(i32 %in, i1 %d) {
341 %a = alloca [17 x i8*], align 8
342 %a2 = alloca [16 x i8*], align 8
343 %b = bitcast [17 x i8*]* %a to i8*
344 %b2 = bitcast [16 x i8*]* %a2 to i8*
345 %t1 = call i32 @foo(i32 %in, i8* %b)
346 %t2 = call i32 @foo(i32 %in, i8* %b)
347 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %b)
348 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %b)
349 br i1 %d, label %bb2, label %bb3
351 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %b2)
352 %t3 = call i32 @foo(i32 %in, i8* %b2)
353 %t4 = call i32 @foo(i32 %in, i8* %b2)
354 %t5 = add i32 %t1, %t2
355 %t6 = add i32 %t3, %t4
356 %t7 = add i32 %t5, %t6
363 ; Regression test for PR15707. %buf1 and %buf2 should not be merged
365 ;CHECK-LABEL: myCall_pr15707:
366 ;NOFIRSTUSE: subq $200008, %rsp
367 ;NOCOLOR: subq $200008, %rsp
368 define void @myCall_pr15707() {
369 %buf1 = alloca i8, i32 100000, align 16
370 %buf2 = alloca i8, i32 100000, align 16
372 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %buf1)
373 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %buf1)
375 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %buf1)
376 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %buf2)
377 %result1 = call i32 @foo(i32 0, i8* %buf1)
378 %result2 = call i32 @foo(i32 0, i8* %buf2)
383 ; Check that we don't assert and crash even when there are allocas
384 ; outside the declared lifetime regions.
385 ;CHECK-LABEL: bad_range:
386 define void @bad_range() nounwind ssp {
388 %A.i1 = alloca [100 x i32], align 4
389 %B.i2 = alloca [100 x i32], align 4
390 %A.i = alloca [100 x i32], align 4
391 %B.i = alloca [100 x i32], align 4
392 %0 = bitcast [100 x i32]* %A.i to i8*
393 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %0) nounwind
394 %1 = bitcast [100 x i32]* %B.i to i8*
395 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %1) nounwind
396 call void @bar([100 x i32]* %A.i, [100 x i32]* %B.i) nounwind
397 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %0) nounwind
398 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %1) nounwind
402 ; I am used outside the marked lifetime.
403 call void @bar([100 x i32]* %A.i, [100 x i32]* %B.i) nounwind
408 ; Check that we don't assert and crash even when there are usages
409 ; of allocas which do not read or write outside the declared lifetime regions.
410 ;CHECK-LABEL: shady_range:
412 %struct.Klass = type { i32, i32 }
414 define i32 @shady_range(i32 %argc, i8** nocapture %argv) uwtable {
415 %a.i = alloca [4 x %struct.Klass], align 16
416 %b.i = alloca [4 x %struct.Klass], align 16
417 %a8 = bitcast [4 x %struct.Klass]* %a.i to i8*
418 %b8 = bitcast [4 x %struct.Klass]* %b.i to i8*
419 ; I am used outside the lifetime zone below:
420 %z2 = getelementptr inbounds [4 x %struct.Klass], [4 x %struct.Klass]* %a.i, i64 0, i64 0, i32 0
421 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %a8)
422 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %b8)
423 %z3 = load i32, i32* %z2, align 16
424 %r = call i32 @foo(i32 %z3, i8* %a8)
425 %r2 = call i32 @foo(i32 %z3, i8* %b8)
426 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %a8)
427 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %b8)
431 ; In this case 'itar1' and 'itar2' can't be overlapped if we treat
432 ; lifetime.start as the beginning of the lifetime, but we can
433 ; overlap if we consider first use of the slot as lifetime
434 ; start. See llvm bug 25776.
436 ;CHECK-LABEL: ifthen_twoslots:
437 ;YESCOLOR: subq $1544, %rsp
438 ;NOFIRSTUSE: subq $2056, %rsp
439 ;NOCOLOR: subq $2568, %rsp
441 define i32 @ifthen_twoslots(i32 %x) #0 {
443 %b1 = alloca [128 x i32], align 16
444 %b2 = alloca [128 x i32], align 16
445 %b3 = alloca [128 x i32], align 16
446 %b4 = alloca [128 x i32], align 16
447 %b5 = alloca [128 x i32], align 16
448 %tmp = bitcast [128 x i32]* %b1 to i8*
449 call void @llvm.lifetime.start.p0i8(i64 512, i8* %tmp)
450 %tmp1 = bitcast [128 x i32]* %b2 to i8*
451 call void @llvm.lifetime.start.p0i8(i64 512, i8* %tmp1)
453 %tobool = icmp eq i32 %and, 0
454 br i1 %tobool, label %if.else, label %if.then
456 if.then: ; preds = %entry
457 %tmp2 = bitcast [128 x i32]* %b3 to i8*
458 call void @llvm.lifetime.start.p0i8(i64 512, i8* %tmp2)
459 %a1 = getelementptr inbounds [128 x i32], [128 x i32]* %b1, i64 0, i64 0
460 %a2 = getelementptr inbounds [128 x i32], [128 x i32]* %b3, i64 0, i64 0
461 call void @initb(i32* %a1, i32* %a2, i32* null)
462 call void @llvm.lifetime.end.p0i8(i64 512, i8* %tmp2)
465 if.else: ; preds = %entry
466 %tmp3 = bitcast [128 x i32]* %b4 to i8*
467 call void @llvm.lifetime.start.p0i8(i64 512, i8* %tmp3)
468 %tmp4 = bitcast [128 x i32]* %b5 to i8*
469 call void @llvm.lifetime.start.p0i8(i64 512, i8* %tmp4)
470 %a3 = getelementptr inbounds [128 x i32], [128 x i32]* %b2, i64 0, i64 0
471 %a4 = getelementptr inbounds [128 x i32], [128 x i32]* %b4, i64 0, i64 0
472 %a5 = getelementptr inbounds [128 x i32], [128 x i32]* %b5, i64 0, i64 0
473 call void @initb(i32* %a3, i32* %a4, i32* %a5) #3
474 call void @llvm.lifetime.end.p0i8(i64 512, i8* %tmp4)
475 call void @llvm.lifetime.end.p0i8(i64 512, i8* %tmp3)
478 if.end: ; preds = %if.else, %if.then
479 call void @llvm.lifetime.end.p0i8(i64 512, i8* %tmp1)
480 call void @llvm.lifetime.end.p0i8(i64 512, i8* %tmp)
485 ; This function is intended to test the case where you
486 ; have a reference to a stack slot that lies outside of
487 ; the START/END lifetime markers-- the flow analysis
488 ; should catch this and build the lifetime based on the
491 ;CHECK-LABEL: while_loop:
492 ;YESCOLOR: subq $1032, %rsp
493 ;NOFIRSTUSE: subq $1544, %rsp
494 ;NOCOLOR: subq $1544, %rsp
496 define i32 @while_loop(i32 %x) #0 {
498 %b1 = alloca [128 x i32], align 16
499 %b2 = alloca [128 x i32], align 16
500 %b3 = alloca [128 x i32], align 16
501 %tmp = bitcast [128 x i32]* %b1 to i8*
502 call void @llvm.lifetime.start.p0i8(i64 512, i8* %tmp) #3
503 %tmp1 = bitcast [128 x i32]* %b2 to i8*
504 call void @llvm.lifetime.start.p0i8(i64 512, i8* %tmp1) #3
506 %tobool = icmp eq i32 %and, 0
507 br i1 %tobool, label %if.else, label %if.then
509 if.then: ; preds = %entry
510 %arraydecay = getelementptr inbounds [128 x i32], [128 x i32]* %b2, i64 0, i64 0
511 call void @inita(i32* %arraydecay) #3
514 if.else: ; preds = %entry
515 %arraydecay1 = getelementptr inbounds [128 x i32], [128 x i32]* %b1, i64 0, i64 0
516 call void @inita(i32* %arraydecay1) #3
517 %arraydecay3 = getelementptr inbounds [128 x i32], [128 x i32]* %b3, i64 0, i64 0
518 call void @inita(i32* %arraydecay3) #3
519 %tobool25 = icmp eq i32 %x, 0
520 br i1 %tobool25, label %if.end, label %while.body.lr.ph
522 while.body.lr.ph: ; preds = %if.else
523 %tmp2 = bitcast [128 x i32]* %b3 to i8*
526 while.body: ; preds = %while.body.lr.ph, %while.body
527 %x.addr.06 = phi i32 [ %x, %while.body.lr.ph ], [ %dec, %while.body ]
528 %dec = add nsw i32 %x.addr.06, -1
529 call void @llvm.lifetime.start.p0i8(i64 512, i8* %tmp2) #3
530 call void @inita(i32* %arraydecay3) #3
531 call void @llvm.lifetime.end.p0i8(i64 512, i8* %tmp2) #3
532 %tobool2 = icmp eq i32 %dec, 0
533 br i1 %tobool2, label %if.end.loopexit, label %while.body
535 if.end.loopexit: ; preds = %while.body
538 if.end: ; preds = %if.end.loopexit, %if.else, %if.then
539 call void @llvm.lifetime.end.p0i8(i64 512, i8* %tmp1) #3
540 call void @llvm.lifetime.end.p0i8(i64 512, i8* %tmp) #3
544 ; Test case motivated by PR27903. Same routine inlined multiple times
545 ; into a caller results in a multi-segment lifetime, but the second
546 ; lifetime has no explicit references to the stack slot. Such slots
547 ; have to be treated conservatively.
549 ;CHECK-LABEL: twobod_b27903:
550 ;YESCOLOR: subq $96, %rsp
551 ;NOFIRSTUSE: subq $96, %rsp
552 ;NOCOLOR: subq $96, %rsp
554 define i32 @twobod_b27903(i32 %y, i32 %x) {
556 %buffer.i = alloca [12 x i32], align 16
557 %abc = alloca [12 x i32], align 16
558 %tmp = bitcast [12 x i32]* %buffer.i to i8*
559 call void @llvm.lifetime.start.p0i8(i64 48, i8* %tmp)
560 %idxprom.i = sext i32 %y to i64
561 %arrayidx.i = getelementptr inbounds [12 x i32], [12 x i32]* %buffer.i, i64 0, i64 %idxprom.i
562 call void @inita(i32* %arrayidx.i)
563 %add.i = add nsw i32 %x, %y
564 call void @llvm.lifetime.end.p0i8(i64 48, i8* %tmp)
565 %tobool = icmp eq i32 %y, 0
566 br i1 %tobool, label %if.end, label %if.then
568 if.then: ; preds = %entry
569 %tmp1 = bitcast [12 x i32]* %abc to i8*
570 call void @llvm.lifetime.start.p0i8(i64 48, i8* %tmp1)
571 %arrayidx = getelementptr inbounds [12 x i32], [12 x i32]* %abc, i64 0, i64 %idxprom.i
572 call void @inita(i32* %arrayidx)
573 call void @llvm.lifetime.start.p0i8(i64 48, i8* %tmp)
574 call void @inita(i32* %arrayidx.i)
575 %add.i9 = add nsw i32 %add.i, %y
576 call void @llvm.lifetime.end.p0i8(i64 48, i8* %tmp)
577 call void @llvm.lifetime.end.p0i8(i64 48, i8* %tmp1)
580 if.end: ; preds = %if.then, %entry
581 %x.addr.0 = phi i32 [ %add.i9, %if.then ], [ %add.i, %entry ]
585 ;CHECK-LABEL: multi_segment:
586 ;YESCOLOR: subq $256, %rsp
587 ;NOFIRSTUSE: subq $256, %rsp
588 ;NOCOLOR: subq $512, %rsp
589 define i1 @multi_segment(i1, i1)
592 %foo = alloca [32 x i64]
593 %bar = alloca [32 x i64]
594 %foo_i8 = bitcast [32 x i64]* %foo to i8*
595 %bar_i8 = bitcast [32 x i64]* %bar to i8*
596 call void @llvm.lifetime.start.p0i8(i64 256, i8* %bar_i8)
597 call void @baz([32 x i64]* %bar, i32 1)
598 call void @llvm.lifetime.end.p0i8(i64 256, i8* %bar_i8)
599 call void @llvm.lifetime.start.p0i8(i64 256, i8* %foo_i8)
600 call void @baz([32 x i64]* %foo, i32 1)
601 call void @llvm.lifetime.end.p0i8(i64 256, i8* %foo_i8)
602 call void @llvm.lifetime.start.p0i8(i64 256, i8* %bar_i8)
603 call void @baz([32 x i64]* %bar, i32 1)
604 call void @llvm.lifetime.end.p0i8(i64 256, i8* %bar_i8)
608 ;CHECK-LABEL: pr32488:
609 ;YESCOLOR: subq $256, %rsp
610 ;NOFIRSTUSE: subq $256, %rsp
611 ;NOCOLOR: subq $512, %rsp
612 define i1 @pr32488(i1, i1)
615 %foo = alloca [32 x i64]
616 %bar = alloca [32 x i64]
617 %foo_i8 = bitcast [32 x i64]* %foo to i8*
618 %bar_i8 = bitcast [32 x i64]* %bar to i8*
619 br i1 %0, label %if_false, label %if_true
621 call void @llvm.lifetime.start.p0i8(i64 256, i8* %bar_i8)
622 call void @baz([32 x i64]* %bar, i32 0)
623 br i1 %1, label %if_false.1, label %onerr
625 call void @llvm.lifetime.end.p0i8(i64 256, i8* %bar_i8)
628 call void @llvm.lifetime.start.p0i8(i64 256, i8* %foo_i8)
629 call void @baz([32 x i64]* %foo, i32 1)
630 br i1 %1, label %if_true.1, label %onerr
632 call void @llvm.lifetime.end.p0i8(i64 256, i8* %foo_i8)
637 call void @llvm.lifetime.end.p0i8(i64 256, i8* %foo_i8)
638 call void @llvm.lifetime.end.p0i8(i64 256, i8* %bar_i8)
639 call void @destructor()
643 %Data = type { [32 x i64] }
645 declare void @destructor()
647 declare void @inita(i32*)
649 declare void @initb(i32*,i32*,i32*)
651 declare void @bar([100 x i32]* , [100 x i32]*) nounwind
653 declare void @baz([32 x i64]*, i32)
655 declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) nounwind
657 declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) nounwind
659 declare i32 @foo(i32, i8*)