Home | History | Annotate | Download | only in X86
      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
      4 
      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"
      7 
      8 ;CHECK-LABEL: myCall_w2:
      9 ;YESCOLOR: subq  $144, %rsp
     10 ;NOCOLOR: subq  $272, %rsp
     11 
     12 define i32 @myCall_w2(i32 %in) {
     13 entry:
     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(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(i64 -1, i8* %b)
     22   call void @llvm.lifetime.start(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(i64 -1, i8* %b2)
     26   %t5 = add i32 %t1, %t2
     27   %t6 = add i32 %t3, %t4
     28   %t7 = add i32 %t5, %t6
     29   ret i32 %t7
     30 }
     31 
     32 
     33 ;CHECK-LABEL: myCall2_no_merge
     34 ;YESCOLOR: subq  $272, %rsp
     35 ;NOCOLOR: subq  $272, %rsp
     36 
     37 define i32 @myCall2_no_merge(i32 %in, i1 %d) {
     38 entry:
     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(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
     47 bb2:
     48   call void @llvm.lifetime.start(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(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(i64 -1, i8* %b)
     56   ret i32 %t7
     57 bb3:
     58   call void @llvm.lifetime.end(i64 -1, i8* %b)
     59   ret i32 0
     60 }
     61 
     62 ;CHECK-LABEL: myCall2_w2
     63 ;YESCOLOR: subq  $144, %rsp
     64 ;NOCOLOR: subq  $272, %rsp
     65 
     66 define i32 @myCall2_w2(i32 %in, i1 %d) {
     67 entry:
     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(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(i64 -1, i8* %b)
     76   br i1 %d, label %bb2, label %bb3
     77 bb2:
     78   call void @llvm.lifetime.start(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(i64 -1, i8* %b2)
     82   %t5 = add i32 %t1, %t2
     83   %t6 = add i32 %t3, %t4
     84   %t7 = add i32 %t5, %t6
     85   ret i32 %t7
     86 bb3:
     87   ret i32 0
     88 }
     89 
     90 ;CHECK-LABEL: myCall_w4:
     91 ;YESCOLOR: subq  $120, %rsp
     92 ;NOFIRSTUSE: subq  $200, %rsp
     93 ;NOCOLOR: subq  $408, %rsp
     94 
     95 define i32 @myCall_w4(i32 %in) {
     96 entry:
     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(i64 -1, i8* %b4)
    106   call void @llvm.lifetime.start(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(i64 -1, i8* %b1)
    110   call void @llvm.lifetime.start(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(i64 -1, i8* %b2)
    114   call void @llvm.lifetime.start(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(i64 -1, i8* %b3)
    118   %t11 = call i32 @foo(i32 %in, i8* %b4)
    119   call void @llvm.lifetime.end(i64 -1, i8* %b4)
    120   %t5 = add i32 %t1, %t2
    121   %t6 = add i32 %t3, %t4
    122   %t7 = add i32 %t5, %t6
    123   ret i32 %t7
    124 }
    125 
    126 ;CHECK-LABEL: myCall2_w4:
    127 ;YESCOLOR: subq  $112, %rsp
    128 ;NOCOLOR: subq  $400, %rsp
    129 
    130 define i32 @myCall2_w4(i32 %in) {
    131 entry:
    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(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(i64 -1, i8* %b1)
    144   call void @llvm.lifetime.start(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(i64 -1, i8* %b2)
    148   call void @llvm.lifetime.start(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(i64 -1, i8* %b3)
    152   br i1 undef, label %bb2, label %bb3
    153 bb2:
    154   call void @llvm.lifetime.start(i64 -1, i8* %b4)
    155   %t11 = call i32 @foo(i32 %in, i8* %b4)
    156   call void @llvm.lifetime.end(i64 -1, i8* %b4)
    157   %t5 = add i32 %t1, %t2
    158   %t6 = add i32 %t3, %t4
    159   %t7 = add i32 %t5, %t6
    160   ret i32 %t7
    161 bb3:
    162   ret i32 0
    163 }
    164 
    165 
    166 ;CHECK-LABEL: myCall2_noend:
    167 ;YESCOLOR: subq  $144, %rsp
    168 ;NOCOLOR: subq  $272, %rsp
    169 
    170 
    171 define i32 @myCall2_noend(i32 %in, i1 %d) {
    172 entry:
    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(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(i64 -1, i8* %b)
    181   br i1 %d, label %bb2, label %bb3
    182 bb2:
    183   call void @llvm.lifetime.start(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
    189   ret i32 %t7
    190 bb3:
    191   ret i32 0
    192 }
    193 
    194 ;CHECK-LABEL: myCall2_noend2:
    195 ;YESCOLOR: subq  $144, %rsp
    196 ;NOCOLOR: subq  $272, %rsp
    197 define i32 @myCall2_noend2(i32 %in, i1 %d) {
    198 entry:
    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(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
    207 bb2:
    208   call void @llvm.lifetime.end(i64 -1, i8* %b)
    209   call void @llvm.lifetime.start(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
    215   ret i32 %t7
    216 bb3:
    217   ret i32 0
    218 }
    219 
    220 
    221 ;CHECK-LABEL: myCall2_nostart:
    222 ;YESCOLOR: subq  $272, %rsp
    223 ;NOCOLOR: subq  $272, %rsp
    224 define i32 @myCall2_nostart(i32 %in, i1 %d) {
    225 entry:
    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(i64 -1, i8* %b)
    233   br i1 %d, label %bb2, label %bb3
    234 bb2:
    235   call void @llvm.lifetime.start(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
    241   ret i32 %t7
    242 bb3:
    243   ret i32 0
    244 }
    245 
    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 {
    251 entry:
    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(i64 -1, i8* %0) nounwind
    258   %1 = bitcast [100 x i32]* %B.i to i8*
    259   call void @llvm.lifetime.start(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(i64 -1, i8* %0) nounwind
    262   call void @llvm.lifetime.end(i64 -1, i8* %1) nounwind
    263   %2 = bitcast [100 x i32]* %A.i1 to i8*
    264   call void @llvm.lifetime.start(i64 -1, i8* %2) nounwind
    265   %3 = bitcast [100 x i32]* %B.i2 to i8*
    266   call void @llvm.lifetime.start(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(i64 -1, i8* %2) nounwind
    269   call void @llvm.lifetime.end(i64 -1, i8* %3) nounwind
    270   ret void
    271 }
    272 
    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) {
    277 entry:
    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(i64 -1, i8* %b)
    285   br i1 %d, label %bb0, label %bb1
    286 
    287 bb0:
    288   %I1 = bitcast [17 x i8*]* %a to i8*
    289   br label %bb2
    290 
    291 bb1:
    292   %I2 = bitcast [16 x i8*]* %a2 to i8*
    293   br label %bb2
    294 
    295 bb2:
    296   %split = phi i8* [ %I1, %bb0 ], [ %I2, %bb1 ]
    297   call void @llvm.lifetime.start(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(i64 -1, i8* %split)
    304   ret i32 %t7
    305 bb3:
    306   ret i32 0
    307 }
    308 
    309 
    310 ;CHECK-LABEL: multi_region_bb:
    311 ;YESCOLOR: subq  $272, %rsp
    312 ;NOCOLOR: subq  $272, %rsp
    313 
    314 define void @multi_region_bb() nounwind ssp {
    315 entry:
    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(i64 -1, i8* %0) nounwind ; <---- start #1
    322   %1 = bitcast [100 x i32]* %B.i to i8*
    323   call void @llvm.lifetime.start(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(i64 -1, i8* %0) nounwind
    326   call void @llvm.lifetime.end(i64 -1, i8* %1) nounwind
    327   %2 = bitcast [100 x i32]* %A.i1 to i8*
    328   call void @llvm.lifetime.start(i64 -1, i8* %2) nounwind
    329   %3 = bitcast [100 x i32]* %B.i2 to i8*
    330   call void @llvm.lifetime.start(i64 -1, i8* %3) nounwind
    331   call void @llvm.lifetime.start(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(i64 -1, i8* %2) nounwind
    334   call void @llvm.lifetime.end(i64 -1, i8* %0) nounwind
    335   call void @llvm.lifetime.end(i64 -1, i8* %3) nounwind
    336   ret void
    337 }
    338 
    339 define i32 @myCall_end_before_begin(i32 %in, i1 %d) {
    340 entry:
    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(i64 -1, i8* %b)
    348   call void @llvm.lifetime.start(i64 -1, i8* %b)
    349   br i1 %d, label %bb2, label %bb3
    350 bb2:
    351   call void @llvm.lifetime.start(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
    357   ret i32 %t7
    358 bb3:
    359   ret i32 0
    360 }
    361 
    362 
    363 ; Regression test for PR15707.  %buf1 and %buf2 should not be merged
    364 ; in this test case.
    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
    371 
    372   call void @llvm.lifetime.start(i64 -1, i8* %buf1)
    373   call void @llvm.lifetime.end(i64 -1, i8* %buf1)
    374 
    375   call void @llvm.lifetime.start(i64 -1, i8* %buf1)
    376   call void @llvm.lifetime.start(i64 -1, i8* %buf2)
    377   %result1 = call i32 @foo(i32 0, i8* %buf1)
    378   %result2 = call i32 @foo(i32 0, i8* %buf2)
    379   ret void
    380 }
    381 
    382 
    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 {
    387 entry:
    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(i64 -1, i8* %0) nounwind
    394   %1 = bitcast [100 x i32]* %B.i to i8*
    395   call void @llvm.lifetime.start(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(i64 -1, i8* %0) nounwind
    398   call void @llvm.lifetime.end(i64 -1, i8* %1) nounwind
    399   br label %block2
    400 
    401 block2:
    402   ; I am used outside the marked lifetime.
    403   call void @bar([100 x i32]* %A.i, [100 x i32]* %B.i) nounwind
    404   ret void
    405 }
    406 
    407 
    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:
    411 
    412 %struct.Klass = type { i32, i32 }
    413 
    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(i64 -1, i8* %a8)
    422   call void @llvm.lifetime.start(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(i64 -1, i8* %a8)
    427   call void @llvm.lifetime.end(i64 -1, i8* %b8)
    428   ret i32 9
    429 }
    430 
    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.
    435 
    436 ;CHECK-LABEL: ifthen_twoslots:
    437 ;YESCOLOR: subq  $1544, %rsp
    438 ;NOFIRSTUSE: subq $2056, %rsp
    439 ;NOCOLOR: subq  $2568, %rsp
    440 
    441 define i32 @ifthen_twoslots(i32 %x) #0 {
    442 entry:
    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(i64 512, i8* %tmp)
    450   %tmp1 = bitcast [128 x i32]* %b2 to i8*
    451   call void @llvm.lifetime.start(i64 512, i8* %tmp1)
    452   %and = and i32 %x, 1
    453   %tobool = icmp eq i32 %and, 0
    454   br i1 %tobool, label %if.else, label %if.then
    455 
    456 if.then:                                          ; preds = %entry
    457   %tmp2 = bitcast [128 x i32]* %b3 to i8*
    458   call void @llvm.lifetime.start(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(i64 512, i8* %tmp2)
    463   br label %if.end
    464 
    465 if.else:                                          ; preds = %entry
    466   %tmp3 = bitcast [128 x i32]* %b4 to i8*
    467   call void @llvm.lifetime.start(i64 512, i8* %tmp3)
    468   %tmp4 = bitcast [128 x i32]* %b5 to i8*
    469   call void @llvm.lifetime.start(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(i64 512, i8* %tmp4)
    475   call void @llvm.lifetime.end(i64 512, i8* %tmp3)
    476   br label %if.end
    477 
    478 if.end:                                           ; preds = %if.else, %if.then
    479   call void @llvm.lifetime.end(i64 512, i8* %tmp1)
    480   call void @llvm.lifetime.end(i64 512, i8* %tmp)
    481   ret i32 0
    482 
    483 }
    484 
    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
    489 ; markers only.
    490 
    491 ;CHECK-LABEL: while_loop:
    492 ;YESCOLOR: subq  $1032, %rsp
    493 ;NOFIRSTUSE: subq  $1544, %rsp
    494 ;NOCOLOR: subq  $1544, %rsp
    495 
    496 define i32 @while_loop(i32 %x) #0 {
    497 entry:
    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(i64 512, i8* %tmp) #3
    503   %tmp1 = bitcast [128 x i32]* %b2 to i8*
    504   call void @llvm.lifetime.start(i64 512, i8* %tmp1) #3
    505   %and = and i32 %x, 1
    506   %tobool = icmp eq i32 %and, 0
    507   br i1 %tobool, label %if.else, label %if.then
    508 
    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
    512   br label %if.end
    513 
    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
    521 
    522 while.body.lr.ph:                                 ; preds = %if.else
    523   %tmp2 = bitcast [128 x i32]* %b3 to i8*
    524   br label %while.body
    525 
    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(i64 512, i8* %tmp2) #3
    530   call void @inita(i32* %arraydecay3) #3
    531   call void @llvm.lifetime.end(i64 512, i8* %tmp2) #3
    532   %tobool2 = icmp eq i32 %dec, 0
    533   br i1 %tobool2, label %if.end.loopexit, label %while.body
    534 
    535 if.end.loopexit:                                  ; preds = %while.body
    536   br label %if.end
    537 
    538 if.end:                                           ; preds = %if.end.loopexit, %if.else, %if.then
    539   call void @llvm.lifetime.end(i64 512, i8* %tmp1) #3
    540   call void @llvm.lifetime.end(i64 512, i8* %tmp) #3
    541   ret i32 0
    542 }
    543 
    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.
    548 
    549 ;CHECK-LABEL: twobod_b27903:
    550 ;YESCOLOR: subq  $96, %rsp
    551 ;NOFIRSTUSE: subq  $96, %rsp
    552 ;NOCOLOR: subq  $96, %rsp
    553 
    554 define i32 @twobod_b27903(i32 %y, i32 %x) {
    555 entry:
    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(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(i64 48, i8* %tmp)
    565   %tobool = icmp eq i32 %y, 0
    566   br i1 %tobool, label %if.end, label %if.then
    567 
    568 if.then:                                          ; preds = %entry
    569   %tmp1 = bitcast [12 x i32]* %abc to i8*
    570   call void @llvm.lifetime.start(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(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(i64 48, i8* %tmp)
    577   call void @llvm.lifetime.end(i64 48, i8* %tmp1)
    578   br label %if.end
    579 
    580 if.end:                                           ; preds = %if.then, %entry
    581   %x.addr.0 = phi i32 [ %add.i9, %if.then ], [ %add.i, %entry ]
    582   ret i32 %x.addr.0
    583 }
    584 
    585 declare void @inita(i32*)
    586 
    587 declare void @initb(i32*,i32*,i32*)
    588 
    589 declare void @bar([100 x i32]* , [100 x i32]*) nounwind
    590 
    591 declare void @llvm.lifetime.start(i64, i8* nocapture) nounwind
    592 
    593 declare void @llvm.lifetime.end(i64, i8* nocapture) nounwind
    594 
    595 declare i32 @foo(i32, i8*)
    596