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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

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

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The problem is that expand_debug_expr follows all TER definitions for
SSA_NAMEs, and in this testcase it just creates really huge expression that we
then try to simplify, and nonzero_bits have bad time complexity for such large
expressions.
  pretmp_33 = a;
  a.1_6 = pretmp_33 & 231;
  a.2_21 = a.1_6 ^ 14;
  a.1_22 = a.2_21 & 231;
  a.2_17 = a.1_22 ^ 14;
  a.1_19 = a.2_17 & 231;
  a.2_37 = a.1_19 ^ 14;
  a.1_28 = a.2_37 & 231;
  a.2_29 = a.1_28 ^ 14;
  a.1_42 = a.2_29 & 231;
  a.5_41 = a.1_42 ^ 15;
  # DEBUG D#1 => a.5_41 < 0
  # DEBUG e => (int) D#1
  a.1_14 = a.5_41 & 231;
  a.2_25 = a.1_14 ^ 14;
  a.1_13 = a.2_25 & 231;
  a.2_44 = a.1_13 ^ 14;
  a.1_45 = a.2_44 & 231;
  a.2_46 = a.1_45 ^ 14;
  a.1_47 = a.2_46 & 231;
  a.2_48 = a.1_47 ^ 14;
  a.1_49 = a.2_48 & 231;
  a.5_51 = a.1_49 ^ 15;
  # DEBUG D#1 => a.5_51 < 0
  # DEBUG e => (int) D#1
  a.1_56 = a.5_51 & 231;
  a.2_57 = a.1_56 ^ 14;
  a.1_58 = a.2_57 & 231;
  a.2_59 = a.1_58 ^ 14;
  a.1_60 = a.2_59 & 231;
  a.2_61 = a.1_60 ^ 14;
  a.1_62 = a.2_61 & 231;
  a.2_63 = a.1_62 ^ 14;
  a.1_64 = a.2_63 & 231;
  a.5_66 = a.1_64 ^ 15;
  # DEBUG D#1 => a.5_66 < 0
  # DEBUG e => (int) D#1
...

Best would be to limit somehow the number of nested:
    case SSA_NAME:
      {
        gimple g = get_gimple_for_ssa_name (exp);
        if (g)
          {
            op0 = expand_debug_expr (gimple_assign_rhs_to_tree (g));
            if (!op0)
              return NULL;
          }
levels, perhaps by adding DEBUG_EXPR_DECLs to break too deep chains. 
Supposedly it would need to be done at the end of TER or so,
simply for all debug stmts, look at the nesting depth of
get_gimple_for_ssa_name links from their expressions, and if it goes over say 5
or 10,
add some DEBUG_EXPR_DECLs and debug stmts for them right after the
corresponding SSA_NAME definitions and replace all debug uses of the SSA_NAME
with that DEBUG_EXPR_DECL.

Alex, what do you think about that?

Reply via email to