1 ; RUN: llc < %s -mtriple=thumb-linux-androideabi -verify-machineinstrs | FileCheck %s -check-prefix=Thumb-android 2 ; RUN: llc < %s -mtriple=thumb-linux-unknown-gnueabi -verify-machineinstrs | FileCheck %s -check-prefix=Thumb-linux 3 ; RUN: llc < %s -mtriple=thumb-linux-androideabi -filetype=obj 4 ; RUN: llc < %s -mtriple=thumb-linux-unknown-gnueabi -filetype=obj 5 6 7 ; Just to prevent the alloca from being optimized away 8 declare void @dummy_use(i32*, i32) 9 10 define void @test_basic() #0 { 11 %mem = alloca i32, i32 10 12 call void @dummy_use (i32* %mem, i32 10) 13 ret void 14 15 ; Thumb-android-LABEL: test_basic: 16 17 ; Thumb-android: push {r4, r5} 18 ; Thumb-android-NEXT: mov r5, sp 19 ; Thumb-android-NEXT: ldr r4, .LCPI0_0 20 ; Thumb-android-NEXT: ldr r4, [r4] 21 ; Thumb-android-NEXT: cmp r4, r5 22 ; Thumb-android-NEXT: blo .LBB0_2 23 24 ; Thumb-android: mov r4, #48 25 ; Thumb-android-NEXT: mov r5, #0 26 ; Thumb-android-NEXT: push {lr} 27 ; Thumb-android-NEXT: bl __morestack 28 ; Thumb-android-NEXT: pop {r4} 29 ; Thumb-android-NEXT: mov lr, r4 30 ; Thumb-android-NEXT: pop {r4, r5} 31 ; Thumb-android-NEXT: bx lr 32 33 ; Thumb-android: pop {r4, r5} 34 35 ; Thumb-android: .p2align 2 36 ; Thumb-android: .LCPI0_0: 37 ; Thumb-android-NEXT: .long __STACK_LIMIT 38 39 ; Thumb-linux-LABEL: test_basic: 40 41 ; Thumb-linux: push {r4, r5} 42 ; Thumb-linux-NEXT: mov r5, sp 43 ; Thumb-linux-NEXT: ldr r4, .LCPI0_0 44 ; Thumb-linux-NEXT: ldr r4, [r4] 45 ; Thumb-linux-NEXT: cmp r4, r5 46 ; Thumb-linux-NEXT: blo .LBB0_2 47 48 ; Thumb-linux: mov r4, #48 49 ; Thumb-linux-NEXT: mov r5, #0 50 ; Thumb-linux-NEXT: push {lr} 51 ; Thumb-linux-NEXT: bl __morestack 52 ; Thumb-linux-NEXT: pop {r4} 53 ; Thumb-linux-NEXT: mov lr, r4 54 ; Thumb-linux-NEXT: pop {r4, r5} 55 ; Thumb-linux-NEXT: bx lr 56 57 ; Thumb-linux: pop {r4, r5} 58 59 } 60 61 define i32 @test_nested(i32 * nest %closure, i32 %other) #0 { 62 %addend = load i32 , i32 * %closure 63 %result = add i32 %other, %addend 64 %mem = alloca i32, i32 10 65 call void @dummy_use (i32* %mem, i32 10) 66 ret i32 %result 67 68 ; Thumb-android-LABEL: test_nested: 69 70 ; Thumb-android: push {r4, r5} 71 ; Thumb-android-NEXT: mov r5, sp 72 ; Thumb-android-NEXT: ldr r4, .LCPI1_0 73 ; Thumb-android-NEXT: ldr r4, [r4] 74 ; Thumb-android-NEXT: cmp r4, r5 75 ; Thumb-android-NEXT: blo .LBB1_2 76 77 ; Thumb-android: mov r4, #56 78 ; Thumb-android-NEXT: mov r5, #0 79 ; Thumb-android-NEXT: push {lr} 80 ; Thumb-android-NEXT: bl __morestack 81 ; Thumb-android-NEXT: pop {r4} 82 ; Thumb-android-NEXT: mov lr, r4 83 ; Thumb-android-NEXT: pop {r4, r5} 84 ; Thumb-android-NEXT: bx lr 85 86 ; Thumb-android: pop {r4, r5} 87 88 ; Thumb-linux-LABEL: test_nested: 89 90 ; Thumb-linux: push {r4, r5} 91 ; Thumb-linux-NEXT: mov r5, sp 92 ; Thumb-linux-NEXT: ldr r4, .LCPI1_0 93 ; Thumb-linux-NEXT: ldr r4, [r4] 94 ; Thumb-linux-NEXT: cmp r4, r5 95 ; Thumb-linux-NEXT: blo .LBB1_2 96 97 ; Thumb-linux: mov r4, #56 98 ; Thumb-linux-NEXT: mov r5, #0 99 ; Thumb-linux-NEXT: push {lr} 100 ; Thumb-linux-NEXT: bl __morestack 101 ; Thumb-linux-NEXT: pop {r4} 102 ; Thumb-linux-NEXT: mov lr, r4 103 ; Thumb-linux-NEXT: pop {r4, r5} 104 ; Thumb-linux-NEXT: bx lr 105 106 ; Thumb-linux: pop {r4, r5} 107 108 } 109 110 define void @test_large() #0 { 111 %mem = alloca i32, i32 10000 112 call void @dummy_use (i32* %mem, i32 0) 113 ret void 114 115 ; Thumb-android-LABEL: test_large: 116 117 ; Thumb-android: push {r4, r5} 118 ; Thumb-android-NEXT: mov r5, sp 119 ; Thumb-android-NEXT: sub r5, #40192 120 ; Thumb-android-NEXT: ldr r4, .LCPI2_2 121 ; Thumb-android-NEXT: ldr r4, [r4] 122 ; Thumb-android-NEXT: cmp r4, r5 123 ; Thumb-android-NEXT: blo .LBB2_2 124 125 ; Thumb-android: mov r4, #40192 126 ; Thumb-android-NEXT: mov r5, #0 127 ; Thumb-android-NEXT: push {lr} 128 ; Thumb-android-NEXT: bl __morestack 129 ; Thumb-android-NEXT: pop {r4} 130 ; Thumb-android-NEXT: mov lr, r4 131 ; Thumb-android-NEXT: pop {r4, r5} 132 ; Thumb-android-NEXT: bx lr 133 134 ; Thumb-android: pop {r4, r5} 135 136 ; Thumb-linux-LABEL: test_large: 137 138 ; Thumb-linux: push {r4, r5} 139 ; Thumb-linux-NEXT: mov r5, sp 140 ; Thumb-linux-NEXT: sub r5, #40192 141 ; Thumb-linux-NEXT: ldr r4, .LCPI2_2 142 ; Thumb-linux-NEXT: ldr r4, [r4] 143 ; Thumb-linux-NEXT: cmp r4, r5 144 ; Thumb-linux-NEXT: blo .LBB2_2 145 146 ; Thumb-linux: mov r4, #40192 147 ; Thumb-linux-NEXT: mov r5, #0 148 ; Thumb-linux-NEXT: push {lr} 149 ; Thumb-linux-NEXT: bl __morestack 150 ; Thumb-linux-NEXT: pop {r4} 151 ; Thumb-linux-NEXT: mov lr, r4 152 ; Thumb-linux-NEXT: pop {r4, r5} 153 ; Thumb-linux-NEXT: bx lr 154 155 ; Thumb-linux: pop {r4, r5} 156 157 } 158 159 define fastcc void @test_fastcc() #0 { 160 %mem = alloca i32, i32 10 161 call void @dummy_use (i32* %mem, i32 10) 162 ret void 163 164 ; Thumb-android-LABEL: test_fastcc: 165 166 ; Thumb-android: push {r4, r5} 167 ; Thumb-android-NEXT: mov r5, sp 168 ; Thumb-android-NEXT: ldr r4, .LCPI3_0 169 ; Thumb-android-NEXT: ldr r4, [r4] 170 ; Thumb-android-NEXT: cmp r4, r5 171 ; Thumb-android-NEXT: blo .LBB3_2 172 173 ; Thumb-android: mov r4, #48 174 ; Thumb-android-NEXT: mov r5, #0 175 ; Thumb-android-NEXT: push {lr} 176 ; Thumb-android-NEXT: bl __morestack 177 ; Thumb-android-NEXT: pop {r4} 178 ; Thumb-android-NEXT: mov lr, r4 179 ; Thumb-android-NEXT: pop {r4, r5} 180 ; Thumb-android-NEXT: bx lr 181 182 ; Thumb-android: pop {r4, r5} 183 184 ; Thumb-linux-LABEL: test_fastcc: 185 186 ; Thumb-linux: push {r4, r5} 187 ; Thumb-linux-NEXT: mov r5, sp 188 ; Thumb-linux-NEXT: ldr r4, .LCPI3_0 189 ; Thumb-linux-NEXT: ldr r4, [r4] 190 ; Thumb-linux-NEXT: cmp r4, r5 191 ; Thumb-linux-NEXT: blo .LBB3_2 192 193 ; Thumb-linux: mov r4, #48 194 ; Thumb-linux-NEXT: mov r5, #0 195 ; Thumb-linux-NEXT: push {lr} 196 ; Thumb-linux-NEXT: bl __morestack 197 ; Thumb-linux-NEXT: pop {r4} 198 ; Thumb-linux-NEXT: mov lr, r4 199 ; Thumb-linux-NEXT: pop {r4, r5} 200 ; Thumb-linux-NEXT: bx lr 201 202 ; Thumb-linux: pop {r4, r5} 203 204 } 205 206 define fastcc void @test_fastcc_large() #0 { 207 %mem = alloca i32, i32 10000 208 call void @dummy_use (i32* %mem, i32 0) 209 ret void 210 211 ; Thumb-android-LABEL: test_fastcc_large: 212 213 ; Thumb-android: push {r4, r5} 214 ; Thumb-android-NEXT: mov r5, sp 215 ; Thumb-android-NEXT: sub r5, #40192 216 ; Thumb-android-NEXT: ldr r4, .LCPI4_2 217 ; Thumb-android-NEXT: ldr r4, [r4] 218 ; Thumb-android-NEXT: cmp r4, r5 219 ; Thumb-android-NEXT: blo .LBB4_2 220 221 ; Thumb-android: mov r4, #40192 222 ; Thumb-android-NEXT: mov r5, #0 223 ; Thumb-android-NEXT: push {lr} 224 ; Thumb-android-NEXT: bl __morestack 225 ; Thumb-android-NEXT: pop {r4} 226 ; Thumb-android-NEXT: mov lr, r4 227 ; Thumb-android-NEXT: pop {r4, r5} 228 ; Thumb-android-NEXT: bx lr 229 230 ; Thumb-android: pop {r4, r5} 231 232 ; Thumb-linux-LABEL: test_fastcc_large: 233 234 ; Thumb-linux: push {r4, r5} 235 ; Thumb-linux-NEXT: mov r5, sp 236 ; Thumb-linux-NEXT: sub r5, #40192 237 ; Thumb-linux-NEXT: ldr r4, .LCPI4_2 238 ; Thumb-linux-NEXT: ldr r4, [r4] 239 ; Thumb-linux-NEXT: cmp r4, r5 240 ; Thumb-linux-NEXT: blo .LBB4_2 241 242 ; Thumb-linux: mov r4, #40192 243 ; Thumb-linux-NEXT: mov r5, #0 244 ; Thumb-linux-NEXT: push {lr} 245 ; Thumb-linux-NEXT: bl __morestack 246 ; Thumb-linux-NEXT: pop {r4} 247 ; Thumb-linux-NEXT: mov lr, r4 248 ; Thumb-linux-NEXT: pop {r4, r5} 249 ; Thumb-linux-NEXT: bx lr 250 251 ; Thumb-linux: pop {r4, r5} 252 253 } 254 255 define void @test_nostack() #0 { 256 ret void 257 258 ; Thumb-android-LABEL: test_nostack: 259 ; Thumb-android-NOT: bl __morestack 260 261 ; Thumb-linux-LABEL: test_nostack: 262 ; Thumb-linux-NOT: bl __morestack 263 } 264 265 attributes #0 = { "split-stack" } 266