| Francis Visoiu Mistrih | 164560b | 2018-03-14 20:34:03 +0000 | [diff] [blame] | 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 | ... |
| 11 | --- |
| 12 | name: foo |
| 13 | # CHECK-LABEL: name: foo |
| 14 | tracksRegLiveness: true |
| 15 | body: | |
| 16 | bb.0: |
| 17 | $x19 = IMPLICIT_DEF |
| 18 | $x20 = IMPLICIT_DEF |
| 19 | $x21 = IMPLICIT_DEF |
| 20 | $x22 = IMPLICIT_DEF |
| 21 | $x23 = IMPLICIT_DEF |
| 22 | $x24 = IMPLICIT_DEF |
| 23 | $x25 = IMPLICIT_DEF |
| 24 | $x26 = IMPLICIT_DEF |
| 25 | |
| 26 | ; The local stack size is 0, so the last ldp in the sequence will also |
| 27 | ; restore the stack. |
| 28 | ; CHECK: $x24, $x23 = frame-destroy LDPXi $sp, 2 |
| 29 | ; CHECK-NEXT: $x22, $x21 = frame-destroy LDPXi $sp, 4 |
| 30 | ; CHECK-NEXT: $x20, $x19 = frame-destroy LDPXi $sp, 6 |
| 31 | |
| 32 | ; Before running the load-store optimizer, we emit a ldp and an add. |
| 33 | ; BEFORELDSTOPT-NEXT: $x26, $x25 = frame-destroy LDPXi $sp, 0 |
| 34 | ; BEFORELDSTOPT-NEXT: $sp = frame-destroy ADDXri $sp, 64, 0 |
| 35 | |
| 36 | ; We want to make sure that after running the load-store optimizer, the ldp |
| 37 | ; and the add get merged into a post-index ldp. |
| 38 | ; AFTERLDSTOPT-NEXT: early-clobber $sp, $x26, $x25 = frame-destroy LDPXpost $sp, 8 |
| 39 | |
| 40 | RET_ReallyLR |
| 41 | ... |
| 42 | --- |
| 43 | name: bar |
| 44 | # CHECK-LABEL: name: bar |
| 45 | tracksRegLiveness: true |
| 46 | stack: |
| 47 | - { id : 0, size: 8, alignment: 4, |
| 48 | stack-id: 0, callee-saved-register: '', callee-saved-restored: true, |
| Francis Visoiu Mistrih | 57fcd34 | 2018-04-25 18:58:06 +0000 | [diff] [blame] | 49 | local-offset: -4, debug-info-variable: '', debug-info-expression: '', |
| 50 | debug-info-location: '' } |
| Francis Visoiu Mistrih | 164560b | 2018-03-14 20:34:03 +0000 | [diff] [blame] | 51 | |
| 52 | body: | |
| 53 | bb.0: |
| 54 | $x19 = IMPLICIT_DEF |
| 55 | $x20 = IMPLICIT_DEF |
| 56 | $x21 = IMPLICIT_DEF |
| 57 | $x22 = IMPLICIT_DEF |
| 58 | $x23 = IMPLICIT_DEF |
| 59 | $x24 = IMPLICIT_DEF |
| 60 | $x25 = IMPLICIT_DEF |
| 61 | $x26 = IMPLICIT_DEF |
| 62 | |
| 63 | ; The local stack size is not 0, and we can combine the CSR stack size with |
| 64 | ; the local stack size. This results in rewriting the offsets for all the |
| 65 | ; save/restores and forbids us to merge the stack adjustment and the last pop. |
| 66 | ; In this case, there is no point of moving the first CSR pair at the end. |
| 67 | ; CHECK: $x26, $x25 = frame-destroy LDPXi $sp, 2 |
| 68 | ; CHECK-NEXT: $x24, $x23 = frame-destroy LDPXi $sp, 4 |
| 69 | ; CHECK-NEXT: $x22, $x21 = frame-destroy LDPXi $sp, 6 |
| 70 | ; CHECK-NEXT: $x20, $x19 = frame-destroy LDPXi $sp, 8 |
| 71 | ; CHECK-NEXT: $sp = frame-destroy ADDXri $sp, 80, 0 |
| 72 | RET_ReallyLR |
| 73 | ... |