[PATCH] Don't error on coverage mismatch by request
Richard Guenther
rguenther@suse.de
Wed Nov 29 13:02:00 GMT 2006
This makes coverage mismatch errors a warning if requested by
-Wcoverage-mismatch and assumes execution counts to be zero in
this case as we do for missing coverage info.
This allows the same profile data to be used if re-compiling with
like small bugfixes added to a big project without the need to
re-do possibly lengthy profiling.
Bootstrapped and tested on x86_64-unknown-linux-gnu.
Ok for mainline?
Thanks,
Richard.
2006-11-23 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.
Index: gcc/doc/invoke.texi
===================================================================
*** gcc/doc/invoke.texi (revision 119120)
--- gcc/doc/invoke.texi (working copy)
*************** Objective-C and Objective-C++ Dialects}.
*** 220,226 ****
@gccoptlist{-fsyntax-only -pedantic -pedantic-errors @gol
-w -Wextra -Wall -Waggregate-return -Wno-attributes @gol
-Wc++-compat -Wcast-align -Wcast-qual -Wchar-subscripts -Wcomment @gol
! -Wconversion -Wno-deprecated-declarations @gol
-Wdisabled-optimization -Wno-div-by-zero -Wno-endif-labels @gol
-Werror -Werror-implicit-function-declaration @gol
-Wfatal-errors -Wfloat-equal -Wformat -Wformat=2 @gol
--- 220,226 ----
@gccoptlist{-fsyntax-only -pedantic -pedantic-errors @gol
-w -Wextra -Wall -Waggregate-return -Wno-attributes @gol
-Wc++-compat -Wcast-align -Wcast-qual -Wchar-subscripts -Wcomment @gol
! -Wconversion -Wcoverage-mismatch -Wno-deprecated-declarations @gol
-Wdisabled-optimization -Wno-div-by-zero -Wno-endif-labels @gol
-Werror -Werror-implicit-function-declaration @gol
-Wfatal-errors -Wfloat-equal -Wformat -Wformat=2 @gol
*************** Make all warnings into errors.
*** 3400,3405 ****
--- 3400,3417 ----
This option is only active when @option{-fstack-protector} is active. It
warns about functions that will not be protected against stack smashing.
+ @item -Wcoverage-mismatch
+ @opindex Wcoverage-mismatch
+ Warn if feedback profiles do not match when using the
+ @option{-fprofile-use} option.
+ If a source file was changed between @option{-fprofile-gen} and
+ @option{-fprofile-use}, the files with the profile feedback do not
+ 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, but the
+ compilation runs without errors.
+
@end table
@node Debugging Options
*************** The following options are enabled: @code
*** 5395,5400 ****
--- 5407,5415 ----
@code{-funroll-loops}, @code{-fpeel-loops}, @code{-ftracer},
@code{-fno-loop-optimize}.
+ By default, GCC emits an error message if the feedback profiles do not
+ match. The error abort can be avoided by using
+ @option{-Wcoverage-mismatch}.
@end table
The following options control compiler behavior regarding floating
Index: gcc/coverage.c
===================================================================
*** gcc/coverage.c (revision 119120)
--- gcc/coverage.c (working copy)
*************** get_coverage_counts (unsigned counter, u
*** 351,370 ****
}
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)
! {
! 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;
}
--- 351,381 ----
}
checksum = compute_checksum ();
! if (entry->checksum != checksum
! || entry->summary.num != expected)
{
! 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 (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)
! {
! inform ("coverage mismatch ignored due to -Wcoverage-mismatch");
! inform ("execution counts assumed to be zero");
! }
!
return 0;
}
Index: gcc/common.opt
===================================================================
*** gcc/common.opt (revision 119120)
--- gcc/common.opt (working copy)
*************** Wvolatile-register-var
*** 177,182 ****
--- 177,186 ----
Common Var(warn_register_var)
Warn when a register variable is declared volatile
+ Wcoverage-mismatch
+ Common Var(warn_coverage_mismatch)
+ Warn when profiles in -fprofile-use do not match
+
aux-info
Common Separate
-aux-info <file> Emit declaration information into <file>
More information about the Gcc-patches
mailing list