[gcc r11-6562] vregs: Fix up instantiate_virtual_regs_in_insn for asm goto with outputs [PR98603]
Jakub Jelinek
jakub@gcc.gnu.org
Sat Jan 9 09:49:12 GMT 2021
https://gcc.gnu.org/g:16dae48e9cd0421106517fc657c8743a14468945
commit r11-6562-g16dae48e9cd0421106517fc657c8743a14468945
Author: Jakub Jelinek <jakub@redhat.com>
Date: Sat Jan 9 10:48:20 2021 +0100
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.
Diff:
---
gcc/function.c | 8 ++++++--
gcc/testsuite/gcc.target/aarch64/pr98603.c | 11 +++++++++++
gcc/testsuite/gcc.target/i386/pr98603.c | 11 +++++++++++
3 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/gcc/function.c b/gcc/function.c
index 4b9c0a5aa19..a3ed3987b95 100644
--- a/gcc/function.c
+++ b/gcc/function.c
@@ -1785,12 +1785,16 @@ instantiate_virtual_regs_in_insn (rtx_insn *insn)
{
error_for_asm (insn, "impossible constraint in %<asm%>");
/* For asm goto, instead of fixing up all the edges
- just clear the template and clear input operands
- (asm goto doesn't have any output operands). */
+ just clear the template and clear input and output operands
+ and strip away clobbers. */
if (JUMP_P (insn))
{
rtx asm_op = extract_asm_operands (PATTERN (insn));
+ PATTERN (insn) = asm_op;
+ PUT_MODE (asm_op, VOIDmode);
ASM_OPERANDS_TEMPLATE (asm_op) = ggc_strdup ("");
+ ASM_OPERANDS_OUTPUT_CONSTRAINT (asm_op) = "";
+ ASM_OPERANDS_OUTPUT_IDX (asm_op) = 0;
ASM_OPERANDS_INPUT_VEC (asm_op) = rtvec_alloc (0);
ASM_OPERANDS_INPUT_CONSTRAINT_VEC (asm_op) = rtvec_alloc (0);
}
diff --git a/gcc/testsuite/gcc.target/aarch64/pr98603.c b/gcc/testsuite/gcc.target/aarch64/pr98603.c
new file mode 100644
index 00000000000..f75d8e4e23a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/pr98603.c
@@ -0,0 +1,11 @@
+/* PR rtl-optimization/98603 */
+/* { dg-do compile } */
+/* { dg-options "-O0" } */
+
+int
+foo (void)
+{
+ int b, c;
+ asm goto ("" : "=R" (b), "=r" (c) : : : lab); /* { dg-error "impossible constraint in 'asm'" } */
+lab:;
+}
diff --git a/gcc/testsuite/gcc.target/i386/pr98603.c b/gcc/testsuite/gcc.target/i386/pr98603.c
new file mode 100644
index 00000000000..9bf924ec06b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr98603.c
@@ -0,0 +1,11 @@
+/* PR rtl-optimization/98603 */
+/* { dg-do compile } */
+/* { dg-options "-O0 -w" } */
+
+int
+foo (void)
+{
+ int b, c;
+ asm goto ("" : "=r" (b), "=r" (c) : "I" (128) : : lab); /* { dg-error "impossible constraint in 'asm'" } */
+lab:;
+}
More information about the Gcc-cvs
mailing list