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