1 # RUN: llc -run-pass=prologepilog -reverse-csr-restore-seq -o - -mtriple=aarch64-- %s | FileCheck %s --check-prefixes=CHECK
2 # RUN: llc -start-before=prologepilog -stop-after=aarch64-ldst-opt -reverse-csr-restore-seq -o - -mtriple=aarch64-- %s | FileCheck %s --check-prefixes=CHECK
6 define void @foo() nounwind { entry: unreachable }
8 define void @bar() nounwind { entry: unreachable }
10 define void @baz() nounwind { entry: unreachable }
15 # CHECK-LABEL: name: foo
16 tracksRegLiveness: true
28 ; The local stack size is 0, so the last ldp in the sequence will also
30 ; CHECK: $x24, $x23 = frame-destroy LDPXi $sp, 2
31 ; CHECK-NEXT: $x22, $x21 = frame-destroy LDPXi $sp, 4
32 ; CHECK-NEXT: $x20, $x19 = frame-destroy LDPXi $sp, 6
34 ; The ldp and the stack increment get merged even before
35 ; the load-store optimizer.
36 ; CHECK-NEXT: early-clobber $sp, $x26, $x25 = frame-destroy LDPXpost $sp, 8
42 # CHECK-LABEL: name: bar
43 tracksRegLiveness: true
45 - { id : 0, size: 8, alignment: 4,
46 stack-id: default, callee-saved-register: '', callee-saved-restored: true,
47 local-offset: -4, debug-info-variable: '', debug-info-expression: '',
48 debug-info-location: '' }
61 ; The local stack size is not 0, and we can combine the CSR stack size with
62 ; the local stack size. This results in rewriting the offsets for all the
63 ; save/restores and forbids us to merge the stack adjustment and the last pop.
64 ; In this case, there is no point of moving the first CSR pair at the end.
65 ; We do it anyway, as it's a small price to pay for the resulting
66 ; simplification in the epilogue emission code.
67 ; CHECK: $x24, $x23 = frame-destroy LDPXi $sp, 4
68 ; CHECK-NEXT: $x22, $x21 = frame-destroy LDPXi $sp, 6
69 ; CHECK-NEXT: $x20, $x19 = frame-destroy LDPXi $sp, 8
70 ; CHECK-NEXT: $x26, $x25 = frame-destroy LDPXi $sp, 2
71 ; CHECK-NEXT: $sp = frame-destroy ADDXri $sp, 80, 0
75 # Check that the load from the offset 0 is moved at the end even when hasFP is
78 # CHECK-LABEL: name: baz
80 tracksRegLiveness: true
92 ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp
93 BL @foo, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit $x0, implicit-def $sp, implicit-def $x0
94 ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp
98 ; CHECK: $x21, $x20 = frame-destroy LDPXi $sp, 2
99 ; CHECK-NEXT: early-clobber $sp, $lr = frame-destroy LDRXpost $sp, 32