1*9880d681SAndroid Build Coastguard Worker; RUN: llc -verify-machineinstrs < %s -mtriple=aarch64-none-linux-gnu -tailcallopt | FileCheck %s 2*9880d681SAndroid Build Coastguard Worker 3*9880d681SAndroid Build Coastguard Worker; This test is designed to be run in the situation where the 4*9880d681SAndroid Build Coastguard Worker; call-frame is not reserved (hence disable-fp-elim), but where 5*9880d681SAndroid Build Coastguard Worker; callee-pop can occur (hence tailcallopt). 6*9880d681SAndroid Build Coastguard Worker 7*9880d681SAndroid Build Coastguard Workerdeclare fastcc void @will_pop([8 x i32], i32 %val) 8*9880d681SAndroid Build Coastguard Worker 9*9880d681SAndroid Build Coastguard Workerdefine fastcc void @foo(i32 %in) { 10*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: foo: 11*9880d681SAndroid Build Coastguard Worker 12*9880d681SAndroid Build Coastguard Worker %addr = alloca i8, i32 %in 13*9880d681SAndroid Build Coastguard Worker 14*9880d681SAndroid Build Coastguard Worker; Normal frame setup stuff: 15*9880d681SAndroid Build Coastguard Worker; CHECK: stp x29, x30, [sp, #-16]! 16*9880d681SAndroid Build Coastguard Worker; CHECK: mov x29, sp 17*9880d681SAndroid Build Coastguard Worker 18*9880d681SAndroid Build Coastguard Worker; Reserve space for call-frame: 19*9880d681SAndroid Build Coastguard Worker; CHECK: str w{{[0-9]+}}, [sp, #-16]! 20*9880d681SAndroid Build Coastguard Worker 21*9880d681SAndroid Build Coastguard Worker call fastcc void @will_pop([8 x i32] undef, i32 42) 22*9880d681SAndroid Build Coastguard Worker; CHECK: bl will_pop 23*9880d681SAndroid Build Coastguard Worker 24*9880d681SAndroid Build Coastguard Worker; Since @will_pop is fastcc with tailcallopt, it will put the stack 25*9880d681SAndroid Build Coastguard Worker; back where it needs to be, we shouldn't duplicate that 26*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: sub sp, sp, #16 27*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: add sp, sp, 28*9880d681SAndroid Build Coastguard Worker 29*9880d681SAndroid Build Coastguard Worker; CHECK: mov sp, x29 30*9880d681SAndroid Build Coastguard Worker; CHECK: ldp x29, x30, [sp], #16 31*9880d681SAndroid Build Coastguard Worker ret void 32*9880d681SAndroid Build Coastguard Worker} 33*9880d681SAndroid Build Coastguard Worker 34*9880d681SAndroid Build Coastguard Workerdeclare void @wont_pop([8 x i32], i32 %val) 35*9880d681SAndroid Build Coastguard Worker 36*9880d681SAndroid Build Coastguard Workerdefine void @foo1(i32 %in) { 37*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: foo1: 38*9880d681SAndroid Build Coastguard Worker 39*9880d681SAndroid Build Coastguard Worker %addr = alloca i8, i32 %in 40*9880d681SAndroid Build Coastguard Worker; Normal frame setup again 41*9880d681SAndroid Build Coastguard Worker; CHECK: stp x29, x30, [sp, #-16]! 42*9880d681SAndroid Build Coastguard Worker; CHECK: mov x29, sp 43*9880d681SAndroid Build Coastguard Worker 44*9880d681SAndroid Build Coastguard Worker; Reserve space for call-frame 45*9880d681SAndroid Build Coastguard Worker; CHECK: str w{{[0-9]+}}, [sp, #-16]! 46*9880d681SAndroid Build Coastguard Worker 47*9880d681SAndroid Build Coastguard Worker call void @wont_pop([8 x i32] undef, i32 42) 48*9880d681SAndroid Build Coastguard Worker; CHECK: bl wont_pop 49*9880d681SAndroid Build Coastguard Worker 50*9880d681SAndroid Build Coastguard Worker; This time we *do* need to unreserve the call-frame 51*9880d681SAndroid Build Coastguard Worker; CHECK: add sp, sp, #16 52*9880d681SAndroid Build Coastguard Worker 53*9880d681SAndroid Build Coastguard Worker; Check for epilogue (primarily to make sure sp spotted above wasn't 54*9880d681SAndroid Build Coastguard Worker; part of it). 55*9880d681SAndroid Build Coastguard Worker; CHECK: mov sp, x29 56*9880d681SAndroid Build Coastguard Worker; CHECK: ldp x29, x30, [sp], #16 57*9880d681SAndroid Build Coastguard Worker ret void 58*9880d681SAndroid Build Coastguard Worker} 59