Commit 650cfcab by Neil Vachharajani Committed by Neil Vachharajani

Sanitize the behavior of -Wcoverage-mismatch.

2010-05-04  Neil Vachharajani <nvachhar@google.com>

        * doc/invoke.texi (-Wcoverage-mismatch): Updated documentation as
        per new semantics.
        * opts.c (decode_options): Enable -Werror=coverage-mismatch.
        * coverage.c (get_coverage_counts): Always emit a warning.  Adjust
        conditions for printing notes.
        * common.opt (-Wcoverage-mismatch): Allow negative, default to
        true, update documentation.
        * Makefile.in (coverage.o): Add dependence on DIAGNOSTIC_H and intl.h.
        * testsuite/gcc.dg/tree-prof/wcoverage-mismatch.c: Adjusted.

From-SVN: r159050
parent 55a46075
2010-05-04 Neil Vachharajani <nvachhar@google.com>
* doc/invoke.texi (-Wcoverage-mismatch): Updated documentation as
per new semantics.
* opts.c (decode_options): Enable -Werror=coverage-mismatch.
* coverage.c (get_coverage_counts): Always emit a warning. Adjust
conditions for printing notes.
* common.opt (-Wcoverage-mismatch): Allow negative, default to
true, update documentation.
* Makefile.in (coverage.o): Add dependence on DIAGNOSTIC_H and intl.h.
* testsuite/gcc.dg/tree-prof/wcoverage-mismatch.c: Adjusted.
2010-05-04 Jakub Jelinek <jakub@redhat.com>
PR c/43981
......
......@@ -2947,7 +2947,8 @@ ipa-struct-reorg.o: ipa-struct-reorg.c ipa-struct-reorg.h $(CONFIG_H) $(SYSTEM_H
coverage.o : coverage.c $(GCOV_IO_H) $(CONFIG_H) $(SYSTEM_H) coretypes.h \
$(TM_H) $(RTL_H) $(TREE_H) $(FLAGS_H) output.h $(REGS_H) $(EXPR_H) \
$(FUNCTION_H) $(TOPLEV_H) $(GGC_H) langhooks.h $(COVERAGE_H) gt-coverage.h \
$(HASHTAB_H) tree-iterator.h $(CGRAPH_H) $(TREE_PASS_H) gcov-io.c $(TM_P_H)
$(HASHTAB_H) tree-iterator.h $(CGRAPH_H) $(TREE_PASS_H) gcov-io.c $(TM_P_H) \
$(DIAGNOSTIC_H) intl.h
cselib.o : cselib.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \
$(REGS_H) hard-reg-set.h $(FLAGS_H) $(REAL_H) insn-config.h $(RECOG_H) \
$(EMIT_RTL_H) $(TOPLEV_H) output.h $(FUNCTION_H) $(TREE_PASS_H) \
......
......@@ -249,8 +249,8 @@ Common Var(warn_unused_variable) Init(-1) Warning
Warn when a variable is unused
Wcoverage-mismatch
Common RejectNegative Var(warn_coverage_mismatch) Warning
Warn instead of error in case profiles in -fprofile-use do not match
Common Var(warn_coverage_mismatch) Init(1) Warning
Warn in case profiles in -fprofile-use do not match
aux-info
Common Separate
......
......@@ -46,6 +46,8 @@ along with GCC; see the file COPYING3. If not see
#include "tree-iterator.h"
#include "cgraph.h"
#include "tree-pass.h"
#include "diagnostic.h"
#include "intl.h"
#include "gcov-io.c"
......@@ -357,34 +359,33 @@ get_coverage_counts (unsigned counter, unsigned expected,
|| entry->summary.num != expected)
{
static int warned = 0;
bool warning_printed = false;
tree id = DECL_ASSEMBLER_NAME (current_function_decl);
if (warn_coverage_mismatch)
warning (OPT_Wcoverage_mismatch, "coverage mismatch for function "
warning_printed =
warning_at (input_location, OPT_Wcoverage_mismatch,
"coverage mismatch for function "
"%qE while reading counter %qs", id, ctr_names[counter]);
else
error ("coverage mismatch for function %qE while reading counter %qs",
id, ctr_names[counter]);
if (!inhibit_warnings)
if (warning_printed)
{
if (entry->checksum != checksum)
inform (input_location, "checksum is %x instead of %x", entry->checksum, checksum);
inform (input_location, "checksum is %x instead of %x",
entry->checksum, checksum);
else
inform (input_location, "number of counters is %d instead of %d",
entry->summary.num, expected);
}
if (warn_coverage_mismatch
&& !inhibit_warnings
if (!(errorcount || sorrycount)
&& !warned++)
{
inform (input_location, "coverage mismatch ignored due to -Wcoverage-mismatch");
inform (input_location, "coverage mismatch ignored");
inform (input_location, flag_guess_branch_prob
? "execution counts estimated"
: "execution counts assumed to be zero");
? G_("execution counts estimated")
: G_("execution counts assumed to be zero"));
if (!flag_guess_branch_prob)
inform (input_location, "this can result in poorly optimized code");
inform (input_location,
"this can result in poorly optimized code");
}
}
return NULL;
......
......@@ -2755,12 +2755,13 @@ Warn if feedback profiles do not match when using the
If a source file was changed between @option{-fprofile-gen} and
@option{-fprofile-use}, the files with the profile feedback can fail
to match the source file and GCC can not use the profile feedback
information. By default, GCC emits an error message in this case.
The option @option{-Wcoverage-mismatch} emits a warning instead of an
error. GCC does not use appropriate feedback profiles, so using this
option can result in poorly optimized code. This option is useful
only in the case of very minor changes such as bug fixes to an
existing code-base.
information. By default, this warning is enabled and is treated as an
error. @option{-Wno-coverage-mismatch} can be used to disable the
warning or @option{-Wno-error=coverage-mismatch} can be used to
disable the error. Disable the error for this warning can result in
poorly optimized code, so disabling the error is useful only in the
case of very minor changes such as bug fixes to an existing code-base.
Completely disabling the warning is not recommended.
@end table
......
......@@ -946,6 +946,9 @@ decode_options (unsigned int argc, const char **argv)
else
set_param_value ("min-crossjump-insns", initial_min_crossjump_insns);
/* Enable -Werror=coverage-mismatch by default */
enable_warning_as_error("coverage-mismatch", 1, lang_mask);
if (first_time_p)
{
/* Initialize whether `char' is signed. */
......
/* { dg-options "-O2 -Wcoverage-mismatch -w" } */
/* { dg-options "-O2 -Wno-coverage-mismatch" } */
int __attribute__((noinline)) bar (void)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment