From: Richard Biener <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] Add -fchecking
Date: Tue, 27 Oct 2015 13:35:00 -0000 [thread overview]
Message-ID: <alpine.LSU.2.11.1510271415490.28064@zhemvz.fhfr.qr> (raw)
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");
next reply other threads:[~2015-10-27 13:17 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-27 13:35 Richard Biener [this message]
2015-10-27 15:33 ` Mikhail Maltsev
2015-10-27 18:06 ` Jeff Law
2015-10-28 10:13 ` Richard Biener
2015-11-07 20:47 ` Gerald Pfeifer
2015-11-08 0:41 ` Jeff Law
2015-11-08 9:12 ` Richard Biener
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.LSU.2.11.1510271415490.28064@zhemvz.fhfr.qr \
--to=rguenther@suse.de \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).