summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>2014-11-10 08:53:16 +0000
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>2014-11-10 08:53:16 +0000
commitc7bd9c39e4a8a4b6909c6e1f2b45fa581927a70a (patch)
tree609f00aaaa86d1c51912ba852cdaaf6424edac1a
parentee080c0c1de3e896dc1ee7352ba2621477706127 (diff)
downloadgcc-c7bd9c39e4a8a4b6909c6e1f2b45fa581927a70a.tar.gz
* gimple-low.c (lower_function_body): Clear the location of the first
inserted representative return if it also fills in for the fallthru. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@217278 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/gimple-low.c12
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.misc-tests/gcov-16.c24
4 files changed, 44 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index d3f061eaff7..97fc20e6dd0 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2014-11-10 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gimple-low.c (lower_function_body): Clear the location of the first
+ inserted representative return if it also fills in for the fallthru.
+
2014-11-10 Yuri Rumyantsev <ysrumyan@gmail.com>
* tree-if-conv.c (add_to_predicate_list): Check unconditionally
diff --git a/gcc/gimple-low.c b/gcc/gimple-low.c
index 310ade86c1f..3507d3cb09d 100644
--- a/gcc/gimple-low.c
+++ b/gcc/gimple-low.c
@@ -129,7 +129,8 @@ lower_function_body (void)
/* If the function falls off the end, we need a null return statement.
If we've already got one in the return_statements vector, we don't
need to do anything special. Otherwise build one by hand. */
- if (gimple_seq_may_fallthru (lowered_body)
+ bool may_fallthru = gimple_seq_may_fallthru (lowered_body);
+ if (may_fallthru
&& (data.return_statements.is_empty ()
|| (gimple_return_retval (data.return_statements.last().stmt)
!= NULL)))
@@ -138,6 +139,7 @@ lower_function_body (void)
gimple_set_location (x, cfun->function_end_locus);
gimple_set_block (x, DECL_INITIAL (current_function_decl));
gsi_insert_after (&i, x, GSI_CONTINUE_LINKING);
+ may_fallthru = false;
}
/* If we lowered any return statements, emit the representative
@@ -148,6 +150,14 @@ lower_function_body (void)
x = gimple_build_label (t.label);
gsi_insert_after (&i, x, GSI_CONTINUE_LINKING);
gsi_insert_after (&i, t.stmt, GSI_CONTINUE_LINKING);
+ if (may_fallthru)
+ {
+ /* Remove the line number from the representative return statement.
+ It now fills in for the fallthru too. Failure to remove this
+ will result in incorrect results for coverage analysis. */
+ gimple_set_location (t.stmt, UNKNOWN_LOCATION);
+ may_fallthru = false;
+ }
}
/* Once the old body has been lowered, replace it with the new
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index cd049812ee9..8c9df3d70c4 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2014-11-10 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gcc.misc-tests/gcov-16.c: New test.
+
2014-11-10 Yuri Rumyantsev <ysrumyan@gmail.com>
* gcc.dg/tree-ssa/ifc-cd.c: New test.
diff --git a/gcc/testsuite/gcc.misc-tests/gcov-16.c b/gcc/testsuite/gcc.misc-tests/gcov-16.c
new file mode 100644
index 00000000000..738113c92cb
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/gcov-16.c
@@ -0,0 +1,24 @@
+/* { dg-options "-fprofile-arcs -ftest-coverage" } */
+/* { dg-do run { target native } } */
+
+void
+bar (void)
+{}
+
+void
+foo (int i)
+{
+ if (i > 1) /* count(1) */
+ return; /* count(#####) */
+
+ bar (); /* count(1) */
+}
+
+int
+main (void)
+{
+ foo (0);
+ return 0;
+}
+
+/* { dg-final { run-gcov gcov-16.c } } */