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 %x0 = bitcast i32* %x to i8*
15 %y0 = bitcast i32* %y to i8*
16 %z0 = bitcast i32* %z to i8*
17 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %z0)
18 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 -1, i8* %z0)
19 ; CHECK-NEXT: Alive: <z>
21 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %x0)
22 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 -1, i8* %x0)
23 ; CHECK-NEXT: Alive: <x z>
25 call void @capture32(i32* %x)
26 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %x0)
27 ; CHECK: call void @llvm.lifetime.end.p0i8(i64 -1, i8* %x0)
28 ; CHECK-NEXT: Alive: <z>
30 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %y0)
31 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 -1, i8* %y0)
32 ; CHECK-NEXT: Alive: <y z>
34 call void @capture32(i32* %y)
35 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %y0)
36 ; CHECK: call void @llvm.lifetime.end.p0i8(i64 -1, i8* %y0)
37 ; CHECK-NEXT: Alive: <z>
39 call void @capture32(i32* %z)
40 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %z0)
41 ; CHECK: call void @llvm.lifetime.end.p0i8(i64 -1, i8* %z0)
42 ; CHECK-NEXT: Alive: <>
47 define void @no_markers() {
48 ; CHECK-LABEL: define void @no_markers()
51 ; CHECK-NEXT: Alive: <y>
52 %x = alloca i32, align 4
53 %y = alloca i32, align 4
54 %x0 = bitcast i32* %x to i8*
55 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %x0)
56 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 -1, i8* %x0)
57 ; CHECK-NEXT: Alive: <x y>
59 call void @capture32(i32* %x)
60 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %x0)
61 ; CHECK: call void @llvm.lifetime.end.p0i8(i64 -1, i8* %x0)
62 ; CHECK-NEXT: Alive: <y>
64 call void @capture32(i32* %y)
69 ; CHECK-LABEL: define void @g()
72 ; CHECK-NEXT: Alive: <>
73 %x = alloca i32, align 4
74 %y = alloca i32, align 4
75 %z = alloca i64, align 4
76 %x0 = bitcast i32* %x to i8*
77 %y0 = bitcast i32* %y to i8*
78 %z0 = bitcast i64* %z to i8*
79 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %x0)
80 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 -1, i8* %x0)
81 ; CHECK-NEXT: Alive: <x>
83 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %y0)
84 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 -1, i8* %y0)
85 ; CHECK-NEXT: Alive: <x y>
87 call void @capture32(i32* %x)
88 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %x0)
89 ; CHECK: call void @llvm.lifetime.end.p0i8(i64 -1, i8* %x0)
90 ; CHECK-NEXT: Alive: <y>
92 call void @capture32(i32* %y)
93 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %y0)
94 ; CHECK: call void @llvm.lifetime.end.p0i8(i64 -1, i8* %y0)
95 ; CHECK-NEXT: Alive: <>
97 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %z0)
98 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 -1, i8* %z0)
99 ; CHECK-NEXT: Alive: <z>
101 call void @capture64(i64* %z)
102 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %z0)
103 ; CHECK: call void @llvm.lifetime.end.p0i8(i64 -1, i8* %z0)
104 ; CHECK-NEXT: Alive: <>
108 ; CHECK-NEXT: Alive: <>
112 ; CHECK-LABEL: define void @h()
115 ; CHECK-NEXT: Alive: <>
116 %x = alloca i32, align 16
117 ; CHECK: %x = alloca i32, align 16
118 ; CHECK-NEXT: Alive: <>
119 %z = alloca i64, align 4
120 %y = alloca i32, align 4
121 %x0 = bitcast i32* %x to i8*
122 %y0 = bitcast i32* %y to i8*
123 %z0 = bitcast i64* %z to i8*
124 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %x0)
125 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 -1, i8* %x0)
126 ; CHECK-NEXT: Alive: <x>
128 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %y0)
129 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 -1, i8* %y0)
130 ; CHECK-NEXT: Alive: <x y>
132 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %z0)
133 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 -1, i8* %z0)
134 ; CHECK-NEXT: Alive: <x y z>
136 call void @capture32(i32* %x)
137 call void @capture32(i32* %y)
138 call void @capture64(i64* %z)
139 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %x0)
140 ; CHECK: call void @llvm.lifetime.end.p0i8(i64 -1, i8* %x0)
141 ; CHECK-NEXT: Alive: <y z>
143 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %y0)
144 ; CHECK: call void @llvm.lifetime.end.p0i8(i64 -1, i8* %y0)
145 ; CHECK-NEXT: Alive: <z>
147 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %z0)
148 ; CHECK: call void @llvm.lifetime.end.p0i8(i64 -1, i8* %z0)
149 ; CHECK-NEXT: Alive: <>
154 define void @i(i1 zeroext %a, i1 zeroext %b) {
155 ; CHECK-LABEL: define void @i(i1 zeroext %a, i1 zeroext %b)
158 ; CHECK-NEXT: Alive: <>
159 %x1 = alloca i64, align 8
160 %x2 = alloca i64, align 8
161 %y = alloca i64, align 8
162 %y1 = alloca i64, align 8
163 %y2 = alloca i64, align 8
164 %z = alloca i64, align 8
165 %z1 = alloca i64, align 8
166 %z2 = alloca i64, align 8
167 %0 = bitcast i64* %x1 to i8*
168 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %0)
169 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 -1, i8* %0)
170 ; CHECK-NEXT: Alive: <x1>
172 %1 = bitcast i64* %x2 to i8*
173 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %1)
174 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 -1, i8* %1)
175 ; CHECK-NEXT: Alive: <x1 x2>
177 call void @capture64(i64* nonnull %x1)
178 call void @capture64(i64* nonnull %x2)
179 br i1 %a, label %if.then, label %if.else4
180 ; CHECK: br i1 %a, label %if.then, label %if.else4
181 ; CHECK-NEXT: Alive: <x1 x2>
183 if.then: ; preds = %entry
185 ; CHECK-NEXT: Alive: <x1 x2>
186 %2 = bitcast i64* %y to i8*
187 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %2)
188 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 -1, i8* %2)
189 ; CHECK-NEXT: Alive: <x1 x2 y>
191 call void @capture64(i64* nonnull %y)
192 br i1 %b, label %if.then3, label %if.else
194 if.then3: ; preds = %if.then
196 ; CHECK-NEXT: Alive: <x1 x2 y>
197 %3 = bitcast i64* %y1 to i8*
198 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %3)
199 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 -1, i8* %3)
200 ; CHECK-NEXT: Alive: <x1 x2 y y1>
202 call void @capture64(i64* nonnull %y1)
203 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %3)
204 ; CHECK: call void @llvm.lifetime.end.p0i8(i64 -1, i8* %3)
205 ; CHECK-NEXT: Alive: <x1 x2 y>
209 if.else: ; preds = %if.then
211 ; CHECK-NEXT: Alive: <x1 x2 y>
212 %4 = bitcast i64* %y2 to i8*
213 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %4)
214 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 -1, i8* %4)
215 ; CHECK-NEXT: Alive: <x1 x2 y y2>
217 call void @capture64(i64* nonnull %y2)
218 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %4)
219 ; CHECK: call void @llvm.lifetime.end.p0i8(i64 -1, i8* %4)
220 ; CHECK-NEXT: Alive: <x1 x2 y>
224 if.end: ; preds = %if.else, %if.then3
226 ; CHECK-NEXT: Alive: <x1 x2 y>
227 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %2)
228 ; CHECK: call void @llvm.lifetime.end.p0i8(i64 -1, i8* %2)
229 ; CHECK-NEXT: Alive: <x1 x2>
233 if.else4: ; preds = %entry
235 ; CHECK-NEXT: Alive: <x1 x2>
237 %5 = bitcast i64* %z to i8*
238 ; CHECK: %5 = bitcast i64* %z to i8*
239 ; CHECK-NEXT: Alive: <x1 x2>
241 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %5)
242 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 -1, i8* %5)
243 ; CHECK-NEXT: Alive: <x1 x2 z>
245 call void @capture64(i64* nonnull %z)
246 br i1 %b, label %if.then6, label %if.else7
248 if.then6: ; preds = %if.else4
250 ; CHECK-NEXT: Alive: <x1 x2 z>
251 %6 = bitcast i64* %z1 to i8*
252 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %6)
253 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 -1, i8* %6)
254 ; CHECK-NEXT: Alive: <x1 x2 z z1>
256 call void @capture64(i64* nonnull %z1)
257 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %6)
258 ; CHECK: call void @llvm.lifetime.end.p0i8(i64 -1, i8* %6)
259 ; CHECK-NEXT: Alive: <x1 x2 z>
263 if.else7: ; preds = %if.else4
265 ; CHECK-NEXT: Alive: <x1 x2 z>
266 %7 = bitcast i64* %z2 to i8*
267 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %7)
268 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 -1, i8* %7)
269 ; CHECK-NEXT: Alive: <x1 x2 z z2>
271 call void @capture64(i64* nonnull %z2)
272 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %7)
273 ; CHECK: call void @llvm.lifetime.end.p0i8(i64 -1, i8* %7)
274 ; CHECK-NEXT: Alive: <x1 x2 z>
278 if.end8: ; preds = %if.else7, %if.then6
280 ; CHECK-NEXT: Alive: <x1 x2 z>
281 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %5)
282 ; CHECK: call void @llvm.lifetime.end.p0i8(i64 -1, i8* %5)
283 ; CHECK-NEXT: Alive: <x1 x2>
287 if.end9: ; preds = %if.end8, %if.end
289 ; CHECK-NEXT: Alive: <x1 x2>
290 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %1)
291 ; CHECK: call void @llvm.lifetime.end.p0i8(i64 -1, i8* %1)
292 ; CHECK-NEXT: Alive: <x1>
294 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %0)
295 ; CHECK: call void @llvm.lifetime.end.p0i8(i64 -1, i8* %0)
296 ; CHECK-NEXT: Alive: <>
301 define void @no_merge1(i1 %d) {
302 ; CHECK-LABEL: define void @no_merge1(i1 %d)
305 ; CHECK-NEXT: Alive: <>
306 %x = alloca i32, align 4
307 %y = alloca i32, align 4
308 %x0 = bitcast i32* %x to i8*
309 %y0 = bitcast i32* %y to i8*
310 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %x0)
311 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 -1, i8* %x0)
312 ; CHECK-NEXT: Alive: <x>
314 call void @capture32(i32* %x)
315 br i1 %d, label %bb2, label %bb3
317 bb2: ; preds = %entry
319 ; CHECK-NEXT: Alive: <x>
320 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %y0)
321 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 -1, i8* %y0)
322 ; CHECK-NEXT: Alive: <x y>
324 call void @capture32(i32* %y)
325 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %y0)
326 ; CHECK: call void @llvm.lifetime.end.p0i8(i64 -1, i8* %y0)
327 ; CHECK-NEXT: Alive: <x>
329 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %x0)
330 ; CHECK: call void @llvm.lifetime.end.p0i8(i64 -1, i8* %x0)
331 ; CHECK-NEXT: Alive: <>
335 bb3: ; preds = %entry
337 ; CHECK-NEXT: Alive: <x>
338 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %x0)
339 ; CHECK: call void @llvm.lifetime.end.p0i8(i64 -1, i8* %x0)
340 ; CHECK-NEXT: Alive: <>
345 define void @merge1(i1 %d) {
346 ; CHECK-LABEL: define void @merge1(i1 %d)
349 ; CHECK-NEXT: Alive: <>
350 %x = alloca i32, align 4
351 %y = alloca i32, align 4
352 %x0 = bitcast i32* %x to i8*
353 %y0 = bitcast i32* %y to i8*
354 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %x0)
355 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 -1, i8* %x0)
356 ; CHECK-NEXT: Alive: <x>
358 call void @capture32(i32* %x)
359 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %x0)
360 ; CHECK: call void @llvm.lifetime.end.p0i8(i64 -1, i8* %x0)
361 ; CHECK-NEXT: Alive: <>
363 br i1 %d, label %bb2, label %bb3
365 bb2: ; preds = %entry
367 ; CHECK-NEXT: Alive: <>
368 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %y0)
369 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 -1, i8* %y0)
370 ; CHECK-NEXT: Alive: <y>
372 call void @capture32(i32* %y)
373 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %y0)
374 ; CHECK: call void @llvm.lifetime.end.p0i8(i64 -1, i8* %y0)
375 ; CHECK-NEXT: Alive: <>
379 bb3: ; preds = %entry
381 ; CHECK-NEXT: Alive: <>
385 define void @merge2_noend(i1 %d) {
386 ; CHECK-LABEL: define void @merge2_noend(i1 %d)
389 ; CHECK-NEXT: Alive: <>
390 %x = alloca i32, align 4
391 %y = alloca i32, align 4
392 %x0 = bitcast i32* %x to i8*
393 %y0 = bitcast i32* %y to i8*
394 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %x0)
395 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 -1, i8* %x0)
396 ; CHECK-NEXT: Alive: <x>
398 call void @capture32(i32* %x)
399 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %x0)
400 ; CHECK: call void @llvm.lifetime.end.p0i8(i64 -1, i8* %x0)
401 ; CHECK-NEXT: Alive: <>
403 br i1 %d, label %bb2, label %bb3
405 bb2: ; preds = %entry
407 ; CHECK-NEXT: Alive: <>
408 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %y0)
409 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 -1, i8* %y0)
410 ; CHECK-NEXT: Alive: <y>
412 call void @capture32(i32* %y)
415 bb3: ; preds = %entry
417 ; CHECK-NEXT: Alive: <>
421 define void @merge3_noend(i1 %d) {
422 ; CHECK-LABEL: define void @merge3_noend(i1 %d)
425 ; CHECK-NEXT: Alive: <>
426 %x = alloca i32, align 4
427 %y = alloca i32, align 4
428 %x0 = bitcast i32* %x to i8*
429 %y0 = bitcast i32* %y to i8*
430 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %x0)
431 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 -1, i8* %x0)
432 ; CHECK-NEXT: Alive: <x>
434 call void @capture32(i32* %x)
435 br i1 %d, label %bb2, label %bb3
437 bb2: ; preds = %entry
439 ; CHECK-NEXT: Alive: <x>
440 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %x0)
441 ; CHECK: call void @llvm.lifetime.end.p0i8(i64 -1, i8* %x0)
442 ; CHECK-NEXT: Alive: <>
444 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %y0)
445 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 -1, i8* %y0)
446 ; CHECK-NEXT: Alive: <y>
448 call void @capture32(i32* %y)
451 bb3: ; preds = %entry
453 ; CHECK-NEXT: Alive: <x>
457 define void @nomerge4_nostart(i1 %d) {
458 ; CHECK-LABEL: define void @nomerge4_nostart(i1 %d)
461 ; CHECK-NEXT: Alive: <x>
462 %x = alloca i32, align 4
463 %y = alloca i32, align 4
464 %x0 = bitcast i32* %x to i8*
465 %y0 = bitcast i32* %y to i8*
466 call void @capture32(i32* %x)
467 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %x0)
468 ; CHECK: call void @llvm.lifetime.end.p0i8(i64 -1, i8* %x0)
469 ; CHECK-NEXT: Alive: <x>
471 br i1 %d, label %bb2, label %bb3
473 bb2: ; preds = %entry
475 ; CHECK-NEXT: Alive: <x>
476 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %y0)
477 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 -1, i8* %y0)
478 ; CHECK-NEXT: Alive: <x y>
480 call void @capture32(i32* %y)
483 bb3: ; preds = %entry
485 ; CHECK-NEXT: Alive: <x>
489 define void @array_merge() {
490 ; CHECK-LABEL: define void @array_merge()
493 ; CHECK-NEXT: Alive: <>
494 %A.i1 = alloca [100 x i32], align 4
495 %B.i2 = alloca [100 x i32], align 4
496 %A.i = alloca [100 x i32], align 4
497 %B.i = alloca [100 x i32], align 4
498 %0 = bitcast [100 x i32]* %A.i to i8*
499 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %0)
500 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 -1, i8* %0)
501 ; CHECK-NEXT: Alive: <A.i>
503 %1 = bitcast [100 x i32]* %B.i to i8*
504 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %1)
505 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 -1, i8* %1)
506 ; CHECK-NEXT: Alive: <A.i B.i>
508 call void @capture100x32([100 x i32]* %A.i)
509 ; CHECK: call void @capture100x32([100 x i32]* %A.i)
510 ; CHECK-NEXT: Alive: <A.i B.i>
512 call void @capture100x32([100 x i32]* %B.i)
513 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %0)
514 ; CHECK: call void @llvm.lifetime.end.p0i8(i64 -1, i8* %0)
515 ; CHECK-NEXT: Alive: <B.i>
517 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %1)
518 ; CHECK: call void @llvm.lifetime.end.p0i8(i64 -1, i8* %1)
519 ; CHECK-NEXT: Alive: <>
521 %2 = bitcast [100 x i32]* %A.i1 to i8*
522 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %2)
523 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 -1, i8* %2)
524 ; CHECK-NEXT: Alive: <A.i1>
526 %3 = bitcast [100 x i32]* %B.i2 to i8*
527 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %3)
528 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 -1, i8* %3)
529 ; CHECK-NEXT: Alive: <A.i1 B.i2>
531 call void @capture100x32([100 x i32]* %A.i1)
532 call void @capture100x32([100 x i32]* %B.i2)
533 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %2)
534 ; CHECK: call void @llvm.lifetime.end.p0i8(i64 -1, i8* %2)
535 ; CHECK-NEXT: Alive: <B.i2>
537 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %3)
538 ; CHECK: call void @llvm.lifetime.end.p0i8(i64 -1, i8* %3)
539 ; CHECK-NEXT: Alive: <>
544 define void @myCall_pr15707() {
545 ; CHECK-LABEL: define void @myCall_pr15707()
548 ; CHECK-NEXT: Alive: <>
549 %buf1 = alloca i8, i32 100000, align 16
550 %buf2 = alloca i8, i32 100000, align 16
551 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %buf1)
552 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 -1, i8* %buf1)
553 ; CHECK-NEXT: Alive: <buf1>
555 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %buf1)
556 ; CHECK: call void @llvm.lifetime.end.p0i8(i64 -1, i8* %buf1)
557 ; CHECK-NEXT: Alive: <>
559 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %buf1)
560 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 -1, i8* %buf1)
561 ; CHECK-NEXT: Alive: <buf1>
563 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %buf2)
564 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 -1, i8* %buf2)
565 ; CHECK-NEXT: Alive: <buf1 buf2>
567 call void @capture8(i8* %buf1)
568 call void @capture8(i8* %buf2)
572 define void @bad_range() {
573 ; CHECK-LABEL: define void @bad_range()
576 ; CHECK-NEXT: Alive: <A.i1 B.i2>
577 %A.i1 = alloca [100 x i32], align 4
578 %B.i2 = alloca [100 x i32], align 4
579 %A.i = alloca [100 x i32], align 4
580 %B.i = alloca [100 x i32], align 4
581 %0 = bitcast [100 x i32]* %A.i to i8*
582 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %0)
583 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 -1, i8* %0)
584 ; CHECK-NEXT: Alive: <A.i A.i1 B.i2>
586 %1 = bitcast [100 x i32]* %B.i to i8*
587 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %1)
588 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 -1, i8* %1)
589 ; CHECK-NEXT: Alive: <A.i A.i1 B.i B.i2>
591 call void @capture100x32([100 x i32]* %A.i)
592 call void @capture100x32([100 x i32]* %B.i)
593 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %0)
594 ; CHECK: call void @llvm.lifetime.end.p0i8(i64 -1, i8* %0)
595 ; CHECK-NEXT: Alive: <A.i1 B.i B.i2>
597 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %1)
598 ; CHECK: call void @llvm.lifetime.end.p0i8(i64 -1, i8* %1)
599 ; CHECK-NEXT: Alive: <A.i1 B.i2>
603 block2: ; preds = %entry
605 ; CHECK-NEXT: Alive: <A.i1 B.i2>
606 call void @capture100x32([100 x i32]* %A.i)
607 call void @capture100x32([100 x i32]* %B.i)
611 %struct.Klass = type { i32, i32 }
613 define i32 @shady_range(i32 %argc, i8** nocapture %argv) {
614 ; CHECK-LABEL: define i32 @shady_range(i32 %argc, i8** nocapture %argv)
617 ; CHECK-NEXT: Alive: <>
618 %a.i = alloca [4 x %struct.Klass], align 16
619 %b.i = alloca [4 x %struct.Klass], align 16
620 %a8 = bitcast [4 x %struct.Klass]* %a.i to i8*
621 %b8 = bitcast [4 x %struct.Klass]* %b.i to i8*
622 %z2 = getelementptr inbounds [4 x %struct.Klass], [4 x %struct.Klass]* %a.i, i64 0, i64 0, i32 0
623 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %a8)
624 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 -1, i8* %a8)
625 ; CHECK-NEXT: Alive: <a.i>
627 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %b8)
628 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 -1, i8* %b8)
629 ; CHECK-NEXT: Alive: <a.i b.i>
631 call void @capture8(i8* %a8)
632 call void @capture8(i8* %b8)
633 %z3 = load i32, i32* %z2, align 16
634 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %a8)
635 ; CHECK: call void @llvm.lifetime.end.p0i8(i64 -1, i8* %a8)
636 ; CHECK-NEXT: Alive: <b.i>
638 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %b8)
639 ; CHECK: call void @llvm.lifetime.end.p0i8(i64 -1, i8* %b8)
640 ; CHECK-NEXT: Alive: <>
645 define void @end_loop() {
646 ; CHECK-LABEL: define void @end_loop()
649 ; CHECK-NEXT: Alive: <>
650 %x = alloca i8, align 4
651 call void @llvm.lifetime.start.p0i8(i64 1, i8* %x)
652 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 1, i8* %x)
653 ; CHECK-NEXT: Alive: <x>
657 l2: ; preds = %l2, %entry
659 ; MAY-NEXT: Alive: <x>
660 ; MUST-NEXT: Alive: <>
661 call void @capture8(i8* %x)
662 call void @llvm.lifetime.end.p0i8(i64 1, i8* %x)
663 ; CHECK: call void @llvm.lifetime.end.p0i8(i64 1, i8* %x)
664 ; CHECK-NEXT: Alive: <>
669 define void @start_loop() {
670 ; CHECK-LABEL: define void @start_loop()
673 ; CHECK-NEXT: Alive: <>
674 %x = alloca i8, align 4
675 %y = alloca i8, align 4
676 call void @llvm.lifetime.start.p0i8(i64 1, i8* %x)
677 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 1, i8* %x)
678 ; CHECK-NEXT: Alive: <x>
682 l2: ; preds = %l2, %entry
684 ; CHECK-NEXT: Alive: <x>
685 call void @llvm.lifetime.start.p0i8(i64 1, i8* %y)
686 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 1, i8* %y)
687 ; CHECK-NEXT: Alive: <x y>
689 call void @capture8(i8* %y)
690 call void @llvm.lifetime.end.p0i8(i64 1, i8* %y)
691 ; CHECK: call void @llvm.lifetime.end.p0i8(i64 1, i8* %y)
692 ; CHECK-NEXT: Alive: <x>
694 call void @llvm.lifetime.start.p0i8(i64 1, i8* %x)
695 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 1, i8* %x)
696 ; CHECK-NEXT: Alive: <x>
698 call void @capture8(i8* %x)
702 %struct.char_array = type { [500 x i8] }
704 define dso_local void @gep_test(i32 %cond) {
705 ; CHECK-LABEL: define dso_local void @gep_test
708 ; CHECK-NEXT: Alive: <>
709 %a = alloca %struct.char_array, align 8
710 %b = alloca %struct.char_array, align 8
711 %tobool.not = icmp eq i32 %cond, 0
712 br i1 %tobool.not, label %if.else, label %if.then
714 if.then: ; preds = %entry
716 ; CHECK-NEXT: Alive: <>
717 %0 = getelementptr inbounds %struct.char_array, %struct.char_array* %a, i64 0, i32 0, i64 0
718 call void @llvm.lifetime.start.p0i8(i64 500, i8* nonnull %0)
719 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 500, i8* nonnull %0)
720 ; CHECK-NEXT: Alive: <a>
721 tail call void @capture8(i8* %0)
722 call void @llvm.lifetime.end.p0i8(i64 500, i8* nonnull %0)
723 ; CHECK: call void @llvm.lifetime.end.p0i8(i64 500, i8* nonnull %0)
724 ; CHECK-NEXT: Alive: <>
727 if.else: ; preds = %entry
729 ; CHECK-NEXT: Alive: <>
730 %1 = getelementptr inbounds %struct.char_array, %struct.char_array* %b, i64 0, i32 0, i64 0
731 call void @llvm.lifetime.start.p0i8(i64 500, i8* nonnull %1)
732 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 500, i8* nonnull %1)
733 ; CHECK-NEXT: Alive: <b>
734 tail call void @capture8(i8* %1)
735 call void @llvm.lifetime.end.p0i8(i64 500, i8* nonnull %1)
736 ; CHECK: call void @llvm.lifetime.end.p0i8(i64 500, i8* nonnull %1)
737 ; CHECK-NEXT: Alive: <>
740 if.end: ; preds = %if.else, %if.then
742 ; CHECK-NEXT: Alive: <>
746 define void @if_must(i1 %a) {
747 ; CHECK-LABEL: define void @if_must
750 ; CHECK-NEXT: Alive: <>
751 %x = alloca i8, align 4
752 %y = alloca i8, align 4
754 br i1 %a, label %if.then, label %if.else
755 ; CHECK: br i1 %a, label %if.then, label %if.else
756 ; CHECK-NEXT: Alive: <>
760 ; CHECK-NEXT: Alive: <>
761 call void @llvm.lifetime.start.p0i8(i64 1, i8* %y)
762 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 1, i8* %y)
763 ; CHECK-NEXT: Alive: <y>
766 ; CHECK: br label %if.end
767 ; CHECK-NEXT: Alive: <y>
771 ; CHECK-NEXT: Alive: <>
772 call void @llvm.lifetime.start.p0i8(i64 1, i8* %y)
773 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 1, i8* %y)
774 ; CHECK-NEXT: Alive: <y>
776 call void @llvm.lifetime.start.p0i8(i64 1, i8* %x)
777 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 1, i8* %x)
778 ; CHECK-NEXT: Alive: <x y>
781 ; CHECK: br label %if.end
782 ; CHECK-NEXT: Alive: <x y>
786 ; MAY-NEXT: Alive: <x y>
787 ; MUST-NEXT: Alive: <y>
792 define void @unreachable() {
793 ; CHECK-LABEL: define void @unreachable
796 ; CHECK-NEXT: Alive: <>
797 %x = alloca i8, align 4
798 %y = alloca i8, align 4
800 call void @llvm.lifetime.start.p0i8(i64 1, i8* %y)
801 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 1, i8* %y)
802 ; CHECK-NEXT: Alive: <y>
804 call void @llvm.lifetime.start.p0i8(i64 1, i8* %x)
805 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 1, i8* %x)
806 ; CHECK-NEXT: Alive: <x y>
809 ; CHECK: br label %end
810 ; CHECK-NEXT: Alive: <x y>
815 call void @llvm.lifetime.start.p0i8(i64 4, i8* %y)
818 ; CHECK: br label %end
823 ; CHECK-NEXT: Alive: <x y>
828 define void @non_alloca(i8* %p) {
829 ; CHECK-LABEL: define void @non_alloca
832 ; MAY-NEXT: Alive: <x y>
833 ; MUST-NEXT: Alive: <>
834 %x = alloca i8, align 4
835 %y = alloca i8, align 4
837 call void @llvm.lifetime.start.p0i8(i64 4, i8* %p)
838 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 4, i8* %p)
839 ; MAY-NEXT: Alive: <x y>
840 ; MUST-NEXT: Alive: <>
842 call void @llvm.lifetime.start.p0i8(i64 4, i8* %x)
843 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 4, i8* %x)
844 ; MAY-NEXT: Alive: <x y>
845 ; MUST-NEXT: Alive: <>
847 call void @llvm.lifetime.end.p0i8(i64 4, i8* %p)
848 ; CHECK: call void @llvm.lifetime.end.p0i8(i64 4, i8* %p)
849 ; MAY-NEXT: Alive: <x y>
850 ; MUST-NEXT: Alive: <>
855 define void @select_alloca(i1 %v) {
856 ; CHECK-LABEL: define void @select_alloca
859 ; MAY-NEXT: Alive: <x y>
860 ; MUST-NEXT: Alive: <>
861 %x = alloca i8, align 4
862 %y = alloca i8, align 4
863 %cxcy = select i1 %v, i8* %x, i8* %y
865 call void @llvm.lifetime.start.p0i8(i64 1, i8* %cxcy)
866 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 1, i8* %cxcy)
867 ; MAY-NEXT: Alive: <x y>
868 ; MUST-NEXT: Alive: <>
870 call void @llvm.lifetime.start.p0i8(i64 1, i8* %x)
871 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 1, i8* %x)
872 ; MAY-NEXT: Alive: <x y>
873 ; MUST-NEXT: Alive: <>
875 call void @llvm.lifetime.end.p0i8(i64 1, i8* %x)
876 ; CHECK: call void @llvm.lifetime.end.p0i8(i64 1, i8* %x)
877 ; MAY-NEXT: Alive: <x y>
878 ; MUST-NEXT: Alive: <>
883 define void @alloca_offset() {
884 ; CHECK-LABEL: define void @alloca_offset
887 ; MAY-NEXT: Alive: <x>
888 ; MUST-NEXT: Alive: <>
889 %x = alloca [5 x i32], align 4
890 %x2 = getelementptr [5 x i32], [5 x i32]* %x, i64 0, i64 1
892 call void @llvm.lifetime.start.p0i32(i64 20, i32* %x2)
893 ; CHECK: call void @llvm.lifetime.start.p0i32(i64 20, i32* %x2)
894 ; MAY-NEXT: Alive: <x>
895 ; MUST-NEXT: Alive: <>
897 call void @llvm.lifetime.end.p0i32(i64 20, i32* %x2)
898 ; CHECK: call void @llvm.lifetime.end.p0i32(i64 20, i32* %x2)
899 ; MAY-NEXT: Alive: <x>
900 ; MUST-NEXT: Alive: <>
905 define void @alloca_size() {
906 ; CHECK-LABEL: define void @alloca_size
909 ; MAY-NEXT: Alive: <x>
910 ; MUST-NEXT: Alive: <>
911 %x = alloca [5 x i32], align 4
912 %x2 = getelementptr [5 x i32], [5 x i32]* %x, i64 0, i64 0
914 call void @llvm.lifetime.start.p0i32(i64 15, i32* %x2)
915 ; CHECK: call void @llvm.lifetime.start.p0i32(i64 15, i32* %x2)
916 ; MAY-NEXT: Alive: <x>
917 ; MUST-NEXT: Alive: <>
919 call void @llvm.lifetime.end.p0i32(i64 15, i32* %x2)
920 ; CHECK: call void @llvm.lifetime.end.p0i32(i64 15, i32* %x2)
921 ; MAY-NEXT: Alive: <x>
922 ; MUST-NEXT: Alive: <>
927 define void @multiple_start_end() {
928 ; CHECK-LABEL: define void @multiple_start_end
931 ; CHECK-NEXT: Alive: <>
933 call void @llvm.lifetime.start.p0i8(i64 1, i8* %x)
934 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 1, i8* %x)
935 ; CHECK-NEXT: Alive: <x>
937 call void @llvm.lifetime.start.p0i8(i64 1, i8* %x)
938 ; CHECK: call void @llvm.lifetime.start.p0i8(i64 1, i8* %x)
939 ; CHECK-NEXT: Alive: <x>
941 call void @llvm.lifetime.end.p0i8(i64 1, i8* %x)
942 ; CHECK: call void @llvm.lifetime.end.p0i8(i64 1, i8* %x)
943 ; CHECK-NEXT: Alive: <>
945 call void @llvm.lifetime.end.p0i8(i64 1, i8* %x)
946 ; CHECK: call void @llvm.lifetime.end.p0i8(i64 1, i8* %x)
947 ; CHECK-NEXT: Alive: <>
952 declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture)
953 declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture)
954 declare void @llvm.lifetime.start.p0i32(i64, i32* nocapture)
955 declare void @llvm.lifetime.end.p0i32(i64, i32* nocapture)
956 declare void @capture8(i8*)
957 declare void @capture32(i32*)
958 declare void @capture64(i64*)
959 declare void @capture100x32([100 x i32]*)