* [Bug rtl-optimization/103979] asm goto is not considered volatile with output operands
2022-01-11 16:29 [Bug c/103979] New: asm goto is not considered volatile gareth.webb+gccbugzilla at outlook dot com
@ 2022-01-11 18:46 ` pinskia at gcc dot gnu.org
2023-01-25 22:17 ` pinskia at gcc dot gnu.org
` (11 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-11 18:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103979
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|asm goto is not considered |asm goto is not considered
|volatile |volatile with output
| |operands
Last reconfirmed| |2022-01-11
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
Keywords| |ice-on-valid-code,
| |inline-asm, wrong-code
Component|c |rtl-optimization
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I suspect the code was not updated once output operands were allowed to have it
marked as volatile. As inline-asm without output operands is always considered
volatile.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug rtl-optimization/103979] asm goto is not considered volatile with output operands
2022-01-11 16:29 [Bug c/103979] New: asm goto is not considered volatile gareth.webb+gccbugzilla at outlook dot com
2022-01-11 18:46 ` [Bug rtl-optimization/103979] asm goto is not considered volatile with output operands pinskia at gcc dot gnu.org
@ 2023-01-25 22:17 ` pinskia at gcc dot gnu.org
2023-01-30 18:06 ` jakub at gcc dot gnu.org
` (10 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-01-25 22:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103979
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ndesaulniers at google dot com
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 108548 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug rtl-optimization/103979] asm goto is not considered volatile with output operands
2022-01-11 16:29 [Bug c/103979] New: asm goto is not considered volatile gareth.webb+gccbugzilla at outlook dot com
2022-01-11 18:46 ` [Bug rtl-optimization/103979] asm goto is not considered volatile with output operands pinskia at gcc dot gnu.org
2023-01-25 22:17 ` pinskia at gcc dot gnu.org
@ 2023-01-30 18:06 ` jakub at gcc dot gnu.org
2023-01-30 18:18 ` jakub at gcc dot gnu.org
` (9 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-01-30 18:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103979
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
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;
}
also ICEs at -O2, not during fwprop (note, I can't reproduce the #c0 testcase,
neither with trunk nor 11 branch on x86_64-linux), but during sra.
I think we shouldn't just follow blindly the docs, but see what e.g. Linux
kernel as heavy user of asm goto with outputs (and I think mostly without
volatile) wants.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug rtl-optimization/103979] asm goto is not considered volatile with output operands
2022-01-11 16:29 [Bug c/103979] New: asm goto is not considered volatile gareth.webb+gccbugzilla at outlook dot com
` (2 preceding siblings ...)
2023-01-30 18:06 ` jakub at gcc dot gnu.org
@ 2023-01-30 18:18 ` jakub at gcc dot gnu.org
2023-06-26 23:38 ` [Bug middle-end/103979] " pinskia at gcc dot gnu.org
` (8 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-01-30 18:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103979
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Tried to reproduce the #c0 ICE all the way back to
r11-5002-ge3b3b59683c1e7d31a9d313dd97394abebf644be but couldn't, even that
version successfully DCEs the asm goto (though, in all cases during RTL
optimizations, GIMPLE keeps them).
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug middle-end/103979] asm goto is not considered volatile with output operands
2022-01-11 16:29 [Bug c/103979] New: asm goto is not considered volatile gareth.webb+gccbugzilla at outlook dot com
` (3 preceding siblings ...)
2023-01-30 18:18 ` jakub at gcc dot gnu.org
@ 2023-06-26 23:38 ` pinskia at gcc dot gnu.org
2023-06-26 23:53 ` pinskia at gcc dot gnu.org
` (7 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-06-26 23:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103979
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #3)
> I think we shouldn't just follow blindly the docs, but see what e.g. Linux
> kernel as heavy user of asm goto with outputs (and I think mostly without
> volatile) wants.
They will need volatile, at least on powerpc. The reason is they use asm goto
now for loading/storing from/to userspace. PR 110420 is another case where asm
goto is removed on accident due not to being volatile.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug middle-end/103979] asm goto is not considered volatile with output operands
2022-01-11 16:29 [Bug c/103979] New: asm goto is not considered volatile gareth.webb+gccbugzilla at outlook dot com
` (4 preceding siblings ...)
2023-06-26 23:38 ` [Bug middle-end/103979] " pinskia at gcc dot gnu.org
@ 2023-06-26 23:53 ` pinskia at gcc dot gnu.org
2023-06-27 0:10 ` pinskia at gcc dot gnu.org
` (6 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-06-26 23:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103979
--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #3)
> 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;
> }
>
That is going to be turned into a different issue ...
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug middle-end/103979] asm goto is not considered volatile with output operands
2022-01-11 16:29 [Bug c/103979] New: asm goto is not considered volatile gareth.webb+gccbugzilla at outlook dot com
` (5 preceding siblings ...)
2023-06-26 23:53 ` pinskia at gcc dot gnu.org
@ 2023-06-27 0:10 ` pinskia at gcc dot gnu.org
2023-06-27 3:26 ` pinskia at gcc dot gnu.org
` (5 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-06-27 0:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103979
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |pinskia at gcc dot gnu.org
Status|NEW |ASSIGNED
--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
MIne, I filed PR 110422 for the SRA issue.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug middle-end/103979] asm goto is not considered volatile with output operands
2022-01-11 16:29 [Bug c/103979] New: asm goto is not considered volatile gareth.webb+gccbugzilla at outlook dot com
` (6 preceding siblings ...)
2023-06-27 0:10 ` pinskia at gcc dot gnu.org
@ 2023-06-27 3:26 ` pinskia at gcc dot gnu.org
2023-06-27 16:28 ` cvs-commit at gcc dot gnu.org
` (4 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-06-27 3:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103979
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
URL| |https://gcc.gnu.org/piperma
| |il/gcc-patches/2023-June/62
| |2906.html
Keywords| |patch
--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Patch posted:
https://gcc.gnu.org/pipermail/gcc-patches/2023-June/622906.html
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug middle-end/103979] asm goto is not considered volatile with output operands
2022-01-11 16:29 [Bug c/103979] New: asm goto is not considered volatile gareth.webb+gccbugzilla at outlook dot com
` (7 preceding siblings ...)
2023-06-27 3:26 ` pinskia at gcc dot gnu.org
@ 2023-06-27 16:28 ` cvs-commit at gcc dot gnu.org
2023-06-27 16:29 ` pinskia at gcc dot gnu.org
` (3 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-06-27 16:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103979
--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Andrew Pinski <pinskia@gcc.gnu.org>:
https://gcc.gnu.org/g:478840a2ca491fbff44371caee4983d1e7b7b7cf
commit r14-2133-g478840a2ca491fbff44371caee4983d1e7b7b7cf
Author: Andrew Pinski <apinski@marvell.com>
Date: Mon Jun 26 17:14:06 2023 -0700
Mark asm goto with outputs as volatile
The manual references asm goto as being implicitly volatile already
and that was done when asm goto could not have outputs. When outputs
were added to `asm goto`, only asm goto without outputs were still being
marked as volatile. Now some parts of GCC decide, removing the `asm goto`
is ok if the output is not used, though not updating the CFG (this happens
on both the RTL level and the gimple level). Since the biggest user of `asm
goto`
is the Linux kernel and they expect them to be volatile (they use them to
copy to/from userspace), we should just mark the inline-asm as volatile.
OK? Bootstrapped and tested on x86_64-linux-gnu.
PR middle-end/110420
PR middle-end/103979
PR middle-end/98619
gcc/ChangeLog:
* gimplify.cc (gimplify_asm_expr): Mark asm with labels as
volatile.
gcc/testsuite/ChangeLog:
* gcc.c-torture/compile/asmgoto-6.c: New test.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug middle-end/103979] asm goto is not considered volatile with output operands
2022-01-11 16:29 [Bug c/103979] New: asm goto is not considered volatile gareth.webb+gccbugzilla at outlook dot com
` (8 preceding siblings ...)
2023-06-27 16:28 ` cvs-commit at gcc dot gnu.org
@ 2023-06-27 16:29 ` pinskia at gcc dot gnu.org
2023-06-27 16:46 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-06-27 16:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103979
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to work| |14.0
--- Comment #10 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed in GCC 14 and will be backporting to GCC 12.x and 13.x.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug middle-end/103979] asm goto is not considered volatile with output operands
2022-01-11 16:29 [Bug c/103979] New: asm goto is not considered volatile gareth.webb+gccbugzilla at outlook dot com
` (9 preceding siblings ...)
2023-06-27 16:29 ` pinskia at gcc dot gnu.org
@ 2023-06-27 16:46 ` cvs-commit at gcc dot gnu.org
2023-06-27 17:21 ` cvs-commit at gcc dot gnu.org
2023-06-27 17:24 ` pinskia at gcc dot gnu.org
12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-06-27 16:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103979
--- Comment #11 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Andrew Pinski
<pinskia@gcc.gnu.org>:
https://gcc.gnu.org/g:81fa6dfe1691e93664ef3b4fa66c1e057acea281
commit r13-7484-g81fa6dfe1691e93664ef3b4fa66c1e057acea281
Author: Andrew Pinski <apinski@marvell.com>
Date: Mon Jun 26 17:14:06 2023 -0700
Mark asm goto with outputs as volatile
The manual references asm goto as being implicitly volatile already
and that was done when asm goto could not have outputs. When outputs
were added to `asm goto`, only asm goto without outputs were still being
marked as volatile. Now some parts of GCC decide, removing the `asm goto`
is ok if the output is not used, though not updating the CFG (this happens
on both the RTL level and the gimple level). Since the biggest user of `asm
goto`
is the Linux kernel and they expect them to be volatile (they use them to
copy to/from userspace), we should just mark the inline-asm as volatile.
OK? Bootstrapped and tested on x86_64-linux-gnu.
PR middle-end/110420
PR middle-end/103979
PR middle-end/98619
gcc/ChangeLog:
* gimplify.cc (gimplify_asm_expr): Mark asm with labels as
volatile.
gcc/testsuite/ChangeLog:
* gcc.c-torture/compile/asmgoto-6.c: New test.
(cherry picked from commit 478840a2ca491fbff44371caee4983d1e7b7b7cf)
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug middle-end/103979] asm goto is not considered volatile with output operands
2022-01-11 16:29 [Bug c/103979] New: asm goto is not considered volatile gareth.webb+gccbugzilla at outlook dot com
` (10 preceding siblings ...)
2023-06-27 16:46 ` cvs-commit at gcc dot gnu.org
@ 2023-06-27 17:21 ` cvs-commit at gcc dot gnu.org
2023-06-27 17:24 ` pinskia at gcc dot gnu.org
12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-06-27 17:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103979
--- Comment #12 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Andrew Pinski
<pinskia@gcc.gnu.org>:
https://gcc.gnu.org/g:ee3bb7cb5d2ecfc64adcfd61afb390e72cc08661
commit r12-9732-gee3bb7cb5d2ecfc64adcfd61afb390e72cc08661
Author: Andrew Pinski <apinski@marvell.com>
Date: Mon Jun 26 17:14:06 2023 -0700
Mark asm goto with outputs as volatile
The manual references asm goto as being implicitly volatile already
and that was done when asm goto could not have outputs. When outputs
were added to `asm goto`, only asm goto without outputs were still being
marked as volatile. Now some parts of GCC decide, removing the `asm goto`
is ok if the output is not used, though not updating the CFG (this happens
on both the RTL level and the gimple level). Since the biggest user of `asm
goto`
is the Linux kernel and they expect them to be volatile (they use them to
copy to/from userspace), we should just mark the inline-asm as volatile.
OK? Bootstrapped and tested on x86_64-linux-gnu.
PR middle-end/110420
PR middle-end/103979
PR middle-end/98619
gcc/ChangeLog:
* gimplify.cc (gimplify_asm_expr): Mark asm with labels as
volatile.
gcc/testsuite/ChangeLog:
* gcc.c-torture/compile/asmgoto-6.c: New test.
(cherry picked from commit 478840a2ca491fbff44371caee4983d1e7b7b7cf)
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug middle-end/103979] asm goto is not considered volatile with output operands
2022-01-11 16:29 [Bug c/103979] New: asm goto is not considered volatile gareth.webb+gccbugzilla at outlook dot com
` (11 preceding siblings ...)
2023-06-27 17:21 ` cvs-commit at gcc dot gnu.org
@ 2023-06-27 17:24 ` pinskia at gcc dot gnu.org
12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-06-27 17:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103979
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |12.4
Known to work| |12.3.1, 13.1.1
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #13 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 14+ messages in thread