1 ; RUN: opt < %s -jump-threading -disable-output 2 3 %struct.ham = type { i8, i8, i16, i32 } 4 %struct.zot = type { i32 (...)** } 5 %struct.quux.0 = type { %struct.wombat } 6 %struct.wombat = type { %struct.zot } 7 8 @global = external global %struct.ham*, align 8 9 @global.1 = external constant i8* 10 11 declare i32 @wombat.2() 12 13 define void @blam() { 14 bb: 15 %tmp = load i32, i32* undef 16 %tmp1 = icmp eq i32 %tmp, 0 17 br i1 %tmp1, label %bb11, label %bb2 18 19 bb2: 20 %tmp3 = tail call i32 @wombat.2() 21 switch i32 %tmp3, label %bb4 [ 22 i32 0, label %bb5 23 i32 1, label %bb7 24 i32 2, label %bb7 25 i32 3, label %bb11 26 ] 27 28 bb4: 29 br label %bb7 30 31 bb5: 32 %tmp6 = tail call i32 @wombat.2() 33 br label %bb7 34 35 bb7: 36 %tmp8 = phi i32 [ 0, %bb5 ], [ 1, %bb4 ], [ 2, %bb2 ], [ 2, %bb2 ] 37 %tmp9 = icmp eq i32 %tmp8, 0 38 br i1 %tmp9, label %bb11, label %bb10 39 40 bb10: 41 ret void 42 43 bb11: 44 ret void 45 } 46 47 define void @spam(%struct.ham* %arg) { 48 bb: 49 %tmp = load i8, i8* undef, align 8 50 switch i8 %tmp, label %bb11 [ 51 i8 1, label %bb11 52 i8 2, label %bb11 53 i8 3, label %bb1 54 i8 4, label %bb1 55 ] 56 57 bb1: 58 br label %bb2 59 60 bb2: 61 %tmp3 = phi i32 [ 0, %bb1 ], [ %tmp3, %bb8 ] 62 br label %bb4 63 64 bb4: 65 %tmp5 = load i8, i8* undef, align 8 66 switch i8 %tmp5, label %bb11 [ 67 i8 0, label %bb11 68 i8 1, label %bb10 69 i8 2, label %bb10 70 i8 3, label %bb6 71 i8 4, label %bb6 72 ] 73 74 bb6: 75 br label %bb7 76 77 bb7: 78 br i1 undef, label %bb8, label %bb10 79 80 bb8: 81 %tmp9 = icmp eq %struct.ham* undef, %arg 82 br i1 %tmp9, label %bb10, label %bb2 83 84 bb10: 85 switch i32 %tmp3, label %bb4 [ 86 i32 0, label %bb14 87 i32 1, label %bb11 88 i32 2, label %bb12 89 ] 90 91 bb11: 92 unreachable 93 94 bb12: 95 %tmp13 = load %struct.ham*, %struct.ham** undef 96 br label %bb14 97 98 bb14: 99 %tmp15 = phi %struct.ham* [ %tmp13, %bb12 ], [ null, %bb10 ] 100 br label %bb16 101 102 bb16: 103 %tmp17 = load i8, i8* undef, align 8 104 switch i8 %tmp17, label %bb11 [ 105 i8 0, label %bb11 106 i8 11, label %bb18 107 i8 12, label %bb18 108 ] 109 110 bb18: 111 br label %bb19 112 113 bb19: 114 br label %bb20 115 116 bb20: 117 %tmp21 = load %struct.ham*, %struct.ham** undef 118 switch i8 undef, label %bb22 [ 119 i8 0, label %bb4 120 i8 11, label %bb10 121 i8 12, label %bb10 122 ] 123 124 bb22: 125 br label %bb23 126 127 bb23: 128 %tmp24 = icmp eq %struct.ham* %tmp21, null 129 br i1 %tmp24, label %bb35, label %bb25 130 131 bb25: 132 %tmp26 = icmp eq %struct.ham* %tmp15, null 133 br i1 %tmp26, label %bb34, label %bb27 134 135 bb27: 136 %tmp28 = load %struct.ham*, %struct.ham** undef 137 %tmp29 = icmp eq %struct.ham* %tmp28, %tmp21 138 br i1 %tmp29, label %bb35, label %bb30 139 140 bb30: 141 br label %bb31 142 143 bb31: 144 %tmp32 = load i8, i8* undef, align 8 145 %tmp33 = icmp eq i8 %tmp32, 0 146 br i1 %tmp33, label %bb31, label %bb34 147 148 bb34: 149 br label %bb35 150 151 bb35: 152 %tmp36 = phi i1 [ true, %bb34 ], [ false, %bb23 ], [ true, %bb27 ] 153 br label %bb37 154 155 bb37: 156 %tmp38 = icmp eq %struct.ham* %tmp15, null 157 br i1 %tmp38, label %bb39, label %bb41 158 159 bb39: 160 %tmp40 = load %struct.ham*, %struct.ham** @global 161 br label %bb41 162 163 bb41: 164 %tmp42 = select i1 %tmp36, %struct.ham* undef, %struct.ham* undef 165 ret void 166 } 167 168 declare i32 @foo(...) 169 170 define void @zot() align 2 personality i8* bitcast (i32 (...)* @foo to i8*) { 171 bb: 172 invoke void @bar() 173 to label %bb1 unwind label %bb3 174 175 bb1: 176 invoke void @bar() 177 to label %bb2 unwind label %bb4 178 179 bb2: 180 invoke void @bar() 181 to label %bb6 unwind label %bb17 182 183 bb3: 184 %tmp = landingpad { i8*, i32 } 185 catch i8* bitcast (i8** @global.1 to i8*) 186 catch i8* null 187 unreachable 188 189 bb4: 190 %tmp5 = landingpad { i8*, i32 } 191 catch i8* bitcast (i8** @global.1 to i8*) 192 catch i8* null 193 unreachable 194 195 bb6: 196 invoke void @bar() 197 to label %bb7 unwind label %bb19 198 199 bb7: 200 invoke void @bar() 201 to label %bb10 unwind label %bb8 202 203 bb8: 204 %tmp9 = landingpad { i8*, i32 } 205 cleanup 206 catch i8* bitcast (i8** @global.1 to i8*) 207 catch i8* null 208 unreachable 209 210 bb10: 211 %tmp11 = load i32 (%struct.zot*)*, i32 (%struct.zot*)** undef, align 8 212 %tmp12 = invoke i32 %tmp11(%struct.zot* nonnull undef) 213 to label %bb13 unwind label %bb21 214 215 bb13: 216 invoke void @bar() 217 to label %bb14 unwind label %bb23 218 219 bb14: 220 %tmp15 = load i32 (%struct.zot*)*, i32 (%struct.zot*)** undef, align 8 221 %tmp16 = invoke i32 %tmp15(%struct.zot* nonnull undef) 222 to label %bb26 unwind label %bb23 223 224 bb17: 225 %tmp18 = landingpad { i8*, i32 } 226 catch i8* bitcast (i8** @global.1 to i8*) 227 catch i8* null 228 unreachable 229 230 bb19: 231 %tmp20 = landingpad { i8*, i32 } 232 catch i8* bitcast (i8** @global.1 to i8*) 233 catch i8* null 234 unreachable 235 236 bb21: 237 %tmp22 = landingpad { i8*, i32 } 238 catch i8* bitcast (i8** @global.1 to i8*) 239 catch i8* null 240 unreachable 241 242 bb23: 243 %tmp24 = phi %struct.quux.0* [ null, %bb26 ], [ null, %bb14 ], [ undef, %bb13 ] 244 %tmp25 = landingpad { i8*, i32 } 245 catch i8* bitcast (i8** @global.1 to i8*) 246 catch i8* null 247 br label %bb30 248 249 bb26: 250 %tmp27 = load i32 (%struct.zot*)*, i32 (%struct.zot*)** undef, align 8 251 %tmp28 = invoke i32 %tmp27(%struct.zot* nonnull undef) 252 to label %bb29 unwind label %bb23 253 254 bb29: 255 unreachable 256 257 bb30: 258 %tmp31 = icmp eq %struct.quux.0* %tmp24, null 259 br i1 %tmp31, label %bb32, label %bb29 260 261 bb32: 262 unreachable 263 } 264 265 declare void @bar() 266