• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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=true  < %s | FileCheck %s --check-prefix=NOCOLOR --check-prefix=CHECK
3
4target 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"
5target triple = "x86_64-apple-macosx10.8.0"
6
7;CHECK-LABEL: myCall_w2:
8;YESCOLOR: subq  $144, %rsp
9;NOCOLOR: subq  $272, %rsp
10
11define i32 @myCall_w2(i32 %in) {
12entry:
13  %a = alloca [17 x i8*], align 8
14  %a2 = alloca [16 x i8*], align 8
15  %b = bitcast [17 x i8*]* %a to i8*
16  %b2 = bitcast [16 x i8*]* %a2 to i8*
17  call void @llvm.lifetime.start(i64 -1, i8* %b)
18  %t1 = call i32 @foo(i32 %in, i8* %b)
19  %t2 = call i32 @foo(i32 %in, i8* %b)
20  call void @llvm.lifetime.end(i64 -1, i8* %b)
21  call void @llvm.lifetime.start(i64 -1, i8* %b2)
22  %t3 = call i32 @foo(i32 %in, i8* %b2)
23  %t4 = call i32 @foo(i32 %in, i8* %b2)
24  call void @llvm.lifetime.end(i64 -1, i8* %b2)
25  %t5 = add i32 %t1, %t2
26  %t6 = add i32 %t3, %t4
27  %t7 = add i32 %t5, %t6
28  ret i32 %t7
29}
30
31
32;CHECK-LABEL: myCall2_no_merge
33;YESCOLOR: subq  $272, %rsp
34;NOCOLOR: subq  $272, %rsp
35
36define i32 @myCall2_no_merge(i32 %in, i1 %d) {
37entry:
38  %a = alloca [17 x i8*], align 8
39  %a2 = alloca [16 x i8*], align 8
40  %b = bitcast [17 x i8*]* %a to i8*
41  %b2 = bitcast [16 x i8*]* %a2 to i8*
42  call void @llvm.lifetime.start(i64 -1, i8* %b)
43  %t1 = call i32 @foo(i32 %in, i8* %b)
44  %t2 = call i32 @foo(i32 %in, i8* %b)
45  br i1 %d, label %bb2, label %bb3
46bb2:
47  call void @llvm.lifetime.start(i64 -1, i8* %b2)
48  %t3 = call i32 @foo(i32 %in, i8* %b2)
49  %t4 = call i32 @foo(i32 %in, i8* %b2)
50  call void @llvm.lifetime.end(i64 -1, i8* %b2)
51  %t5 = add i32 %t1, %t2
52  %t6 = add i32 %t3, %t4
53  %t7 = add i32 %t5, %t6
54  call void @llvm.lifetime.end(i64 -1, i8* %b)
55  ret i32 %t7
56bb3:
57  call void @llvm.lifetime.end(i64 -1, i8* %b)
58  ret i32 0
59}
60
61;CHECK-LABEL: myCall2_w2
62;YESCOLOR: subq  $144, %rsp
63;NOCOLOR: subq  $272, %rsp
64
65define i32 @myCall2_w2(i32 %in, i1 %d) {
66entry:
67  %a = alloca [17 x i8*], align 8
68  %a2 = alloca [16 x i8*], align 8
69  %b = bitcast [17 x i8*]* %a to i8*
70  %b2 = bitcast [16 x i8*]* %a2 to i8*
71  call void @llvm.lifetime.start(i64 -1, i8* %b)
72  %t1 = call i32 @foo(i32 %in, i8* %b)
73  %t2 = call i32 @foo(i32 %in, i8* %b)
74  call void @llvm.lifetime.end(i64 -1, i8* %b)
75  br i1 %d, label %bb2, label %bb3
76bb2:
77  call void @llvm.lifetime.start(i64 -1, i8* %b2)
78  %t3 = call i32 @foo(i32 %in, i8* %b2)
79  %t4 = call i32 @foo(i32 %in, i8* %b2)
80  call void @llvm.lifetime.end(i64 -1, i8* %b2)
81  %t5 = add i32 %t1, %t2
82  %t6 = add i32 %t3, %t4
83  %t7 = add i32 %t5, %t6
84  ret i32 %t7
85bb3:
86  ret i32 0
87}
88
89;CHECK-LABEL: myCall_w4:
90;YESCOLOR: subq  $200, %rsp
91;NOCOLOR: subq  $408, %rsp
92
93define i32 @myCall_w4(i32 %in) {
94entry:
95  %a1 = alloca [14 x i8*], align 8
96  %a2 = alloca [13 x i8*], align 8
97  %a3 = alloca [12 x i8*], align 8
98  %a4 = alloca [11 x i8*], align 8
99  %b1 = bitcast [14 x i8*]* %a1 to i8*
100  %b2 = bitcast [13 x i8*]* %a2 to i8*
101  %b3 = bitcast [12 x i8*]* %a3 to i8*
102  %b4 = bitcast [11 x i8*]* %a4 to i8*
103  call void @llvm.lifetime.start(i64 -1, i8* %b4)
104  call void @llvm.lifetime.start(i64 -1, i8* %b1)
105  %t1 = call i32 @foo(i32 %in, i8* %b1)
106  %t2 = call i32 @foo(i32 %in, i8* %b1)
107  call void @llvm.lifetime.end(i64 -1, i8* %b1)
108  call void @llvm.lifetime.start(i64 -1, i8* %b2)
109  %t9 = call i32 @foo(i32 %in, i8* %b2)
110  %t8 = call i32 @foo(i32 %in, i8* %b2)
111  call void @llvm.lifetime.end(i64 -1, i8* %b2)
112  call void @llvm.lifetime.start(i64 -1, i8* %b3)
113  %t3 = call i32 @foo(i32 %in, i8* %b3)
114  %t4 = call i32 @foo(i32 %in, i8* %b3)
115  call void @llvm.lifetime.end(i64 -1, i8* %b3)
116  %t11 = call i32 @foo(i32 %in, i8* %b4)
117  call void @llvm.lifetime.end(i64 -1, i8* %b4)
118  %t5 = add i32 %t1, %t2
119  %t6 = add i32 %t3, %t4
120  %t7 = add i32 %t5, %t6
121  ret i32 %t7
122}
123
124;CHECK-LABEL: myCall2_w4:
125;YESCOLOR: subq  $112, %rsp
126;NOCOLOR: subq  $400, %rsp
127
128define i32 @myCall2_w4(i32 %in) {
129entry:
130  %a1 = alloca [14 x i8*], align 8
131  %a2 = alloca [13 x i8*], align 8
132  %a3 = alloca [12 x i8*], align 8
133  %a4 = alloca [11 x i8*], align 8
134  %b1 = bitcast [14 x i8*]* %a1 to i8*
135  %b2 = bitcast [13 x i8*]* %a2 to i8*
136  %b3 = bitcast [12 x i8*]* %a3 to i8*
137  %b4 = bitcast [11 x i8*]* %a4 to i8*
138  call void @llvm.lifetime.start(i64 -1, i8* %b1)
139  %t1 = call i32 @foo(i32 %in, i8* %b1)
140  %t2 = call i32 @foo(i32 %in, i8* %b1)
141  call void @llvm.lifetime.end(i64 -1, i8* %b1)
142  call void @llvm.lifetime.start(i64 -1, i8* %b2)
143  %t9 = call i32 @foo(i32 %in, i8* %b2)
144  %t8 = call i32 @foo(i32 %in, i8* %b2)
145  call void @llvm.lifetime.end(i64 -1, i8* %b2)
146  call void @llvm.lifetime.start(i64 -1, i8* %b3)
147  %t3 = call i32 @foo(i32 %in, i8* %b3)
148  %t4 = call i32 @foo(i32 %in, i8* %b3)
149  call void @llvm.lifetime.end(i64 -1, i8* %b3)
150  br i1 undef, label %bb2, label %bb3
151bb2:
152  call void @llvm.lifetime.start(i64 -1, i8* %b4)
153  %t11 = call i32 @foo(i32 %in, i8* %b4)
154  call void @llvm.lifetime.end(i64 -1, i8* %b4)
155  %t5 = add i32 %t1, %t2
156  %t6 = add i32 %t3, %t4
157  %t7 = add i32 %t5, %t6
158  ret i32 %t7
159bb3:
160  ret i32 0
161}
162
163
164;CHECK-LABEL: myCall2_noend:
165;YESCOLOR: subq  $144, %rsp
166;NOCOLOR: subq  $272, %rsp
167
168
169define i32 @myCall2_noend(i32 %in, i1 %d) {
170entry:
171  %a = alloca [17 x i8*], align 8
172  %a2 = alloca [16 x i8*], align 8
173  %b = bitcast [17 x i8*]* %a to i8*
174  %b2 = bitcast [16 x i8*]* %a2 to i8*
175  call void @llvm.lifetime.start(i64 -1, i8* %b)
176  %t1 = call i32 @foo(i32 %in, i8* %b)
177  %t2 = call i32 @foo(i32 %in, i8* %b)
178  call void @llvm.lifetime.end(i64 -1, i8* %b)
179  br i1 %d, label %bb2, label %bb3
180bb2:
181  call void @llvm.lifetime.start(i64 -1, i8* %b2)
182  %t3 = call i32 @foo(i32 %in, i8* %b2)
183  %t4 = call i32 @foo(i32 %in, i8* %b2)
184  %t5 = add i32 %t1, %t2
185  %t6 = add i32 %t3, %t4
186  %t7 = add i32 %t5, %t6
187  ret i32 %t7
188bb3:
189  ret i32 0
190}
191
192;CHECK-LABEL: myCall2_noend2:
193;YESCOLOR: subq  $144, %rsp
194;NOCOLOR: subq  $272, %rsp
195define i32 @myCall2_noend2(i32 %in, i1 %d) {
196entry:
197  %a = alloca [17 x i8*], align 8
198  %a2 = alloca [16 x i8*], align 8
199  %b = bitcast [17 x i8*]* %a to i8*
200  %b2 = bitcast [16 x i8*]* %a2 to i8*
201  call void @llvm.lifetime.start(i64 -1, i8* %b)
202  %t1 = call i32 @foo(i32 %in, i8* %b)
203  %t2 = call i32 @foo(i32 %in, i8* %b)
204  br i1 %d, label %bb2, label %bb3
205bb2:
206  call void @llvm.lifetime.end(i64 -1, i8* %b)
207  call void @llvm.lifetime.start(i64 -1, i8* %b2)
208  %t3 = call i32 @foo(i32 %in, i8* %b2)
209  %t4 = call i32 @foo(i32 %in, i8* %b2)
210  %t5 = add i32 %t1, %t2
211  %t6 = add i32 %t3, %t4
212  %t7 = add i32 %t5, %t6
213  ret i32 %t7
214bb3:
215  ret i32 0
216}
217
218
219;CHECK-LABEL: myCall2_nostart:
220;YESCOLOR: subq  $144, %rsp
221;NOCOLOR: subq  $272, %rsp
222define i32 @myCall2_nostart(i32 %in, i1 %d) {
223entry:
224  %a = alloca [17 x i8*], align 8
225  %a2 = alloca [16 x i8*], align 8
226  %b = bitcast [17 x i8*]* %a to i8*
227  %b2 = bitcast [16 x i8*]* %a2 to i8*
228  %t1 = call i32 @foo(i32 %in, i8* %b)
229  %t2 = call i32 @foo(i32 %in, i8* %b)
230  call void @llvm.lifetime.end(i64 -1, i8* %b)
231  br i1 %d, label %bb2, label %bb3
232bb2:
233  call void @llvm.lifetime.start(i64 -1, i8* %b2)
234  %t3 = call i32 @foo(i32 %in, i8* %b2)
235  %t4 = call i32 @foo(i32 %in, i8* %b2)
236  %t5 = add i32 %t1, %t2
237  %t6 = add i32 %t3, %t4
238  %t7 = add i32 %t5, %t6
239  ret i32 %t7
240bb3:
241  ret i32 0
242}
243
244; Adopt the test from Transforms/Inline/array_merge.ll'
245;CHECK-LABEL: array_merge:
246;YESCOLOR: subq  $816, %rsp
247;NOCOLOR: subq  $1616, %rsp
248define void @array_merge() nounwind ssp {
249entry:
250  %A.i1 = alloca [100 x i32], align 4
251  %B.i2 = alloca [100 x i32], align 4
252  %A.i = alloca [100 x i32], align 4
253  %B.i = alloca [100 x i32], align 4
254  %0 = bitcast [100 x i32]* %A.i to i8*
255  call void @llvm.lifetime.start(i64 -1, i8* %0) nounwind
256  %1 = bitcast [100 x i32]* %B.i to i8*
257  call void @llvm.lifetime.start(i64 -1, i8* %1) nounwind
258  call void @bar([100 x i32]* %A.i, [100 x i32]* %B.i) nounwind
259  call void @llvm.lifetime.end(i64 -1, i8* %0) nounwind
260  call void @llvm.lifetime.end(i64 -1, i8* %1) nounwind
261  %2 = bitcast [100 x i32]* %A.i1 to i8*
262  call void @llvm.lifetime.start(i64 -1, i8* %2) nounwind
263  %3 = bitcast [100 x i32]* %B.i2 to i8*
264  call void @llvm.lifetime.start(i64 -1, i8* %3) nounwind
265  call void @bar([100 x i32]* %A.i1, [100 x i32]* %B.i2) nounwind
266  call void @llvm.lifetime.end(i64 -1, i8* %2) nounwind
267  call void @llvm.lifetime.end(i64 -1, i8* %3) nounwind
268  ret void
269}
270
271;CHECK-LABEL: func_phi_lifetime:
272;YESCOLOR: subq  $272, %rsp
273;NOCOLOR: subq  $272, %rsp
274define i32 @func_phi_lifetime(i32 %in, i1 %d) {
275entry:
276  %a = alloca [17 x i8*], align 8
277  %a2 = alloca [16 x i8*], align 8
278  %b = bitcast [17 x i8*]* %a to i8*
279  %b2 = bitcast [16 x i8*]* %a2 to i8*
280  %t1 = call i32 @foo(i32 %in, i8* %b)
281  %t2 = call i32 @foo(i32 %in, i8* %b)
282  call void @llvm.lifetime.end(i64 -1, i8* %b)
283  br i1 %d, label %bb0, label %bb1
284
285bb0:
286  %I1 = bitcast [17 x i8*]* %a to i8*
287  br label %bb2
288
289bb1:
290  %I2 = bitcast [16 x i8*]* %a2 to i8*
291  br label %bb2
292
293bb2:
294  %split = phi i8* [ %I1, %bb0 ], [ %I2, %bb1 ]
295  call void @llvm.lifetime.start(i64 -1, i8* %split)
296  %t3 = call i32 @foo(i32 %in, i8* %b2)
297  %t4 = call i32 @foo(i32 %in, i8* %b2)
298  %t5 = add i32 %t1, %t2
299  %t6 = add i32 %t3, %t4
300  %t7 = add i32 %t5, %t6
301  call void @llvm.lifetime.end(i64 -1, i8* %split)
302  ret i32 %t7
303bb3:
304  ret i32 0
305}
306
307
308;CHECK-LABEL: multi_region_bb:
309define void @multi_region_bb() nounwind ssp {
310entry:
311  %A.i1 = alloca [100 x i32], align 4
312  %B.i2 = alloca [100 x i32], align 4
313  %A.i = alloca [100 x i32], align 4
314  %B.i = alloca [100 x i32], align 4
315  %0 = bitcast [100 x i32]* %A.i to i8*
316  call void @llvm.lifetime.start(i64 -1, i8* %0) nounwind ; <---- start #1
317  %1 = bitcast [100 x i32]* %B.i to i8*
318  call void @llvm.lifetime.start(i64 -1, i8* %1) nounwind
319  call void @bar([100 x i32]* %A.i, [100 x i32]* %B.i) nounwind
320  call void @llvm.lifetime.end(i64 -1, i8* %0) nounwind
321  call void @llvm.lifetime.end(i64 -1, i8* %1) nounwind
322  %2 = bitcast [100 x i32]* %A.i1 to i8*
323  call void @llvm.lifetime.start(i64 -1, i8* %2) nounwind
324  %3 = bitcast [100 x i32]* %B.i2 to i8*
325  call void @llvm.lifetime.start(i64 -1, i8* %3) nounwind
326  call void @llvm.lifetime.start(i64 -1, i8* %0) nounwind  ; <---- start #2
327  call void @bar([100 x i32]* %A.i1, [100 x i32]* %B.i2) nounwind
328  call void @llvm.lifetime.end(i64 -1, i8* %2) nounwind
329  call void @llvm.lifetime.end(i64 -1, i8* %0) nounwind
330  call void @llvm.lifetime.end(i64 -1, i8* %3) nounwind
331  ret void
332}
333;YESCOLOR: subq  $272, %rsp
334;NOCOLOR: subq  $272, %rsp
335
336define i32 @myCall_end_before_begin(i32 %in, i1 %d) {
337entry:
338  %a = alloca [17 x i8*], align 8
339  %a2 = alloca [16 x i8*], align 8
340  %b = bitcast [17 x i8*]* %a to i8*
341  %b2 = bitcast [16 x i8*]* %a2 to i8*
342  %t1 = call i32 @foo(i32 %in, i8* %b)
343  %t2 = call i32 @foo(i32 %in, i8* %b)
344  call void @llvm.lifetime.end(i64 -1, i8* %b)
345  call void @llvm.lifetime.start(i64 -1, i8* %b)
346  br i1 %d, label %bb2, label %bb3
347bb2:
348  call void @llvm.lifetime.start(i64 -1, i8* %b2)
349  %t3 = call i32 @foo(i32 %in, i8* %b2)
350  %t4 = call i32 @foo(i32 %in, i8* %b2)
351  %t5 = add i32 %t1, %t2
352  %t6 = add i32 %t3, %t4
353  %t7 = add i32 %t5, %t6
354  ret i32 %t7
355bb3:
356  ret i32 0
357}
358
359
360; Regression test for PR15707.  %buf1 and %buf2 should not be merged
361; in this test case.
362;CHECK-LABEL: myCall_pr15707:
363;YESCOLOR: subq $200008, %rsp
364;NOCOLOR: subq $200008, %rsp
365define void @myCall_pr15707() {
366  %buf1 = alloca i8, i32 100000, align 16
367  %buf2 = alloca i8, i32 100000, align 16
368
369  call void @llvm.lifetime.start(i64 -1, i8* %buf1)
370  call void @llvm.lifetime.end(i64 -1, i8* %buf1)
371
372  call void @llvm.lifetime.start(i64 -1, i8* %buf1)
373  call void @llvm.lifetime.start(i64 -1, i8* %buf2)
374  %result1 = call i32 @foo(i32 0, i8* %buf1)
375  %result2 = call i32 @foo(i32 0, i8* %buf2)
376  ret void
377}
378
379
380; Check that we don't assert and crash even when there are allocas
381; outside the declared lifetime regions.
382;CHECK-LABEL: bad_range:
383define void @bad_range() nounwind ssp {
384entry:
385  %A.i1 = alloca [100 x i32], align 4
386  %B.i2 = alloca [100 x i32], align 4
387  %A.i = alloca [100 x i32], align 4
388  %B.i = alloca [100 x i32], align 4
389  %0 = bitcast [100 x i32]* %A.i to i8*
390  call void @llvm.lifetime.start(i64 -1, i8* %0) nounwind
391  %1 = bitcast [100 x i32]* %B.i to i8*
392  call void @llvm.lifetime.start(i64 -1, i8* %1) nounwind
393  call void @bar([100 x i32]* %A.i, [100 x i32]* %B.i) nounwind
394  call void @llvm.lifetime.end(i64 -1, i8* %0) nounwind
395  call void @llvm.lifetime.end(i64 -1, i8* %1) nounwind
396  br label %block2
397
398block2:
399  ; I am used outside the marked lifetime.
400  call void @bar([100 x i32]* %A.i, [100 x i32]* %B.i) nounwind
401  ret void
402}
403
404
405; Check that we don't assert and crash even when there are usages
406; of allocas which do not read or write outside the declared lifetime regions.
407;CHECK-LABEL: shady_range:
408
409%struct.Klass = type { i32, i32 }
410
411define i32 @shady_range(i32 %argc, i8** nocapture %argv) uwtable {
412  %a.i = alloca [4 x %struct.Klass], align 16
413  %b.i = alloca [4 x %struct.Klass], align 16
414  %a8 = bitcast [4 x %struct.Klass]* %a.i to i8*
415  %b8 = bitcast [4 x %struct.Klass]* %b.i to i8*
416  ; I am used outside the lifetime zone below:
417  %z2 = getelementptr inbounds [4 x %struct.Klass], [4 x %struct.Klass]* %a.i, i64 0, i64 0, i32 0
418  call void @llvm.lifetime.start(i64 -1, i8* %a8)
419  call void @llvm.lifetime.start(i64 -1, i8* %b8)
420  %z3 = load i32, i32* %z2, align 16
421  %r = call i32 @foo(i32 %z3, i8* %a8)
422  %r2 = call i32 @foo(i32 %z3, i8* %b8)
423  call void @llvm.lifetime.end(i64 -1, i8* %a8)
424  call void @llvm.lifetime.end(i64 -1, i8* %b8)
425  ret i32 9
426}
427
428declare void @bar([100 x i32]* , [100 x i32]*) nounwind
429
430declare void @llvm.lifetime.start(i64, i8* nocapture) nounwind
431
432declare void @llvm.lifetime.end(i64, i8* nocapture) nounwind
433
434declare i32 @foo(i32, i8*)
435