diff mbox

Fix ICE in reset_unmarked_insns_debug_uses (PR middle-end/49308)

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

Commit Message

Jakub Jelinek June 7, 2011, 12:24 p.m. UTC
On Mon, Jun 06, 2011 at 10:27:51AM -0300, Alexandre Oliva wrote:
> On Jun  6, 2011, Eric Botcazou <ebotcazou@adacore.com> wrote:
> 
> >> It might be too late for DF to do anything sensible to preserve the
> >> debug info rather than just throw it away, as your partial approval
> >> suggests.
> 
> > OK, let me think about this a little more.
> 
> >> Indeed, sorry, I misread it.
> 
> > Mind installing these bits separately?  My understanding is that they are 
> > independent correctness fixes.
> 
> Tested, installed.

This broke e.g. the attached testcase.
The problem is that after resetting+rescanning a debug insn
reset_unmarked_insns_debug_uses continued walking the DF chains for that
debug insn, but those were all invalidated by the
df_insn_rescan_debug_internal call.

Fixed thusly.  Additionally I've renamed a variable that was shadowing
a variable of the same name, which confused me quite a bit when debugging
it - I was expecting insn to be a DEBUG_INSN, while it was something
completely different.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2011-06-07  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/49308
	* dce.c (reset_unmarked_insns_debug_uses): Avoid shadowing insn
	variable.  After resetting and rescanning insn continue with previous
	statement.

	* gfortran.dg/pr49308.f90: New test.



	Jakub

Comments

Jakub Jelinek June 9, 2011, 7:47 a.m. UTC | #1
On Tue, Jun 07, 2011 at 02:24:49PM +0200, Jakub Jelinek wrote:
> Fixed thusly.  Additionally I've renamed a variable that was shadowing
> a variable of the same name, which confused me quite a bit when debugging
> it - I was expecting insn to be a DEBUG_INSN, while it was something
> completely different.
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

Alex said on IRC this looks obvious to him and I agree, so I've installed
it to trunk as such.

> 2011-06-07  Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR middle-end/49308
> 	* dce.c (reset_unmarked_insns_debug_uses): Avoid shadowing insn
> 	variable.  After resetting and rescanning insn continue with previous
> 	statement.
> 
> 	* gfortran.dg/pr49308.f90: New test.
> 
> --- gcc/dce.c.jj	2011-06-06 19:07:08.000000000 +0200
> +++ gcc/dce.c	2011-06-07 11:08:12.000000000 +0200
> @@ -514,11 +514,11 @@ reset_unmarked_insns_debug_uses (void)
>  	      struct df_link *defs;
>  	      for (defs = DF_REF_CHAIN (use); defs; defs = defs->next)
>  		{
> -		  rtx insn;
> +		  rtx ref_insn;
>  		  if (DF_REF_IS_ARTIFICIAL (defs->ref))
>  		    continue;
> -		  insn = DF_REF_INSN (defs->ref);
> -		  if (!marked_insn_p (insn))
> +		  ref_insn = DF_REF_INSN (defs->ref);
> +		  if (!marked_insn_p (ref_insn))
>  		    break;
>  		}
>  	      if (!defs)
> @@ -527,6 +527,7 @@ reset_unmarked_insns_debug_uses (void)
>  		 each of the DEFs?  */
>  	      INSN_VAR_LOCATION_LOC (insn) = gen_rtx_UNKNOWN_VAR_LOC ();
>  	      df_insn_rescan_debug_internal (insn);
> +	      break;
>  	    }
>  	}
>  }
> --- gcc/testsuite/gfortran.dg/pr49308.f90.jj	2011-06-07 11:39:39.000000000 +0200
> +++ gcc/testsuite/gfortran.dg/pr49308.f90	2011-06-07 11:30:25.000000000 +0200
> @@ -0,0 +1,28 @@
> +! PR middle-end/49308
> +! { dg-do compile }
> +! { dg-options "-O2 -funroll-loops -g" }
> +
> +subroutine foo(n, b, d, e)
> +  type t
> +    integer :: f
> +  end type t
> +  type s
> +    type(t), pointer :: g
> +  end type s
> +  type u
> +    type(s), dimension(:), pointer :: h
> +  end type
> +  integer :: i, k, n
> +  type(u), pointer :: a, e
> +  character(len=250) :: b, c, d
> +  logical :: l
> +  do i = 1, n
> +    j = i - 1
> +    if (j/=0) c = trim(b) // adjustl(d(j))
> +  end do
> +  a => e
> +  do k = 1, size(a%h)
> +     l = (a%h(k)%g%f == a%h(1)%g%f)
> +     if (.not.(l)) call bar()
> +  enddo
> +end subroutine foo

	Jakub
diff mbox

Patch

--- gcc/dce.c.jj	2011-06-06 19:07:08.000000000 +0200
+++ gcc/dce.c	2011-06-07 11:08:12.000000000 +0200
@@ -514,11 +514,11 @@  reset_unmarked_insns_debug_uses (void)
 	      struct df_link *defs;
 	      for (defs = DF_REF_CHAIN (use); defs; defs = defs->next)
 		{
-		  rtx insn;
+		  rtx ref_insn;
 		  if (DF_REF_IS_ARTIFICIAL (defs->ref))
 		    continue;
-		  insn = DF_REF_INSN (defs->ref);
-		  if (!marked_insn_p (insn))
+		  ref_insn = DF_REF_INSN (defs->ref);
+		  if (!marked_insn_p (ref_insn))
 		    break;
 		}
 	      if (!defs)
@@ -527,6 +527,7 @@  reset_unmarked_insns_debug_uses (void)
 		 each of the DEFs?  */
 	      INSN_VAR_LOCATION_LOC (insn) = gen_rtx_UNKNOWN_VAR_LOC ();
 	      df_insn_rescan_debug_internal (insn);
+	      break;
 	    }
 	}
 }
--- gcc/testsuite/gfortran.dg/pr49308.f90.jj	2011-06-07 11:39:39.000000000 +0200
+++ gcc/testsuite/gfortran.dg/pr49308.f90	2011-06-07 11:30:25.000000000 +0200
@@ -0,0 +1,28 @@ 
+! PR middle-end/49308
+! { dg-do compile }
+! { dg-options "-O2 -funroll-loops -g" }
+
+subroutine foo(n, b, d, e)
+  type t
+    integer :: f
+  end type t
+  type s
+    type(t), pointer :: g
+  end type s
+  type u
+    type(s), dimension(:), pointer :: h
+  end type
+  integer :: i, k, n
+  type(u), pointer :: a, e
+  character(len=250) :: b, c, d
+  logical :: l
+  do i = 1, n
+    j = i - 1
+    if (j/=0) c = trim(b) // adjustl(d(j))
+  end do
+  a => e
+  do k = 1, size(a%h)
+     l = (a%h(k)%g%f == a%h(1)%g%f)
+     if (.not.(l)) call bar()
+  enddo
+end subroutine foo