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

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

https://gcc.gnu.org/g:3a715d3e136fc4dfdc42cb6a3ee1a7df3e2a171a

commit r14-468-g3a715d3e136fc4dfdc42cb6a3ee1a7df3e2a171a
Author: Jakub Jelinek <ja...@redhat.com>
Date:   Thu May 4 09:36:05 2023 +0200

    i386: Fix up handling of debug insns in STV [PR109676]

    The following testcase ICEs because STV replaces there
    (debug_insn 114 47 51 8 (var_location:TI D#3 (reg:TI 91 [ p ])) -1
         (nil))
    with
    (debug_insn 114 47 51 8 (var_location:TI D#3 (reg:V1TI 91 [ p ])) -1
         (nil))
    which is invalid because of the mode mismatch.
    STV has fix_debug_reg_uses function which is supposed to fix this up
    and adjust such debug insns into
    (debug_insn 114 47 51 8 (var_location:TI D#3 (subreg:TI (reg:V1TI 91 [ p ])
0)) -1
         (nil))
    but it doesn't trigger here.
    The IL before stv1 has:
    (debug_insn 114 47 51 8 (var_location:TI D#3 (reg:TI 91 [ p ])) -1
         (nil))
    ...
    (insn 63 62 64 8 (set (mem/c:TI (reg/f:DI 89 [ .result_ptr ]) [0
<retval>.mStorage+0 S16 A32])
            (reg:TI 91 [ p ])) "pr109676.C":4:48 87 {*movti_internal}
         (expr_list:REG_DEAD (reg:TI 91 [ p ])
            (nil)))
    in bb 8 and
    (insn 97 96 98 9 (set (reg:TI 91 [ p ])
            (mem/c:TI (plus:DI (reg/f:DI 19 frame)
                    (const_int -32 [0xffffffffffffffe0])) [0 p+0 S16 A128]))
"pr109676.C":26:12 87 {*movti_internal}
         (nil))
    (insn 98 97 99 9 (set (mem/c:TI (plus:DI (reg/f:DI 19 frame)
                    (const_int -64 [0xffffffffffffffc0])) [0 tmp+0 S16 A128])
            (reg:TI 91 [ p ])) "pr109676.C":26:12 87 {*movti_internal}
         (nil))
    in bb9.
    PUT_MODE on a REG is done in two spots in
timode_scalar_chain::convert_insn,
    one is:
      switch (GET_CODE (dst))
        {
        case REG:
          if (GET_MODE (dst) == TImode)
            {
              PUT_MODE (dst, V1TImode);
              fix_debug_reg_uses (dst);
            }
          if (GET_MODE (dst) == V1TImode)
    when seeing the REG in SET_DEST and another one the hunk the patch adjusts.
    Because bb 8 comes first in the order the pass walks the bbs, we first
    notice the TImode pseudo on insn 63 where it is SET_SRC, use PUT_MODE there
    unconditionally, so for a shared REG it changes all other uses in the IL,
    and then don't call fix_debug_reg_uses because DF_REG_DEF_CHAIN (REGNO
(src))
    is non-NULL - the REG is set in insn 97 but we haven't processed it yet.
    Later on we process insn 97, but because the REG in SET_DEST already has
    V1TImode, we don't do anything, even when the src handling code earlier
    relied on it being done.

    The following patch fixes this by using similar code for both dst and src,
    in particular calling fix_debug_reg_uses once when we actually change REG
    mode from TImode to V1TImode, and not later on.

    2023-05-04  Jakub Jelinek  <ja...@redhat.com>

            PR debug/109676
            * config/i386/i386-features.cc (timode_scalar_chain::convert_insn):
            If src is REG, change its mode to V1TImode and call
fix_debug_reg_uses
            for it only if it still has TImode.  Don't decide whether to call
            fix_debug_reg_uses based on whether SRC is ever set or not.

            * g++.target/i386/pr109676.C: New test.

Reply via email to