[PR debug/41343] introduce debug expr temps

Richard Guenther richard.guenther@gmail.com
Fri Oct 9 11:29:00 GMT 2009


On Fri, Oct 9, 2009 at 9:36 AM, Alexandre Oliva <aoliva@redhat.com> wrote:
> On Oct  7, 2009, Alexandre Oliva <aoliva@redhat.com> wrote:
>
>> On Oct  6, 2009, Richard Guenther <richard.guenther@gmail.com> wrote:
>>>> Anyhow, if we find it not to be true, it shouldn't be too hard to get
>>>> debug temps into SSA operands, especially if we're to add vops to debug
>>>> bind stmts as well.
>
>>> Gah.  Over my dead body!
>
>> :-)
>
>>> Fair enough.  Mind adding a comment here?  Mind adding
>>> a DEBUG_DECL_UID macro that encapsulates the negation?
>
>> Will do.
>
> The patch below introduces DEBUG_TEMP_UID, it removes debug temp bind
> stmts without values during SSA updates (removing them upon reset would
> invalidate iterators),

Hm.  Please instead replace them with GIMPLE_NOPs on reset, it should
be possible to do that in-place.  If there isn't a nice suitable way of doing
it already please add a helper function in gimple.c that does this.
gimple_make_nop whould be a suitable name for this.

> and it avoids the creation of debug temp bind
> stmts when the expressions are safe to move, i.e., if they refer to SSA
> names or to constants.
>
> So, given:
>
>  a_1 = b_2;
>  c_3 = -d_4;
>  e_5 = f_6 + g_7;
>  # DEBUG h => a_1
>  # DEBUG i => c_3
>  # DEBUG j => e_5
>  # DEBUG k => a_1 + c_3
>  # DEBUG l => -e_5
>
> if a_1, c_3 and e_5 are removed, we'll emit:
>
>  ;; (nothing for a_1 = b_2)
>  # DEBUG D#1 => -d_4
>  # DEBUG D#2 => f_6 + g_7
>  # DEBUG h => b_2
>  # DEBUG i => -d_4
>  # DEBUG j => f_6 + g_7
>  # DEBUG k => b_2 + D#1
>  # DEBUG l => -D#2
>
> i.e., if the SSA name whose DEF is being removed is by itself in a debug
> bind stmt's value, we'll use the expression formerly assigned to the
> DEF.  If it's not by itself, we'll only use the expression if it's an
> SSA name or constant.

I'd like to see

# DEBUG j => D#2

here.  Thus restrict the "if the SSA name whose DEF is being removed
is by itself
in a debug bind stmt's value, we'll use the expression formerly assigned to the
DEF." to the case where there is a single use.

              if (!no_value)
                value = gimple_assign_rhs_to_tree (def_stmt);
            }
          if (!value)
            no_value = true;
+         else if (is_gimple_min_invariant (value)
+                  || is_gimple_reg (value))
+           {
+             vsafe = true;
+             vexpr = value;
+           }
+         else
+           {
+             switch (get_gimple_rhs_class (TREE_CODE (value)))
+               {
+               case GIMPLE_BINARY_RHS:
+                 vsafe
+                   = ((is_gimple_min_invariant (TREE_OPERAND (value, 0))
...
+                 if (vsafe)
+                   vexpr = value;
+                 break;
+
+               default:
+                 gcc_unreachable ();
+               }
+           }

vsafe computation can be simplified.

  vsafe = (!gimple_assign_single_p (def_stmt)
             || is_gimple_min_invariant (value)
            || is_gimple_reg (value));

For the single-use issue add

  if (!gimple_assign_single_p (def_stmt)
      && !has_single_use (var))
    vsafe = false;

well - of course with a proper has_single_use that also counts debug stmts.

> I also added the testcases from the bug reports, and I realized cselib
> did not distinguish between different DEBUG_EXPR_DECLs, so I fixed that.
>
> Here's the patch I'm testing now.  Ok to install if it regstraps?

Ok with the above changes.

Thanks,
Richard.



More information about the Gcc-patches mailing list