blob: b5e03f08280ff7d6a0f71399ca97de4dc7191fa8 [file] [log] [blame]
Tim Northover3b0846e2014-05-24 12:50:23 +00001; RUN: llc -verify-machineinstrs < %s -mtriple=aarch64-none-linux-gnu -tailcallopt | FileCheck %s
Tim Northovere0e3aef2013-01-31 12:12:40 +00002
3; This test is designed to be run in the situation where the
4; call-frame is not reserved (hence disable-fp-elim), but where
5; callee-pop can occur (hence tailcallopt).
6
7declare fastcc void @will_pop([8 x i32], i32 %val)
8
9define fastcc void @foo(i32 %in) {
Stephen Lind24ab202013-07-14 06:24:09 +000010; CHECK-LABEL: foo:
Tim Northovere0e3aef2013-01-31 12:12:40 +000011
12 %addr = alloca i8, i32 %in
13
14; Normal frame setup stuff:
Tim Northover3b0846e2014-05-24 12:50:23 +000015; CHECK: stp x29, x30, [sp, #-16]!
16; CHECK: mov x29, sp
Tim Northovere0e3aef2013-01-31 12:12:40 +000017
18; Reserve space for call-frame:
Chad Rosier11c825f2015-09-30 19:44:40 +000019; CHECK: str w{{[0-9]+}}, [sp, #-16]!
Tim Northovere0e3aef2013-01-31 12:12:40 +000020
21 call fastcc void @will_pop([8 x i32] undef, i32 42)
22; CHECK: bl will_pop
23
24; Since @will_pop is fastcc with tailcallopt, it will put the stack
25; back where it needs to be, we shouldn't duplicate that
26; CHECK-NOT: sub sp, sp, #16
27; CHECK-NOT: add sp, sp,
28
Tim Northover3b0846e2014-05-24 12:50:23 +000029; CHECK: mov sp, x29
30; CHECK: ldp x29, x30, [sp], #16
Tim Northovere0e3aef2013-01-31 12:12:40 +000031 ret void
32}
33
34declare void @wont_pop([8 x i32], i32 %val)
35
36define void @foo1(i32 %in) {
Stephen Lind24ab202013-07-14 06:24:09 +000037; CHECK-LABEL: foo1:
Tim Northovere0e3aef2013-01-31 12:12:40 +000038
39 %addr = alloca i8, i32 %in
40; Normal frame setup again
Tim Northover3b0846e2014-05-24 12:50:23 +000041; CHECK: stp x29, x30, [sp, #-16]!
42; CHECK: mov x29, sp
Tim Northovere0e3aef2013-01-31 12:12:40 +000043
44; Reserve space for call-frame
Chad Rosier11c825f2015-09-30 19:44:40 +000045; CHECK: str w{{[0-9]+}}, [sp, #-16]!
Tim Northovere0e3aef2013-01-31 12:12:40 +000046
47 call void @wont_pop([8 x i32] undef, i32 42)
Benjamin Kramer01b75cc2013-03-09 18:25:40 +000048; CHECK: bl wont_pop
Tim Northovere0e3aef2013-01-31 12:12:40 +000049
50; This time we *do* need to unreserve the call-frame
Benjamin Kramer01b75cc2013-03-09 18:25:40 +000051; CHECK: add sp, sp, #16
Tim Northovere0e3aef2013-01-31 12:12:40 +000052
53; Check for epilogue (primarily to make sure sp spotted above wasn't
54; part of it).
Tim Northover3b0846e2014-05-24 12:50:23 +000055; CHECK: mov sp, x29
56; CHECK: ldp x29, x30, [sp], #16
Tim Northovere0e3aef2013-01-31 12:12:40 +000057 ret void
58}