1; RUN: llc < %s -march=avr -mcpu=avr5 | FileCheck %s 2 3; The original reason for this failure is that the BranchFolderPass disables liveness 4; tracking unless you override the trackLivenessAfterRegAlloc function and return true. 5; This probably should be the default because all main targets do this (maybe some gpu targets don't). 6 7; More info can be found at https://github.com/avr-rust/rust/issues/99. 8 9%struct.quux = type { [0 x i8], i64, [0 x i8], i64, [0 x i8], i64, [0 x i8], i64, [0 x i8] } 10%struct.foo = type { [0 x i8], %struct.blam, [0 x i8], i32, [0 x i8], i32, [0 x i8], i8, [0 x i8], %struct.blam.0, [0 x i8], %struct.blam.0, [0 x i8] } 11%struct.blam = type {} 12%struct.blam.0 = type { [0 x i8], i8, [2 x i8] } 13%struct.quux.1 = type { [0 x i8], %struct.wombat, [0 x i8], i64, [0 x i8], i64, [0 x i8], i16, [0 x i8], %struct.quux, [0 x i8], i64, [0 x i8], i16, [0 x i8] } 14%struct.wombat = type {} 15 16declare zeroext i1 @zot(%struct.quux*, %struct.foo*) 17 18declare void @wibble(i16, i16) 19 20; CHECK-LABEL: main 21define zeroext i1 @main(%struct.quux.1* %arg, %struct.foo* %arg62) { 22bb: 23 %tmp63 = alloca [128 x i8], align 1 24 %tmp = getelementptr inbounds %struct.quux.1, %struct.quux.1* %arg, i16 0, i32 5 25 %tmp64 = getelementptr inbounds %struct.quux.1, %struct.quux.1* %arg, i16 0, i32 13 26 %tmp65 = bitcast %struct.foo* %arg62 to i32* 27 %tmp66 = icmp eq i32 undef, 0 28 br i1 undef, label %bb92, label %bb67 29 30bb67: 31 br i1 %tmp66, label %bb83, label %bb68 32 33bb68: 34 %tmp69 = load i64, i64* null, align 1 35 br label %bb70 36 37bb70: 38 %tmp71 = phi i16 [ 128, %bb68 ], [ %tmp79, %bb70 ] 39 %tmp72 = phi i64 [ %tmp69, %bb68 ], [ %tmp74, %bb70 ] 40 %tmp73 = getelementptr inbounds i8, i8* null, i16 -1 41 %tmp74 = lshr i64 %tmp72, 4 42 %tmp75 = trunc i64 %tmp72 to i8 43 %tmp76 = and i8 %tmp75, 15 44 %tmp77 = add nuw nsw i8 %tmp76, 87 45 %tmp78 = select i1 undef, i8 undef, i8 %tmp77 46 store i8 %tmp78, i8* %tmp73, align 1 47 %tmp79 = add nsw i16 %tmp71, -1 48 %tmp80 = icmp eq i8* %tmp73, null 49 %tmp81 = or i1 undef, %tmp80 50 br i1 %tmp81, label %bb82, label %bb70 51 52bb82: 53 call void @wibble(i16 %tmp79, i16 128) 54 unreachable 55 56bb83: 57 %tmp84 = icmp eq i32 undef, 0 58 %tmp85 = load i64, i64* null, align 1 59 br i1 %tmp84, label %bb87, label %bb86 60 61bb86: 62 unreachable 63 64bb87: 65 br label %bb88 66 67bb88: 68 %tmp89 = phi i64 [ %tmp90, %bb88 ], [ %tmp85, %bb87 ] 69 %tmp90 = udiv i64 %tmp89, 10000 70 %tmp91 = icmp ugt i64 %tmp89, 99999999 71 br label %bb88 72 73bb92: 74 br label %bb93 75 76bb93: 77 br i1 undef, label %bb95, label %bb94 78 79bb94: 80 unreachable 81 82bb95: 83 br label %bb96 84 85bb96: 86 %tmp97 = phi i64 [ %tmp98, %bb96 ], [ undef, %bb95 ] 87 %tmp98 = udiv i64 %tmp97, 10000 88 %tmp99 = icmp ugt i64 %tmp97, 99999999 89 br i1 %tmp99, label %bb96, label %bb100 90 91bb100: 92 br label %bb101 93 94bb101: 95 %tmp102 = and i32 undef, 16 96 %tmp103 = icmp eq i32 %tmp102, 0 97 br i1 undef, label %bb130, label %bb104 98 99bb104: 100 br i1 %tmp103, label %bb117, label %bb105 101 102bb105: 103 br label %bb106 104 105bb106: 106 %tmp107 = phi i16 [ 128, %bb105 ], [ %tmp113, %bb106 ] 107 %tmp108 = phi i64 [ undef, %bb105 ], [ %tmp111, %bb106 ] 108 %tmp109 = phi i8* [ undef, %bb105 ], [ %tmp110, %bb106 ] 109 %tmp110 = getelementptr inbounds i8, i8* %tmp109, i16 -1 110 %tmp111 = lshr i64 %tmp108, 4 111 %tmp112 = trunc i64 %tmp108 to i8 112 %tmp113 = add nsw i16 %tmp107, -1 113 %tmp114 = icmp eq i8* %tmp110, null 114 %tmp115 = or i1 undef, %tmp114 115 br i1 %tmp115, label %bb116, label %bb106 116 117bb116: 118 call void @wibble(i16 %tmp113, i16 128) 119 unreachable 120 121bb117: 122 %tmp118 = load i64, i64* %tmp, align 1 123 br i1 undef, label %bb120, label %bb119 124 125bb119: 126 unreachable 127 128bb120: 129 %tmp121 = icmp ugt i64 %tmp118, 9999 130 br i1 %tmp121, label %bb122, label %bb127 131 132bb122: 133 br label %bb123 134 135bb123: 136 %tmp124 = phi i64 [ %tmp125, %bb123 ], [ %tmp118, %bb122 ] 137 %tmp125 = udiv i64 %tmp124, 10000 138 %tmp126 = icmp ugt i64 %tmp124, 99999999 139 br label %bb123 140 141bb127: 142 %tmp128 = load i32, i32* %tmp65, align 1 143 %tmp129 = icmp eq i32 undef, 0 144 br label %bb162 145 146bb130: 147 br i1 %tmp103, label %bb142, label %bb131 148 149bb131: 150 br label %bb132 151 152bb132: 153 %tmp133 = phi i64 [ undef, %bb131 ], [ %tmp134, %bb132 ] 154 %tmp134 = lshr i64 %tmp133, 4 155 %tmp135 = trunc i64 %tmp133 to i8 156 %tmp136 = and i8 %tmp135, 15 157 %tmp137 = add nuw nsw i8 %tmp136, 87 158 %tmp138 = select i1 undef, i8 undef, i8 %tmp137 159 store i8 %tmp138, i8* undef, align 1 160 %tmp139 = icmp eq i8* undef, null 161 %tmp140 = or i1 undef, %tmp139 162 br i1 %tmp140, label %bb141, label %bb132 163 164bb141: 165 unreachable 166 167bb142: 168 %tmp143 = icmp eq i32 undef, 0 169 %tmp144 = load i64, i64* %tmp, align 1 170 br i1 %tmp143, label %bb156, label %bb145 171 172bb145: 173 br label %bb146 174 175bb146: 176 %tmp147 = phi i16 [ 128, %bb145 ], [ %tmp151, %bb146 ] 177 %tmp148 = phi i64 [ %tmp144, %bb145 ], [ %tmp150, %bb146 ] 178 %tmp149 = getelementptr inbounds i8, i8* null, i16 -1 179 %tmp150 = lshr i64 %tmp148, 4 180 %tmp151 = add nsw i16 %tmp147, -1 181 %tmp152 = icmp eq i64 %tmp150, 0 182 %tmp153 = icmp eq i8* %tmp149, null 183 %tmp154 = or i1 %tmp152, %tmp153 184 br i1 %tmp154, label %bb155, label %bb146 185 186bb155: 187 call void @wibble(i16 %tmp151, i16 128) 188 unreachable 189 190bb156: 191 br label %bb157 192 193bb157: 194 %tmp158 = phi i64 [ %tmp159, %bb157 ], [ %tmp144, %bb156 ] 195 %tmp159 = udiv i64 %tmp158, 10000 196 %tmp160 = icmp ugt i64 %tmp158, 99999999 197 br i1 %tmp160, label %bb157, label %bb161 198 199bb161: 200 unreachable 201 202bb162: 203 br i1 %tmp129, label %bb164, label %bb163 204 205bb163: 206 unreachable 207 208bb164: 209 %tmp165 = and i32 %tmp128, 32 210 %tmp166 = icmp eq i32 %tmp165, 0 211 br i1 %tmp166, label %bb169, label %bb167 212 213bb167: 214 br label %bb168 215 216bb168: 217 br label %bb168 218 219bb169: 220 br label %bb170 221 222bb170: 223 br i1 undef, label %bb172, label %bb171 224 225bb171: 226 store i32 0, i32* undef, align 1 227 call void @llvm.memcpy.p0i8.p0i8.i16(i8* align 1 undef, i8* align 1 null, i16 3, i1 false) 228 call void @llvm.memcpy.p0i8.p0i8.i16(i8* align 1 undef, i8* align 1 null, i16 3, i1 false) 229 br label %bb214 230 231bb172: 232 %tmp173 = call zeroext i1 @zot(%struct.quux* noalias nonnull readonly dereferenceable(32) undef, %struct.foo* nonnull dereferenceable(15) %arg62) 233 br i1 %tmp173, label %bb214, label %bb174 234 235bb174: 236 %tmp175 = load i32, i32* %tmp65, align 1 237 %tmp176 = icmp eq i32 undef, 0 238 br label %bb177 239 240bb177: 241 br i1 %tmp176, label %bb190, label %bb178 242 243bb178: 244 %tmp179 = getelementptr inbounds [128 x i8], [128 x i8]* %tmp63, i16 0, i16 0 245 br label %bb180 246 247bb180: 248 %tmp181 = phi i64 [ 0, %bb178 ], [ %tmp182, %bb180 ] 249 %tmp182 = lshr i64 %tmp181, 4 250 %tmp183 = trunc i64 %tmp181 to i8 251 %tmp184 = and i8 %tmp183, 15 252 %tmp185 = add nuw nsw i8 %tmp184, 87 253 %tmp186 = select i1 false, i8 0, i8 %tmp185 254 store i8 %tmp186, i8* null, align 1 255 %tmp187 = icmp eq i8* null, %tmp179 256 %tmp188 = or i1 undef, %tmp187 257 br i1 %tmp188, label %bb189, label %bb180 258 259bb189: 260 call void @wibble(i16 0, i16 128) 261 unreachable 262 263bb190: 264 %tmp191 = and i32 %tmp175, 32 265 %tmp192 = icmp eq i32 %tmp191, 0 266 br i1 %tmp192, label %bb201, label %bb193 267 268bb193: 269 br label %bb194 270 271bb194: 272 %tmp195 = phi i64 [ 0, %bb193 ], [ %tmp196, %bb194 ] 273 %tmp196 = lshr i64 %tmp195, 4 274 %tmp197 = add nsw i16 0, -1 275 %tmp198 = icmp eq i64 %tmp196, 0 276 %tmp199 = or i1 %tmp198, undef 277 br i1 %tmp199, label %bb200, label %bb194 278 279bb200: 280 call void @wibble(i16 %tmp197, i16 128) 281 unreachable 282 283bb201: 284 br i1 undef, label %bb202, label %bb207 285 286bb202: 287 br label %bb203 288 289bb203: 290 %tmp204 = phi i64 [ %tmp205, %bb203 ], [ 0, %bb202 ] 291 %tmp205 = udiv i64 %tmp204, 10000 292 %tmp206 = icmp ugt i64 %tmp204, 99999999 293 br i1 %tmp206, label %bb203, label %bb207 294 295bb207: 296 br label %bb208 297 298bb208: 299 store i16* %tmp64, i16** undef, align 1 300 %tmp209 = load i32, i32* %tmp65, align 1 301 %tmp210 = icmp eq i32 undef, 0 302 %tmp211 = and i32 %tmp209, 16 303 %tmp212 = icmp eq i32 %tmp211, 0 304 br i1 %tmp210, label %bb215, label %bb213 305 306bb213: 307 unreachable 308 309bb214: 310 br label %bb221 311 312bb215: 313 br i1 %tmp212, label %bb220, label %bb216 314 315bb216: 316 br label %bb217 317 318bb217: 319 br i1 undef, label %bb218, label %bb219 320 321bb218: 322 unreachable 323 324bb219: 325 br label %bb221 326 327bb220: 328 unreachable 329 330bb221: 331 store %struct.quux.1* %arg, %struct.quux.1** undef, align 1 332 ret i1 undef 333} 334 335declare void @llvm.memcpy.p0i8.p0i8.i16(i8* nocapture writeonly, i8* nocapture readonly, i16, i1) 336 337