diff mbox

Fix PR46528

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

Commit Message

Jakub Jelinek Dec. 2, 2010, 2:28 p.m. UTC
On Thu, Nov 25, 2010 at 04:53:33PM +0100, Richard Guenther wrote:
> This fixes the problem on the testcase in PR46528 where we end up
> with mismatched profiles when doing -g0 -fprofile-generate vs.
> -g -fprofile-use as in (some) profiledbootstrap runs.

I don't think this is 100% correct, it might still trigger if there
are no normal stmts with location, only debug stmts with location, then
last will be still set and might result in differences.

Fixed thusly, ok for trunk?

2010-12-02  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/46528
	PR debug/46338
	* profile.c (branch_prob): Make sure last is never set to a debug
	stmt.


	Jakub

Comments

Richard Biener Dec. 2, 2010, 3:41 p.m. UTC | #1
On Thu, 2 Dec 2010, Jakub Jelinek wrote:

> On Thu, Nov 25, 2010 at 04:53:33PM +0100, Richard Guenther wrote:
> > This fixes the problem on the testcase in PR46528 where we end up
> > with mismatched profiles when doing -g0 -fprofile-generate vs.
> > -g -fprofile-use as in (some) profiledbootstrap runs.
> 
> I don't think this is 100% correct, it might still trigger if there
> are no normal stmts with location, only debug stmts with location, then
> last will be still set and might result in differences.
> 
> Fixed thusly, ok for trunk?

Ok if it passed profiledbootstrap.

Thanks,
Richard.

> 2010-12-02  Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR tree-optimization/46528
> 	PR debug/46338
> 	* profile.c (branch_prob): Make sure last is never set to a debug
> 	stmt.
> 
> --- gcc/profile.c	2010-11-26 10:50:25.562279727 +0100
> +++ gcc/profile.c	2010-11-30 16:22:51.582292282 +0100
> @@ -937,11 +937,12 @@ branch_prob (void)
>  	  /* It may happen that there are compiler generated statements
>  	     without a locus at all.  Go through the basic block from the
>  	     last to the first statement looking for a locus.  */
> -	  for (gsi = gsi_last_bb (bb); !gsi_end_p (gsi); gsi_prev (&gsi))
> +	  for (gsi = gsi_last_nondebug_bb (bb);
> +	       !gsi_end_p (gsi);
> +	       gsi_prev_nondebug (&gsi))
>  	    {
>  	      last = gsi_stmt (gsi);
> -	      if (!is_gimple_debug (last)
> -		  && gimple_has_location (last))
> +	      if (gimple_has_location (last))
>  		break;
>  	    }
>  
> 
> 	Jakub
> 
>
diff mbox

Patch

--- gcc/profile.c	2010-11-26 10:50:25.562279727 +0100
+++ gcc/profile.c	2010-11-30 16:22:51.582292282 +0100
@@ -937,11 +937,12 @@  branch_prob (void)
 	  /* It may happen that there are compiler generated statements
 	     without a locus at all.  Go through the basic block from the
 	     last to the first statement looking for a locus.  */
-	  for (gsi = gsi_last_bb (bb); !gsi_end_p (gsi); gsi_prev (&gsi))
+	  for (gsi = gsi_last_nondebug_bb (bb);
+	       !gsi_end_p (gsi);
+	       gsi_prev_nondebug (&gsi))
 	    {
 	      last = gsi_stmt (gsi);
-	      if (!is_gimple_debug (last)
-		  && gimple_has_location (last))
+	      if (gimple_has_location (last))
 		break;
 	    }