AArch64/ARM64: remove AArch64 from tree prior to renaming ARM64.
[oota-llvm.git] / test / CodeGen / AArch64 / fastcc-reserved.ll
1 ; RUN: llc -verify-machineinstrs < %s -mtriple=arm64-none-linux-gnu -tailcallopt | FileCheck %s --check-prefix=CHECK-ARM64
2
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
7 declare fastcc void @will_pop([8 x i32], i32 %val)
8
9 define fastcc void @foo(i32 %in) {
10 ; CHECK-LABEL: foo:
11
12   %addr = alloca i8, i32 %in
13
14 ; Normal frame setup stuff:
15 ; CHECK: sub sp, sp,
16 ; CHECK: stp x29, x30
17 ; CHECK-ARM64: stp     x29, x30, [sp, #-16]!
18 ; CHECK-ARM64: mov     x29, sp
19
20 ; Reserve space for call-frame:
21 ; CHECK: sub sp, sp, #16
22 ; CHECK-ARM64: sub sp, sp, #16
23
24   call fastcc void @will_pop([8 x i32] undef, i32 42)
25 ; CHECK: bl will_pop
26 ; CHECK-ARM64: bl will_pop
27
28 ; Since @will_pop is fastcc with tailcallopt, it will put the stack
29 ; back where it needs to be, we shouldn't duplicate that
30 ; CHECK-NOT: sub sp, sp, #16
31 ; CHECK-NOT: add sp, sp,
32 ; CHECK-ARM64-NOT: sub sp, sp, #16
33 ; CHECK-ARM64-NOT: add sp, sp,
34
35 ; CHECK: ldp x29, x30
36 ; CHECK: add sp, sp,
37 ; CHECK-ARM64: mov     sp, x29
38 ; CHECK-ARM64: ldp     x29, x30, [sp], #16
39   ret void
40 }
41
42 declare void @wont_pop([8 x i32], i32 %val)
43
44 define void @foo1(i32 %in) {
45 ; CHECK-LABEL: foo1:
46
47   %addr = alloca i8, i32 %in
48 ; Normal frame setup again
49 ; CHECK: sub sp, sp,
50 ; CHECK: stp x29, x30
51 ; CHECK-ARM64: stp     x29, x30, [sp, #-16]!
52 ; CHECK-ARM64: mov     x29, sp
53
54 ; Reserve space for call-frame
55 ; CHECK: sub sp, sp, #16
56 ; CHECK-ARM64: sub sp, sp, #16
57
58   call void @wont_pop([8 x i32] undef, i32 42)
59 ; CHECK: bl wont_pop
60 ; CHECK-ARM64: bl wont_pop
61
62 ; This time we *do* need to unreserve the call-frame
63 ; CHECK: add sp, sp, #16
64 ; CHECK-ARM64: add sp, sp, #16
65
66 ; Check for epilogue (primarily to make sure sp spotted above wasn't
67 ; part of it).
68 ; CHECK: ldp x29, x30
69 ; CHECK: add sp, sp,
70 ; CHECK-ARM64: mov     sp, x29
71 ; CHECK-ARM64: ldp     x29, x30, [sp], #16
72   ret void
73 }