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

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
If you change it to #pragma omp declare simd it will start certainly earlier.
I think the bug is in the inliner.
Before dse1 we have:
  V m;

  <bb 2> :
  m_2 = j;
  # DEBUG m => m_2
and dse1 turns that into:
  # DEBUG D#1 => j
  # DEBUG m => D#1
But it seems the inliner doesn't remap the DEBUG_EXPR_DECLs, which means they
are shared between different functions, and during expansion the corresponding
DEBUG_EXPRs are shared between the functions too:
    case DEBUG_EXPR_DECL:
      op0 = DECL_RTL_IF_SET (exp);

      if (op0)
        return op0;

      op0 = gen_rtx_DEBUG_EXPR (mode);
      DEBUG_EXPR_TREE_DECL (op0) = exp;
      SET_DECL_RTL (exp, op0);

      return op0;
because DECL_RTL will be set after expanding first function referencing that.

So, I guess one option is to remap DEBUG_EXPR_DECLs during inlining (and
function versioning etc.), but guess that would need to be done very carefully
for the DW_OP_GNU_parameter_ref case of optimized away arguments, another one
would be to clear DECL_RTL of DEBUG_EXPR_DECLs at the end of expansion (say
push DEBUG_EXPR_DECLs for which we SET_DECL_RTL into a vector and then walk the
vector and clear DECL_RTLs), or do this only for the vector type mode mismatch
case (ignore DECL_RTL in that case and therefore force a different DEBUG_EXPR).

Reply via email to