Skip to content

Commit 7313d7d

Browse files
committed
[AArch64][v8.3a] Add missing imp-defs on RETA*.
RETA always implicitly uses LR, unlike RET which merely has an alias that defaults it to LR. Additionally, RETA implicitly uses SP as well, which it uses as a discriminator to authenticate LR. This isn't usually noticeable, because RET_ReallyLR is used in most of the backend. However, the post-RA scheduler, if enabled, will cause miscompiles if the imp-uses are missing. While there, fix a typo in the lone affected testcase.
1 parent 643ac6c commit 7313d7d

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

llvm/lib/Target/AArch64/AArch64InstrFormats.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1427,6 +1427,7 @@ class AuthOneOperand<bits<3> opc, bits<1> M, string asm>
14271427
let Inst{9-5} = Rn;
14281428
}
14291429

1430+
let Uses = [LR,SP] in
14301431
class AuthReturn<bits<3> op, bits<1> M, string asm>
14311432
: AuthBase<M, (outs), (ins), asm, "", []> {
14321433
let Inst{24} = 0;

llvm/test/CodeGen/AArch64/branch-target-enforcment.mir renamed to llvm/test/CodeGen/AArch64/branch-target-enforcement.mir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ body: |
142142
INLINEASM &"", 1, 12, implicit-def dead early-clobber $lr
143143
$w0 = ORRWrs $wzr, $wzr, 0
144144
early-clobber $sp, $lr = frame-destroy LDRXpost $sp, 16 :: (load 8 from %stack.0)
145-
RETAA implicit killed $w0
145+
RETAA implicit $sp, implicit $lr, implicit killed $w0
146146
147147
---
148148
# Function starts with PACIBSP, which implicitly acts as BTI JC, so no change
@@ -166,7 +166,7 @@ body: |
166166
INLINEASM &"", 1, 12, implicit-def dead early-clobber $lr
167167
$w0 = ORRWrs $wzr, $wzr, 0
168168
early-clobber $sp, $lr = frame-destroy LDRXpost $sp, 16 :: (load 8 from %stack.0)
169-
RETAB implicit killed $w0
169+
RETAB implicit $sp, implicit $lr, implicit killed $w0
170170
171171
---
172172
# Function contains a jump table, so every target of the jump table must start

0 commit comments

Comments
 (0)