1; RUN: opt < %s -ipsccp -S | FileCheck %s 2 3;;======================== test1 4 5define internal i32 @test1a(i32 %A) { 6 %X = add i32 1, 2 7 ret i32 %A 8} 9; CHECK: define internal i32 @test1a 10; CHECK: ret i32 undef 11 12define i32 @test1b() { 13 %X = call i32 @test1a( i32 17 ) 14 ret i32 %X 15 16; CHECK: define i32 @test1b 17; CHECK: ret i32 17 18} 19 20 21 22;;======================== test2 23 24define internal i32 @test2a(i32 %A) { 25 %C = icmp eq i32 %A, 0 26 br i1 %C, label %T, label %F 27T: 28 %B = call i32 @test2a( i32 0 ) 29 ret i32 0 30F: 31 %C.upgrd.1 = call i32 @test2a(i32 1) 32 ret i32 %C.upgrd.1 33} 34; CHECK: define internal i32 @test2a 35; CHECK-NEXT: br label %T 36; CHECK: ret i32 undef 37 38 39define i32 @test2b() { 40 %X = call i32 @test2a(i32 0) 41 ret i32 %X 42} 43; CHECK: define i32 @test2b 44; CHECK-NEXT: %X = call i32 @test2a(i32 0) 45; CHECK-NEXT: ret i32 0 46 47 48;;======================== test3 49 50@G = internal global i32 undef 51 52define void @test3a() { 53 %X = load i32* @G 54 store i32 %X, i32* @G 55 ret void 56} 57; CHECK: define void @test3a 58; CHECK-NEXT: ret void 59 60 61define i32 @test3b() { 62 %V = load i32* @G 63 %C = icmp eq i32 %V, 17 64 br i1 %C, label %T, label %F 65T: 66 store i32 17, i32* @G 67 ret i32 %V 68F: 69 store i32 123, i32* @G 70 ret i32 0 71} 72; CHECK: define i32 @test3b 73; CHECK-NOT: store 74; CHECK: ret i32 0 75 76 77;;======================== test4 78 79define internal {i64,i64} @test4a() { 80 %a = insertvalue {i64,i64} undef, i64 4, 1 81 %b = insertvalue {i64,i64} %a, i64 5, 0 82 ret {i64,i64} %b 83} 84 85define i64 @test4b() { 86 %a = invoke {i64,i64} @test4a() 87 to label %A unwind label %B 88A: 89 %b = extractvalue {i64,i64} %a, 0 90 %c = call i64 @test4c(i64 %b) 91 ret i64 %c 92B: 93 %val = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) 94 catch i8* null 95 ret i64 0 96} 97; CHECK: define i64 @test4b() 98; CHECK: %c = call i64 @test4c(i64 5) 99; CHECK-NEXT: ret i64 5 100 101 102define internal i64 @test4c(i64 %a) { 103 ret i64 %a 104} 105; CHECK: define internal i64 @test4c 106; CHECK: ret i64 undef 107 108 109 110;;======================== test5 111 112; PR4313 113define internal {i64,i64} @test5a() { 114 %a = insertvalue {i64,i64} undef, i64 4, 1 115 %b = insertvalue {i64,i64} %a, i64 5, 0 116 ret {i64,i64} %b 117} 118 119define i64 @test5b() { 120 %a = invoke {i64,i64} @test5a() 121 to label %A unwind label %B 122A: 123 %c = call i64 @test5c({i64,i64} %a) 124 ret i64 %c 125B: 126 %val = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) 127 catch i8* null 128 ret i64 0 129} 130 131; CHECK: define i64 @test5b() 132; CHECK: A: 133; CHECK-NEXT: %c = call i64 @test5c({ i64, i64 } %a) 134; CHECK-NEXT: ret i64 5 135 136define internal i64 @test5c({i64,i64} %a) { 137 %b = extractvalue {i64,i64} %a, 0 138 ret i64 %b 139} 140 141 142;;======================== test6 143 144define i64 @test6a() { 145 ret i64 0 146} 147 148define i64 @test6b() { 149 %a = call i64 @test6a() 150 ret i64 %a 151} 152; CHECK: define i64 @test6b 153; CHECK: ret i64 0 154 155;;======================== test7 156 157 158%T = type {i32,i32} 159 160define internal %T @test7a(i32 %A) { 161 %X = add i32 1, %A 162 %mrv0 = insertvalue %T undef, i32 %X, 0 163 %mrv1 = insertvalue %T %mrv0, i32 %A, 1 164 ret %T %mrv1 165; CHECK: @test7a 166; CHECK-NEXT: %mrv0 = insertvalue %T undef, i32 18, 0 167; CHECK-NEXT: %mrv1 = insertvalue %T %mrv0, i32 17, 1 168} 169 170define i32 @test7b() { 171 %X = call %T @test7a(i32 17) 172 %Y = extractvalue %T %X, 0 173 %Z = add i32 %Y, %Y 174 ret i32 %Z 175; CHECK: define i32 @test7b 176; CHECK-NEXT: call %T @test7a(i32 17) 177; CHECK-NEXT: ret i32 36 178} 179 180;;======================== test8 181 182 183define internal {} @test8a(i32 %A, i32* %P) { 184 store i32 %A, i32* %P 185 ret {} {} 186; CHECK: @test8a 187; CHECK-NEXT: store i32 5, 188; CHECK-NEXT: ret 189} 190 191define void @test8b(i32* %P) { 192 %X = call {} @test8a(i32 5, i32* %P) 193 ret void 194; CHECK: define void @test8b 195; CHECK-NEXT: call {} @test8a 196; CHECK-NEXT: ret void 197} 198 199;;======================== test9 200 201@test9g = internal global { } zeroinitializer 202 203define void @test9() { 204entry: 205 %local_foo = alloca { } 206 load { }* @test9g 207 store { } %0, { }* %local_foo 208 ret void 209} 210 211declare i32 @__gxx_personality_v0(...) 212 213;;======================== test10 214 215define i32 @test10a() nounwind { 216entry: 217 %call = call i32 @test10b(i32 undef) 218 ret i32 %call 219; CHECK: define i32 @test10a 220; CHECK: ret i32 0 221} 222 223define internal i32 @test10b(i32 %x) nounwind { 224entry: 225 %r = and i32 %x, 1 226 ret i32 %r 227; CHECK: define internal i32 @test10b 228; CHECK: ret i32 undef 229} 230