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

Martin Jambor <jamborm at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jamborm at gcc dot gnu.org

--- Comment #6 from Martin Jambor <jamborm at gcc dot gnu.org> ---
(In reply to Jan Hubicka from comment #5)
> Hi,
> this patch fixes the ICE, though I think we do have a design issue here
> while producing debug info across ltrans boundary.
> 
> Martin, Jakub: as discussed on IRC it would be nice to add predicate
> when the body is really needed and avoid materializing if it is not.
> Can you add one?
> 
> Something like param_adjustemnts->need_callee_parm_decls_p ()

I think that in practice the existence of param_adjustemnts is by far
the biggest part of the test and the patch already checks for that.

A more precise check would probably be the following?


/* Return true if any of the original parameters of the function has been
   removed or replaced.  */

bool
ipa_param_adjustments::orig_parameter_removed_p ()
{
  if (m_always_copy_start == 0)
    return false;

  unsigned adj_len = vec_safe_length (m_adj_params);
  if (adj_len < m_always_copy_start)
    return true;

  unsigned i;
  for (i = 0; i < m_always_copy_start; i++)
    {
      ipa_adjusted_param *apm = &(*m_adj_params)[i];
      if (apm->op != IPA_PARAM_OP_COPY
          || apm->base_index != i)
        break;
    }
  if (i == m_always_copy_start)
    return false;

  /* In all likelihood, the ith parameter has been removed, verify. */
  bool complex_case = false;
  for (unsigned j = i; j < adj_len; j++)
    {
      ipa_adjusted_param *apm = &(*m_adj_params)[j];
      if (apm->op == IPA_PARAM_OP_COPY
          || apm->base_index == i)
        {
          complex_case = true;
          break;
        }
    }
  if (!complex_case)
    return true;

  auto_vec<bool, 16> kept;
  kept.safe_grow_cleared (m_always_copy_start - i, true);
  for (unsigned j = i; j < adj_len; j++)
    {
      ipa_adjusted_param *apm = &(*m_adj_params)[j];
      if (apm->op == IPA_PARAM_OP_COPY)
        kept[apm->base_index - i] = true;
    }
  for (unsigned j = 0; j < m_always_copy_start - i; j++)
    if (!kept[j])
      return true;

  return false;
}

Reply via email to