diff mbox

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

Message ID 20101102234327.GN29412@tyan-ft48-01.lab.bos.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek Nov. 2, 2010, 11:43 p.m. UTC
On Tue, Nov 02, 2010 at 09:46:54PM +0100, Eric Botcazou wrote:
> > Yes, but after reload it also skips USE/CLOBBERs.  I'm not sure we want to
> > do that in cfgcleanup, in reload1.c it should be fine, as reload_completed
> > there is still 0, and in gcse.c it is fine too.
> 
> There is another flavor of *_active_insn in ifcvt.c. :-)  Would it work to:
>  - export last_active_insn from ifcvt.c,
>  - call it in cfgcleanup.c,
>  - replace the other uses of prev_real_insn by prev_active_insn,
>  - delete prev_real_insn,
>  - document that next_real_insn can return DEBUG_INSNs (and that its uses may 
> need to be audited wrt DEBUG_INSNs in a ??? note)?

So far I have done 3) from the above list, bootstrapped/regtested on
x86_64-linux and i686-linux, getting tired so I've postponed the rest for
later on, will try to get to it soon.  Ok?

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

	PR debug/46252
	* reload1.c (delete_dead_insn): Use prev_active_insn instead of
	prev_real_insn.
	* gcse.c (insert_insn_end_basic_block): Likewise.

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



	Jakub

Comments

Eric Botcazou Nov. 3, 2010, 8:23 a.m. UTC | #1
> 2010-11-01  Jakub Jelinek  <jakub@redhat.com>
>
> 	PR debug/46252
> 	* reload1.c (delete_dead_insn): Use prev_active_insn instead of
> 	prev_real_insn.
> 	* gcse.c (insert_insn_end_basic_block): Likewise.
>
> 	* gcc.dg/pr46252.c: New test.

OK, thanks.
Eric Botcazou Nov. 4, 2010, 4 p.m. UTC | #2
> So far I have done 3) from the above list, bootstrapped/regtested on
> x86_64-linux and i686-linux, getting tired so I've postponed the rest for
> later on, will try to get to it soon.  

While the 3rd use of prev_real_insn in the middle-end has disappeared in the 
meantime, it turns out that it is used in several back-ends.
diff mbox

Patch

--- 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_active_insn (insn);
   rtx prev_dest;
 
   /* If the previous insn sets a register that dies in our insn, delete it
--- gcc/gcse.c.jj	2010-09-13 20:54:20.000000000 +0200
+++ gcc/gcse.c	2010-11-02 22:37:14.022260983 +0100
@@ -3574,7 +3574,7 @@  insert_insn_end_basic_block (struct expr
 	 the new instruction just before the tablejump.  */
       if (GET_CODE (PATTERN (insn)) == ADDR_VEC
 	  || GET_CODE (PATTERN (insn)) == ADDR_DIFF_VEC)
-	insn = prev_real_insn (insn);
+	insn = prev_active_insn (insn);
 
 #ifdef HAVE_cc0
       /* FIXME: 'twould be nice to call prev_cc0_setter here but it aborts
--- 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 ();
+}