Commit 7ffc0411 by Steven Bosscher Committed by Steven Bosscher

re PR tree-optimization/24225 (ICE: segmentation fault in profile.c:branch_prob)

PR tree-optimization/24225

gcc/
	* profile.c (branch_prob): Look from end to start through a
	basic block when looking for a locus.

testsuite/
	* gcc.dg/pr24225.c: New test.

From-SVN: r105857
parent 77c4f044
2005-10-24 Steven Bosscher <stevenb@suse.de>
PR tree-optimization/24255
* profile.c (branch_prob): Look from end to start through a
basic block when looking for a locus.
2005-10-24 Richard Henderson <rth@redhat.com> 2005-10-24 Richard Henderson <rth@redhat.com>
* pa.c (store_reg_modify): Set RTX_FRAME_RELATED_P on each set in * pa.c (store_reg_modify): Set RTX_FRAME_RELATED_P on each set in
...@@ -83,7 +89,7 @@ ...@@ -83,7 +89,7 @@
2005-10-20 Steven Bosscher <stevenb@suse.de> 2005-10-20 Steven Bosscher <stevenb@suse.de>
PR tree-optimization/24225 PR tree-optimization/24307
* tree-cfg.c (tree_find_edge_insert_loc): Handle naked RETURN_EXPR. * tree-cfg.c (tree_find_edge_insert_loc): Handle naked RETURN_EXPR.
2005-10-20 Alexandre Oliva <aoliva@redhat.com> 2005-10-20 Alexandre Oliva <aoliva@redhat.com>
......
...@@ -806,13 +806,27 @@ branch_prob (void) ...@@ -806,13 +806,27 @@ branch_prob (void)
FOR_EACH_EDGE (e, ei, bb->succs) FOR_EACH_EDGE (e, ei, bb->succs)
{ {
tree last = last_stmt (bb); block_stmt_iterator bsi;
tree last = NULL;
/* 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 (bsi = bsi_last (bb); !bsi_end_p (bsi); bsi_prev (&bsi))
{
last = bsi_stmt (bsi);
if (EXPR_LOCUS (last))
break;
}
/* Edge with goto locus might get wrong coverage info unless /* Edge with goto locus might get wrong coverage info unless
it is the only edge out of BB. it is the only edge out of BB.
Don't do that when the locuses match, so Don't do that when the locuses match, so
if (blah) goto something; if (blah) goto something;
is not computed twice. */ is not computed twice. */
if (e->goto_locus && !single_succ_p (bb) if (last && EXPR_LOCUS (last)
&& e->goto_locus
&& !single_succ_p (bb)
#ifdef USE_MAPPED_LOCATION #ifdef USE_MAPPED_LOCATION
&& (LOCATION_FILE (e->goto_locus) && (LOCATION_FILE (e->goto_locus)
!= LOCATION_FILE (EXPR_LOCATION (last)) != LOCATION_FILE (EXPR_LOCATION (last))
...@@ -820,8 +834,7 @@ branch_prob (void) ...@@ -820,8 +834,7 @@ branch_prob (void)
!= LOCATION_LINE (EXPR_LOCATION (last))))) != LOCATION_LINE (EXPR_LOCATION (last)))))
#else #else
&& (e->goto_locus->file != EXPR_LOCUS (last)->file && (e->goto_locus->file != EXPR_LOCUS (last)->file
|| (e->goto_locus->line || (e->goto_locus->line != EXPR_LOCUS (last)->line)))
!= EXPR_LOCUS (last)->line)))
#endif #endif
{ {
basic_block new = split_edge (e); basic_block new = split_edge (e);
......
2005-10-24 Steven Bosscher <stevenb@suse.de>
* gcc.dg/pr24225.c: New test.
2005-10-24 Asher Langton <langton2@llnl.gov> 2005-10-24 Asher Langton <langton2@llnl.gov>
* gfortran.dg/dup_save_1.f90: New test. * gfortran.dg/dup_save_1.f90: New test.
/* This was an ICE caused by the compiler-generated stack save/restore
statements around s[b]. */
/* { dg-do compile} */
/* { dg-options "-O1 -fprofile-arcs" } */
int
foo (int a, int b)
{
if (a)
return 1;
{
int s [b];
return 0;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment