llvm-project/llvm/test/CodeGen/ARM/GlobalISel
Diogo Sampaio d94d079a6a [ARM][Thumb2] Fix ADD/SUB invalid writes to SP
Summary:
This patch fixes pr23772  [ARM] r226200 can emit illegal thumb2 instruction: "sub sp, r12, #80".
The violation was that SUB and ADD (reg, immediate) instructions can only write to SP if the source register is also SP. So the above instructions was unpredictable.
To enforce that the instruction t2(ADD|SUB)ri does not write to SP we now enforce the destination register to be rGPR (That exclude PC and SP).
Different than the ARM specification, that defines one instruction that can read from SP, and one that can't, here we inserted one that can't write to SP, and other that can only write to SP as to reuse most of the hard-coded size optimizations.
When performing this change, it uncovered that emitting Thumb2 Reg plus Immediate could not emit all variants of ADD SP, SP #imm instructions before so it was refactored to be able to. (see test/CodeGen/Thumb2/mve-stacksplot.mir where we use a subw sp, sp, Imm12 variant )
It also uncovered a disassembly issue of adr.w instructions, that were only written as SUBW instructions (see llvm/test/MC/Disassembler/ARM/thumb2.txt).

Reviewers: eli.friedman, dmgreen, carwil, olista01, efriedma, andreadb

Reviewed By: efriedma

Subscribers: gbedwell, john.brawn, efriedma, ostannard, kristof.beyls, hiraditya, dmgreen, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D70680
2020-01-14 11:47:19 +00:00
..
arm-call-lowering.ll
arm-instruction-select-cmp.mir
arm-instruction-select-combos.mir
arm-instruction-select.mir [globalisel] Rename G_GEP to G_PTR_ADD 2019-11-05 10:31:17 -08:00
arm-irtranslator.ll [globalisel] Rename G_GEP to G_PTR_ADD 2019-11-05 10:31:17 -08:00
arm-isel-divmod.ll
arm-isel-fp.ll
arm-isel-globals-pic.ll
arm-isel-globals-ropi-rwpi.ll
arm-isel-globals-static.ll
arm-isel.ll
arm-legalize-binops-neon.mir
arm-legalize-binops.mir
arm-legalize-bitcounts.mir
arm-legalize-casts.mir
arm-legalize-cmp.mir
arm-legalize-consts.mir [GlobalISel]: Allow targets to override how to widen constants during legalization 2019-12-03 10:41:10 -08:00
arm-legalize-control-flow.mir
arm-legalize-divmod.mir [globalisel] Add G_SEXT_INREG 2019-08-09 21:11:20 +00:00
arm-legalize-exts.mir [globalisel] Add G_SEXT_INREG 2019-08-09 21:11:20 +00:00
arm-legalize-fp.mir [GlobalISel]: Allow targets to override how to widen constants during legalization 2019-12-03 10:41:10 -08:00
arm-legalize-globals.mir
arm-legalize-load-store.mir [globalisel] Rename G_GEP to G_PTR_ADD 2019-11-05 10:31:17 -08:00
arm-legalize-select.mir
arm-legalize-vfp4.mir [globalisel] Rename G_GEP to G_PTR_ADD 2019-11-05 10:31:17 -08:00
arm-legalizer.mir
arm-param-lowering.ll [globalisel] Rename G_GEP to G_PTR_ADD 2019-11-05 10:31:17 -08:00
arm-regbankselect.mir [globalisel] Rename G_GEP to G_PTR_ADD 2019-11-05 10:31:17 -08:00
arm-select-copy_to_regclass-of-fptosi.mir
arm-select-globals-pic.mir
arm-select-globals-ropi-rwpi.mir
arm-select-globals-static.mir
arm-unsupported.ll
irtranslator-varargs-lowering.ll [globalisel] Rename G_GEP to G_PTR_ADD 2019-11-05 10:31:17 -08:00
lit.local.cfg
pr35375.ll
select-clz.mir
select-dbg.mir
select-fp-const.mir
select-fp.mir
select-neon.mir
select-pkhbt.mir
select-pr35926.mir
select-revsh.mir
thumb-instruction-select-cmp.mir
thumb-isel-globals-pic.ll
thumb-isel-globals-ropi-rwpi.ll
thumb-isel-globals-static.ll
thumb-select-arithmetic-ops.mir [ARM][Thumb2] Fix ADD/SUB invalid writes to SP 2020-01-14 11:47:19 +00:00
thumb-select-br.mir
thumb-select-casts.mir
thumb-select-exts.mir
thumb-select-globals-pic.mir
thumb-select-globals-ropi-rwpi.mir
thumb-select-globals-static.mir
thumb-select-imm.mir
thumb-select-load-store.mir [ARM][Thumb2] Fix ADD/SUB invalid writes to SP 2020-01-14 11:47:19 +00:00
thumb-select-logical-ops.mir
thumb-select-phi.mir
thumb-select-select.mir
thumb-select-shifts.mir