1; Disable shrink-wrapping on the first test otherwise we wouldn't 2; exerce the path for PR18136. 3; RUN: llc -mtriple=thumbv7-apple-none-macho < %s -enable-shrink-wrap=false | FileCheck %s 4; RUN: llc -mtriple=thumbv6m-apple-none-macho -disable-fp-elim < %s | FileCheck %s --check-prefix=CHECK-T1 5; RUN: llc -mtriple=thumbv7-apple-darwin-ios -disable-fp-elim < %s | FileCheck %s --check-prefix=CHECK-IOS 6; RUN: llc -mtriple=thumbv7--linux-gnueabi -disable-fp-elim < %s | FileCheck %s --check-prefix=CHECK-LINUX 7 8 9declare void @bar(i8*) 10 11%bigVec = type [2 x double] 12 13@var = global %bigVec zeroinitializer 14 15define void @check_simple() minsize { 16; CHECK-LABEL: check_simple: 17; CHECK: push {r3, r4, r5, r6, r7, lr} 18; CHECK-NOT: sub sp, sp, 19; ... 20; CHECK-NOT: add sp, sp, 21; CHECK: pop {r0, r1, r2, r3, r7, pc} 22 23; CHECK-T1-LABEL: check_simple: 24; CHECK-T1: push {r3, r4, r5, r6, r7, lr} 25; CHECK-T1: add r7, sp, #16 26; CHECK-T1-NOT: sub sp, sp, 27; ... 28; CHECK-T1-NOT: add sp, sp, 29; CHECK-T1: pop {r0, r1, r2, r3, r7, pc} 30 31 ; iOS always has a frame pointer and messing with the push affects 32 ; how it's set in the prologue. Make sure we get that right. 33; CHECK-IOS-LABEL: check_simple: 34; CHECK-IOS: push {r3, r4, r5, r6, r7, lr} 35; CHECK-NOT: sub sp, 36; CHECK-IOS: add r7, sp, #16 37; CHECK-NOT: sub sp, 38; ... 39; CHECK-NOT: add sp, 40; CHEC: pop {r3, r4, r5, r6, r7, pc} 41 42 %var = alloca i8, i32 16 43 call void @bar(i8* %var) 44 ret void 45} 46 47define void @check_simple_too_big() minsize { 48; CHECK-LABEL: check_simple_too_big: 49; CHECK: push {r7, lr} 50; CHECK: sub sp, 51; ... 52; CHECK: add sp, 53; CHECK: pop {r7, pc} 54 %var = alloca i8, i32 64 55 call void @bar(i8* %var) 56 ret void 57} 58 59define void @check_vfp_fold() minsize { 60; CHECK-LABEL: check_vfp_fold: 61; CHECK: push {r[[GLOBREG:[0-9]+]], lr} 62; CHECK: vpush {d6, d7, d8, d9} 63; CHECK-NOT: sub sp, 64; ... 65; CHECK-NOT: add sp, 66; CHECK: vpop {d6, d7, d8, d9} 67; CHECK: pop {r[[GLOBREG]], pc} 68 69 ; iOS uses aligned NEON stores here, which is convenient since we 70 ; want to make sure that works too. 71; CHECK-IOS-LABEL: check_vfp_fold: 72; CHECK-IOS: push {r4, r7, lr} 73; CHECK-IOS: sub.w r4, sp, #16 74; CHECK-IOS: bfc r4, #0, #4 75; CHECK-IOS: mov sp, r4 76; CHECK-IOS: vst1.64 {d8, d9}, [r4:128] 77; CHECK-IOS: sub sp, #16 78; ... 79; CHECK-IOS: add r4, sp, #16 80; CHECK-IOS: vld1.64 {d8, d9}, [r4:128] 81; CHECK-IOS: mov sp, r4 82; CHECK-IOS: pop {r4, r7, pc} 83 84 %var = alloca i8, i32 16 85 86 call void asm "", "r,~{d8},~{d9}"(i8* %var) 87 call void @bar(i8* %var) 88 89 ret void 90} 91 92; This function should use just enough space that the "add sp, sp, ..." could be 93; folded in except that doing so would clobber the value being returned. 94define i64 @check_no_return_clobber() minsize { 95; CHECK-LABEL: check_no_return_clobber: 96; CHECK: push {r1, r2, r3, r4, r5, r6, r7, lr} 97; CHECK-NOT: sub sp, 98; ... 99; CHECK: add sp, #24 100; CHECK: pop {r7, pc} 101 102 ; Just to keep iOS FileCheck within previous function: 103; CHECK-IOS-LABEL: check_no_return_clobber: 104 105 %var = alloca i8, i32 20 106 call void @bar(i8* %var) 107 ret i64 0 108} 109 110define arm_aapcs_vfpcc double @check_vfp_no_return_clobber() minsize { 111; CHECK-LABEL: check_vfp_no_return_clobber: 112; CHECK: push {r[[GLOBREG:[0-9]+]], lr} 113; CHECK: vpush {d0, d1, d2, d3, d4, d5, d6, d7, d8, d9} 114; CHECK-NOT: sub sp, 115; ... 116; CHECK: add sp, #64 117; CHECK: vpop {d8, d9} 118; CHECK: pop {r[[GLOBREG]], pc} 119 120 %var = alloca i8, i32 64 121 122 %tmp = load %bigVec, %bigVec* @var 123 call void @bar(i8* %var) 124 store %bigVec %tmp, %bigVec* @var 125 126 ret double 1.0 127} 128 129@dbl = global double 0.0 130 131; PR18136: there was a bug determining where the first eligible pop in a 132; basic-block was when the entire block was epilogue code. 133define void @test_fold_point(i1 %tst) minsize { 134; CHECK-LABEL: test_fold_point: 135 136 ; Important to check for beginning of basic block, because if it gets 137 ; if-converted the test is probably no longer checking what it should. 138; CHECK: {{LBB[0-9]+_2}}: 139; CHECK-NEXT: vpop {d7, d8} 140; CHECK-NEXT: pop {r4, pc} 141 142 ; With a guaranteed frame-pointer, we want to make sure that its offset in the 143 ; push block is correct, even if a few registers have been tacked onto a later 144 ; vpush (PR18160). 145; CHECK-IOS-LABEL: test_fold_point: 146; CHECK-IOS: push {r4, r7, lr} 147; CHECK-IOS-NEXT: add r7, sp, #4 148; CHECK-IOS-NEXT: vpush {d7, d8} 149 150 ; We want some memory so there's a stack adjustment to fold... 151 %var = alloca i8, i32 8 152 153 ; We want a long-lived floating register so that a callee-saved dN is used and 154 ; there's both a vpop and a pop. 155 %live_val = load double, double* @dbl 156 br i1 %tst, label %true, label %end 157true: 158 call void @bar(i8* %var) 159 store double %live_val, double* @dbl 160 br label %end 161end: 162 ; We want the epilogue to be the only thing in a basic block so that we hit 163 ; the correct edge-case (first inst in block is correct one to adjust). 164 ret void 165} 166 167define void @test_varsize(...) minsize { 168; CHECK-T1-LABEL: test_varsize: 169; CHECK-T1: sub sp, #16 170; CHECK-T1: push {r5, r6, r7, lr} 171; ... 172; CHECK-T1: pop {r2, r3, r7} 173; CHECK-T1: pop {[[POP_REG:r[0-3]]]} 174; CHECK-T1: add sp, #16 175; CHECK-T1: bx [[POP_REG]] 176 177; CHECK-LABEL: test_varsize: 178; CHECK: sub sp, #16 179; CHECK: push {r5, r6, r7, lr} 180; ... 181; CHECK: pop.w {r2, r3, r7, lr} 182; CHECK: add sp, #16 183; CHECK: bx lr 184 185 %var = alloca i8, i32 8 186 call void @llvm.va_start(i8* %var) 187 call void @bar(i8* %var) 188 ret void 189} 190 191%"MyClass" = type { i8*, i32, i32, float, float, float, [2 x i8], i32, i32* } 192 193declare float @foo() 194 195declare void @bar3() 196 197declare %"MyClass"* @bar2(%"MyClass"* returned, i16*, i32, float, float, i32, i32, i1 zeroext, i1 zeroext, i32) 198 199define fastcc float @check_vfp_no_return_clobber2(i16* %r, i16* %chars, i32 %length, i1 zeroext %flag) minsize { 200entry: 201; CHECK-LINUX-LABEL: check_vfp_no_return_clobber2 202; CHECK-LINUX: vpush {d0, d1, d2, d3, d4, d5, d6, d7, d8} 203; CHECK-NOT: sub sp, 204; ... 205; CHECK-LINUX: add sp 206; CHECK-LINUX: vpop {d8} 207 %run = alloca %"MyClass", align 4 208 %call = call %"MyClass"* @bar2(%"MyClass"* %run, i16* %chars, i32 %length, float 0.000000e+00, float 0.000000e+00, i32 1, i32 1, i1 zeroext false, i1 zeroext true, i32 3) 209 %call1 = call float @foo() 210 %cmp = icmp eq %"MyClass"* %run, null 211 br i1 %cmp, label %exit, label %if.then 212 213if.then: ; preds = %entry 214 call void @bar3() 215 br label %exit 216 217exit: ; preds = %if.then, %entry 218 ret float %call1 219} 220 221declare void @llvm.va_start(i8*) nounwind 222