diff options
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 399eb6e..ba9f128 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) |