[PATCH] combine: RTX changes depending on presence of DEBUG_INSN

Jakub Jelinek jakub@redhat.com
Thu May 27 19:03:00 GMT 2010


On Thu, May 27, 2010 at 08:42:55PM +0200, Andreas Krebbel wrote:
> Hi Eric,
> 
> >The result of the transformation is supposed to be used only there so I don't
> >see the theoritical problem.  You need to find out what happens exactly.
> 
> In the example I'm debugging the code at the end of
> make_compound_operation swaps 2 PLUS operands and changes the src
> operand in-place affecting the original insn. This is certainly not
> supposed to happen here.

If make_compound_operation clobbers its argument, then either
we need to call it on copy_rtx (src), or change make_compound_operation
not to touch the original rtx, instead just create new rtx.

Or, perhaps best, don't call make_compound_operation in propagate_for_debug,
but instead in propagate_for_debug_subst on demand.  The advantage
of that is that we don't create GC garbage that way needlessly, just because
we saw some DEBUG_INSN, but only when we actually see we want to substitute.

Here is a totally untested patch that implements it:

--- gcc/combine.c	2010-05-25 11:27:47.000000000 +0200
+++ gcc/combine.c	2010-05-27 20:56:34.420583830 +0200
@@ -2271,6 +2271,7 @@ cleanup_auto_inc_dec (rtx src, bool afte
 
   return x;
 }
+#endif
 
 /* Auxiliary data structure for propagate_for_debug_stmt.  */
 
@@ -2294,12 +2295,16 @@ propagate_for_debug_subst (rtx from, con
   if (!pair->adjusted)
     {
       pair->adjusted = true;
+#ifdef AUTO_INC_DEC
       pair->to = cleanup_auto_inc_dec (pair->to, pair->after, VOIDmode);
+#else
+      pair->to = copy_rtx (pair->to);
+#endif
+      pair->to = make_compound_operation (pair->to, SET);
       return pair->to;
     }
   return copy_rtx (pair->to);
 }
-#endif
 
 /* Replace occurrences of DEST with SRC in DEBUG_INSNs between INSN
    and LAST.  If MOVE holds, debug insns must also be moved past
@@ -2309,16 +2314,12 @@ static void
 propagate_for_debug (rtx insn, rtx last, rtx dest, rtx src, bool move)
 {
   rtx next, move_pos = move ? last : NULL_RTX, loc;
-  bool first_p;
 
-#ifdef AUTO_INC_DEC
   struct rtx_subst_pair p;
   p.to = src;
   p.adjusted = false;
   p.after = move;
-#endif
 
-  first_p = true;
   next = NEXT_INSN (insn);
   while (next != last)
     {
@@ -2326,17 +2327,8 @@ propagate_for_debug (rtx insn, rtx last,
       next = NEXT_INSN (insn);
       if (DEBUG_INSN_P (insn))
 	{
-	  if (first_p)
-	    {
-	      src = make_compound_operation (src, SET);
-	      first_p = false;
-	    }
-#ifdef AUTO_INC_DEC
 	  loc = simplify_replace_fn_rtx (INSN_VAR_LOCATION_LOC (insn),
 					 dest, propagate_for_debug_subst, &p);
-#else
-	  loc = simplify_replace_rtx (INSN_VAR_LOCATION_LOC (insn), dest, src);
-#endif
 	  if (loc == INSN_VAR_LOCATION_LOC (insn))
 	    continue;
 	  INSN_VAR_LOCATION_LOC (insn) = loc;


	Jakub



More information about the Gcc-patches mailing list