1; RUN: llc < %s -mtriple=thumbv6-apple-darwin | FileCheck %s 2; RUN: llc < %s -mtriple=thumbv6-apple-darwin -regalloc=basic | FileCheck %s 3; rdar://8819685 4 5@__bar = external hidden global i8* 6@__baz = external hidden global i8* 7 8define i8* @_foo() { 9entry: 10; CHECK: foo: 11 12 %size = alloca i32, align 4 13 %0 = load i8** @__bar, align 4 14 %1 = icmp eq i8* %0, null 15 br i1 %1, label %bb1, label %bb3 16; CHECK: bne 17 18bb1: 19 store i32 1026, i32* %size, align 4 20 %2 = alloca [1026 x i8], align 1 21; CHECK: mov [[R0:r[0-9]+]], sp 22; CHECK: adds {{r[0-9]+}}, [[R0]], {{r[0-9]+}} 23 %3 = getelementptr inbounds [1026 x i8]* %2, i32 0, i32 0 24 %4 = call i32 @_called_func(i8* %3, i32* %size) nounwind 25 %5 = icmp eq i32 %4, 0 26 br i1 %5, label %bb2, label %bb3 27 28bb2: 29 %6 = call i8* @strdup(i8* %3) nounwind 30 store i8* %6, i8** @__baz, align 4 31 br label %bb3 32 33bb3: 34 %.0 = phi i8* [ %0, %entry ], [ %6, %bb2 ], [ %3, %bb1 ] 35; CHECK: subs r4, #5 36; CHECK-NEXT: mov sp, r4 37; CHECK-NEXT: pop {r4, r5, r6, r7, pc} 38 ret i8* %.0 39} 40 41declare noalias i8* @strdup(i8* nocapture) nounwind 42declare i32 @_called_func(i8*, i32*) nounwind