diff --git a/gcc/gcc/Makefile.in b/gcc/gcc/Makefile.in index ca68570..f6d4afa 100644 --- a/gcc/gcc/Makefile.in +++ b/gcc/gcc/Makefile.in @@ -2942,7 +2942,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) \ diff --git a/gcc/gcc/common.opt b/gcc/gcc/common.opt index e62e3d5..806bd1f 100644 --- a/gcc/gcc/common.opt +++ b/gcc/gcc/common.opt @@ -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 diff --git a/gcc/gcc/coverage.c b/gcc/gcc/coverage.c index e04d22b..e279f03 100644 --- a/gcc/gcc/coverage.c +++ b/gcc/gcc/coverage.c @@ -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 " - "%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) + warning_printed = + warning_at (input_location, OPT_Wcoverage_mismatch, + "coverage mismatch for function " + "%qE while reading counter %qs", id, ctr_names[counter]); + 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 - && !warned++) - { - inform (input_location, "coverage mismatch ignored due to -Wcoverage-mismatch"); - inform (input_location, flag_guess_branch_prob - ? "execution counts estimated" - : "execution counts assumed to be zero"); - if (!flag_guess_branch_prob) - inform (input_location, "this can result in poorly optimized code"); + + if (!(errorcount || sorrycount) + && !warned++) + { + inform (input_location, "coverage mismatch ignored"); + inform (input_location, flag_guess_branch_prob + ? _("execution counts estimated") + : _("execution counts assumed to be zero")); + if (!flag_guess_branch_prob) + inform (input_location, + "this can result in poorly optimized code"); + } } return NULL; diff --git a/gcc/gcc/doc/invoke.texi b/gcc/gcc/doc/invoke.texi index fefb0ab..492b82b 100644 --- a/gcc/gcc/doc/invoke.texi +++ b/gcc/gcc/doc/invoke.texi @@ -2746,12 +2746,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 diff --git a/gcc/gcc/opts.c b/gcc/gcc/opts.c index 507b502..fd8a504 100644 --- a/gcc/gcc/opts.c +++ b/gcc/gcc/opts.c @@ -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. */ diff --git a/gcc/gcc/testsuite/gcc.dg/tree-prof/wcoverage-mismatch.c b/gcc/gcc/testsuite/gcc.dg/tree-prof/wcoverage-mismatch.c index 74fe7f8..e423105 100644 --- a/gcc/gcc/testsuite/gcc.dg/tree-prof/wcoverage-mismatch.c +++ b/gcc/gcc/testsuite/gcc.dg/tree-prof/wcoverage-mismatch.c @@ -1,4 +1,4 @@ -/* { dg-options "-O2 -Wcoverage-mismatch -w" } */ +/* { dg-options "-O2 -Wno-coverage-mismatch" } */ int __attribute__((noinline)) bar (void) {