1 # RUN: llc -run-pass=prologepilog -reverse-csr-restore-seq -o - -mtriple=aarch64-- %s | FileCheck %s --check-prefixes=CHECK,BEFORELDSTOPT
2 # RUN: llc -start-before=prologepilog -stop-after=aarch64-ldst-opt -reverse-csr-restore-seq -o - -mtriple=aarch64-- %s | FileCheck %s --check-prefixes=CHECK,AFTERLDSTOPT
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 ; Before running the load-store optimizer, we emit a ldp and an add.
35 ; BEFORELDSTOPT-NEXT: $x26, $x25 = frame-destroy LDPXi $sp, 0
36 ; BEFORELDSTOPT-NEXT: $sp = frame-destroy ADDXri $sp, 64, 0
38 ; We want to make sure that after running the load-store optimizer, the ldp
39 ; and the add get merged into a post-index ldp.
40 ; AFTERLDSTOPT-NEXT: early-clobber $sp, $x26, $x25 = frame-destroy LDPXpost $sp, 8
46 # CHECK-LABEL: name: bar
47 tracksRegLiveness: true
49 - { id : 0, size: 8, alignment: 4,
50 stack-id: default, callee-saved-register: '', callee-saved-restored: true,
51 local-offset: -4, debug-info-variable: '', debug-info-expression: '',
52 debug-info-location: '' }
65 ; The local stack size is not 0, and we can combine the CSR stack size with
66 ; the local stack size. This results in rewriting the offsets for all the
67 ; save/restores and forbids us to merge the stack adjustment and the last pop.
68 ; In this case, there is no point of moving the first CSR pair at the end.
69 ; CHECK: $x26, $x25 = frame-destroy LDPXi $sp, 2
70 ; CHECK-NEXT: $x24, $x23 = frame-destroy LDPXi $sp, 4
71 ; CHECK-NEXT: $x22, $x21 = frame-destroy LDPXi $sp, 6
72 ; CHECK-NEXT: $x20, $x19 = frame-destroy LDPXi $sp, 8
73 ; CHECK-NEXT: $sp = frame-destroy ADDXri $sp, 80, 0
77 # Check that the load from the offset 0 is moved at the end even when hasFP is
80 # CHECK-LABEL: name: baz
82 tracksRegLiveness: true
94 ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp
95 BL @foo, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit $x0, implicit-def $sp, implicit-def $x0
96 ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp
100 ; CHECK: $x21, $x20 = frame-destroy LDPXi $sp, 2
101 ; BEFORELDSTOPT-NEXT: $lr = frame-destroy LDRXui $sp, 0
102 ; BEFORELDSTOPT-NEXT: $sp = frame-destroy ADDXri $sp, 32, 0
104 ; AFTERLDSTOPT-NEXT: early-clobber $sp, $lr = frame-destroy LDRXpost $sp, 32