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

--- Comment #9 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Kyrylo Tkachov <[email protected]>:

https://gcc.gnu.org/g:1ae9479cc0ebde73867123358920752d98465131

commit r17-3182-g1ae9479cc0ebde73867123358920752d98465131
Author: Kyrylo Tkachov <[email protected]>
Date:   Thu Aug 6 22:22:48 2026 +0200

    cfgexpand: Check partition MEM_EXPRs once the RTL of parameters is final
[PR126701]

    verify_partition_mem_exprs checks that no two out-of-SSA partitions carry
one
    MEM_EXPR at different addresses.  It ran before the loop that restores the
RTL
    of PARM_DECL and RESULT_DECL default definitions, and that loop is what
gives
    the partition of such a default definition its decl back:

      FOR_EACH_SSA_NAME (i, name, cfun)
        adjust_one_expanded_partition_var (name);   /* Merges in a MEM_EXPR. 
*/
      ...
          if (MEM_P (in))
            set_mem_attributes (in, var, true);     /* Takes it out again.  */

    Walking the names of a partition attaches the variable of any of them to
that
    partition's location, preferring an ignored one.  A partition that holds
the
    default definition of a parameter next to names of a store-motion temporary
is
    therefore given the temporary as its MEM_EXPR for the span between the two
    loops, and the partition of the temporary itself has it as well:

      part 20  MEM_EXPR g0_lsm.14  addr (plus (virtual-stack-vars) (const_int
-256))
      part 26  MEM_EXPR g0_lsm.14  addr (reg/v:DI 142)

    The parameter takes its MEM_EXPR back before any statement is expanded, so
the
    insn stream is unaffected, but the check in between sees the two and
aborts.

    Run the check once the RTL of every partition is final.
    With the out-of-SSA fixes for PR126405 reverted it still fires on all
    three of that PR's tests, the PARM_DECL one included.

    Bootstrapped and tested on aarch64-none-linux-gnu.
    Ok for trunk?
    Thanks,
    Kyrill

    gcc/ChangeLog:

            PR middle-end/126701
            * cfgexpand.cc (verify_partition_mem_exprs): Document when it may
            be called.
            (pass_expand::execute): Call it after the RTL of PARM_DECL and
            RESULT_DECL default definitions is restored.
            * tree-outof-ssa.cc (split_overlapping_partition_decls): Note the
            variable a partition of a parameter or result default definition
            ends up with.

    gcc/testsuite/ChangeLog:

            PR middle-end/126701
            * gcc.dg/pr126701.c: New test.

    Signed-off-by: Kyrylo Tkachov <[email protected]>

Reply via email to