Home | History | Annotate | Download | only in ScalarRepl
      1 ; RUN: opt -scalarrepl -S < %s | FileCheck %s
      2 
      3 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"
      4 target triple = "x86_64-unknown-linux-gnu"
      5 
      6 declare void @llvm.lifetime.start(i64, i8*)
      7 declare void @llvm.lifetime.end(i64, i8*)
      8 
      9 %t1 = type {i32, i32, i32}
     10 
     11 define void @test1() {
     12 ; CHECK: @test1
     13   %A = alloca %t1
     14   %A1 = getelementptr %t1* %A, i32 0, i32 0
     15   %A2 = getelementptr %t1* %A, i32 0, i32 1
     16   %A3 = getelementptr %t1* %A, i32 0, i32 2
     17   %B = bitcast i32* %A1 to i8*
     18   store i32 0, i32* %A1
     19   call void @llvm.lifetime.start(i64 -1, i8* %B)
     20   ret void
     21 ; CHECK-NEXT: ret void
     22 }
     23 
     24 define void @test2() {
     25 ; CHECK: @test2
     26   %A = alloca %t1
     27   %A1 = getelementptr %t1* %A, i32 0, i32 0
     28   %A2 = getelementptr %t1* %A, i32 0, i32 1
     29   %A3 = getelementptr %t1* %A, i32 0, i32 2
     30   %B = bitcast i32* %A2 to i8*
     31   store i32 0, i32* %A2
     32   call void @llvm.lifetime.start(i64 -1, i8* %B)
     33   %C = load i32* %A2
     34   ret void
     35 ; CHECK: ret void
     36 }
     37 
     38 define void @test3() {
     39 ; CHECK: @test3
     40   %A = alloca %t1
     41   %A1 = getelementptr %t1* %A, i32 0, i32 0
     42   %A2 = getelementptr %t1* %A, i32 0, i32 1
     43   %A3 = getelementptr %t1* %A, i32 0, i32 2
     44   %B = bitcast i32* %A2 to i8*
     45   store i32 0, i32* %A2
     46   call void @llvm.lifetime.start(i64 6, i8* %B)
     47   %C = load i32* %A2
     48   ret void
     49 ; CHECK-NEXT: ret void
     50 }
     51 
     52 define void @test4() {
     53 ; CHECK: @test4
     54   %A = alloca %t1
     55   %A1 = getelementptr %t1* %A, i32 0, i32 0
     56   %A2 = getelementptr %t1* %A, i32 0, i32 1
     57   %A3 = getelementptr %t1* %A, i32 0, i32 2
     58   %B = bitcast i32* %A2 to i8*
     59   store i32 0, i32* %A2
     60   call void @llvm.lifetime.start(i64 1, i8* %B)
     61   %C = load i32* %A2
     62   ret void
     63 ; CHECK-NEXT: ret void
     64 }
     65 
     66 %t2 = type {i32, [4 x i8], i32}
     67 
     68 define void @test5() {
     69 ; CHECK: @test5
     70   %A = alloca %t2
     71 ; CHECK: alloca{{.*}}i8
     72 ; CHECK: alloca{{.*}}i8
     73 ; CHECK: alloca{{.*}}i8
     74 
     75   %A21 = getelementptr %t2* %A, i32 0, i32 1, i32 0
     76   %A22 = getelementptr %t2* %A, i32 0, i32 1, i32 1
     77   %A23 = getelementptr %t2* %A, i32 0, i32 1, i32 2
     78   %A24 = getelementptr %t2* %A, i32 0, i32 1, i32 3
     79 ; CHECK-NOT: store i8 1
     80   store i8 1, i8* %A21
     81   store i8 2, i8* %A22
     82   store i8 3, i8* %A23
     83   store i8 4, i8* %A24
     84 
     85   %A1 = getelementptr %t2* %A, i32 0, i32 0
     86   %A2 = getelementptr %t2* %A, i32 0, i32 1, i32 1
     87   %A3 = getelementptr %t2* %A, i32 0, i32 2
     88   store i8 0, i8* %A2
     89   call void @llvm.lifetime.start(i64 5, i8* %A2)
     90 ; CHECK: llvm.lifetime{{.*}}i64 1
     91 ; CHECK: llvm.lifetime{{.*}}i64 1
     92 ; CHECK: llvm.lifetime{{.*}}i64 1
     93   %C = load i8* %A2
     94   ret void
     95 }
     96 
     97 %t3 = type {[4 x i16], [4 x i8]}
     98 
     99 define void @test6() {
    100 ; CHECK: @test6
    101   %A = alloca %t3
    102 ; CHECK: alloca i8
    103 ; CHECK: alloca i8
    104 ; CHECK: alloca i8
    105 
    106   %A11 = getelementptr %t3* %A, i32 0, i32 0, i32 0
    107   %A12 = getelementptr %t3* %A, i32 0, i32 0, i32 1
    108   %A13 = getelementptr %t3* %A, i32 0, i32 0, i32 2
    109   %A14 = getelementptr %t3* %A, i32 0, i32 0, i32 3
    110   store i16 11, i16* %A11
    111   store i16 12, i16* %A12
    112   store i16 13, i16* %A13
    113   store i16 14, i16* %A14
    114 ; CHECK-NOT: store i16 11
    115 ; CHECK-NOT: store i16 12
    116 ; CHECK-NOT: store i16 13
    117 ; CHECK-NOT: store i16 14
    118 
    119   %A21 = getelementptr %t3* %A, i32 0, i32 1, i32 0
    120   %A22 = getelementptr %t3* %A, i32 0, i32 1, i32 1
    121   %A23 = getelementptr %t3* %A, i32 0, i32 1, i32 2
    122   %A24 = getelementptr %t3* %A, i32 0, i32 1, i32 3
    123   store i8 21, i8* %A21
    124   store i8 22, i8* %A22
    125   store i8 23, i8* %A23
    126   store i8 24, i8* %A24
    127 ; CHECK: store i8 21
    128 ; CHECK: store i8 22
    129 ; CHECK: store i8 23
    130 ; CHECK-NOT: store i8 24
    131 
    132   %B = bitcast i16* %A13 to i8*
    133   call void @llvm.lifetime.start(i64 7, i8* %B)
    134 ; CHECK: lifetime.start{{.*}}i64 1
    135 ; CHECK: lifetime.start{{.*}}i64 1
    136 ; CHECK: lifetime.start{{.*}}i64 1
    137 
    138   ret void
    139 }
    140