This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix -fcompare-debug issue in reload1 (PR debug/46252)


Hi!

delete_dead_insn removes unused preceeding insn, but will not do that
if there are debug insns in between.
Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?

2010-11-01  Jakub Jelinek  <jakub@redhat.com>

	PR debug/46252
	* rtl.h (prev_real_nondebug_insn): New prototype.
	* emit-rtl.c (prev_real_nondebug_insn): New function.
	* reload1.c (delete_dead_insn): Use it instead of
	prev_real_insn.
	* cfgcleanup.c (try_head_merge_bb): Likewise.

	* gcc.dg/pr46252.c: New test.

--- gcc/rtl.h.jj	2010-11-01 09:07:23.000000000 +0100
+++ gcc/rtl.h	2010-11-01 15:41:31.000000000 +0100
@@ -1751,6 +1751,7 @@ extern rtx prev_nonnote_nondebug_insn (r
 extern rtx next_nonnote_nondebug_insn (rtx);
 extern rtx prev_real_insn (rtx);
 extern rtx next_real_insn (rtx);
+extern rtx prev_real_nondebug_insn (rtx);
 extern rtx prev_active_insn (rtx);
 extern rtx next_active_insn (rtx);
 extern int active_insn_p (const_rtx);
--- gcc/emit-rtl.c.jj	2010-11-01 09:07:23.000000000 +0100
+++ gcc/emit-rtl.c	2010-11-01 15:41:01.000000000 +0100
@@ -3133,8 +3133,8 @@ next_real_insn (rtx insn)
   return insn;
 }
 
-/* Return the last INSN, CALL_INSN or JUMP_INSN before INSN;
-   or 0, if there is none.  This routine does not look inside
+/* Return the last INSN, CALL_INSN, JUMP_INSN or DEBUG_INSN
+   before INSN; or 0, if there is none.  This routine does not look inside
    SEQUENCEs.  */
 
 rtx
@@ -3150,6 +3150,23 @@ prev_real_insn (rtx insn)
   return insn;
 }
 
+/* Return the last INSN, CALL_INSN or JUMP_INSN before INSN;
+   or 0, if there is none.  This routine does not look inside
+   SEQUENCEs.  */
+
+rtx
+prev_real_nondebug_insn (rtx insn)
+{
+  while (insn)
+    {
+      insn = PREV_INSN (insn);
+      if (insn == 0 || NONDEBUG_INSN_P (insn))
+	break;
+    }
+
+  return insn;
+}
+
 /* Return the last CALL_INSN in the current list, or 0 if there is none.
    This routine does not look inside SEQUENCEs.  */
 
--- gcc/reload1.c.jj	2010-11-01 09:07:24.000000000 +0100
+++ gcc/reload1.c	2010-11-01 15:39:21.000000000 +0100
@@ -2112,7 +2112,7 @@ spill_failure (rtx insn, enum reg_class 
 static void
 delete_dead_insn (rtx insn)
 {
-  rtx prev = prev_real_insn (insn);
+  rtx prev = prev_real_nondebug_insn (insn);
   rtx prev_dest;
 
   /* If the previous insn sets a register that dies in our insn, delete it
--- gcc/cfgcleanup.c.jj	2010-11-01 09:07:23.000000000 +0100
+++ gcc/cfgcleanup.c	2010-11-01 15:42:08.000000000 +0100
@@ -2054,9 +2054,7 @@ try_head_merge_bb (basic_block bb)
       max_match--;
       if (max_match == 0)
 	return false;
-      do
-	e0_last_head = prev_real_insn (e0_last_head);
-      while (DEBUG_INSN_P (e0_last_head));
+      e0_last_head = prev_real_nondebug_insn (e0_last_head);
     }
 
   if (max_match == 0)
--- gcc/testsuite/gcc.dg/pr46252.c.jj	2010-11-01 16:12:22.000000000 +0100
+++ gcc/testsuite/gcc.dg/pr46252.c	2010-11-01 16:12:07.000000000 +0100
@@ -0,0 +1,15 @@
+/* PR debug/46252 */
+/* { dg-do compile } */
+/* { dg-options "-O -frerun-cse-after-loop -fno-tree-loop-optimize -funroll-loops -fcompare-debug" } */
+
+void
+foo (float *f)
+{
+  int i;
+  for (i = 0; i < 4; i++)
+    f[i] = i;
+  bar ();
+  for (i = 0; i < 4; i++)
+    if (f[i] != i)
+      __builtin_abort ();
+}

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]