| 1 |
; RUN: llc < %s -mtriple=thumbv7-apple-darwin -mcpu=cortex-a8 -O3 | FileCheck %s |
| 2 |
|
| 3 |
@.str = private constant [4 x i8] c"%d\0A\00", align 4 ; <ptr> [#uses=1] |
| 4 |
|
| 5 |
define internal fastcc i32 @Callee(i32 %i) nounwind { |
| 6 |
entry: |
| 7 |
; CHECK-LABEL: Callee: |
| 8 |
; CHECK: push |
| 9 |
; CHECK: mov r4, sp |
| 10 |
; CHECK: sub.w [[R12:r[0-9]+]], r4, #1000 |
| 11 |
; CHECK: mov sp, [[R12]] |
| 12 |
%0 = icmp eq i32 %i, 0 ; <i1> [#uses=1] |
| 13 |
br i1 %0, label %bb2, label %bb |
| 14 |
|
| 15 |
bb: ; preds = %entry |
| 16 |
%1 = alloca [1000 x i8], align 4 ; <ptr> [#uses=1] |
| 17 |
%.sub = getelementptr inbounds [1000 x i8], ptr %1, i32 0, i32 0 ; <ptr> [#uses=2] |
| 18 |
%2 = call i32 (ptr, i32, i32, ptr, ...) @__sprintf_chk(ptr %.sub, i32 0, i32 1000, ptr @.str, i32 %i) nounwind ; <i32> [#uses=0] |
| 19 |
%3 = load i8, ptr %.sub, align 4 ; <i8> [#uses=1] |
| 20 |
%4 = sext i8 %3 to i32 ; <i32> [#uses=1] |
| 21 |
ret i32 %4 |
| 22 |
|
| 23 |
bb2: ; preds = %entry |
| 24 |
; Must restore sp from fp here. Make sure not to leave sp in a temporarily invalid |
| 25 |
; state though. rdar://8465407 |
| 26 |
; CHECK-NOT: mov sp, r7 |
| 27 |
; CHECK: sub.w r4, r7, #8 |
| 28 |
; CHECK: mov sp, r4 |
| 29 |
; CHECK: pop |
| 30 |
ret i32 0 |
| 31 |
} |
| 32 |
|
| 33 |
declare i32 @__sprintf_chk(ptr, i32, i32, ptr, ...) nounwind |
| 34 |
|
| 35 |
define i32 @main() nounwind { |
| 36 |
; CHECK-LABEL: main: |
| 37 |
bb.nph: |
| 38 |
br label %bb |
| 39 |
|
| 40 |
bb: ; preds = %bb, %bb.nph |
| 41 |
%0 = phi i32 [ 0, %bb.nph ], [ %3, %bb ] ; <i32> [#uses=2] |
| 42 |
%j.01 = phi i32 [ 0, %bb.nph ], [ %2, %bb ] ; <i32> [#uses=1] |
| 43 |
%1 = tail call fastcc i32 @Callee(i32 %0) nounwind ; <i32> [#uses=1] |
| 44 |
%2 = add nsw i32 %1, %j.01 ; <i32> [#uses=2] |
| 45 |
%3 = add nsw i32 %0, 1 ; <i32> [#uses=2] |
| 46 |
%exitcond = icmp eq i32 %3, 10000 ; <i1> [#uses=1] |
| 47 |
br i1 %exitcond, label %bb2, label %bb |
| 48 |
|
| 49 |
bb2: ; preds = %bb |
| 50 |
; No need to restore sp from fp here. |
| 51 |
; CHECK: printf |
| 52 |
; CHECK-NOT: mov sp, r7 |
| 53 |
; CHECK-NOT: sub sp, #12 |
| 54 |
; CHECK: pop |
| 55 |
%4 = tail call i32 (ptr, ...) @printf(ptr @.str, i32 %2) nounwind ; <i32> [#uses=0] |
| 56 |
ret i32 0 |
| 57 |
} |
| 58 |
|
| 59 |
declare i32 @printf(ptr nocapture, ...) nounwind |