[Bug c++/96354] [10/11 Regression] ICE in maybe_canonicalize_mem_ref_addr, at gimple-fold.c:4903 since r10-2271-gd81ab49d0586fca0

jakub at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Jul 28 14:45:59 GMT 2020


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

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
So we have:
  # DEBUG this => &<retval>
  <retval> ={v} {CLOBBER};
  # DEBUG D#1 => &<retval>.d
  # DEBUG D#2 => MEM[(double *)&<retval>]
  # DEBUG __trans_tmp_3 => D#2
in matmul during inlining, and inline it as:
  # DEBUG this => &D.2697[_13]
  _24 = &D.2697[_13];
  *_24 ={v} {CLOBBER};
  # DEBUG D#1 => &D.2697[_13].d
  # DEBUG D#2 => MEM[(double *)&D.2697[_13]]
  # DEBUG __trans_tmp_3 => D#2
  # DEBUG this => NULL
Generally, we are more lax about IL restrictions we have in debug stmts
compared to other stmts, e.g. verify_gimple_debug always returns false.
So, do we want to allow this case?
I believe cfgexpand.c handles that:
    case MEM_REF:
      if (!is_gimple_mem_ref_addr (TREE_OPERAND (exp, 0)))
        {
          tree newexp = fold_binary (MEM_REF, TREE_TYPE (exp),
                                     TREE_OPERAND (exp, 0),
                                     TREE_OPERAND (exp, 1));
          if (newexp)
            return expand_debug_expr (newexp);
        }
      /* FALLTHROUGH */
    case INDIRECT_REF:
or punts if the folding doesn't come up with anything.
So, we could e.g. add bool is_debug argument to
maybe_canonicalize_mem_ref_addr, pass true only when in GIMPLE_DEBUG and
instead of failing the assertion there return false (what about the other
assertions in there?).
Or instead of bool is_debug take bool *is_debug and if non-NULL (only for
GIMPLE_DEBUG) set it to *false if we'd otherwise fail and tell that way to the
caller that it should reset the debug stmt?
richi, your thoughts on this?


More information about the Gcc-bugs mailing list