[Bug tree-optimization/105860] [10/11/12/13 Regression] Miscompilation causing clobbered union contents since r10-918-gc56c86024f8fba0c

cvs-commit at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Jul 12 11:18:23 GMT 2022


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)


More information about the Gcc-bugs mailing list