vregs: Fix up instantiate_virtual_regs_in_insn for asm goto with outputs [PR98603]
authorJakub Jelinek <jakub@redhat.com>
Sat, 9 Jan 2021 09:48:20 +0000 (10:48 +0100)
committerJakub Jelinek <jakub@redhat.com>
Sat, 9 Jan 2021 09:48:20 +0000 (10:48 +0100)
commit16dae48e9cd0421106517fc657c8743a14468945
tree585a37079b9a6ac307ed2016ff7c63a3996cdfdc
parent57450da2fef3a32dc463b85e7b3d67f519b282cb
vregs: Fix up instantiate_virtual_regs_in_insn for asm goto with outputs [PR98603]

If an asm insn fails constraint checking during vregs, it is just deleted.
We don't delete asm goto though because of the edges to the labels, so
instantiate_virtual_regs_in_insn would just remove the inputs and their
constraints, the pattern etc.
This worked fine when asm goto couldn't have output operands, but causes
ICEs later on when it has more than one output (and furthermore doesn't
really remove the problematic outputs).  The problem is that
for multiple outputs we have a PARALLEL with multiple ASM_OPERANDS, but
those must use the same ASM_OPERANDS_INPUT_VEC etc., but the code was
adjusting just one.

The following patch turns invalid asm goto into a bare
asm goto ("" : : : : lab, lab2, lab3);
i.e. no inputs/outputs/clobbers, just the labels.

2021-01-09  Jakub Jelinek  <jakub@redhat.com>

PR rtl-optimization/98603
* function.c (instantiate_virtual_regs_in_insn): For asm goto
with impossible constraints, drop all SETs, CLOBBERs, drop PARALLEL
if any, set ASM_OPERANDS mode to VOIDmode and change
ASM_OPERANDS_OUTPUT_CONSTRAINT and ASM_OPERANDS_OUTPUT_IDX.

* gcc.target/i386/pr98603.c: New test.
* gcc.target/aarch64/pr98603.c: New test.
gcc/function.c
gcc/testsuite/gcc.target/aarch64/pr98603.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/pr98603.c [new file with mode: 0644]