aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2017-04-28 14:51:05 +0200
committerMartin Liska <marxin@gcc.gnu.org>2017-04-28 12:51:05 +0000
commit6e49961ce47b8c554ff6081ef95a68a0616f0a93 (patch)
tree581504fe21555bdbe3723111eb739d6cdc3e53ce /gcc/testsuite
parent9b9d6370d48146a0dd8ed327ecdbfc9273abf91a (diff)
downloadgcc-6e49961ce47b8c554ff6081ef95a68a0616f0a93.zip
gcc-6e49961ce47b8c554ff6081ef95a68a0616f0a93.tar.gz
gcc-6e49961ce47b8c554ff6081ef95a68a0616f0a93.tar.bz2
Make gcno more precise about BBs really belonging to a line (PR gcov-profile/79891).
2017-04-28 Martin Liska <mliska@suse.cz> PR gcov-profile/79891 * gcov.c (add_line_counts): Assign BBs to lines just if the BB is marked by compiler as living on a line. (get_cycles_count): Remove usage of the union. (output_intermediate_file): Likewise. (find_source): Fix GNU coding style. (accumulate_line_counts): Remove old non-all block mode. (output_lines): Remove usage of the union. * profile.c (output_location): Include all BBs, even if belonging to a same line (and file) as a previous BB. 2017-04-28 Martin Liska <mliska@suse.cz> PR gcov-profile/79891 * gcc.misc-tests/gcov-17.c: New test. * gcc.misc-tests/gcov-18.c: New test. From-SVN: r247374
Diffstat (limited to 'gcc/testsuite')
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gcc.misc-tests/gcov-17.c51
-rw-r--r--gcc/testsuite/gcc.misc-tests/gcov-18.c29
3 files changed, 86 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a33c19a..cf3199b 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2017-04-28 Martin Liska <mliska@suse.cz>
+
+ PR gcov-profile/79891
+ * gcc.misc-tests/gcov-17.c: New test.
+ * gcc.misc-tests/gcov-18.c: New test.
+
2017-04-28 Tom de Vries <tom@codesourcery.com>
* g++.dg/parse/error2.C: Remove superfluous '{ target *-*-* }' in
diff --git a/gcc/testsuite/gcc.misc-tests/gcov-17.c b/gcc/testsuite/gcc.misc-tests/gcov-17.c
new file mode 100644
index 0000000..e388608
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/gcov-17.c
@@ -0,0 +1,51 @@
+/* Test gcov block mode. Compiler generates following CFG:
+
+ <bb 3>:
+ if (false_var_4 != 0)
+ goto <bb 4>;
+ else
+ goto <bb 5>;
+
+ <bb 4>:
+ ret_6 = 111;
+ PROF_edge_counter_10 = __gcov0.UuT[0];
+ PROF_edge_counter_11 = PROF_edge_counter_10 + 1;
+ __gcov0.UuT[0] = PROF_edge_counter_11;
+
+ <bb 5>:
+ # ret_1 = PHI <ret_5(3), ret_6(4)>
+ goto <bb 7>;
+
+It's important not to include <bb 5> to any line as it's actually shared
+by both branches of the condition in <bb 3>.
+
+*/
+
+/* { dg-options "-fprofile-arcs -ftest-coverage" } */
+/* { dg-do run { target native } } */
+
+unsigned int
+UuT (void)
+{
+ unsigned int true_var = 1;
+ unsigned int false_var = 0;
+ unsigned int ret = 0;
+
+ if (true_var) /* count(1) */
+ {
+ if (false_var) /* count(1) */
+ ret = 111; /* count(#####) */
+ }
+ else
+ ret = 999; /* count(#####) */
+ return ret;
+}
+
+int
+main (int argc, char **argv)
+{
+ UuT ();
+ return 0;
+}
+
+/* { dg-final { run-gcov { -a gcov-17.c } } } */
diff --git a/gcc/testsuite/gcc.misc-tests/gcov-18.c b/gcc/testsuite/gcc.misc-tests/gcov-18.c
new file mode 100644
index 0000000..ae10178
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/gcov-18.c
@@ -0,0 +1,29 @@
+/* Test gcov block mode. As the example does jump to a statement
+ that is on a line with different ones, we must calculate such jump
+ just once. */
+
+/* { dg-options "-fprofile-arcs -ftest-coverage" } */
+/* { dg-do run { target native } } */
+
+int a = 0;
+
+void foo() /* count(1) */
+{
+ a = 1;
+}
+
+void bar() /* count(1) */
+{
+ a++;
+}
+
+int main() /* count(1) */
+{
+ foo (); goto baz; lab: bar (); /* count(2) */
+
+ baz:
+ if (a == 1) /* count(2) */
+ goto lab; /* count(1) */
+}
+
+/* { dg-final { run-gcov { gcov-18.c } } } */