1 ; RUN: opt < %s -ipsccp -S | FileCheck %s 2 3 ;;======================== test1 4 5 define 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 12 define 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 24 define internal i32 @test2a(i32 %A) { 25 %C = icmp eq i32 %A, 0 26 br i1 %C, label %T, label %F 27 T: 28 %B = call i32 @test2a( i32 0 ) 29 ret i32 0 30 F: 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 39 define 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 52 define 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 61 define i32 @test3b() { 62 %V = load i32* @G 63 %C = icmp eq i32 %V, 17 64 br i1 %C, label %T, label %F 65 T: 66 store i32 17, i32* @G 67 ret i32 %V 68 F: 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 79 define 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 85 define i64 @test4b() { 86 %a = invoke {i64,i64} @test4a() 87 to label %A unwind label %B 88 A: 89 %b = extractvalue {i64,i64} %a, 0 90 %c = call i64 @test4c(i64 %b) 91 ret i64 %c 92 B: 93 ret i64 0 94 } 95 ; CHECK: define i64 @test4b() 96 ; CHECK: %c = call i64 @test4c(i64 5) 97 ; CHECK-NEXT: ret i64 5 98 99 100 define internal i64 @test4c(i64 %a) { 101 ret i64 %a 102 } 103 ; CHECK: define internal i64 @test4c 104 ; CHECK: ret i64 undef 105 106 107 108 ;;======================== test5 109 110 ; PR4313 111 define internal {i64,i64} @test5a() { 112 %a = insertvalue {i64,i64} undef, i64 4, 1 113 %b = insertvalue {i64,i64} %a, i64 5, 0 114 ret {i64,i64} %b 115 } 116 117 define i64 @test5b() { 118 %a = invoke {i64,i64} @test5a() 119 to label %A unwind label %B 120 A: 121 %c = call i64 @test5c({i64,i64} %a) 122 ret i64 %c 123 B: 124 ret i64 0 125 } 126 127 ; CHECK: define i64 @test5b() 128 ; CHECK: A: 129 ; CHECK-NEXT: %c = call i64 @test5c({ i64, i64 } %a) 130 ; CHECK-NEXT: ret i64 5 131 132 define internal i64 @test5c({i64,i64} %a) { 133 %b = extractvalue {i64,i64} %a, 0 134 ret i64 %b 135 } 136 137 138 ;;======================== test6 139 140 define i64 @test6a() { 141 ret i64 0 142 } 143 144 define i64 @test6b() { 145 %a = call i64 @test6a() 146 ret i64 %a 147 } 148 ; CHECK: define i64 @test6b 149 ; CHECK: ret i64 0 150 151 ;;======================== test7 152 153 154 %T = type {i32,i32} 155 156 define internal %T @test7a(i32 %A) { 157 %X = add i32 1, %A 158 %mrv0 = insertvalue %T undef, i32 %X, 0 159 %mrv1 = insertvalue %T %mrv0, i32 %A, 1 160 ret %T %mrv1 161 ; CHECK: @test7a 162 ; CHECK-NEXT: %mrv0 = insertvalue %T undef, i32 18, 0 163 ; CHECK-NEXT: %mrv1 = insertvalue %T %mrv0, i32 17, 1 164 } 165 166 define i32 @test7b() { 167 %X = call %T @test7a(i32 17) 168 %Y = extractvalue %T %X, 0 169 %Z = add i32 %Y, %Y 170 ret i32 %Z 171 ; CHECK: define i32 @test7b 172 ; CHECK-NEXT: call %T @test7a(i32 17) 173 ; CHECK-NEXT: ret i32 36 174 } 175 176 ;;======================== test8 177 178 179 define internal {} @test8a(i32 %A, i32* %P) { 180 store i32 %A, i32* %P 181 ret {} {} 182 ; CHECK: @test8a 183 ; CHECK-NEXT: store i32 5, 184 ; CHECK-NEXT: ret 185 } 186 187 define void @test8b(i32* %P) { 188 %X = call {} @test8a(i32 5, i32* %P) 189 ret void 190 ; CHECK: define void @test8b 191 ; CHECK-NEXT: call {} @test8a 192 ; CHECK-NEXT: ret void 193 } 194 195 ;;======================== test9 196 197 @test9g = internal global { } zeroinitializer 198 199 define void @test9() { 200 entry: 201 %local_foo = alloca { } 202 load { }* @test9g 203 store { } %0, { }* %local_foo 204 ret void 205 } 206 207