[PATCH] D70680: [ARM][Thumb2] Fix ADD/SUB invalid writes to SP
Eli Friedman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 9 13:30:53 PST 2019
efriedma added inline comments.
================
Comment at: llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp:3285
// we can handle a larger range of immediates.
+ const bool ToSP = DefMI.getOperand(0).getReg() == ARM::SP;
+ const unsigned t2ADD = ToSP ? ARM::t2ADDspImm : ARM::t2ADDri;
----------------
dnsampaio wrote:
> efriedma wrote:
> > Do we need to care about the source register here? t2ADDrr doesn't restrict it. (I guess that might also be a bug?)
> From my tests, `rr` does block writing to `SP` and not reading from it:
> ```./llvm-mc --assemble -triple=thumbv7-apple-darwin9 -mcpu=cortex-a9 --show-encoding <<< "add.w sp, r0, r1"
> .section __TEXT,__text,regular,pure_instructions
> <stdin>:1:7: error: source register must be sp if destination is sp
> add.w sp, r0, r1```
>
> In that case, just checking that the destination is `SP` is enough.
We might need to split t2ADDrr eventually, but I guess this is fine for now.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D70680/new/
https://reviews.llvm.org/D70680
More information about the llvm-commits
mailing list