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