public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/98603] New: aarch64: ICE in extract_insn (ira) on asm goto with bad constraint
@ 2021-01-08 13:54 acoplan at gcc dot gnu.org
  2021-01-08 14:19 ` [Bug rtl-optimization/98603] " jakub at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: acoplan at gcc dot gnu.org @ 2021-01-08 13:54 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98603

            Bug ID: 98603
           Summary: aarch64: ICE in extract_insn (ira) on asm goto with
                    bad constraint
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: acoplan at gcc dot gnu.org
  Target Milestone: ---

$ cat test.c
int a() {
  int b, c;
  asm goto("" : "=R"(b), "=r"(c) : : : d);
d:
}
$ aarch64-elf-gcc -c test.c
test.c: In function 'a':
test.c:3:3: error: impossible constraint in 'asm'
    3 |   asm goto("" : "=R"(b), "=r"(c) : : : d);
      |   ^~~
test.c:5:1: error: unrecognizable insn:
    5 | }
      | ^
(jump_insn 7 2 8 2 (parallel [
            (set (reg:SI 93 [ b ])
                (asm_operands:SI ("") ("=R") 0 []
                     []
                     [
                        (label_ref:DI 8)
                    ] test.c:3))
            (set (reg:SI 94 [ c ])
                (asm_operands:SI ("") ("=r") 1 []
                     []
                     [
                        (label_ref:DI 8)
                    ] test.c:3))
        ]) "test.c":3:3 -1
     (nil)
 -> 8)
during RTL pass: ira
test.c:5:1: internal compiler error: in extract_insn, at recog.c:2760
0xd574db _fatal_insn(char const*, rtx_def const*, char const*, int, char
const*)
        /home/alecop01/toolchain/src/gcc/gcc/rtl-error.c:108
0xd574fa _fatal_insn_not_found(rtx_def const*, char const*, int, char const*)
        /home/alecop01/toolchain/src/gcc/gcc/rtl-error.c:116
0xd27455 extract_insn(rtx_insn*)
        /home/alecop01/toolchain/src/gcc/gcc/recog.c:2760
0xbb4266 ira
        /home/alecop01/toolchain/src/gcc/gcc/ira.c:5423
0xbb4266 execute
        /home/alecop01/toolchain/src/gcc/gcc/ira.c:5945
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug rtl-optimization/98603] aarch64: ICE in extract_insn (ira) on asm goto with bad constraint
  2021-01-08 13:54 [Bug rtl-optimization/98603] New: aarch64: ICE in extract_insn (ira) on asm goto with bad constraint acoplan at gcc dot gnu.org
@ 2021-01-08 14:19 ` jakub at gcc dot gnu.org
  2021-01-08 14:40 ` jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-01-08 14:19 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98603

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org,
                   |                            |vmakarov at gcc dot gnu.org

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The bug is function.c (instantiate_virtual_regs_in_insn):
      if (!check_asm_operands (PATTERN (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).  */
          if (JUMP_P (insn))
            {
              rtx asm_op = extract_asm_operands (PATTERN (insn));
              ASM_OPERANDS_TEMPLATE (asm_op) = ggc_strdup ("");
              ASM_OPERANDS_INPUT_VEC (asm_op) = rtvec_alloc (0);
              ASM_OPERANDS_INPUT_CONSTRAINT_VEC (asm_op) = rtvec_alloc (0);
            }
          else
            delete_insn (insn);
        }
As the comment documents, that was correct before support for outputs in asm
goto has been added, but for asm insn with outputs, there are multiple
problems.
One is that extract_asm_operands extracts just one of the ASM_OPERANDS, but
with multiple outputs there can be several, and those need to be handled in
sync.
And the other is that we still keep the incorrectly constrained outputs if any
in the IL.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug rtl-optimization/98603] aarch64: ICE in extract_insn (ira) on asm goto with bad constraint
  2021-01-08 13:54 [Bug rtl-optimization/98603] New: aarch64: ICE in extract_insn (ira) on asm goto with bad constraint acoplan at gcc dot gnu.org
  2021-01-08 14:19 ` [Bug rtl-optimization/98603] " jakub at gcc dot gnu.org
@ 2021-01-08 14:40 ` jakub at gcc dot gnu.org
  2021-01-09  9:49 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-01-08 14:40 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98603

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2021-01-08
           Assignee|unassigned at gcc dot gnu.org      |jakub at gcc dot gnu.org
             Status|UNCONFIRMED                 |ASSIGNED

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 49920
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49920&action=edit
gcc11-pr98603.patch

Untested fix.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug rtl-optimization/98603] aarch64: ICE in extract_insn (ira) on asm goto with bad constraint
  2021-01-08 13:54 [Bug rtl-optimization/98603] New: aarch64: ICE in extract_insn (ira) on asm goto with bad constraint acoplan at gcc dot gnu.org
  2021-01-08 14:19 ` [Bug rtl-optimization/98603] " jakub at gcc dot gnu.org
  2021-01-08 14:40 ` jakub at gcc dot gnu.org
@ 2021-01-09  9:49 ` cvs-commit at gcc dot gnu.org
  2021-01-09  9:53 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-01-09  9:49 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98603

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

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.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug rtl-optimization/98603] aarch64: ICE in extract_insn (ira) on asm goto with bad constraint
  2021-01-08 13:54 [Bug rtl-optimization/98603] New: aarch64: ICE in extract_insn (ira) on asm goto with bad constraint acoplan at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2021-01-09  9:49 ` cvs-commit at gcc dot gnu.org
@ 2021-01-09  9:53 ` jakub at gcc dot gnu.org
  2022-10-27  7:55 ` linkw at gcc dot gnu.org
  2022-10-27 14:42 ` pinskia at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-01-09  9:53 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98603

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Should be fixed now.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug rtl-optimization/98603] aarch64: ICE in extract_insn (ira) on asm goto with bad constraint
  2021-01-08 13:54 [Bug rtl-optimization/98603] New: aarch64: ICE in extract_insn (ira) on asm goto with bad constraint acoplan at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2021-01-09  9:53 ` jakub at gcc dot gnu.org
@ 2022-10-27  7:55 ` linkw at gcc dot gnu.org
  2022-10-27 14:42 ` pinskia at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: linkw at gcc dot gnu.org @ 2022-10-27  7:55 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98603

Kewen Lin <linkw at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |asolokha at gmx dot com

--- Comment #5 from Kewen Lin <linkw at gcc dot gnu.org> ---
*** Bug 97940 has been marked as a duplicate of this bug. ***

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug rtl-optimization/98603] aarch64: ICE in extract_insn (ira) on asm goto with bad constraint
  2021-01-08 13:54 [Bug rtl-optimization/98603] New: aarch64: ICE in extract_insn (ira) on asm goto with bad constraint acoplan at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2022-10-27  7:55 ` linkw at gcc dot gnu.org
@ 2022-10-27 14:42 ` pinskia at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-10-27 14:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98603

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |11.0

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-10-27 14:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-08 13:54 [Bug rtl-optimization/98603] New: aarch64: ICE in extract_insn (ira) on asm goto with bad constraint acoplan at gcc dot gnu.org
2021-01-08 14:19 ` [Bug rtl-optimization/98603] " jakub at gcc dot gnu.org
2021-01-08 14:40 ` jakub at gcc dot gnu.org
2021-01-09  9:49 ` cvs-commit at gcc dot gnu.org
2021-01-09  9:53 ` jakub at gcc dot gnu.org
2022-10-27  7:55 ` linkw at gcc dot gnu.org
2022-10-27 14:42 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).