* [Bug middle-end/105860] Miscompilation causing clobbered union contents
2022-06-06 12:51 [Bug analyzer/105860] New: Miscompilation causing clobbered union contents tpg+gcc at mutabah dot net
@ 2022-06-15 11:43 ` marxin at gcc dot gnu.org
2022-06-15 12:05 ` tpg+gcc at mutabah dot net
` (10 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-06-15 11:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105860
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
CC| |marxin at gcc dot gnu.org
Status|UNCONFIRMED |WAITING
Last reconfirmed| |2022-06-15
--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Can you please contact a self-contained test case (that contains an assert or
so) that I can run?
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/105860] Miscompilation causing clobbered union contents
2022-06-06 12:51 [Bug analyzer/105860] New: Miscompilation causing clobbered union contents tpg+gcc at mutabah dot net
2022-06-15 11:43 ` [Bug middle-end/105860] " marxin at gcc dot gnu.org
@ 2022-06-15 12:05 ` tpg+gcc at mutabah dot net
2022-06-15 12:50 ` [Bug middle-end/105860] [10/11/12/13 Regression] Miscompilation causing clobbered union contents since r10-918-gc56c86024f8fba0c marxin at gcc dot gnu.org
` (9 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: tpg+gcc at mutabah dot net @ 2022-06-15 12:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105860
--- Comment #2 from John Hodge <tpg+gcc at mutabah dot net> ---
Created attachment 53144
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53144&action=edit
Reproduction, partially minimised and including assertion
Attached is an updated reproduction, that includes asserts.
This fails the assert when compiled with gcc 10.3.0-1ubuntu1~20.04 when -O1 is
passed, and passes when no optimisation is enabled.
(Platform is x86_64, in case that wasn't already obvious from the disassembly)
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/105860] [10/11/12/13 Regression] Miscompilation causing clobbered union contents since r10-918-gc56c86024f8fba0c
2022-06-06 12:51 [Bug analyzer/105860] New: Miscompilation causing clobbered union contents tpg+gcc at mutabah dot net
2022-06-15 11:43 ` [Bug middle-end/105860] " marxin at gcc dot gnu.org
2022-06-15 12:05 ` tpg+gcc at mutabah dot net
@ 2022-06-15 12:50 ` marxin at gcc dot gnu.org
2022-06-15 23:20 ` pinskia at gcc dot gnu.org
` (8 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-06-15 12:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105860
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |wrong-code
Status|WAITING |NEW
CC| |jamborm at gcc dot gnu.org
Summary|Miscompilation causing |[10/11/12/13 Regression]
|clobbered union contents |Miscompilation causing
| |clobbered union contents
| |since
| |r10-918-gc56c86024f8fba0c
Assignee|dmalcolm at gcc dot gnu.org |unassigned at gcc dot gnu.org
--- Comment #3 from Martin Liška <marxin at gcc dot gnu.org> ---
Oh, great, thanks for it! It started with Martin's r10-918-gc56c86024f8fba0c.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/105860] [10/11/12/13 Regression] Miscompilation causing clobbered union contents since r10-918-gc56c86024f8fba0c
2022-06-06 12:51 [Bug analyzer/105860] New: Miscompilation causing clobbered union contents tpg+gcc at mutabah dot net
` (2 preceding siblings ...)
2022-06-15 12:50 ` [Bug middle-end/105860] [10/11/12/13 Regression] Miscompilation causing clobbered union contents since r10-918-gc56c86024f8fba0c marxin at gcc dot gnu.org
@ 2022-06-15 23:20 ` pinskia at gcc dot gnu.org
2022-06-28 10:49 ` jakub at gcc dot gnu.org
` (7 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-06-15 23:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105860
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |10.4
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/105860] [10/11/12/13 Regression] Miscompilation causing clobbered union contents since r10-918-gc56c86024f8fba0c
2022-06-06 12:51 [Bug analyzer/105860] New: Miscompilation causing clobbered union contents tpg+gcc at mutabah dot net
` (3 preceding siblings ...)
2022-06-15 23:20 ` pinskia at gcc dot gnu.org
@ 2022-06-28 10:49 ` jakub at gcc dot gnu.org
2022-07-01 18:12 ` jamborm at gcc dot gnu.org
` (6 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-06-28 10:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105860
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|10.4 |10.5
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 10.4 is being released, retargeting bugs to GCC 10.5.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/105860] [10/11/12/13 Regression] Miscompilation causing clobbered union contents since r10-918-gc56c86024f8fba0c
2022-06-06 12:51 [Bug analyzer/105860] New: Miscompilation causing clobbered union contents tpg+gcc at mutabah dot net
` (4 preceding siblings ...)
2022-06-28 10:49 ` jakub at gcc dot gnu.org
@ 2022-07-01 18:12 ` jamborm at gcc dot gnu.org
2022-07-01 20:49 ` [Bug tree-optimization/105860] " jamborm at gcc dot gnu.org
` (5 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jamborm at gcc dot gnu.org @ 2022-07-01 18:12 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105860
Martin Jambor <jamborm at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |jamborm at gcc dot gnu.org
Status|NEW |ASSIGNED
--- Comment #5 from Martin Jambor <jamborm at gcc dot gnu.org> ---
Mine.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/105860] [10/11/12/13 Regression] Miscompilation causing clobbered union contents since r10-918-gc56c86024f8fba0c
2022-06-06 12:51 [Bug analyzer/105860] New: Miscompilation causing clobbered union contents tpg+gcc at mutabah dot net
` (5 preceding siblings ...)
2022-07-01 18:12 ` jamborm at gcc dot gnu.org
@ 2022-07-01 20:49 ` jamborm at gcc dot gnu.org
2022-07-04 15:08 ` cvs-commit at gcc dot gnu.org
` (4 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jamborm at gcc dot gnu.org @ 2022-07-01 20:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105860
--- Comment #6 from Martin Jambor <jamborm at gcc dot gnu.org> ---
I proposed a fix on the mailing list:
https://gcc.gnu.org/pipermail/gcc-patches/2022-July/597674.html
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/105860] [10/11/12/13 Regression] Miscompilation causing clobbered union contents since r10-918-gc56c86024f8fba0c
2022-06-06 12:51 [Bug analyzer/105860] New: Miscompilation causing clobbered union contents tpg+gcc at mutabah dot net
` (6 preceding siblings ...)
2022-07-01 20:49 ` [Bug tree-optimization/105860] " jamborm at gcc dot gnu.org
@ 2022-07-04 15:08 ` cvs-commit at gcc dot gnu.org
2022-07-11 16:47 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-07-04 15:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105860
--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Martin Jambor <jamborm@gcc.gnu.org>:
https://gcc.gnu.org/g:b110e5283e368b5377e04766e4ff82cd52634208
commit r13-1460-gb110e5283e368b5377e04766e4ff82cd52634208
Author: Martin Jambor <mjambor@suse.cz>
Date: Fri Jul 1 20:57:18 2022 +0200
tree-sra: Fix union handling in build_reconstructed_reference
As the testcase in PR 105860 shows, the code that tries to re-use the
handled_component chains in SRA can be horribly confused by unions,
where it thinks it has found a compatible structure under which it can
chain the references, but in fact it found the type it was looking
for elsewhere in a union and generated a write to a completely wrong
part of an aggregate.
I don't remember whether the plan was to support unions at all in
build_reconstructed_reference but it can work, to an extent, if we
make sure that we start the search only outside the outermost union,
which is what the patch does (and the extra testcase verifies).
gcc/ChangeLog:
2022-07-01 Martin Jambor <mjambor@suse.cz>
PR tree-optimization/105860
* tree-sra.cc (build_reconstructed_reference): Start expr
traversal only just below the outermost union.
gcc/testsuite/ChangeLog:
2022-07-01 Martin Jambor <mjambor@suse.cz>
PR tree-optimization/105860
* gcc.dg/tree-ssa/alias-access-path-13.c: New test.
* gcc.dg/tree-ssa/pr105860.c: Likewise.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/105860] [10/11/12/13 Regression] Miscompilation causing clobbered union contents since r10-918-gc56c86024f8fba0c
2022-06-06 12:51 [Bug analyzer/105860] New: Miscompilation causing clobbered union contents tpg+gcc at mutabah dot net
` (7 preceding siblings ...)
2022-07-04 15:08 ` cvs-commit at gcc dot gnu.org
@ 2022-07-11 16:47 ` cvs-commit at gcc dot gnu.org
2022-07-12 11:18 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-07-11 16:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105860
--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Martin Jambor
<jamborm@gcc.gnu.org>:
https://gcc.gnu.org/g:1a78fffb3845f879e36ba33b4d15e75b3df8d5a7
commit r12-8564-g1a78fffb3845f879e36ba33b4d15e75b3df8d5a7
Author: Martin Jambor <mjambor@suse.cz>
Date: Mon Jul 11 18:43:23 2022 +0200
tree-sra: Fix union handling in build_reconstructed_reference
As the testcase in PR 105860 shows, the code that tries to re-use the
handled_component chains in SRA can be horribly confused by unions,
where it thinks it has found a compatible structure under which it can
chain the references, but in fact it found the type it was looking
for elsewhere in a union and generated a write to a completely wrong
part of an aggregate.
I don't remember whether the plan was to support unions at all in
build_reconstructed_reference but it can work, to an extent, if we
make sure that we start the search only outside the outermost union,
which is what the patch does (and the extra testcase verifies).
Additionally, this commit also contains sqashed in it a backport of
b984b84cbe4bf026edef2ba37685f3958a1dc1cf which fixes the testcase
gcc.dg/tree-ssa/alias-access-path-13.c for many 32-bit targets.
gcc/ChangeLog:
2022-07-01 Martin Jambor <mjambor@suse.cz>
PR tree-optimization/105860
* tree-sra.cc (build_reconstructed_reference): Start expr
traversal only just below the outermost union.
gcc/testsuite/ChangeLog:
2022-07-01 Martin Jambor <mjambor@suse.cz>
PR tree-optimization/105860
* gcc.dg/tree-ssa/alias-access-path-13.c: New test.
* gcc.dg/tree-ssa/pr105860.c: Likewise.
(cherry picked from commit b110e5283e368b5377e04766e4ff82cd52634208)
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/105860] [10/11/12/13 Regression] Miscompilation causing clobbered union contents since r10-918-gc56c86024f8fba0c
2022-06-06 12:51 [Bug analyzer/105860] New: Miscompilation causing clobbered union contents tpg+gcc at mutabah dot net
` (8 preceding siblings ...)
2022-07-11 16:47 ` cvs-commit at gcc dot gnu.org
@ 2022-07-12 11:18 ` cvs-commit at gcc dot gnu.org
2022-07-13 11:19 ` cvs-commit at gcc dot gnu.org
2022-07-13 11:19 ` jamborm at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-07-12 11:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105860
--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Martin Jambor
<jamborm@gcc.gnu.org>:
https://gcc.gnu.org/g:16afe2e2862f3dd93c711d7f8d436dee23c6c34d
commit r11-10144-g16afe2e2862f3dd93c711d7f8d436dee23c6c34d
Author: Martin Jambor <mjambor@suse.cz>
Date: Tue Jul 12 13:16:35 2022 +0200
tree-sra: Fix union handling in build_reconstructed_reference
As the testcase in PR 105860 shows, the code that tries to re-use the
handled_component chains in SRA can be horribly confused by unions,
where it thinks it has found a compatible structure under which it can
chain the references, but in fact it found the type it was looking
for elsewhere in a union and generated a write to a completely wrong
part of an aggregate.
I don't remember whether the plan was to support unions at all in
build_reconstructed_reference but it can work, to an extent, if we
make sure that we start the search only outside the outermost union,
which is what the patch does (and the extra testcase verifies).
Additionally, this commit also contains sqashed in it a backport of
b984b84cbe4bf026edef2ba37685f3958a1dc1cf which fixes the testcase
gcc.dg/tree-ssa/alias-access-path-13.c for many 32-bit targets.
gcc/ChangeLog:
2022-07-01 Martin Jambor <mjambor@suse.cz>
PR tree-optimization/105860
* tree-sra.c (build_reconstructed_reference): Start expr
traversal only just below the outermost union.
gcc/testsuite/ChangeLog:
2022-07-01 Martin Jambor <mjambor@suse.cz>
PR tree-optimization/105860
* gcc.dg/tree-ssa/alias-access-path-13.c: New test.
* gcc.dg/tree-ssa/pr105860.c: Likewise.
(cherry picked from commit b110e5283e368b5377e04766e4ff82cd52634208)
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/105860] [10/11/12/13 Regression] Miscompilation causing clobbered union contents since r10-918-gc56c86024f8fba0c
2022-06-06 12:51 [Bug analyzer/105860] New: Miscompilation causing clobbered union contents tpg+gcc at mutabah dot net
` (9 preceding siblings ...)
2022-07-12 11:18 ` cvs-commit at gcc dot gnu.org
@ 2022-07-13 11:19 ` cvs-commit at gcc dot gnu.org
2022-07-13 11:19 ` jamborm at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-07-13 11:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105860
--- Comment #10 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Martin Jambor
<jamborm@gcc.gnu.org>:
https://gcc.gnu.org/g:2691107f973770bafc84b9e8aae7c791053f411e
commit r10-10894-g2691107f973770bafc84b9e8aae7c791053f411e
Author: Martin Jambor <mjambor@suse.cz>
Date: Wed Jul 13 13:17:25 2022 +0200
tree-sra: Fix union handling in build_reconstructed_reference
As the testcase in PR 105860 shows, the code that tries to re-use the
handled_component chains in SRA can be horribly confused by unions,
where it thinks it has found a compatible structure under which it can
chain the references, but in fact it found the type it was looking
for elsewhere in a union and generated a write to a completely wrong
part of an aggregate.
I don't remember whether the plan was to support unions at all in
build_reconstructed_reference but it can work, to an extent, if we
make sure that we start the search only outside the outermost union,
which is what the patch does (and the extra testcase verifies).
Additionally, this commit also contains sqashed in it a backport of
b984b84cbe4bf026edef2ba37685f3958a1dc1cf which fixes the testcase
gcc.dg/tree-ssa/alias-access-path-13.c for many 32-bit targets.
gcc/ChangeLog:
2022-07-01 Martin Jambor <mjambor@suse.cz>
PR tree-optimization/105860
* tree-sra.c (build_reconstructed_reference): Start expr
traversal only just below the outermost union.
gcc/testsuite/ChangeLog:
2022-07-01 Martin Jambor <mjambor@suse.cz>
PR tree-optimization/105860
* gcc.dg/tree-ssa/alias-access-path-13.c: New test.
* gcc.dg/tree-ssa/pr105860.c: Likewise.
(cherry picked from commit b110e5283e368b5377e04766e4ff82cd52634208)
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/105860] [10/11/12/13 Regression] Miscompilation causing clobbered union contents since r10-918-gc56c86024f8fba0c
2022-06-06 12:51 [Bug analyzer/105860] New: Miscompilation causing clobbered union contents tpg+gcc at mutabah dot net
` (10 preceding siblings ...)
2022-07-13 11:19 ` cvs-commit at gcc dot gnu.org
@ 2022-07-13 11:19 ` jamborm at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: jamborm at gcc dot gnu.org @ 2022-07-13 11:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105860
Martin Jambor <jamborm at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #11 from Martin Jambor <jamborm at gcc dot gnu.org> ---
Fixed. Thanks for reporting.
^ permalink raw reply [flat|nested] 13+ messages in thread