for gcc/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
PR debug/46338
* profile.c (branch_prob): Skip debug stmts for BB end locus.
===================================================================
@@ -937,10 +937,11 @@ 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_bb (bb); !gsi_end_p (gsi);
+ gsi_prev (&gsi))
{
last = gsi_stmt (gsi);
- if (gimple_has_location (last))
+ if (!is_gimple_debug (last) && gimple_has_location (last))
break;
}