[Bug rtl-optimization/104985] [12 Regression] ICE: SIGSEGV in undo_to_marker / adjust_reg_mode with -Os -frounding-math since r12-4767-g81342e95827f77

cvs-commit at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Apr 6 16:45:40 GMT 2022


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

--- Comment #17 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:61bee6aed26eb30b798c75b9a595c9d51e080442

commit r12-8030-g61bee6aed26eb30b798c75b9a595c9d51e080442
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Apr 6 18:42:52 2022 +0200

    combine: Don't record for UNDO_MODE pointers into regno_reg_rtx array
[PR104985]

    The testcase in the PR fails under valgrind on mips64 (but only Martin
    can reproduce, I couldn't).
    But the problem reported there is that SUBST_MODE remembers addresses
    into the regno_reg_rtx array, then some splitter needs a new pseudo
    and calls gen_reg_rtx, which reallocates the regno_reg_rtx array
    and finally undo operation is done and dereferences the old regno_reg_rtx
    entry.
    The rtx values stored in regno_reg_rtx array seems to be created
    by gen_reg_rtx only and since then aren't modified, all we do for it
    is adjusting its fields (e.g. adjust_reg_mode that SUBST_MODE does).

    So, I think it is useless to use where.r for UNDO_MODE and store
    &regno_reg_rtx[regno] in struct undo, we can store just
    regno_reg_rtx[regno] (i.e. pointer to the REG itself instead of
    pointer to pointer to REG) or could also store just the regno.

    The following patch does the latter, and because SUBST_MODE no longer
    needs to be a macro, changes all SUBST_MODE uses to subst_mode.

    2022-04-06  Jakub Jelinek  <jakub@redhat.com>

            PR rtl-optimization/104985
            * combine.cc (struct undo): Add where.regno member.
            (do_SUBST_MODE): Rename to ...
            (subst_mode): ... this.  Change first argument from rtx * into int,
            operate on regno_reg_rtx[regno] and save regno into where.regno.
            (SUBST_MODE): Remove.
            (try_combine): Use subst_mode instead of SUBST_MODE, change first
            argument from regno_reg_rtx[whatever] to whatever.  For UNDO_MODE,
use
            regno_reg_rtx[undo->where.regno] instead of *undo->where.r.
            (undo_to_marker): For UNDO_MODE, use
regno_reg_rtx[undo->where.regno]
            instead of *undo->where.r.
            (simplify_set): Use subst_mode instead of SUBST_MODE, change first
            argument from regno_reg_rtx[whatever] to whatever.


More information about the Gcc-bugs mailing list