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