1 ; RUN: opt < %s -instcombine -S | FileCheck %s 2 3 @T1 = external constant i32 4 @T2 = external constant i32 5 @T3 = external constant i32 6 7 declare i32 @generic_personality(i32, i64, i8*, i8*) 8 declare i32 @__gxx_personality_v0(i32, i64, i8*, i8*) 9 declare i32 @__objc_personality_v0(i32, i64, i8*, i8*) 10 declare i32 @__C_specific_handler(...) 11 12 declare void @bar() 13 14 define void @foo_generic() { 15 ; CHECK-LABEL: @foo_generic( 16 invoke void @bar() 17 to label %cont.a unwind label %lpad.a 18 cont.a: 19 invoke void @bar() 20 to label %cont.b unwind label %lpad.b 21 cont.b: 22 invoke void @bar() 23 to label %cont.c unwind label %lpad.c 24 cont.c: 25 invoke void @bar() 26 to label %cont.d unwind label %lpad.d 27 cont.d: 28 invoke void @bar() 29 to label %cont.e unwind label %lpad.e 30 cont.e: 31 invoke void @bar() 32 to label %cont.f unwind label %lpad.f 33 cont.f: 34 invoke void @bar() 35 to label %cont.g unwind label %lpad.g 36 cont.g: 37 invoke void @bar() 38 to label %cont.h unwind label %lpad.h 39 cont.h: 40 invoke void @bar() 41 to label %cont.i unwind label %lpad.i 42 cont.i: 43 ret void 44 45 lpad.a: 46 %a = landingpad { i8*, i32 } personality i32 (i32, i64, i8*, i8*)* @generic_personality 47 catch i32* @T1 48 catch i32* @T2 49 catch i32* @T1 50 catch i32* @T2 51 unreachable 52 ; CHECK: %a = landingpad 53 ; CHECK-NEXT: @T1 54 ; CHECK-NEXT: @T2 55 ; CHECK-NEXT: unreachable 56 57 lpad.b: 58 %b = landingpad { i8*, i32 } personality i32 (i32, i64, i8*, i8*)* @generic_personality 59 filter [0 x i32*] zeroinitializer 60 catch i32* @T1 61 unreachable 62 ; CHECK: %b = landingpad 63 ; CHECK-NEXT: filter 64 ; CHECK-NEXT: unreachable 65 66 lpad.c: 67 %c = landingpad { i8*, i32 } personality i32 (i32, i64, i8*, i8*)* @generic_personality 68 catch i32* @T1 69 filter [1 x i32*] [i32* @T1] 70 catch i32* @T2 71 unreachable 72 ; CHECK: %c = landingpad 73 ; CHECK-NEXT: @T1 74 ; CHECK-NEXT: filter [0 x i32*] 75 ; CHECK-NEXT: unreachable 76 77 lpad.d: 78 %d = landingpad { i8*, i32 } personality i32 (i32, i64, i8*, i8*)* @generic_personality 79 filter [3 x i32*] zeroinitializer 80 unreachable 81 ; CHECK: %d = landingpad 82 ; CHECK-NEXT: filter [1 x i32*] zeroinitializer 83 ; CHECK-NEXT: unreachable 84 85 lpad.e: 86 %e = landingpad { i8*, i32 } personality i32 (i32, i64, i8*, i8*)* @generic_personality 87 catch i32* @T1 88 filter [3 x i32*] [i32* @T1, i32* @T2, i32* @T2] 89 unreachable 90 ; CHECK: %e = landingpad 91 ; CHECK-NEXT: @T1 92 ; CHECK-NEXT: filter [1 x i32*] [i32* @T2] 93 ; CHECK-NEXT: unreachable 94 95 lpad.f: 96 %f = landingpad { i8*, i32 } personality i32 (i32, i64, i8*, i8*)* @generic_personality 97 filter [2 x i32*] [i32* @T2, i32* @T1] 98 filter [1 x i32*] [i32* @T1] 99 unreachable 100 ; CHECK: %f = landingpad 101 ; CHECK-NEXT: filter [1 x i32*] [i32* @T1] 102 ; CHECK-NEXT: unreachable 103 104 lpad.g: 105 %g = landingpad { i8*, i32 } personality i32 (i32, i64, i8*, i8*)* @generic_personality 106 filter [1 x i32*] [i32* @T1] 107 catch i32* @T3 108 filter [2 x i32*] [i32* @T2, i32* @T1] 109 unreachable 110 ; CHECK: %g = landingpad 111 ; CHECK-NEXT: filter [1 x i32*] [i32* @T1] 112 ; CHECK-NEXT: catch i32* @T3 113 ; CHECK-NEXT: unreachable 114 115 lpad.h: 116 %h = landingpad { i8*, i32 } personality i32 (i32, i64, i8*, i8*)* @generic_personality 117 filter [2 x i32*] [i32* @T1, i32* null] 118 filter [1 x i32*] zeroinitializer 119 unreachable 120 ; CHECK: %h = landingpad 121 ; CHECK-NEXT: filter [1 x i32*] zeroinitializer 122 ; CHECK-NEXT: unreachable 123 124 lpad.i: 125 %i = landingpad { i8*, i32 } personality i32 (i32, i64, i8*, i8*)* @generic_personality 126 cleanup 127 filter [0 x i32*] zeroinitializer 128 unreachable 129 ; CHECK: %i = landingpad 130 ; CHECK-NEXT: filter 131 ; CHECK-NEXT: unreachable 132 } 133 134 define void @foo_cxx() { 135 ; CHECK-LABEL: @foo_cxx( 136 invoke void @bar() 137 to label %cont.a unwind label %lpad.a 138 cont.a: 139 invoke void @bar() 140 to label %cont.b unwind label %lpad.b 141 cont.b: 142 invoke void @bar() 143 to label %cont.c unwind label %lpad.c 144 cont.c: 145 invoke void @bar() 146 to label %cont.d unwind label %lpad.d 147 cont.d: 148 ret void 149 150 lpad.a: 151 %a = landingpad { i8*, i32 } personality i32 (i32, i64, i8*, i8*)* @__gxx_personality_v0 152 catch i32* null 153 catch i32* @T1 154 unreachable 155 ; CHECK: %a = landingpad 156 ; CHECK-NEXT: null 157 ; CHECK-NEXT: unreachable 158 159 lpad.b: 160 %b = landingpad { i8*, i32 } personality i32 (i32, i64, i8*, i8*)* @__gxx_personality_v0 161 filter [1 x i32*] zeroinitializer 162 unreachable 163 ; CHECK: %b = landingpad 164 ; CHECK-NEXT: cleanup 165 ; CHECK-NEXT: unreachable 166 167 lpad.c: 168 %c = landingpad { i8*, i32 } personality i32 (i32, i64, i8*, i8*)* @__gxx_personality_v0 169 filter [2 x i32*] [i32* @T1, i32* null] 170 unreachable 171 ; CHECK: %c = landingpad 172 ; CHECK-NEXT: cleanup 173 ; CHECK-NEXT: unreachable 174 175 lpad.d: 176 %d = landingpad { i8*, i32 } personality i32 (i32, i64, i8*, i8*)* @__gxx_personality_v0 177 cleanup 178 catch i32* null 179 unreachable 180 ; CHECK: %d = landingpad 181 ; CHECK-NEXT: null 182 ; CHECK-NEXT: unreachable 183 } 184 185 define void @foo_objc() { 186 ; CHECK-LABEL: @foo_objc( 187 invoke void @bar() 188 to label %cont.a unwind label %lpad.a 189 cont.a: 190 invoke void @bar() 191 to label %cont.b unwind label %lpad.b 192 cont.b: 193 invoke void @bar() 194 to label %cont.c unwind label %lpad.c 195 cont.c: 196 invoke void @bar() 197 to label %cont.d unwind label %lpad.d 198 cont.d: 199 ret void 200 201 lpad.a: 202 %a = landingpad { i8*, i32 } personality i32 (i32, i64, i8*, i8*)* @__objc_personality_v0 203 catch i32* null 204 catch i32* @T1 205 unreachable 206 ; CHECK: %a = landingpad 207 ; CHECK-NEXT: null 208 ; CHECK-NEXT: unreachable 209 210 lpad.b: 211 %b = landingpad { i8*, i32 } personality i32 (i32, i64, i8*, i8*)* @__objc_personality_v0 212 filter [1 x i32*] zeroinitializer 213 unreachable 214 ; CHECK: %b = landingpad 215 ; CHECK-NEXT: cleanup 216 ; CHECK-NEXT: unreachable 217 218 lpad.c: 219 %c = landingpad { i8*, i32 } personality i32 (i32, i64, i8*, i8*)* @__objc_personality_v0 220 filter [2 x i32*] [i32* @T1, i32* null] 221 unreachable 222 ; CHECK: %c = landingpad 223 ; CHECK-NEXT: cleanup 224 ; CHECK-NEXT: unreachable 225 226 lpad.d: 227 %d = landingpad { i8*, i32 } personality i32 (i32, i64, i8*, i8*)* @__objc_personality_v0 228 cleanup 229 catch i32* null 230 unreachable 231 ; CHECK: %d = landingpad 232 ; CHECK-NEXT: null 233 ; CHECK-NEXT: unreachable 234 } 235 236 define void @foo_seh() { 237 ; CHECK-LABEL: @foo_seh( 238 invoke void @bar() 239 to label %cont.a unwind label %lpad.a 240 cont.a: 241 invoke void @bar() 242 to label %cont.b unwind label %lpad.b 243 cont.b: 244 invoke void @bar() 245 to label %cont.c unwind label %lpad.c 246 cont.c: 247 invoke void @bar() 248 to label %cont.d unwind label %lpad.d 249 cont.d: 250 ret void 251 252 lpad.a: 253 %a = landingpad { i8*, i32 } personality i32 (...)* @__C_specific_handler 254 catch i32* null 255 catch i32* @T1 256 unreachable 257 ; CHECK: %a = landingpad 258 ; CHECK-NEXT: null 259 ; CHECK-NEXT: unreachable 260 261 lpad.b: 262 %b = landingpad { i8*, i32 } personality i32 (...)* @__C_specific_handler 263 filter [1 x i32*] zeroinitializer 264 unreachable 265 ; CHECK: %b = landingpad 266 ; CHECK-NEXT: cleanup 267 ; CHECK-NEXT: unreachable 268 269 lpad.c: 270 %c = landingpad { i8*, i32 } personality i32 (...)* @__C_specific_handler 271 filter [2 x i32*] [i32* @T1, i32* null] 272 unreachable 273 ; CHECK: %c = landingpad 274 ; CHECK-NEXT: cleanup 275 ; CHECK-NEXT: unreachable 276 277 lpad.d: 278 %d = landingpad { i8*, i32 } personality i32 (...)* @__C_specific_handler 279 cleanup 280 catch i32* null 281 unreachable 282 ; CHECK: %d = landingpad 283 ; CHECK-NEXT: null 284 ; CHECK-NEXT: unreachable 285 } 286