Home | History | Annotate | Download | only in ConstProp
      1 ; RUN: opt < %s -constprop -S | FileCheck %s
      2 
      3 %struct = type { i32, [4 x i8] }
      4 
      5 define %struct @test1() {
      6   %A = insertvalue %struct { i32 2, [4 x i8] c"foo\00" }, i32 1, 0
      7   ret %struct %A
      8 ; CHECK: @test1
      9 ; CHECK: ret %struct { i32 1, [4 x i8] c"foo\00" }
     10 }
     11 
     12 define %struct @test2() {
     13   %A = insertvalue %struct { i32 2, [4 x i8] c"foo\00" }, i8 1, 1, 2
     14   ret %struct %A
     15 ; CHECK: @test2
     16 ; CHECK: ret %struct { i32 2, [4 x i8] c"fo\01\00" }
     17 }
     18 
     19 define [3 x %struct] @test3() {
     20   %A = insertvalue [3 x %struct] [ %struct { i32 0, [4 x i8] c"aaaa" }, %struct { i32 1, [4 x i8] c"bbbb" }, %struct { i32 2, [4 x i8] c"cccc" } ], i32 -1, 1, 0
     21   ret [3 x %struct] %A
     22 ; CHECK: @test3
     23 ; CHECK:ret [3 x %struct] [%struct { i32 0, [4 x i8] c"aaaa" }, %struct { i32 -1, [4 x i8] c"bbbb" }, %struct { i32 2, [4 x i8] c"cccc" }]
     24 }
     25 
     26 define %struct @zeroinitializer-test1() {
     27   %A = insertvalue %struct zeroinitializer, i32 1, 0
     28   ret %struct %A
     29 ; CHECK: @zeroinitializer-test1
     30 ; CHECK: ret %struct { i32 1, [4 x i8] zeroinitializer }
     31 }
     32 
     33 define %struct @zeroinitializer-test2() {
     34   %A = insertvalue %struct zeroinitializer, i8 1, 1, 2
     35   ret %struct %A
     36 ; CHECK: @zeroinitializer-test2
     37 ; CHECK: ret %struct { i32 0, [4 x i8] c"\00\00\01\00" }
     38 }
     39 
     40 define [3 x %struct] @zeroinitializer-test3() {
     41   %A = insertvalue [3 x %struct] zeroinitializer, i32 1, 1, 0
     42   ret [3 x %struct] %A
     43 ; CHECK: @zeroinitializer-test3
     44 ; CHECK: ret [3 x %struct] [%struct zeroinitializer, %struct { i32 1, [4 x i8] zeroinitializer }, %struct zeroinitializer]
     45 }
     46 
     47 define %struct @undef-test1() {
     48   %A = insertvalue %struct undef, i32 1, 0
     49   ret %struct %A
     50 ; CHECK: @undef-test1
     51 ; CHECK: ret %struct { i32 1, [4 x i8] undef }
     52 }
     53 
     54 define %struct @undef-test2() {
     55   %A = insertvalue %struct undef, i8 0, 1, 2
     56   ret %struct %A
     57 ; CHECK: @undef-test2
     58 ; CHECK: ret %struct { i32 undef, [4 x i8] [i8 undef, i8 undef, i8 0, i8 undef] }
     59 }
     60 
     61 define [3 x %struct] @undef-test3() {
     62   %A = insertvalue [3 x %struct] undef, i32 0, 1, 0
     63   ret [3 x %struct] %A
     64 ; CHECK: @undef-test3
     65 ; CHECK: ret [3 x %struct] [%struct undef, %struct { i32 0, [4 x i8] undef }, %struct undef]
     66 }
     67 
     68