* [PATCH] Add -fchecking
@ 2015-10-27 13:35 Richard Biener
2015-10-27 15:33 ` Mikhail Maltsev
2015-11-07 20:47 ` Gerald Pfeifer
0 siblings, 2 replies; 7+ messages in thread
From: Richard Biener @ 2015-10-27 13:35 UTC (permalink / raw)
To: gcc-patches
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");
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Add -fchecking
2015-10-27 13:35 [PATCH] Add -fchecking Richard Biener
@ 2015-10-27 15:33 ` Mikhail Maltsev
2015-10-27 18:06 ` Jeff Law
2015-11-07 20:47 ` Gerald Pfeifer
1 sibling, 1 reply; 7+ messages in thread
From: Mikhail Maltsev @ 2015-10-27 15:33 UTC (permalink / raw)
To: Richard Biener, gcc-patches
On 10/27/2015 04:17 PM, Richard Biener wrote:
>
> 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).
I remember that Jakub proposed to use __builtin_expect with
flag_checking. I wonder, if it is possible to implement without hacking
AWK scripts just for this particular case? For example, to define
flag_checking to something like
#define flag_checking __builtin_expect (flag_checking_val, CHECKING_P)
(provided that flag_checking_val is the actual value got from
command-line options).
--
Regards,
Mikhail Maltsev
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Add -fchecking
2015-10-27 15:33 ` Mikhail Maltsev
@ 2015-10-27 18:06 ` Jeff Law
2015-10-28 10:13 ` Richard Biener
0 siblings, 1 reply; 7+ messages in thread
From: Jeff Law @ 2015-10-27 18:06 UTC (permalink / raw)
To: Mikhail Maltsev, Richard Biener, gcc-patches
On 10/27/2015 09:32 AM, Mikhail Maltsev wrote:
> On 10/27/2015 04:17 PM, Richard Biener wrote:
>>
>> 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).
>
> I remember that Jakub proposed to use __builtin_expect with
> flag_checking. I wonder, if it is possible to implement without hacking
> AWK scripts just for this particular case? For example, to define
> flag_checking to something like
>
> #define flag_checking __builtin_expect (flag_checking_val, CHECKING_P)
>
> (provided that flag_checking_val is the actual value got from
> command-line options).
I think this ought to be a follow-up item. And yes, we're going to need
some level of indirection so that we're not writing __builtin_expect all
over the place.
Jeff
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Add -fchecking
2015-10-27 18:06 ` Jeff Law
@ 2015-10-28 10:13 ` Richard Biener
0 siblings, 0 replies; 7+ messages in thread
From: Richard Biener @ 2015-10-28 10:13 UTC (permalink / raw)
To: Jeff Law; +Cc: Mikhail Maltsev, gcc-patches
On Tue, 27 Oct 2015, Jeff Law wrote:
> On 10/27/2015 09:32 AM, Mikhail Maltsev wrote:
> > On 10/27/2015 04:17 PM, Richard Biener wrote:
> > >
> > > 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).
> >
> > I remember that Jakub proposed to use __builtin_expect with
> > flag_checking. I wonder, if it is possible to implement without hacking
> > AWK scripts just for this particular case? For example, to define
> > flag_checking to something like
> >
> > #define flag_checking __builtin_expect (flag_checking_val, CHECKING_P)
> >
> > (provided that flag_checking_val is the actual value got from
> > command-line options).
> I think this ought to be a follow-up item. And yes, we're going to need some
> level of indirection so that we're not writing __builtin_expect all over the
> place.
Yeah, we should do that as followup. We should also make sure to
only make the branch unlikely and not end up with optimizing
all checking code for size (making it even slower than it is now).
Richard.
> Jeff
>
>
--
Richard Biener <rguenther@suse.de>
SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nuernberg)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Add -fchecking
2015-10-27 13:35 [PATCH] Add -fchecking Richard Biener
2015-10-27 15:33 ` Mikhail Maltsev
@ 2015-11-07 20:47 ` Gerald Pfeifer
2015-11-08 0:41 ` Jeff Law
1 sibling, 1 reply; 7+ messages in thread
From: Gerald Pfeifer @ 2015-11-07 20:47 UTC (permalink / raw)
To: Richard Biener; +Cc: gcc-patches
On Tue, 27 Oct 2015, Richard Biener wrote:
> 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).
How (much) do we want to advertize this?
Gerald
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Add -fchecking
2015-11-07 20:47 ` Gerald Pfeifer
@ 2015-11-08 0:41 ` Jeff Law
2015-11-08 9:12 ` Richard Biener
0 siblings, 1 reply; 7+ messages in thread
From: Jeff Law @ 2015-11-08 0:41 UTC (permalink / raw)
To: Gerald Pfeifer, Richard Biener; +Cc: gcc-patches
On 11/07/2015 01:47 PM, Gerald Pfeifer wrote:
> On Tue, 27 Oct 2015, Richard Biener wrote:
>> 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).
>
> How (much) do we want to advertize this?
I don't think much -- it's really a developer-centric option.
Jeff
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Add -fchecking
2015-11-08 0:41 ` Jeff Law
@ 2015-11-08 9:12 ` Richard Biener
0 siblings, 0 replies; 7+ messages in thread
From: Richard Biener @ 2015-11-08 9:12 UTC (permalink / raw)
To: Jeff Law, Gerald Pfeifer, Richard Biener; +Cc: gcc-patches
On November 8, 2015 1:40:57 AM GMT+01:00, Jeff Law <law@redhat.com> wrote:
>On 11/07/2015 01:47 PM, Gerald Pfeifer wrote:
>> On Tue, 27 Oct 2015, Richard Biener wrote:
>>> 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).
>>
>> How (much) do we want to advertize this?
>I don't think much -- it's really a developer-centric option.
Might be worth mentioning on bugs.html as sometimes miscompiles can be detected by -fchecking.
Richard.
>Jeff
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2015-11-08 9:12 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-27 13:35 [PATCH] Add -fchecking Richard Biener
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
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).