diff options
author | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-01-25 12:35:13 +0000 |
---|---|---|
committer | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-01-25 12:35:13 +0000 |
commit | c81ed7c146d5041a176077a5b351fd83f1e4a830 (patch) | |
tree | 38aed0de4ea56447e1382d524e34a85e4c8aed61 /gcc/coverage.c | |
parent | 051641b3f870c9a98d5d540b86f67f3f72e8c618 (diff) | |
download | gcc-c81ed7c146d5041a176077a5b351fd83f1e4a830.tar.gz |
2007-01-25 Richard Guenther <rguenther@suse.de>
* doc/invoke.texi (-Wcoverage-mismatch): Document.
* common.opt (-Wcoverage-mismatch): New warning option.
* coverage.c (get_coverage_counts): Ignore coverage mismatch
if -Wcoverage-mismatch is given.
* gcc.dg/tree-prof/tree-prof.exp: Define _PROFILE_GENERATE
and _PROFILE_USE.
* gcc.dg/tree-prof/wcoverage-mismatch.c: New testcase.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@121169 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/coverage.c')
-rw-r--r-- | gcc/coverage.c | 51 |
1 files changed, 36 insertions, 15 deletions
diff --git a/gcc/coverage.c b/gcc/coverage.c index 399eb6ea6c6..ba9f1285fc2 100644 --- a/gcc/coverage.c +++ b/gcc/coverage.c @@ -347,25 +347,46 @@ get_coverage_counts (unsigned counter, unsigned expected, { warning (0, "no coverage for function %qs found", IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (current_function_decl))); - return 0; + return NULL; } checksum = compute_checksum (); - if (entry->checksum != checksum) - { - error ("coverage mismatch for function %qs while reading counter %qs", - IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (current_function_decl)), - ctr_names[counter]); - error ("checksum is %x instead of %x", entry->checksum, checksum); - return 0; - } - else if (entry->summary.num != expected) + if (entry->checksum != checksum + || entry->summary.num != expected) { - error ("coverage mismatch for function %qs while reading counter %qs", - IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (current_function_decl)), - ctr_names[counter]); - error ("number of counters is %d instead of %d", entry->summary.num, expected); - return 0; + static int warned = 0; + const char *id = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME + (current_function_decl)); + + if (warn_coverage_mismatch) + warning (OPT_Wcoverage_mismatch, "coverage mismatch for function " + "%qs while reading counter %qs", id, ctr_names[counter]); + else + error ("coverage mismatch for function %qs while reading counter %qs", + id, ctr_names[counter]); + + if (!inhibit_warnings) + { + if (entry->checksum != checksum) + inform ("checksum is %x instead of %x", entry->checksum, checksum); + else + inform ("number of counters is %d instead of %d", + entry->summary.num, expected); + } + + if (warn_coverage_mismatch + && !inhibit_warnings + && !warned++) + { + inform ("coverage mismatch ignored due to -Wcoverage-mismatch"); + inform (flag_guess_branch_prob + ? "execution counts estimated" + : "execution counts assumed to be zero"); + if (!flag_guess_branch_prob) + inform ("this can result in poorly optimized code"); + } + + return NULL; } if (summary) |