aboutsummaryrefslogtreecommitdiff
path: root/gcc/coverage.c
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2007-01-25 12:35:13 +0000
committerRichard Guenther <rguenther@suse.de>2007-01-25 12:35:13 +0000
commit15d3a78e6cdc057c434ecc025ec9c36c6ddbb200 (patch)
tree38aed0de4ea56447e1382d524e34a85e4c8aed61 /gcc/coverage.c
parent8eccc2e88af709f3b55a91fec98d7ab93d158fd7 (diff)
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: https://gcc.gnu.org/svn/gcc/trunk@121169 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/coverage.c')
-rw-r--r--gcc/coverage.c51
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)