diff options
author | nathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-12-10 08:32:34 +0000 |
---|---|---|
committer | nathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-12-10 08:32:34 +0000 |
commit | 5b0e70eee581a927fb1007cdfde31fa02179374b (patch) | |
tree | 33bb7445e0b0a2b4ce75136a68cb0e1aab95ae2a /gcc | |
parent | dd7406071f0d37879f539852a27b46dc7f876018 (diff) | |
download | gcc-5b0e70eee581a927fb1007cdfde31fa02179374b.tar.gz |
PR gcov-profile/51449
* coverage.c (coverage_end_function): Always process the coverage
variables.
testsuite/
* g++.dg/gcov/gcov-14.C: New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@182184 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/coverage.c | 43 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/gcov/gcov-14.C | 16 |
4 files changed, 50 insertions, 20 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index cb28824febf..7d290918588 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2011-12-10 Nathan Sidwell <nathan@acm.org> + + PR gcov-profile/51449 + * coverage.c (coverage_end_function): Always process the coverage + variables. + 2011-12-09 Aldy Hernandez <aldyh@redhat.com> PR/51291 diff --git a/gcc/coverage.c b/gcc/coverage.c index 656db92beb1..58a76cafadd 100644 --- a/gcc/coverage.c +++ b/gcc/coverage.c @@ -604,20 +604,33 @@ coverage_end_function (unsigned lineno_checksum, unsigned cfg_checksum) bbg_file_name = NULL; } - /* If the function is extern (i.e. extern inline), then we won't be - outputting it, so don't chain it onto the function list. */ - if (fn_ctr_mask && !DECL_EXTERNAL (current_function_decl)) + if (fn_ctr_mask) { - struct coverage_data *item = ggc_alloc_coverage_data (); + struct coverage_data *item = 0; + + /* If the function is extern (i.e. extern inline), then we won't + be outputting it, so don't chain it onto the function + list. */ + if (!DECL_EXTERNAL (current_function_decl)) + { + item = ggc_alloc_coverage_data (); + + item->ident = current_function_funcdef_no + 1; + item->lineno_checksum = lineno_checksum; + item->cfg_checksum = cfg_checksum; + + item->fn_decl = current_function_decl; + item->next = 0; + *functions_tail = item; + functions_tail = &item->next; + } - item->ident = current_function_funcdef_no + 1; - item->lineno_checksum = lineno_checksum; - item->cfg_checksum = cfg_checksum; for (i = 0; i != GCOV_COUNTERS; i++) { tree var = fn_v_ctrs[i]; - - item->ctr_vars[i] = var; + + if (item) + item->ctr_vars[i] = var; if (var) { tree array_type = build_index_type (size_int (fn_n_ctrs[i] - 1)); @@ -627,17 +640,7 @@ coverage_end_function (unsigned lineno_checksum, unsigned cfg_checksum) DECL_SIZE_UNIT (var) = TYPE_SIZE_UNIT (array_type); varpool_finalize_decl (var); } - } - item->fn_decl = current_function_decl; - item->next = 0; - *functions_tail = item; - functions_tail = &item->next; - } - - if (fn_ctr_mask) - { - for (i = 0; i != GCOV_COUNTERS; i++) - { + fn_b_ctrs[i] = fn_n_ctrs[i] = 0; fn_v_ctrs[i] = NULL_TREE; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ac300e869f1..b17e0fe4d77 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-12-10 Nathan Sidwell <nathan@acm.org> + + PR gcov-profile/51449 + * g++.dg/gcov/gcov-14.C: New. + 2011-12-09 Eric Botcazou <ebotcazou@adacore.com> * gcc.c-torture/compile/20111209-1.c: New test. diff --git a/gcc/testsuite/g++.dg/gcov/gcov-14.C b/gcc/testsuite/g++.dg/gcov/gcov-14.C new file mode 100644 index 00000000000..8f8e3882d82 --- /dev/null +++ b/gcc/testsuite/g++.dg/gcov/gcov-14.C @@ -0,0 +1,16 @@ +/* { dg-options "-fprofile-arcs -ftest-coverage -Ofast" } */ +/* { dg-do run { target native } } */ + +#include <iostream> + +void __attribute__ ((noinline)) + Out (std::ostream &out, double x) +{ out << x << std::endl; } /* count(1) */ + +int main () +{ + Out (std::cout, 1.5); /* count(1) */ + return 0; +} + +/* { dg-final { run-gcov gcov-14.C } } */ |