On May  3, 2012, Alexandre Oliva <aol...@redhat.com> wrote:

> My recent patch for PR48866

... had some inconsistency in behavior between dce and word_dce, as you
pointed out.  I couldn't find any reason for that, so I made them the
same.

Regstrapped on x86_64-linux-gnu and i686-linux-gnu, no regressions
detected by the testsuite, but I'm concerned about potential debug info
regressions, which I'm yet to test.

Once I'm convinced it doesn't regress debug info, is this ok to install?

for  gcc/ChangeLog
from  Alexandre Oliva  <aol...@redhat.com>

	PR debug/52983
	PR debug/48866
	* dce.c (word_dce_process_block): Insert debug temps only if the
	insn is not marked.
	(dce_process_block): Likewise, and if debug.used is not empty,
	and only after iterating over all DEFs that might mark the insn.

Index: gcc/dce.c
===================================================================
--- gcc/dce.c.orig	2012-05-03 15:49:35.324670988 -0300
+++ gcc/dce.c	2012-05-03 15:57:33.000000000 -0300
@@ -858,8 +858,9 @@ word_dce_process_block (basic_block bb, 
 	   anything in local_live.  */
 	if (marked_insn_p (insn))
 	  df_word_lr_simulate_uses (insn, local_live);
-
-	if (debug.used && !bitmap_empty_p (debug.used))
+	/* Insert debug temps for dead REGs used in subsequent debug
+	   insns.  */
+	else if (debug.used && !bitmap_empty_p (debug.used))
 	  {
 	    df_ref *def_rec;
 
@@ -940,18 +941,13 @@ dce_process_block (basic_block bb, bool 
 	/* The insn is needed if there is someone who uses the output.  */
 	if (!needed)
 	  for (def_rec = DF_INSN_DEFS (insn); *def_rec; def_rec++)
-	    {
-	      dead_debug_insert_temp (&debug, DF_REF_REGNO (*def_rec), insn,
-				      DEBUG_TEMP_BEFORE_WITH_VALUE);
-
-	      if (bitmap_bit_p (local_live, DF_REF_REGNO (*def_rec))
-		  || bitmap_bit_p (au, DF_REF_REGNO (*def_rec)))
-		{
-		  needed = true;
-		  mark_insn (insn, true);
-		  break;
-		}
-	    }
+	    if (bitmap_bit_p (local_live, DF_REF_REGNO (*def_rec))
+		|| bitmap_bit_p (au, DF_REF_REGNO (*def_rec)))
+	      {
+		needed = true;
+		mark_insn (insn, true);
+		break;
+	      }
 
 	/* No matter if the instruction is needed or not, we remove
 	   any regno in the defs from the live set.  */
@@ -961,6 +957,12 @@ dce_process_block (basic_block bb, bool 
 	   anything in local_live.  */
 	if (needed)
 	  df_simulate_uses (insn, local_live);
+	/* Insert debug temps for dead REGs used in subsequent debug
+	   insns.  */
+	else if (debug.used && !bitmap_empty_p (debug.used))
+	  for (def_rec = DF_INSN_DEFS (insn); *def_rec; def_rec++)
+	    dead_debug_insert_temp (&debug, DF_REF_REGNO (*def_rec), insn,
+				    DEBUG_TEMP_BEFORE_WITH_VALUE);
       }
 
   dead_debug_finish (&debug, NULL);

-- 
Alexandre Oliva, freedom fighter    http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/   FSF Latin America board member
Free Software Evangelist      Red Hat Brazil Compiler Engineer

Reply via email to