This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Add -fchecking
- From: Richard Biener <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 27 Oct 2015 14:17:05 +0100 (CET)
- Subject: [PATCH] Add -fchecking
- Authentication-results: sourceware.org; auth=none
This adds -fchecking as a way to enable internal consistency checks
even in release builds (or disable checking with -fno-checking - up to
a certain extent - with checking enabled).
Bootstrap & regtest running on x86_64-unknown-linux-gnu.
Richard.
2015-10-27 Richard Biener <rguenther@suse.de>
* common.opt (fchecking): New flag controlling flag_checking.
* passes.c (execute_function_todo): Guard checking code with
flag_checking instead of ENABLE_CHECKING.
(execute_todo): Likewise.
(execute_one_pass): Likewise.
(verify_curr_properties): Always compile.
* timevar.c: Include options.h.
(timer::print): Adjust output.
* doc/invoke.texi (fchecking): Document.
Index: gcc/common.opt
===================================================================
*** gcc/common.opt (revision 229404)
--- gcc/common.opt (working copy)
*************** int optimize_fast
*** 46,56 ****
Variable
bool in_lto_p = false
- ; Enable additional checks of internal state consistency, which may slow
- ; the compiler down.
- Variable
- bool flag_checking = CHECKING_P
-
; 0 means straightforward implementation of complex divide acceptable.
; 1 means wide ranges of inputs must work for complex divide.
; 2 means C99-like requirements for complex multiply and divide.
--- 46,51 ----
*************** fcheck-new
*** 1002,1007 ****
--- 997,1006 ----
Common Var(flag_check_new)
Check the return value of new in C++.
+ fchecking
+ Common Var(flag_checking) Init(CHECKING_P)
+ Perform internal consistency checkings.
+
fcombine-stack-adjustments
Common Report Var(flag_combine_stack_adjustments) Optimization
Looks for opportunities to reduce stack adjustments and stack references.
Index: gcc/passes.c
===================================================================
*** gcc/passes.c (revision 229404)
--- gcc/passes.c (working copy)
*************** execute_function_todo (function *fn, voi
*** 1952,1960 ****
gcc_assert (dom_info_state (fn, CDI_POST_DOMINATORS) == DOM_NONE);
/* If we've seen errors do not bother running any verifiers. */
! if (!seen_error ())
{
- #if defined ENABLE_CHECKING
dom_state pre_verify_state = dom_info_state (fn, CDI_DOMINATORS);
dom_state pre_verify_pstate = dom_info_state (fn, CDI_POST_DOMINATORS);
--- 1952,1960 ----
gcc_assert (dom_info_state (fn, CDI_POST_DOMINATORS) == DOM_NONE);
/* If we've seen errors do not bother running any verifiers. */
! if (!seen_error ()
! && flag_checking)
{
dom_state pre_verify_state = dom_info_state (fn, CDI_DOMINATORS);
dom_state pre_verify_pstate = dom_info_state (fn, CDI_POST_DOMINATORS);
*************** execute_function_todo (function *fn, voi
*** 1988,1994 ****
/* Make sure verifiers don't change dominator state. */
gcc_assert (dom_info_state (fn, CDI_DOMINATORS) == pre_verify_state);
gcc_assert (dom_info_state (fn, CDI_POST_DOMINATORS) == pre_verify_pstate);
- #endif
}
fn->last_verified = flags & TODO_verify_all;
--- 1991,1996 ----
*************** execute_function_todo (function *fn, voi
*** 2008,2018 ****
static void
execute_todo (unsigned int flags)
{
! #if defined ENABLE_CHECKING
! if (cfun
&& need_ssa_update_p (cfun))
gcc_assert (flags & TODO_update_ssa_any);
- #endif
timevar_push (TV_TODO);
--- 2010,2019 ----
static void
execute_todo (unsigned int flags)
{
! if (flag_checking
! && cfun
&& need_ssa_update_p (cfun))
gcc_assert (flags & TODO_update_ssa_any);
timevar_push (TV_TODO);
*************** clear_last_verified (function *fn, void
*** 2076,2089 ****
/* Helper function. Verify that the properties has been turn into the
properties expected by the pass. */
- #ifdef ENABLE_CHECKING
static void
verify_curr_properties (function *fn, void *data)
{
unsigned int props = (size_t)data;
gcc_assert ((fn->curr_properties & props) == props);
}
- #endif
/* Initialize pass dump file. */
/* This is non-static so that the plugins can use it. */
--- 2077,2088 ----
*************** execute_one_pass (opt_pass *pass)
*** 2331,2344 ****
/* Run pre-pass verification. */
execute_todo (pass->todo_flags_start);
! #ifdef ENABLE_CHECKING
! do_per_function (verify_curr_properties,
! (void *)(size_t)pass->properties_required);
! #endif
/* If a timevar is present, start it. */
if (pass->tv_id != TV_NONE)
! timevar_push (pass->tv_id);
/* Do it! */
todo_after = pass->execute (cfun);
--- 2330,2342 ----
/* Run pre-pass verification. */
execute_todo (pass->todo_flags_start);
! if (flag_checking)
! do_per_function (verify_curr_properties,
! (void *)(size_t)pass->properties_required);
/* If a timevar is present, start it. */
if (pass->tv_id != TV_NONE)
! timevar_push (pass->tv_id);
/* Do it! */
todo_after = pass->execute (cfun);
Index: gcc/doc/invoke.texi
===================================================================
*** gcc/doc/invoke.texi (revision 229404)
--- gcc/doc/invoke.texi (working copy)
*************** Objective-C and Objective-C++ Dialects}.
*** 310,316 ****
-fsanitize=@var{style} -fsanitize-recover -fsanitize-recover=@var{style} @gol
-fasan-shadow-offset=@var{number} -fsanitize-sections=@var{s1},@var{s2},... @gol
-fsanitize-undefined-trap-on-error @gol
! -fcheck-pointer-bounds -fchkp-check-incomplete-type @gol
-fchkp-first-field-has-own-bounds -fchkp-narrow-bounds @gol
-fchkp-narrow-to-innermost-array -fchkp-optimize @gol
-fchkp-use-fast-string-functions -fchkp-use-nochk-string-functions @gol
--- 310,316 ----
-fsanitize=@var{style} -fsanitize-recover -fsanitize-recover=@var{style} @gol
-fasan-shadow-offset=@var{number} -fsanitize-sections=@var{s1},@var{s2},... @gol
-fsanitize-undefined-trap-on-error @gol
! -fcheck-pointer-bounds -fchecking -fchkp-check-incomplete-type @gol
-fchkp-first-field-has-own-bounds -fchkp-narrow-bounds @gol
-fchkp-narrow-to-innermost-array -fchkp-optimize @gol
-fchkp-use-fast-string-functions -fchkp-use-nochk-string-functions @gol
*************** structure field attribute (@pxref{Type A
*** 6145,6150 ****
--- 6145,6156 ----
functions for controlling the Pointer Bounds Checker. @xref{Pointer
Bounds Checker builtins}, for more information.
+ @item -fchecking
+ @opindex fchecking
+ @opindex fno-checking
+ Enable internal consistency checking. The default depends on
+ the compiler configuration.
+
@item -fchkp-check-incomplete-type
@opindex fchkp-check-incomplete-type
@opindex fno-chkp-check-incomplete-type
Index: gcc/timevar.c
===================================================================
*** gcc/timevar.c (revision 229404)
--- gcc/timevar.c (working copy)
*************** along with GCC; see the file COPYING3.
*** 22,27 ****
--- 22,28 ----
#include "system.h"
#include "coretypes.h"
#include "timevar.h"
+ #include "options.h"
#ifndef HAVE_CLOCK_T
typedef int clock_t;
*************** timer::print (FILE *fp)
*** 727,736 ****
#endif
fprintf (fp, "%8u kB\n", (unsigned) (total->ggc_mem >> 10));
! #ifdef ENABLE_CHECKING
! fprintf (fp, "Extra diagnostic checks enabled; compiler may run slowly.\n");
! fprintf (fp, "Configure with --enable-checking=release to disable checks.\n");
! #endif
#ifndef ENABLE_ASSERT_CHECKING
fprintf (fp, "Internal checks disabled; compiler is not suited for release.\n");
fprintf (fp, "Configure with --enable-checking=release to enable checks.\n");
--- 728,737 ----
#endif
fprintf (fp, "%8u kB\n", (unsigned) (total->ggc_mem >> 10));
! if (CHECKING_P || flag_checking)
! fprintf (fp, "Extra diagnostic checks enabled; compiler may run slowly.\n");
! if (CHECKING_P)
! fprintf (fp, "Configure with --enable-checking=release to disable checks.\n");
#ifndef ENABLE_ASSERT_CHECKING
fprintf (fp, "Internal checks disabled; compiler is not suited for release.\n");
fprintf (fp, "Configure with --enable-checking=release to enable checks.\n");