Testcase from originally from PR 103979: ``` struct S { char a[64]; }; int foo (void) { struct S s, t; asm goto ("" : "=g" (s) : : : l); t = s; asm goto ("" : "=g" (s) : : : l); return s.a[0] + t.a[63]; l: return -1; } ``` This is not related to asm goto not being volatile but rather SRA (just like complex lowering, PR 105165) does not know how to handle `asm goto` with outputs.
*** Bug 112503 has been marked as a duplicate of this bug. ***
Better testcase from the dup: ``` struct T { int x; }; int foo(void) { struct T v; asm goto("" : "+r"(v.x) : : : lab); return 0; lab: return -5; } ``` Confirmed.
Mine.
The master branch has been updated by Martin Jambor <jamborm@gcc.gnu.org>: https://gcc.gnu.org/g:6764043e88a4208f7c69bf0ccd19ddc7a6016fb1 commit r14-8230-g6764043e88a4208f7c69bf0ccd19ddc7a6016fb1 Author: Martin Jambor <mjambor@suse.cz> Date: Thu Jan 18 14:24:15 2024 +0100 sra: Disqualify bases of operands of asm gotos PR 110422 shows that SRA can ICE assuming there is a single edge outgoing from a block terminated with an asm goto. We need that for BB-terminating statements so that any adjustments they make to the aggregates can be copied over to their replacements. Because we can't have that after ASM gotos, we need to punt. gcc/ChangeLog: 2024-01-17 Martin Jambor <mjambor@suse.cz> PR tree-optimization/110422 * tree-sra.cc (scan_function): Disqualify bases of operands of asm gotos. gcc/testsuite/ChangeLog: 2024-01-17 Martin Jambor <mjambor@suse.cz> PR tree-optimization/110422 * gcc.dg/torture/pr110422.c: New test.
Fixed on trunk, I plan to backport to open release branches in the upcoming weeks.
The releases/gcc-13 branch has been updated by Martin Jambor <jamborm@gcc.gnu.org>: https://gcc.gnu.org/g:2b7204c52392c1c0da9c91a5feae0c44018a6f37 commit r13-8246-g2b7204c52392c1c0da9c91a5feae0c44018a6f37 Author: Martin Jambor <mjambor@suse.cz> Date: Wed Jan 24 20:35:00 2024 +0100 sra: Disqualify bases of operands of asm gotos PR 110422 shows that SRA can ICE assuming there is a single edge outgoing from a block terminated with an asm goto. We need that for BB-terminating statements so that any adjustments they make to the aggregates can be copied over to their replacements. Because we can't have that after ASM gotos, we need to punt. gcc/ChangeLog: 2024-01-17 Martin Jambor <mjambor@suse.cz> PR tree-optimization/110422 * tree-sra.cc (scan_function): Disqualify bases of operands of asm gotos. gcc/testsuite/ChangeLog: 2024-01-17 Martin Jambor <mjambor@suse.cz> PR tree-optimization/110422 * gcc.dg/torture/pr110422.c: New test. (cherry picked from commit 6764043e88a4208f7c69bf0ccd19ddc7a6016fb1)
The releases/gcc-12 branch has been updated by Martin Jambor <jamborm@gcc.gnu.org>: https://gcc.gnu.org/g:fda015646b9450a2147bd9f01e49e3836b724da4 commit r12-10128-gfda015646b9450a2147bd9f01e49e3836b724da4 Author: Martin Jambor <mjambor@suse.cz> Date: Fri Feb 2 13:27:50 2024 +0100 sra: Disqualify bases of operands of asm gotos PR 110422 shows that SRA can ICE assuming there is a single edge outgoing from a block terminated with an asm goto. We need that for BB-terminating statements so that any adjustments they make to the aggregates can be copied over to their replacements. Because we can't have that after ASM gotos, we need to punt. gcc/ChangeLog: 2024-01-17 Martin Jambor <mjambor@suse.cz> PR tree-optimization/110422 * tree-sra.cc (scan_function): Disqualify bases of operands of asm gotos. gcc/testsuite/ChangeLog: 2024-01-17 Martin Jambor <mjambor@suse.cz> PR tree-optimization/110422 * gcc.dg/torture/pr110422.c: New test. (cherry picked from commit 2b7204c52392c1c0da9c91a5feae0c44018a6f37)
The releases/gcc-11 branch has been updated by Martin Jambor <jamborm@gcc.gnu.org>: https://gcc.gnu.org/g:010e4a04c4daaf1b0dacf6aa30fcbdaa73eda33c commit r11-11230-g010e4a04c4daaf1b0dacf6aa30fcbdaa73eda33c Author: Martin Jambor <mjambor@suse.cz> Date: Fri Feb 9 18:58:43 2024 +0100 sra: Disqualify bases of operands of asm gotos PR 110422 shows that SRA can ICE assuming there is a single edge outgoing from a block terminated with an asm goto. We need that for BB-terminating statements so that any adjustments they make to the aggregates can be copied over to their replacements. Because we can't have that after ASM gotos, we need to punt. gcc/ChangeLog: 2024-01-17 Martin Jambor <mjambor@suse.cz> PR tree-optimization/110422 * tree-sra.c (scan_function): Disqualify bases of operands of asm gotos. gcc/testsuite/ChangeLog: 2024-01-17 Martin Jambor <mjambor@suse.cz> PR tree-optimization/110422 * gcc.dg/torture/pr110422.c: New test. (cherry picked from commit 2b7204c52392c1c0da9c91a5feae0c44018a6f37)
Fixed on all opened release branches too.