1; RUN: llc -verify-machineinstrs < %s -mtriple=aarch64-none-linux-gnu | FileCheck %s
2; RUN: llc -verify-machineinstrs < %s -mtriple=aarch64-none-linux-gnu -disable-fp-elim | FileCheck -check-prefix CHECK-WITHFP-ARM64 %s
3
4; Make sure a reasonably sane prologue and epilogue are
5; generated. This test is not robust in the face of an frame-handling
6; evolving, but still has value for unrelated changes, I
7; believe.
8;
9; In particular, it will fail when ldp/stp are used for frame setup,
10; when FP-elim is implemented, and when addressing from FP is
11; implemented.
12
13@var = global i64 0
14@local_addr = global i64* null
15
16declare void @foo()
17
18define void @trivial_func() nounwind {
19; CHECK-LABEL: trivial_func: // @trivial_func
20; CHECK-NEXT: // BB#0
21; CHECK-NEXT: ret
22
23  ret void
24}
25
26define void @trivial_fp_func() {
27; CHECK-WITHFP-AARCH64-LABEL: trivial_fp_func:
28; CHECK-WITHFP-AARCH64: sub sp, sp, #16
29; CHECK-WITHFP-AARCH64: stp x29, x30, [sp]
30; CHECK-WITHFP-AARCH64-NEXT: mov x29, sp
31
32; CHECK-WITHFP-ARM64-LABEL: trivial_fp_func:
33; CHECK-WITHFP-ARM64: stp x29, x30, [sp, #-16]!
34; CHECK-WITHFP-ARM64-NEXT: mov x29, sp
35
36; Dont't really care, but it would be a Bad Thing if this came after the epilogue.
37; CHECK: bl foo
38  call void @foo()
39  ret void
40
41; CHECK-WITHFP: ldp x29, x30, [sp]
42; CHECK-WITHFP: add sp, sp, #16
43
44; CHECK-WITHFP: ret
45}
46
47define void @stack_local() {
48  %local_var = alloca i64
49; CHECK-LABEL: stack_local:
50; CHECK: sub sp, sp, #16
51
52  %val = load i64, i64* @var
53  store i64 %val, i64* %local_var
54; CHECK-DAG: str {{x[0-9]+}}, [sp, #{{[0-9]+}}]
55
56  store i64* %local_var, i64** @local_addr
57; CHECK-DAG: add {{x[0-9]+}}, sp, #{{[0-9]+}}
58
59  ret void
60}
61