• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3#
4--- |
5
6  define void @foo() nounwind { entry: unreachable }
7
8  define void @bar() nounwind { entry: unreachable }
9
10  define void @baz() nounwind { entry: unreachable }
11
12...
13---
14name:            foo
15# CHECK-LABEL: name: foo
16tracksRegLiveness: true
17body:             |
18  bb.0:
19    $x19 = IMPLICIT_DEF
20    $x20 = IMPLICIT_DEF
21    $x21 = IMPLICIT_DEF
22    $x22 = IMPLICIT_DEF
23    $x23 = IMPLICIT_DEF
24    $x24 = IMPLICIT_DEF
25    $x25 = IMPLICIT_DEF
26    $x26 = IMPLICIT_DEF
27
28  ; The local stack size is 0, so the last ldp in the sequence will also
29  ; restore the stack.
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
33
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
37
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
41
42    RET_ReallyLR
43...
44---
45name:            bar
46# CHECK-LABEL: name: bar
47tracksRegLiveness: true
48stack:
49  - { id : 0, size: 8, alignment: 4,
50  stack-id: 0, callee-saved-register: '', callee-saved-restored: true,
51  local-offset: -4, debug-info-variable: '', debug-info-expression: '',
52  debug-info-location: '' }
53
54body:             |
55  bb.0:
56    $x19 = IMPLICIT_DEF
57    $x20 = IMPLICIT_DEF
58    $x21 = IMPLICIT_DEF
59    $x22 = IMPLICIT_DEF
60    $x23 = IMPLICIT_DEF
61    $x24 = IMPLICIT_DEF
62    $x25 = IMPLICIT_DEF
63    $x26 = IMPLICIT_DEF
64
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
74    RET_ReallyLR
75...
76---
77# Check that the load from the offset 0 is moved at the end even when hasFP is
78# false.
79name:            baz
80# CHECK-LABEL: name: baz
81alignment:       2
82tracksRegLiveness: true
83frameInfo:
84  adjustsStack:    true
85  hasCalls:        true
86body:             |
87  bb.0:
88    successors: %bb.1
89
90    $x0 = IMPLICIT_DEF
91    $x20 = IMPLICIT_DEF
92    $x21 = IMPLICIT_DEF
93
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
97    B %bb.1
98
99  bb.1:
100   ; CHECK: $x20, $lr = frame-destroy LDPXi $sp, 2
101   ; BEFORELDSTOPT-NEXT: $x21 = frame-destroy LDRXui $sp, 0
102   ; BEFORELDSTOPT-NEXT: $sp = frame-destroy ADDXri $sp, 32, 0
103
104   ; AFTERLDSTOPT-NEXT: early-clobber $sp, $x21 = frame-destroy LDRXpost $sp, 32
105    RET_ReallyLR
106...
107