1 ; RUN: opt -passes='print<stack-lifetime><may>' -disable-output %s 2>&1 | FileCheck %s --check-prefixes=CHECK,MAY
2 ; RUN: opt -passes='print<stack-lifetime><must>' -disable-output %s 2>&1 | FileCheck %s --check-prefixes=CHECK,MUST
5 ; CHECK-LABEL: define void @f()
8 ; CHECK-NEXT: Alive: <>
9 %x = alloca i32, align 4
10 %y = alloca i32, align 4
11 ; CHECK: %y = alloca i32, align 4
12 ; CHECK-NEXT: Alive: <>
13 %z = alloca i32, align 4
14 call void @llvm.lifetime.start.p0(i64 -1, ptr %z)
15 ; CHECK: call void @llvm.lifetime.start.p0(i64 -1, ptr %z)
16 ; CHECK-NEXT: Alive: <z>
18 call void @llvm.lifetime.start.p0(i64 -1, ptr %x)
19 ; CHECK: call void @llvm.lifetime.start.p0(i64 -1, ptr %x)
20 ; CHECK-NEXT: Alive: <x z>
22 call void @capture32(ptr %x)
23 call void @llvm.lifetime.end.p0(i64 -1, ptr %x)
24 ; CHECK: call void @llvm.lifetime.end.p0(i64 -1, ptr %x)
25 ; CHECK-NEXT: Alive: <z>
27 call void @llvm.lifetime.start.p0(i64 -1, ptr %y)
28 ; CHECK: call void @llvm.lifetime.start.p0(i64 -1, ptr %y)
29 ; CHECK-NEXT: Alive: <y z>
31 call void @capture32(ptr %y)
32 call void @llvm.lifetime.end.p0(i64 -1, ptr %y)
33 ; CHECK: call void @llvm.lifetime.end.p0(i64 -1, ptr %y)
34 ; CHECK-NEXT: Alive: <z>
36 call void @capture32(ptr %z)
37 call void @llvm.lifetime.end.p0(i64 -1, ptr %z)
38 ; CHECK: call void @llvm.lifetime.end.p0(i64 -1, ptr %z)
39 ; CHECK-NEXT: Alive: <>
44 define void @no_markers() {
45 ; CHECK-LABEL: define void @no_markers()
48 ; CHECK-NEXT: Alive: <y>
49 %x = alloca i32, align 4
50 %y = alloca i32, align 4
51 call void @llvm.lifetime.start.p0(i64 -1, ptr %x)
52 ; CHECK: call void @llvm.lifetime.start.p0(i64 -1, ptr %x)
53 ; CHECK-NEXT: Alive: <x y>
55 call void @capture32(ptr %x)
56 call void @llvm.lifetime.end.p0(i64 -1, ptr %x)
57 ; CHECK: call void @llvm.lifetime.end.p0(i64 -1, ptr %x)
58 ; CHECK-NEXT: Alive: <y>
60 call void @capture32(ptr %y)
65 ; CHECK-LABEL: define void @g()
68 ; CHECK-NEXT: Alive: <>
69 %x = alloca i32, align 4
70 %y = alloca i32, align 4
71 %z = alloca i64, align 4
72 call void @llvm.lifetime.start.p0(i64 -1, ptr %x)
73 ; CHECK: call void @llvm.lifetime.start.p0(i64 -1, ptr %x)
74 ; CHECK-NEXT: Alive: <x>
76 call void @llvm.lifetime.start.p0(i64 -1, ptr %y)
77 ; CHECK: call void @llvm.lifetime.start.p0(i64 -1, ptr %y)
78 ; CHECK-NEXT: Alive: <x y>
80 call void @capture32(ptr %x)
81 call void @llvm.lifetime.end.p0(i64 -1, ptr %x)
82 ; CHECK: call void @llvm.lifetime.end.p0(i64 -1, ptr %x)
83 ; CHECK-NEXT: Alive: <y>
85 call void @capture32(ptr %y)
86 call void @llvm.lifetime.end.p0(i64 -1, ptr %y)
87 ; CHECK: call void @llvm.lifetime.end.p0(i64 -1, ptr %y)
88 ; CHECK-NEXT: Alive: <>
90 call void @llvm.lifetime.start.p0(i64 -1, ptr %z)
91 ; CHECK: call void @llvm.lifetime.start.p0(i64 -1, ptr %z)
92 ; CHECK-NEXT: Alive: <z>
94 call void @capture64(ptr %z)
95 call void @llvm.lifetime.end.p0(i64 -1, ptr %z)
96 ; CHECK: call void @llvm.lifetime.end.p0(i64 -1, ptr %z)
97 ; CHECK-NEXT: Alive: <>
101 ; CHECK-NEXT: Alive: <>
105 ; CHECK-LABEL: define void @h()
108 ; CHECK-NEXT: Alive: <>
109 %x = alloca i32, align 16
110 ; CHECK: %x = alloca i32, align 16
111 ; CHECK-NEXT: Alive: <>
112 %z = alloca i64, align 4
113 %y = alloca i32, align 4
114 call void @llvm.lifetime.start.p0(i64 -1, ptr %x)
115 ; CHECK: call void @llvm.lifetime.start.p0(i64 -1, ptr %x)
116 ; CHECK-NEXT: Alive: <x>
118 call void @llvm.lifetime.start.p0(i64 -1, ptr %y)
119 ; CHECK: call void @llvm.lifetime.start.p0(i64 -1, ptr %y)
120 ; CHECK-NEXT: Alive: <x y>
122 call void @llvm.lifetime.start.p0(i64 -1, ptr %z)
123 ; CHECK: call void @llvm.lifetime.start.p0(i64 -1, ptr %z)
124 ; CHECK-NEXT: Alive: <x y z>
126 call void @capture32(ptr %x)
127 call void @capture32(ptr %y)
128 call void @capture64(ptr %z)
129 call void @llvm.lifetime.end.p0(i64 -1, ptr %x)
130 ; CHECK: call void @llvm.lifetime.end.p0(i64 -1, ptr %x)
131 ; CHECK-NEXT: Alive: <y z>
133 call void @llvm.lifetime.end.p0(i64 -1, ptr %y)
134 ; CHECK: call void @llvm.lifetime.end.p0(i64 -1, ptr %y)
135 ; CHECK-NEXT: Alive: <z>
137 call void @llvm.lifetime.end.p0(i64 -1, ptr %z)
138 ; CHECK: call void @llvm.lifetime.end.p0(i64 -1, ptr %z)
139 ; CHECK-NEXT: Alive: <>
144 define void @i(i1 zeroext %a, i1 zeroext %b) {
145 ; CHECK-LABEL: define void @i(i1 zeroext %a, i1 zeroext %b)
148 ; CHECK-NEXT: Alive: <>
149 %x1 = alloca i64, align 8
150 %x2 = alloca i64, align 8
151 %y = alloca i64, align 8
152 %y1 = alloca i64, align 8
153 %y2 = alloca i64, align 8
154 %z = alloca i64, align 8
155 %z1 = alloca i64, align 8
156 %z2 = alloca i64, align 8
157 call void @llvm.lifetime.start.p0(i64 -1, ptr %x1)
158 ; CHECK: call void @llvm.lifetime.start.p0(i64 -1, ptr %x1)
159 ; CHECK-NEXT: Alive: <x1>
161 call void @llvm.lifetime.start.p0(i64 -1, ptr %x2)
162 ; CHECK: call void @llvm.lifetime.start.p0(i64 -1, ptr %x2)
163 ; CHECK-NEXT: Alive: <x1 x2>
165 call void @capture64(ptr nonnull %x1)
166 call void @capture64(ptr nonnull %x2)
167 br i1 %a, label %if.then, label %if.else4
168 ; CHECK: br i1 %a, label %if.then, label %if.else4
169 ; CHECK-NEXT: Alive: <x1 x2>
171 if.then: ; preds = %entry
173 ; CHECK-NEXT: Alive: <x1 x2>
174 call void @llvm.lifetime.start.p0(i64 -1, ptr %y)
175 ; CHECK: call void @llvm.lifetime.start.p0(i64 -1, ptr %y)
176 ; CHECK-NEXT: Alive: <x1 x2 y>
178 call void @capture64(ptr nonnull %y)
179 br i1 %b, label %if.then3, label %if.else
181 if.then3: ; preds = %if.then
183 ; CHECK-NEXT: Alive: <x1 x2 y>
184 call void @llvm.lifetime.start.p0(i64 -1, ptr %y1)
185 ; CHECK: call void @llvm.lifetime.start.p0(i64 -1, ptr %y1)
186 ; CHECK-NEXT: Alive: <x1 x2 y y1>
188 call void @capture64(ptr nonnull %y1)
189 call void @llvm.lifetime.end.p0(i64 -1, ptr %y1)
190 ; CHECK: call void @llvm.lifetime.end.p0(i64 -1, ptr %y1)
191 ; CHECK-NEXT: Alive: <x1 x2 y>
195 if.else: ; preds = %if.then
197 ; CHECK-NEXT: Alive: <x1 x2 y>
198 call void @llvm.lifetime.start.p0(i64 -1, ptr %y2)
199 ; CHECK: call void @llvm.lifetime.start.p0(i64 -1, ptr %y2)
200 ; CHECK-NEXT: Alive: <x1 x2 y y2>
202 call void @capture64(ptr nonnull %y2)
203 call void @llvm.lifetime.end.p0(i64 -1, ptr %y2)
204 ; CHECK: call void @llvm.lifetime.end.p0(i64 -1, ptr %y2)
205 ; CHECK-NEXT: Alive: <x1 x2 y>
209 if.end: ; preds = %if.else, %if.then3
211 ; CHECK-NEXT: Alive: <x1 x2 y>
212 call void @llvm.lifetime.end.p0(i64 -1, ptr %y)
213 ; CHECK: call void @llvm.lifetime.end.p0(i64 -1, ptr %y)
214 ; CHECK-NEXT: Alive: <x1 x2>
218 if.else4: ; preds = %entry
220 ; CHECK-NEXT: Alive: <x1 x2>
221 %z.cast = bitcast ptr %z to ptr
222 ; CHECK: %z.cast = bitcast ptr %z to ptr
223 ; CHECK-NEXT: Alive: <x1 x2>
225 call void @llvm.lifetime.start.p0(i64 -1, ptr %z)
226 ; CHECK: call void @llvm.lifetime.start.p0(i64 -1, ptr %z)
227 ; CHECK-NEXT: Alive: <x1 x2 z>
229 call void @capture64(ptr nonnull %z)
230 br i1 %b, label %if.then6, label %if.else7
232 if.then6: ; preds = %if.else4
234 ; CHECK-NEXT: Alive: <x1 x2 z>
235 call void @llvm.lifetime.start.p0(i64 -1, ptr %z1)
236 ; CHECK: call void @llvm.lifetime.start.p0(i64 -1, ptr %z1)
237 ; CHECK-NEXT: Alive: <x1 x2 z z1>
239 call void @capture64(ptr nonnull %z1)
240 call void @llvm.lifetime.end.p0(i64 -1, ptr %z1)
241 ; CHECK: call void @llvm.lifetime.end.p0(i64 -1, ptr %z1)
242 ; CHECK-NEXT: Alive: <x1 x2 z>
246 if.else7: ; preds = %if.else4
248 ; CHECK-NEXT: Alive: <x1 x2 z>
249 call void @llvm.lifetime.start.p0(i64 -1, ptr %z2)
250 ; CHECK: call void @llvm.lifetime.start.p0(i64 -1, ptr %z2)
251 ; CHECK-NEXT: Alive: <x1 x2 z z2>
253 call void @capture64(ptr nonnull %z2)
254 call void @llvm.lifetime.end.p0(i64 -1, ptr %z2)
255 ; CHECK: call void @llvm.lifetime.end.p0(i64 -1, ptr %z2)
256 ; CHECK-NEXT: Alive: <x1 x2 z>
260 if.end8: ; preds = %if.else7, %if.then6
262 ; CHECK-NEXT: Alive: <x1 x2 z>
263 call void @llvm.lifetime.end.p0(i64 -1, ptr %z)
264 ; CHECK: call void @llvm.lifetime.end.p0(i64 -1, ptr %z)
265 ; CHECK-NEXT: Alive: <x1 x2>
269 if.end9: ; preds = %if.end8, %if.end
271 ; CHECK-NEXT: Alive: <x1 x2>
272 call void @llvm.lifetime.end.p0(i64 -1, ptr %x2)
273 ; CHECK: call void @llvm.lifetime.end.p0(i64 -1, ptr %x2)
274 ; CHECK-NEXT: Alive: <x1>
276 call void @llvm.lifetime.end.p0(i64 -1, ptr %x1)
277 ; CHECK: call void @llvm.lifetime.end.p0(i64 -1, ptr %x1)
278 ; CHECK-NEXT: Alive: <>
283 define void @no_merge1(i1 %d) {
284 ; CHECK-LABEL: define void @no_merge1(i1 %d)
287 ; CHECK-NEXT: Alive: <>
288 %x = alloca i32, align 4
289 %y = alloca i32, align 4
290 call void @llvm.lifetime.start.p0(i64 -1, ptr %x)
291 ; CHECK: call void @llvm.lifetime.start.p0(i64 -1, ptr %x)
292 ; CHECK-NEXT: Alive: <x>
294 call void @capture32(ptr %x)
295 br i1 %d, label %bb2, label %bb3
297 bb2: ; preds = %entry
299 ; CHECK-NEXT: Alive: <x>
300 call void @llvm.lifetime.start.p0(i64 -1, ptr %y)
301 ; CHECK: call void @llvm.lifetime.start.p0(i64 -1, ptr %y)
302 ; CHECK-NEXT: Alive: <x y>
304 call void @capture32(ptr %y)
305 call void @llvm.lifetime.end.p0(i64 -1, ptr %y)
306 ; CHECK: call void @llvm.lifetime.end.p0(i64 -1, ptr %y)
307 ; CHECK-NEXT: Alive: <x>
309 call void @llvm.lifetime.end.p0(i64 -1, ptr %x)
310 ; CHECK: call void @llvm.lifetime.end.p0(i64 -1, ptr %x)
311 ; CHECK-NEXT: Alive: <>
315 bb3: ; preds = %entry
317 ; CHECK-NEXT: Alive: <x>
318 call void @llvm.lifetime.end.p0(i64 -1, ptr %x)
319 ; CHECK: call void @llvm.lifetime.end.p0(i64 -1, ptr %x)
320 ; CHECK-NEXT: Alive: <>
325 define void @merge1(i1 %d) {
326 ; CHECK-LABEL: define void @merge1(i1 %d)
329 ; CHECK-NEXT: Alive: <>
330 %x = alloca i32, align 4
331 %y = alloca i32, align 4
332 call void @llvm.lifetime.start.p0(i64 -1, ptr %x)
333 ; CHECK: call void @llvm.lifetime.start.p0(i64 -1, ptr %x)
334 ; CHECK-NEXT: Alive: <x>
336 call void @capture32(ptr %x)
337 call void @llvm.lifetime.end.p0(i64 -1, ptr %x)
338 ; CHECK: call void @llvm.lifetime.end.p0(i64 -1, ptr %x)
339 ; CHECK-NEXT: Alive: <>
341 br i1 %d, label %bb2, label %bb3
343 bb2: ; preds = %entry
345 ; CHECK-NEXT: Alive: <>
346 call void @llvm.lifetime.start.p0(i64 -1, ptr %y)
347 ; CHECK: call void @llvm.lifetime.start.p0(i64 -1, ptr %y)
348 ; CHECK-NEXT: Alive: <y>
350 call void @capture32(ptr %y)
351 call void @llvm.lifetime.end.p0(i64 -1, ptr %y)
352 ; CHECK: call void @llvm.lifetime.end.p0(i64 -1, ptr %y)
353 ; CHECK-NEXT: Alive: <>
357 bb3: ; preds = %entry
359 ; CHECK-NEXT: Alive: <>
363 define void @merge2_noend(i1 %d) {
364 ; CHECK-LABEL: define void @merge2_noend(i1 %d)
367 ; CHECK-NEXT: Alive: <>
368 %x = alloca i32, align 4
369 %y = alloca i32, align 4
370 call void @llvm.lifetime.start.p0(i64 -1, ptr %x)
371 ; CHECK: call void @llvm.lifetime.start.p0(i64 -1, ptr %x)
372 ; CHECK-NEXT: Alive: <x>
374 call void @capture32(ptr %x)
375 call void @llvm.lifetime.end.p0(i64 -1, ptr %x)
376 ; CHECK: call void @llvm.lifetime.end.p0(i64 -1, ptr %x)
377 ; CHECK-NEXT: Alive: <>
379 br i1 %d, label %bb2, label %bb3
381 bb2: ; preds = %entry
383 ; CHECK-NEXT: Alive: <>
384 call void @llvm.lifetime.start.p0(i64 -1, ptr %y)
385 ; CHECK: call void @llvm.lifetime.start.p0(i64 -1, ptr %y)
386 ; CHECK-NEXT: Alive: <y>
388 call void @capture32(ptr %y)
391 bb3: ; preds = %entry
393 ; CHECK-NEXT: Alive: <>
397 define void @merge3_noend(i1 %d) {
398 ; CHECK-LABEL: define void @merge3_noend(i1 %d)
401 ; CHECK-NEXT: Alive: <>
402 %x = alloca i32, align 4
403 %y = alloca i32, align 4
404 call void @llvm.lifetime.start.p0(i64 -1, ptr %x)
405 ; CHECK: call void @llvm.lifetime.start.p0(i64 -1, ptr %x)
406 ; CHECK-NEXT: Alive: <x>
408 call void @capture32(ptr %x)
409 br i1 %d, label %bb2, label %bb3
411 bb2: ; preds = %entry
413 ; CHECK-NEXT: Alive: <x>
414 call void @llvm.lifetime.end.p0(i64 -1, ptr %x)
415 ; CHECK: call void @llvm.lifetime.end.p0(i64 -1, ptr %x)
416 ; CHECK-NEXT: Alive: <>
418 call void @llvm.lifetime.start.p0(i64 -1, ptr %y)
419 ; CHECK: call void @llvm.lifetime.start.p0(i64 -1, ptr %y)
420 ; CHECK-NEXT: Alive: <y>
422 call void @capture32(ptr %y)
425 bb3: ; preds = %entry
427 ; CHECK-NEXT: Alive: <x>
431 define void @nomerge4_nostart(i1 %d) {
432 ; CHECK-LABEL: define void @nomerge4_nostart(i1 %d)
435 ; CHECK-NEXT: Alive: <x>
436 %x = alloca i32, align 4
437 %y = alloca i32, align 4
438 call void @capture32(ptr %x)
439 call void @llvm.lifetime.end.p0(i64 -1, ptr %x)
440 ; CHECK: call void @llvm.lifetime.end.p0(i64 -1, ptr %x)
441 ; CHECK-NEXT: Alive: <x>
443 br i1 %d, label %bb2, label %bb3
445 bb2: ; preds = %entry
447 ; CHECK-NEXT: Alive: <x>
448 call void @llvm.lifetime.start.p0(i64 -1, ptr %y)
449 ; CHECK: call void @llvm.lifetime.start.p0(i64 -1, ptr %y)
450 ; CHECK-NEXT: Alive: <x y>
452 call void @capture32(ptr %y)
455 bb3: ; preds = %entry
457 ; CHECK-NEXT: Alive: <x>
461 define void @array_merge() {
462 ; CHECK-LABEL: define void @array_merge()
465 ; CHECK-NEXT: Alive: <>
466 %A.i1 = alloca [100 x i32], align 4
467 %B.i2 = alloca [100 x i32], align 4
468 %A.i = alloca [100 x i32], align 4
469 %B.i = alloca [100 x i32], align 4
470 call void @llvm.lifetime.start.p0(i64 -1, ptr %A.i)
471 ; CHECK: call void @llvm.lifetime.start.p0(i64 -1, ptr %A.i)
472 ; CHECK-NEXT: Alive: <A.i>
474 call void @llvm.lifetime.start.p0(i64 -1, ptr %B.i)
475 ; CHECK: call void @llvm.lifetime.start.p0(i64 -1, ptr %B.i)
476 ; CHECK-NEXT: Alive: <A.i B.i>
478 call void @capture100x32(ptr %A.i)
479 ; CHECK: call void @capture100x32(ptr %A.i)
480 ; CHECK-NEXT: Alive: <A.i B.i>
482 call void @capture100x32(ptr %B.i)
483 call void @llvm.lifetime.end.p0(i64 -1, ptr %A.i)
484 ; CHECK: call void @llvm.lifetime.end.p0(i64 -1, ptr %A.i)
485 ; CHECK-NEXT: Alive: <B.i>
487 call void @llvm.lifetime.end.p0(i64 -1, ptr %B.i)
488 ; CHECK: call void @llvm.lifetime.end.p0(i64 -1, ptr %B.i)
489 ; CHECK-NEXT: Alive: <>
491 call void @llvm.lifetime.start.p0(i64 -1, ptr %A.i1)
492 ; CHECK: call void @llvm.lifetime.start.p0(i64 -1, ptr %A.i1)
493 ; CHECK-NEXT: Alive: <A.i1>
495 call void @llvm.lifetime.start.p0(i64 -1, ptr %B.i2)
496 ; CHECK: call void @llvm.lifetime.start.p0(i64 -1, ptr %B.i2)
497 ; CHECK-NEXT: Alive: <A.i1 B.i2>
499 call void @capture100x32(ptr %A.i1)
500 call void @capture100x32(ptr %B.i2)
501 call void @llvm.lifetime.end.p0(i64 -1, ptr %A.i1)
502 ; CHECK: call void @llvm.lifetime.end.p0(i64 -1, ptr %A.i1)
503 ; CHECK-NEXT: Alive: <B.i2>
505 call void @llvm.lifetime.end.p0(i64 -1, ptr %B.i2)
506 ; CHECK: call void @llvm.lifetime.end.p0(i64 -1, ptr %B.i2)
507 ; CHECK-NEXT: Alive: <>
512 define void @myCall_pr15707() {
513 ; CHECK-LABEL: define void @myCall_pr15707()
516 ; CHECK-NEXT: Alive: <>
517 %buf1 = alloca i8, i32 100000, align 16
518 %buf2 = alloca i8, i32 100000, align 16
519 call void @llvm.lifetime.start.p0(i64 -1, ptr %buf1)
520 ; CHECK: call void @llvm.lifetime.start.p0(i64 -1, ptr %buf1)
521 ; CHECK-NEXT: Alive: <buf1>
523 call void @llvm.lifetime.end.p0(i64 -1, ptr %buf1)
524 ; CHECK: call void @llvm.lifetime.end.p0(i64 -1, ptr %buf1)
525 ; CHECK-NEXT: Alive: <>
527 call void @llvm.lifetime.start.p0(i64 -1, ptr %buf1)
528 ; CHECK: call void @llvm.lifetime.start.p0(i64 -1, ptr %buf1)
529 ; CHECK-NEXT: Alive: <buf1>
531 call void @llvm.lifetime.start.p0(i64 -1, ptr %buf2)
532 ; CHECK: call void @llvm.lifetime.start.p0(i64 -1, ptr %buf2)
533 ; CHECK-NEXT: Alive: <buf1 buf2>
535 call void @capture8(ptr %buf1)
536 call void @capture8(ptr %buf2)
540 define void @bad_range() {
541 ; CHECK-LABEL: define void @bad_range()
544 ; CHECK-NEXT: Alive: <A.i1 B.i2>
545 %A.i1 = alloca [100 x i32], align 4
546 %B.i2 = alloca [100 x i32], align 4
547 %A.i = alloca [100 x i32], align 4
548 %B.i = alloca [100 x i32], align 4
549 call void @llvm.lifetime.start.p0(i64 -1, ptr %A.i)
550 ; CHECK: call void @llvm.lifetime.start.p0(i64 -1, ptr %A.i)
551 ; CHECK-NEXT: Alive: <A.i A.i1 B.i2>
553 call void @llvm.lifetime.start.p0(i64 -1, ptr %B.i)
554 ; CHECK: call void @llvm.lifetime.start.p0(i64 -1, ptr %B.i)
555 ; CHECK-NEXT: Alive: <A.i A.i1 B.i B.i2>
557 call void @capture100x32(ptr %A.i)
558 call void @capture100x32(ptr %B.i)
559 call void @llvm.lifetime.end.p0(i64 -1, ptr %A.i)
560 ; CHECK: call void @llvm.lifetime.end.p0(i64 -1, ptr %A.i)
561 ; CHECK-NEXT: Alive: <A.i1 B.i B.i2>
563 call void @llvm.lifetime.end.p0(i64 -1, ptr %B.i)
564 ; CHECK: call void @llvm.lifetime.end.p0(i64 -1, ptr %B.i)
565 ; CHECK-NEXT: Alive: <A.i1 B.i2>
569 block2: ; preds = %entry
571 ; CHECK-NEXT: Alive: <A.i1 B.i2>
572 call void @capture100x32(ptr %A.i)
573 call void @capture100x32(ptr %B.i)
577 %struct.Klass = type { i32, i32 }
579 define i32 @shady_range(i32 %argc, ptr nocapture %argv) {
580 ; CHECK-LABEL: define i32 @shady_range(i32 %argc, ptr nocapture %argv)
583 ; CHECK-NEXT: Alive: <>
584 %a.i = alloca [4 x %struct.Klass], align 16
585 %b.i = alloca [4 x %struct.Klass], align 16
586 call void @llvm.lifetime.start.p0(i64 -1, ptr %a.i)
587 ; CHECK: call void @llvm.lifetime.start.p0(i64 -1, ptr %a.i)
588 ; CHECK-NEXT: Alive: <a.i>
590 call void @llvm.lifetime.start.p0(i64 -1, ptr %b.i)
591 ; CHECK: call void @llvm.lifetime.start.p0(i64 -1, ptr %b.i)
592 ; CHECK-NEXT: Alive: <a.i b.i>
594 call void @capture8(ptr %a.i)
595 call void @capture8(ptr %b.i)
596 %z3 = load i32, ptr %a.i, align 16
597 call void @llvm.lifetime.end.p0(i64 -1, ptr %a.i)
598 ; CHECK: call void @llvm.lifetime.end.p0(i64 -1, ptr %a.i)
599 ; CHECK-NEXT: Alive: <b.i>
601 call void @llvm.lifetime.end.p0(i64 -1, ptr %b.i)
602 ; CHECK: call void @llvm.lifetime.end.p0(i64 -1, ptr %b.i)
603 ; CHECK-NEXT: Alive: <>
608 define void @end_loop() {
609 ; CHECK-LABEL: define void @end_loop()
612 ; CHECK-NEXT: Alive: <>
613 %x = alloca i8, align 4
614 call void @llvm.lifetime.start.p0(i64 1, ptr %x)
615 ; CHECK: call void @llvm.lifetime.start.p0(i64 1, ptr %x)
616 ; CHECK-NEXT: Alive: <x>
620 l2: ; preds = %l2, %entry
622 ; MAY-NEXT: Alive: <x>
623 ; MUST-NEXT: Alive: <>
624 call void @capture8(ptr %x)
625 call void @llvm.lifetime.end.p0(i64 1, ptr %x)
626 ; CHECK: call void @llvm.lifetime.end.p0(i64 1, ptr %x)
627 ; CHECK-NEXT: Alive: <>
632 define void @start_loop() {
633 ; CHECK-LABEL: define void @start_loop()
636 ; CHECK-NEXT: Alive: <>
637 %x = alloca i8, align 4
638 %y = alloca i8, align 4
639 call void @llvm.lifetime.start.p0(i64 1, ptr %x)
640 ; CHECK: call void @llvm.lifetime.start.p0(i64 1, ptr %x)
641 ; CHECK-NEXT: Alive: <x>
645 l2: ; preds = %l2, %entry
647 ; CHECK-NEXT: Alive: <x>
648 call void @llvm.lifetime.start.p0(i64 1, ptr %y)
649 ; CHECK: call void @llvm.lifetime.start.p0(i64 1, ptr %y)
650 ; CHECK-NEXT: Alive: <x y>
652 call void @capture8(ptr %y)
653 call void @llvm.lifetime.end.p0(i64 1, ptr %y)
654 ; CHECK: call void @llvm.lifetime.end.p0(i64 1, ptr %y)
655 ; CHECK-NEXT: Alive: <x>
657 call void @llvm.lifetime.start.p0(i64 1, ptr %x)
658 ; CHECK: call void @llvm.lifetime.start.p0(i64 1, ptr %x)
659 ; CHECK-NEXT: Alive: <x>
661 call void @capture8(ptr %x)
665 %struct.char_array = type { [500 x i8] }
667 define dso_local void @gep_test(i32 %cond) {
668 ; CHECK-LABEL: define dso_local void @gep_test
671 ; CHECK-NEXT: Alive: <>
672 %a = alloca %struct.char_array, align 8
673 %b = alloca %struct.char_array, align 8
674 %tobool.not = icmp eq i32 %cond, 0
675 br i1 %tobool.not, label %if.else, label %if.then
677 if.then: ; preds = %entry
679 ; CHECK-NEXT: Alive: <>
680 call void @llvm.lifetime.start.p0(i64 500, ptr nonnull %a)
681 ; CHECK: call void @llvm.lifetime.start.p0(i64 500, ptr nonnull %a)
682 ; CHECK-NEXT: Alive: <a>
683 tail call void @capture8(ptr %a)
684 call void @llvm.lifetime.end.p0(i64 500, ptr nonnull %a)
685 ; CHECK: call void @llvm.lifetime.end.p0(i64 500, ptr nonnull %a)
686 ; CHECK-NEXT: Alive: <>
689 if.else: ; preds = %entry
691 ; CHECK-NEXT: Alive: <>
692 call void @llvm.lifetime.start.p0(i64 500, ptr nonnull %b)
693 ; CHECK: call void @llvm.lifetime.start.p0(i64 500, ptr nonnull %b)
694 ; CHECK-NEXT: Alive: <b>
695 tail call void @capture8(ptr %b)
696 call void @llvm.lifetime.end.p0(i64 500, ptr nonnull %b)
697 ; CHECK: call void @llvm.lifetime.end.p0(i64 500, ptr nonnull %b)
698 ; CHECK-NEXT: Alive: <>
701 if.end: ; preds = %if.else, %if.then
703 ; CHECK-NEXT: Alive: <>
707 define void @if_must(i1 %a) {
708 ; CHECK-LABEL: define void @if_must
711 ; CHECK-NEXT: Alive: <>
712 %x = alloca i8, align 4
713 %y = alloca i8, align 4
715 br i1 %a, label %if.then, label %if.else
716 ; CHECK: br i1 %a, label %if.then, label %if.else
717 ; CHECK-NEXT: Alive: <>
721 ; CHECK-NEXT: Alive: <>
722 call void @llvm.lifetime.start.p0(i64 1, ptr %y)
723 ; CHECK: call void @llvm.lifetime.start.p0(i64 1, ptr %y)
724 ; CHECK-NEXT: Alive: <y>
727 ; CHECK: br label %if.end
728 ; CHECK-NEXT: Alive: <y>
732 ; CHECK-NEXT: Alive: <>
733 call void @llvm.lifetime.start.p0(i64 1, ptr %y)
734 ; CHECK: call void @llvm.lifetime.start.p0(i64 1, ptr %y)
735 ; CHECK-NEXT: Alive: <y>
737 call void @llvm.lifetime.start.p0(i64 1, ptr %x)
738 ; CHECK: call void @llvm.lifetime.start.p0(i64 1, ptr %x)
739 ; CHECK-NEXT: Alive: <x y>
742 ; CHECK: br label %if.end
743 ; CHECK-NEXT: Alive: <x y>
747 ; MAY-NEXT: Alive: <x y>
748 ; MUST-NEXT: Alive: <y>
753 define void @unreachable() {
754 ; CHECK-LABEL: define void @unreachable
757 ; CHECK-NEXT: Alive: <>
758 %x = alloca i8, align 4
759 %y = alloca i8, align 4
761 call void @llvm.lifetime.start.p0(i64 1, ptr %y)
762 ; CHECK: call void @llvm.lifetime.start.p0(i64 1, ptr %y)
763 ; CHECK-NEXT: Alive: <y>
765 call void @llvm.lifetime.start.p0(i64 1, ptr %x)
766 ; CHECK: call void @llvm.lifetime.start.p0(i64 1, ptr %x)
767 ; CHECK-NEXT: Alive: <x y>
770 ; CHECK: br label %end
771 ; CHECK-NEXT: Alive: <x y>
776 call void @llvm.lifetime.start.p0(i64 4, ptr %y)
779 ; CHECK: br label %end
784 ; CHECK-NEXT: Alive: <x y>
789 define void @non_alloca(ptr %p) {
790 ; CHECK-LABEL: define void @non_alloca
793 ; MAY-NEXT: Alive: <x y>
794 ; MUST-NEXT: Alive: <>
795 %x = alloca i8, align 4
796 %y = alloca i8, align 4
798 call void @llvm.lifetime.start.p0(i64 4, ptr %p)
799 ; CHECK: call void @llvm.lifetime.start.p0(i64 4, ptr %p)
800 ; MAY-NEXT: Alive: <x y>
801 ; MUST-NEXT: Alive: <>
803 call void @llvm.lifetime.start.p0(i64 4, ptr %x)
804 ; CHECK: call void @llvm.lifetime.start.p0(i64 4, ptr %x)
805 ; MAY-NEXT: Alive: <x y>
806 ; MUST-NEXT: Alive: <>
808 call void @llvm.lifetime.end.p0(i64 4, ptr %p)
809 ; CHECK: call void @llvm.lifetime.end.p0(i64 4, ptr %p)
810 ; MAY-NEXT: Alive: <x y>
811 ; MUST-NEXT: Alive: <>
816 define void @select_alloca(i1 %v) {
817 ; CHECK-LABEL: define void @select_alloca
820 ; MAY-NEXT: Alive: <x y>
821 ; MUST-NEXT: Alive: <>
822 %x = alloca i8, align 4
823 %y = alloca i8, align 4
824 %cxcy = select i1 %v, ptr %x, ptr %y
826 call void @llvm.lifetime.start.p0(i64 1, ptr %cxcy)
827 ; CHECK: call void @llvm.lifetime.start.p0(i64 1, ptr %cxcy)
828 ; MAY-NEXT: Alive: <x y>
829 ; MUST-NEXT: Alive: <>
831 call void @llvm.lifetime.start.p0(i64 1, ptr %x)
832 ; CHECK: call void @llvm.lifetime.start.p0(i64 1, ptr %x)
833 ; MAY-NEXT: Alive: <x y>
834 ; MUST-NEXT: Alive: <>
836 call void @llvm.lifetime.end.p0(i64 1, ptr %x)
837 ; CHECK: call void @llvm.lifetime.end.p0(i64 1, ptr %x)
838 ; MAY-NEXT: Alive: <x y>
839 ; MUST-NEXT: Alive: <>
844 define void @alloca_offset() {
845 ; CHECK-LABEL: define void @alloca_offset
848 ; MAY-NEXT: Alive: <x>
849 ; MUST-NEXT: Alive: <>
850 %x = alloca [5 x i32], align 4
851 %x2 = getelementptr [5 x i32], ptr %x, i64 0, i64 1
853 call void @llvm.lifetime.start.p0(i64 20, ptr %x2)
854 ; CHECK: call void @llvm.lifetime.start.p0(i64 20, ptr %x2)
855 ; MAY-NEXT: Alive: <x>
856 ; MUST-NEXT: Alive: <>
858 call void @llvm.lifetime.end.p0(i64 20, ptr %x2)
859 ; CHECK: call void @llvm.lifetime.end.p0(i64 20, ptr %x2)
860 ; MAY-NEXT: Alive: <x>
861 ; MUST-NEXT: Alive: <>
866 define void @alloca_size() {
867 ; CHECK-LABEL: define void @alloca_size
870 ; MAY-NEXT: Alive: <x>
871 ; MUST-NEXT: Alive: <>
872 %x = alloca [5 x i32], align 4
874 call void @llvm.lifetime.start.p0(i64 15, ptr %x)
875 ; CHECK: call void @llvm.lifetime.start.p0(i64 15, ptr %x)
876 ; MAY-NEXT: Alive: <x>
877 ; MUST-NEXT: Alive: <>
879 call void @llvm.lifetime.end.p0(i64 15, ptr %x)
880 ; CHECK: call void @llvm.lifetime.end.p0(i64 15, ptr %x)
881 ; MAY-NEXT: Alive: <x>
882 ; MUST-NEXT: Alive: <>
887 define void @multiple_start_end() {
888 ; CHECK-LABEL: define void @multiple_start_end
891 ; CHECK-NEXT: Alive: <>
893 call void @llvm.lifetime.start.p0(i64 1, ptr %x)
894 ; CHECK: call void @llvm.lifetime.start.p0(i64 1, ptr %x)
895 ; CHECK-NEXT: Alive: <x>
897 call void @llvm.lifetime.start.p0(i64 1, ptr %x)
898 ; CHECK: call void @llvm.lifetime.start.p0(i64 1, ptr %x)
899 ; CHECK-NEXT: Alive: <x>
901 call void @llvm.lifetime.end.p0(i64 1, ptr %x)
902 ; CHECK: call void @llvm.lifetime.end.p0(i64 1, ptr %x)
903 ; CHECK-NEXT: Alive: <>
905 call void @llvm.lifetime.end.p0(i64 1, ptr %x)
906 ; CHECK: call void @llvm.lifetime.end.p0(i64 1, ptr %x)
907 ; CHECK-NEXT: Alive: <>
912 define void @if_must1(i1 %a) {
913 ; CHECK-LABEL: define void @if_must1
916 ; CHECK-NEXT: Alive: <>
917 %x = alloca i8, align 4
918 %y = alloca i8, align 4
920 br i1 %a, label %if.then, label %if.else
921 ; CHECK: br i1 %a, label %if.then, label %if.else
922 ; CHECK-NEXT: Alive: <>
926 ; MAY-NEXT: Alive: <x y>
927 ; MUST-NEXT: Alive: <>
928 call void @llvm.lifetime.end.p0(i64 1, ptr %y)
929 ; CHECK: call void @llvm.lifetime.end.p0(i64 1, ptr %y)
930 ; MAY-NEXT: Alive: <x>
931 ; MUST-NEXT: Alive: <>
934 ; CHECK: br label %if.end
935 ; MAY-NEXT: Alive: <x>
936 ; MUST-NEXT: Alive: <>
940 ; CHECK-NEXT: Alive: <>
941 call void @llvm.lifetime.start.p0(i64 1, ptr %y)
942 ; CHECK: call void @llvm.lifetime.start.p0(i64 1, ptr %y)
943 ; CHECK-NEXT: Alive: <y>
945 call void @llvm.lifetime.start.p0(i64 1, ptr %x)
946 ; CHECK: call void @llvm.lifetime.start.p0(i64 1, ptr %x)
947 ; CHECK-NEXT: Alive: <x y>
950 ; CHECK: br label %if.then
951 ; CHECK-NEXT: Alive: <x y>
955 ; MAY-NEXT: Alive: <x>
956 ; MUST-NEXT: Alive: <>
961 define void @if_must2(i1 %a) {
962 ; CHECK-LABEL: define void @if_must2
965 ; CHECK-NEXT: Alive: <>
966 %x = alloca i8, align 4
967 %y = alloca i8, align 4
969 call void @llvm.lifetime.start.p0(i64 1, ptr %x)
970 ; CHECK: call void @llvm.lifetime.start.p0(i64 1, ptr %x)
971 ; CHECK-NEXT: Alive: <x>
973 br i1 %a, label %if.then, label %if.else
974 ; CHECK: br i1 %a, label %if.then, label %if.else
975 ; CHECK-NEXT: Alive: <x>
979 ; MAY-NEXT: Alive: <x>
980 ; MUST-NEXT: Alive: <>
981 call void @llvm.lifetime.start.p0(i64 1, ptr %y)
982 ; CHECK: call void @llvm.lifetime.start.p0(i64 1, ptr %y)
983 ; MAY-NEXT: Alive: <x y>
984 ; MUST-NEXT: Alive: <y>
987 ; CHECK: br label %if.end
988 ; MAY-NEXT: Alive: <x y>
989 ; MUST-NEXT: Alive: <y>
993 ; CHECK-NEXT: Alive: <x>
994 call void @llvm.lifetime.end.p0(i64 1, ptr %y)
995 ; CHECK: call void @llvm.lifetime.end.p0(i64 1, ptr %y)
996 ; CHECK-NEXT: Alive: <x>
998 call void @llvm.lifetime.end.p0(i64 1, ptr %x)
999 ; CHECK: call void @llvm.lifetime.end.p0(i64 1, ptr %x)
1000 ; CHECK-NEXT: Alive: <>
1003 ; CHECK: br label %if.then
1004 ; CHECK-NEXT: Alive: <>
1008 ; MAY-NEXT: Alive: <x y>
1009 ; MUST-NEXT: Alive: <y>
1014 define void @cycle(i1 %a) {
1015 ; CHECK-LABEL: define void @cycle
1018 ; CHECK-NEXT: Alive: <>
1019 %x = alloca i8, align 4
1020 %y = alloca i8, align 4
1022 call void @llvm.lifetime.start.p0(i64 1, ptr %x)
1023 ; CHECK: call void @llvm.lifetime.start.p0(i64 1, ptr %x)
1024 ; CHECK-NEXT: Alive: <x>
1026 br i1 %a, label %if.then, label %if.end
1027 ; CHECK: br i1 %a, label %if.then, label %if.end
1028 ; CHECK-NEXT: Alive: <x>
1032 ; MAY-NEXT: Alive: <x y>
1033 ; MUST-NEXT: Alive: <x>
1034 call void @llvm.lifetime.start.p0(i64 1, ptr %y)
1035 ; CHECK: call void @llvm.lifetime.start.p0(i64 1, ptr %y)
1036 ; CHECK-NEXT: Alive: <x y>
1038 br i1 %a, label %if.then, label %if.end
1039 ; CHECK: br i1 %a, label %if.then, label %if.end
1040 ; CHECK-NEXT: Alive: <x y>
1044 ; MAY-NEXT: Alive: <x y>
1045 ; MUST-NEXT: Alive: <x>
1050 declare void @llvm.lifetime.start.p0(i64, ptr nocapture)
1051 declare void @llvm.lifetime.end.p0(i64, ptr nocapture)
1052 declare void @capture8(ptr)
1053 declare void @capture32(ptr)
1054 declare void @capture64(ptr)
1055 declare void @capture100x32(ptr)