summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2005-08-04 00:10:54 +0200
committerJan Hubicka <hubicka@gcc.gnu.org>2005-08-03 22:10:54 +0000
commitd783b2a2dc91e1d2c1fea78cac2b6c6c73b3680d (patch)
treefcee55b5f24d9dfb6674c4dbf7fa3c50e5dfb709
parent5336645054c5bc4bf56215863b9d64bd24884f32 (diff)
downloadgcc-d783b2a2dc91e1d2c1fea78cac2b6c6c73b3680d.tar.gz
profile.c (branch_prob): Split edges with goto locus on them to get proper line counts.
* profile.c (branch_prob): Split edges with goto locus on them to get proper line counts. * tree-cfg.c (make_cond_expr_edges): Record user goto locuses, if any. * gcov-1.C: Fix switch counts. * gcov-4b.c: Likewise. From-SVN: r102717
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/profile.c21
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/gcov/gcov-1.C2
-rw-r--r--gcc/testsuite/gcc.misc-tests/gcov-4b.c2
-rw-r--r--gcc/tree-cfg.c18
6 files changed, 50 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index e879f4d3a9d..8a061aed2ee 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2005-08-04 Jan Hubicka <jh@suse.cz>
+
+ * profile.c (branch_prob): Split edges with goto locus on them
+ to get proper line counts.
+ * tree-cfg.c (make_cond_expr_edges): Record user goto locuses, if any.
+
2005-08-03 Paul Brook <paul@codesourcery.com>
* function.c (assign_parms): Round current_function_args_size
diff --git a/gcc/profile.c b/gcc/profile.c
index 95448f076ff..1fc8aa58d50 100644
--- a/gcc/profile.c
+++ b/gcc/profile.c
@@ -806,6 +806,27 @@ branch_prob (void)
FOR_EACH_EDGE (e, ei, bb->succs)
{
+ tree last = last_stmt (bb);
+ /* 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)
+#ifdef USE_MAPPED_LOCATION
+ && (LOCATION_FILE (e->goto_locus)
+ != LOCATION_FILE (EXPR_LOCATION (last))
+ || (LOCATION_LINE (e->goto_locus)
+ != LOCATION_LINE (EXPR_LOCATION (last)))))
+#else
+ && (e->goto_locus->file != EXPR_LOCUS (last)->file
+ || (e->goto_locus->line
+ != EXPR_LOCUS (last)->line)))
+#endif
+ {
+ basic_block new = split_edge (e);
+ single_succ_edge (new)->goto_locus = e->goto_locus;
+ }
if ((e->flags & (EDGE_ABNORMAL | EDGE_ABNORMAL_CALL))
&& e->dest != EXIT_BLOCK_PTR)
need_exit_edge = 1;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 800fc4151a7..acbe5eba8bc 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2005-08-04 Jan Hubicka <jh@suse.cz>
+
+ * gcov-1.C: Fix switch counts.
+ * gcov-4b.c: Likewise.
+
2005-08-03 Jeff Law <law@redhat.com>
* g++.dg/tree-ssa/pr14814.C: xfail test for &this count.
diff --git a/gcc/testsuite/g++.dg/gcov/gcov-1.C b/gcc/testsuite/g++.dg/gcov/gcov-1.C
index 6089adac05b..c279b1452fc 100644
--- a/gcc/testsuite/g++.dg/gcov/gcov-1.C
+++ b/gcc/testsuite/g++.dg/gcov/gcov-1.C
@@ -253,7 +253,7 @@ test_switch (int i, int j)
{
int result = 0; /* count(5) */
- /* branch(80 25) */
+ /* branch(20 0 60 20) */
switch (i) /* count(5) */
/* branch(end) */
{
diff --git a/gcc/testsuite/gcc.misc-tests/gcov-4b.c b/gcc/testsuite/gcc.misc-tests/gcov-4b.c
index 7653c5897ad..da98749f719 100644
--- a/gcc/testsuite/gcc.misc-tests/gcov-4b.c
+++ b/gcc/testsuite/gcc.misc-tests/gcov-4b.c
@@ -207,7 +207,7 @@ test_switch (int i, int j)
{
int result = 0;
- switch (i) /* branch(80 25) */
+ switch (i) /* branch(20 0 60 20) */
/* branch(end) */
{
case 1:
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index bf25f837e76..096da092151 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -577,6 +577,7 @@ make_cond_expr_edges (basic_block bb)
tree entry = last_stmt (bb);
basic_block then_bb, else_bb;
tree then_label, else_label;
+ edge e;
gcc_assert (entry);
gcc_assert (TREE_CODE (entry) == COND_EXPR);
@@ -587,8 +588,21 @@ make_cond_expr_edges (basic_block bb)
then_bb = label_to_block (then_label);
else_bb = label_to_block (else_label);
- make_edge (bb, then_bb, EDGE_TRUE_VALUE);
- make_edge (bb, else_bb, EDGE_FALSE_VALUE);
+ e = make_edge (bb, then_bb, EDGE_TRUE_VALUE);
+#ifdef USE_MAPPED_LOCATION
+ e->goto_locus = EXPR_LOCATION (COND_EXPR_THEN (entry));
+#else
+ e->goto_locus = EXPR_LOCUS (COND_EXPR_THEN (entry));
+#endif
+ e = make_edge (bb, else_bb, EDGE_FALSE_VALUE);
+ if (e)
+ {
+#ifdef USE_MAPPED_LOCATION
+ e->goto_locus = EXPR_LOCATION (COND_EXPR_ELSE (entry));
+#else
+ e->goto_locus = EXPR_LOCUS (COND_EXPR_ELSE (entry));
+#endif
+ }
}
/* Hashing routine for EDGE_TO_CASES. */