From 868a69daa7d852a8dfcc8b0913ba1ffdde061af6 Mon Sep 17 00:00:00 2001 From: steven Date: Mon, 24 Oct 2005 19:20:38 +0000 Subject: [PATCH] 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@105857 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 8 +++++++- gcc/profile.c | 21 +++++++++++++++++---- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gcc.dg/pr24225.c | 15 +++++++++++++++ 4 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr24225.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 14e264cef8f..b22e317e324 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2005-10-24 Steven Bosscher + + 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 * pa.c (store_reg_modify): Set RTX_FRAME_RELATED_P on each set in @@ -83,7 +89,7 @@ 2005-10-20 Steven Bosscher - PR tree-optimization/24225 + PR tree-optimization/24307 * tree-cfg.c (tree_find_edge_insert_loc): Handle naked RETURN_EXPR. 2005-10-20 Alexandre Oliva diff --git a/gcc/profile.c b/gcc/profile.c index 1fc8aa58d50..d260d66e106 100644 --- a/gcc/profile.c +++ b/gcc/profile.c @@ -806,13 +806,27 @@ branch_prob (void) 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 it is the only edge out of BB. Don't do that when the locuses match, so if (blah) goto something; 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 && (LOCATION_FILE (e->goto_locus) != LOCATION_FILE (EXPR_LOCATION (last)) @@ -820,8 +834,7 @@ branch_prob (void) != LOCATION_LINE (EXPR_LOCATION (last))))) #else && (e->goto_locus->file != EXPR_LOCUS (last)->file - || (e->goto_locus->line - != EXPR_LOCUS (last)->line))) + || (e->goto_locus->line != EXPR_LOCUS (last)->line))) #endif { basic_block new = split_edge (e); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e8f970349f6..f952b56f510 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2005-10-24 Steven Bosscher + + * gcc.dg/pr24225.c: New test. + 2005-10-24 Asher Langton * gfortran.dg/dup_save_1.f90: New test. diff --git a/gcc/testsuite/gcc.dg/pr24225.c b/gcc/testsuite/gcc.dg/pr24225.c new file mode 100644 index 00000000000..b364f820d4b --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr24225.c @@ -0,0 +1,15 @@ +/* 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; + } +} -- 2.11.4.GIT