1 ; RUN: llc < %s -mtriple=thumb-apple-ios | FileCheck %s --check-prefix=CHECK
2 ; RUN: llc < %s -mtriple=thumb-none-eabi | FileCheck %s --check-prefix=CHECK
3 ; RUN: llc < %s -o %t -filetype=obj -mtriple=thumbv6-apple-ios
4 ; RUN: llvm-objdump --no-print-imm-hex --triple=thumbv6-apple-ios -d %t | FileCheck %s --check-prefix=CHECK
5 ; RUN: llc < %s -o %t -filetype=obj -mtriple=thumbv6-none-eabi
6 ; RUN: llvm-objdump --no-print-imm-hex --triple=thumbv6-none-eabi -d %t | FileCheck %s --check-prefix=CHECK
8 ; Largest stack for which a single tADDspi/tSUBspi is enough
10 ; CHECK-LABEL: test1{{>?}}:
13 %tmp = alloca [ 508 x i8 ] , align 4
17 ; Largest stack for which three tADDspi/tSUBspis are enough
18 define void @test100() {
19 ; CHECK-LABEL: test100{{>?}}:
26 %tmp = alloca [ 1524 x i8 ] , align 4
30 ; Largest stack for which three tADDspi/tSUBspis are enough
31 define void @test100_nofpelim() "frame-pointer"="all" {
32 ; CHECK-LABEL: test100_nofpelim{{>?}}:
36 ; CHECK: subs [[SCRATCH:r[0-7]]], r7, #7
37 ; CHECK: subs [[SCRATCH]], #1
38 ; CHECK: mov sp, [[SCRATCH]]
40 ; CHECK-SAME: [[SCRATCH]]
41 %tmp = alloca [ 1524 x i8 ] , align 4
45 ; Smallest stack for which we use a constant pool
46 define void @test2() {
47 ; CHECK-LABEL: test2{{>?}}:
48 ; CHECK: ldr [[TEMP:r[0-7]]],
49 ; CHECK: add sp, [[TEMP]]
50 ; CHECK: ldr [[TEMP:r[0-7]]],
51 ; CHECK: add sp, [[TEMP]]
52 %tmp = alloca [ 1528 x i8 ] , align 4
56 ; Smallest stack for which we use a constant pool
57 define void @test2_nofpelim() "frame-pointer"="all" {
58 ; CHECK-LABEL: test2_nofpelim{{>?}}:
59 ; CHECK: ldr [[TEMP:r[0-7]]],
60 ; CHECK: add sp, [[TEMP]]
61 ; CHECK: subs [[SCRATCH:r[0-7]]], r7, #7
62 ; CHECK: subs [[SCRATCH]], #1
63 ; CHECK: mov sp, [[SCRATCH]]
65 ; CHECK-SAME: [[SCRATCH]]
66 %tmp = alloca [ 1528 x i8 ] , align 4
71 ; CHECK-LABEL: test3{{>?}}:
72 ; CHECK: ldr [[TEMP:r[0-7]]],
73 ; CHECK: add sp, [[TEMP]]
74 ; CHECK: ldr [[TEMP2:r[0-7]]],
75 ; CHECK: add [[TEMP2]], sp
76 ; CHECK: ldr [[TEMP3:r[0-7]]],
77 ; CHECK: add sp, [[TEMP3]]
78 %retval = alloca i32, align 4
79 %tmp = alloca i32, align 4
80 %a = alloca [805306369 x i8], align 4
82 %tmp1 = load i32, ptr %tmp
86 define i32 @test3_nofpelim() "frame-pointer"="all" {
87 ; CHECK-LABEL: test3_nofpelim{{>?}}:
88 ; CHECK: ldr [[TEMP:r[0-7]]],
89 ; CHECK: add sp, [[TEMP]]
90 ; CHECK: ldr [[TEMP2:r[0-7]]],
91 ; CHECK: add [[TEMP2]], sp
92 ; CHECK: subs [[SCRATCH:r[0-7]]], r7,
93 ; CHECK: mov sp, [[SCRATCH]]
95 ; CHECK-SAME: [[SCRATCH]]
96 %retval = alloca i32, align 4
97 %tmp = alloca i32, align 4
98 %a = alloca [805306369 x i8], align 8
100 %tmp1 = load i32, ptr %tmp
104 ; Here, the adds get optimized out because they are dead, but the calculation
105 ; of the address of stack_a is dead but not optimized out. When the address
106 ; calculation gets expanded to two instructions, we need to avoid reading a
108 ; No CHECK lines (just test for crashes), as we hope this will be optimised
110 define i32 @test4() {
112 %stack_a = alloca i8, align 1
113 %stack_b = alloca [256 x ptr], align 4
114 %int = ptrtoint ptr %stack_a to i32
115 %add = add i32 %int, 1
119 %add2 = add i32 %add, 1