1; RUN: llc < %s -mtriple=arm-linux-androideabi -verify-machineinstrs | FileCheck %s -check-prefix=ARM-android
2; RUN: llc < %s -mtriple=arm-linux-unknown-gnueabi -verify-machineinstrs | FileCheck %s -check-prefix=ARM-linux
3; RUN: llc < %s -mtriple=arm-linux-androideabi -filetype=obj
4; RUN: llc < %s -mtriple=arm-linux-unknown-gnueabi -filetype=obj
5
6; Just to prevent the alloca from being optimized away
7declare void @dummy_use(i32*, i32)
8
9define i32 @test_basic(i32 %l) #0 {
10        %mem = alloca i32, i32 %l
11        call void @dummy_use (i32* %mem, i32 %l)
12        %terminate = icmp eq i32 %l, 0
13        br i1 %terminate, label %true, label %false
14
15true:
16        ret i32 0
17
18false:
19        %newlen = sub i32 %l, 1
20        %retvalue = call i32 @test_basic(i32 %newlen)
21        ret i32 %retvalue
22
23; ARM-linux:      test_basic:
24
25; ARM-linux:      push    {r4, r5}
26; ARM-linux-NEXT: mrc     p15, #0, r4, c13, c0, #3
27; ARM-linux-NEXT: mov     r5, sp
28; ARM-linux-NEXT: ldr     r4, [r4, #4]
29; ARM-linux-NEXT: cmp     r4, r5
30; ARM-linux-NEXT: blo     .LBB0_2
31
32; ARM-linux:      mov     r4, #16
33; ARM-linux-NEXT: mov     r5, #0
34; ARM-linux-NEXT: stmdb   sp!, {lr}
35; ARM-linux-NEXT: bl      __morestack
36; ARM-linux-NEXT: ldm     sp!, {lr}
37; ARM-linux-NEXT: pop     {r4, r5}
38; ARM-linux-NEXT: bx      lr
39
40; ARM-linux:      pop     {r4, r5}
41
42
43; ARM-android:      test_basic:
44
45; ARM-android:      push    {r4, r5}
46; ARM-android-NEXT: mrc     p15, #0, r4, c13, c0, #3
47; ARM-android-NEXT: mov     r5, sp
48; ARM-android-NEXT: ldr     r4, [r4, #252]
49; ARM-android-NEXT: cmp     r4, r5
50; ARM-android-NEXT: blo     .LBB0_2
51
52; ARM-android:      mov     r4, #16
53; ARM-android-NEXT: mov     r5, #0
54; ARM-android-NEXT: stmdb   sp!, {lr}
55; ARM-android-NEXT: bl      __morestack
56; ARM-android-NEXT: ldm     sp!, {lr}
57; ARM-android-NEXT: pop     {r4, r5}
58; ARM-android-NEXT: bx      lr
59
60; ARM-android:      pop     {r4, r5}
61
62}
63
64attributes #0 = { "split-stack" }
65