public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 1/9] ENABLE_CHECKING refactoring
@ 2015-10-05 23:27 Mikhail Maltsev
  2015-10-05 23:29 ` [PATCH 2/9] ENABLE_CHECKING refactoring: libcpp Mikhail Maltsev
                   ` (11 more replies)
  0 siblings, 12 replies; 77+ messages in thread
From: Mikhail Maltsev @ 2015-10-05 23:27 UTC (permalink / raw)
  To: gcc-patches mailing list, Jeff Law, Richard Biener

[-- Attachment #1: Type: text/plain, Size: 2672 bytes --]

Hi!

This is an updated series of patches which converts 'ENABLE_CHECKING' macro into
a flag, 'flag_checking' (and 'CHECKING_P' macro in several cases). For now
flag_checking is always initialized with the value of 'CHECKING_P', but later it
can be turned into a proper command-line flag and probably split into several
checks. I also added several function which verify internal data structures when
flag_checking is enabled (e.g. checking_verify_flow_info which calls
verify_flow_info). These functions make their callers look somewhat cleaner.

The cases where I left 'CHECKING_P' are:
1. libcpp (turn ICE after an error into fatal error) and pretty-printers (that
would require to pass flag_checking to libcpp just for this single case).
2. Code which fills memory in the pools with some predefined patterns in
deallocation methods (this would add some overhead to each deallocation), though
I have not measured performance impact yet.
3. Generators and generated code.
4. Target-specific code
5. 'struct lra_reg' which has an additional field in checking build
6. Likewise, 'struct moveop_static_params' in insn scheduler and
'cumulative_args_t' in target.h.
7. macro-related code in libcpp (for the same reason)
8. real.c and fwprop.c - I'll profile these and also fix to use flag_checking if
there won't be any measurable overhead.

There are 9 patches:
1. Add flag_checking and CHECKING_P macros
2. Use CHECKING_P in libcpp
3. Ada and Java frontends
4. Fortran frontend
5. Pool allocators
6. Generator programs
7. Most of middle-end (GIMPLE, IPA, RTL) - it can be split further, if needed.
8. Target-specific code
9. C++ frontend - in progress (I will send this part soon).

Some issues related to checking builds:
1. Useless check in graphite: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67842
2. I found a test which fails only on release builds:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58583 (reopened)
3. Another one: gcc.c-torture/compile/pr52073.c which is, I guess, caused by
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67816 (the backtrace is the same,
at least).

Each patch (when applied on top of all the previous ones) compiles in both
checking and release builds. The combined patch passes bootstrap and regression
tests in checking an release builds (apart from 2 issues mentioned above) on
x86_64-linux. I'll also run it through config-list.mk.

-- 
Regards,
    Mikhail Maltsev


gcc/ChangeLog:

2015-10-05  Mikhail Maltsev  <maltsevm@gmail.com>

	* common.opt: Add flag_checking.
	* system.h (CHECKING_P): Define.

libcpp/ChangeLog:

2015-10-05  Mikhail Maltsev  <maltsevm@gmail.com>

	* system.h (CHECKING_P, gcc_checking_assert): Define.

[-- Attachment #2: 0001-Prerequisites-for-ENABLE_CHECKING-conversion.patch --]
[-- Type: text/x-patch, Size: 2082 bytes --]

From 8096ea4714b3b7a96b414a70fd0de34e5e5a707a Mon Sep 17 00:00:00 2001
From: Mikhail Maltsev <maltsevm@gmail.com>
Date: Sun, 20 Sep 2015 04:30:42 +0300
Subject: [PATCH 1/9] Prerequisites for ENABLE_CHECKING conversion

Define CHECKING_P macros. Add flag_checking.
Define gcc_checking_assert in libcpp
---
 gcc/common.opt  | 5 +++++
 gcc/system.h    | 3 +++
 libcpp/system.h | 8 ++++++++
 3 files changed, 16 insertions(+)

diff --git a/gcc/common.opt b/gcc/common.opt
index b0f70fb..5060208 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -46,6 +46,11 @@ int optimize_fast
 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.
diff --git a/gcc/system.h b/gcc/system.h
index f1694b9..dc3b96d 100644
--- a/gcc/system.h
+++ b/gcc/system.h
@@ -716,8 +716,11 @@ extern void fancy_abort (const char *, int, const char *) ATTRIBUTE_NORETURN;
 
 #ifdef ENABLE_CHECKING
 #define gcc_checking_assert(EXPR) gcc_assert (EXPR)
+#define CHECKING_P 1
 #else
+/* N.B.: in release build EXPR is not evaluated.  */
 #define gcc_checking_assert(EXPR) ((void)(0 && (EXPR)))
+#define CHECKING_P 0
 #endif
 
 /* Use gcc_unreachable() to mark unreachable locations (like an
diff --git a/libcpp/system.h b/libcpp/system.h
index a2e8c26..e070bc9 100644
--- a/libcpp/system.h
+++ b/libcpp/system.h
@@ -391,6 +391,14 @@ extern void abort (void);
 #define __builtin_expect(a, b) (a)
 #endif
 
+#ifdef ENABLE_CHECKING
+#define gcc_checking_assert(EXPR) gcc_assert (EXPR)
+#define CHECKING_P 1
+#else
+#define gcc_checking_assert(EXPR) ((void)(0 && (EXPR)))
+#define CHECKING_P 0
+#endif
+
 /* Provide a fake boolean type.  We make no attempt to use the
    C99 _Bool, as it may not be available in the bootstrap compiler,
    and even if it is, it is liable to be buggy.  
-- 
2.1.4


^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 2/9] ENABLE_CHECKING refactoring: libcpp
  2015-10-05 23:27 [PATCH 1/9] ENABLE_CHECKING refactoring Mikhail Maltsev
@ 2015-10-05 23:29 ` Mikhail Maltsev
  2015-10-06 12:40   ` Bernd Schmidt
  2015-10-05 23:30 ` [PATCH 3/9] ENABLE_CHECKING refactoring: Java and Ada Mikhail Maltsev
                   ` (10 subsequent siblings)
  11 siblings, 1 reply; 77+ messages in thread
From: Mikhail Maltsev @ 2015-10-05 23:29 UTC (permalink / raw)
  To: gcc-patches mailing list, Jeff Law, Richard Biener

[-- Attachment #1: Type: text/plain, Size: 415 bytes --]

libcpp/ChangeLog:

2015-10-05  Mikhail Maltsev  <maltsevm@gmail.com>

	* include/line-map.h: Fix use of ENABLE_CHECKING.
	* init.c: Likewise.
	* macro.c (struct macro_arg_token_iter, set_arg_token,
	macro_arg_token_iter_init, macro_arg_token_iter_forward,
	macro_arg_token_iter_get_token, macro_arg_token_iter_get_location,
	alloc_expanded_arg_mem, _cpp_backup_tokens): Likewise.
	* system.h (gcc_assert): Define.


[-- Attachment #2: 0002-libcpp.patch --]
[-- Type: text/x-patch, Size: 5723 bytes --]

From e7e3856c2c748cf0c7ed35ed843ec4ce516c9b4f Mon Sep 17 00:00:00 2001
From: Mikhail Maltsev <maltsevm@gmail.com>
Date: Tue, 22 Sep 2015 02:51:31 +0300
Subject: [PATCH 2/9] libcpp

---
 libcpp/include/line-map.h |  2 +-
 libcpp/init.c             |  2 +-
 libcpp/macro.c            | 38 +++++++++++++++-----------------------
 libcpp/system.h           | 17 +++++++++++++++++
 4 files changed, 34 insertions(+), 25 deletions(-)

diff --git a/libcpp/include/line-map.h b/libcpp/include/line-map.h
index bc747c1..e718fc2 100644
--- a/libcpp/include/line-map.h
+++ b/libcpp/include/line-map.h
@@ -272,7 +272,7 @@ struct GTY((tag ("2"))) line_map_macro : public line_map {
   source_location expansion;
 };
 
-#if defined ENABLE_CHECKING && (GCC_VERSION >= 2007)
+#if CHECKING_P && (GCC_VERSION >= 2007)
 
 /* Assertion macro to be used in line-map code.  */
 #define linemap_assert(EXPR)                  \
diff --git a/libcpp/init.c b/libcpp/init.c
index 2d5626f..0419e95 100644
--- a/libcpp/init.c
+++ b/libcpp/init.c
@@ -535,7 +535,7 @@ cpp_init_builtins (cpp_reader *pfile, int hosted)
 
 /* Sanity-checks are dependent on command-line options, so it is
    called as a subroutine of cpp_read_main_file ().  */
-#if ENABLE_CHECKING
+#if CHECKING_P
 static void sanity_checks (cpp_reader *);
 static void sanity_checks (cpp_reader *pfile)
 {
diff --git a/libcpp/macro.c b/libcpp/macro.c
index 786c21b..60a0753 100644
--- a/libcpp/macro.c
+++ b/libcpp/macro.c
@@ -73,7 +73,7 @@ struct macro_arg_token_iter
      -ftrack-macro-expansion is used this location tracks loci across
      macro expansion.  */
   const source_location *location_ptr;
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
   /* The number of times the iterator went forward. This useful only
      when checking is enabled.  */
   size_t num_forwards;
@@ -1310,14 +1310,11 @@ set_arg_token (macro_arg *arg, const cpp_token *token,
 
   if (loc != NULL)
     {
-#ifdef ENABLE_CHECKING
-      if (kind == MACRO_ARG_TOKEN_STRINGIFIED
-	  || !track_macro_exp_p)
-	/* We can't set the location of a stringified argument
-	   token and we can't set any location if we aren't tracking
-	   macro expansion locations.   */
-	abort ();
-#endif
+      /* We can't set the location of a stringified argument
+	 token and we can't set any location if we aren't tracking
+	 macro expansion locations.   */
+      gcc_checking_assert (kind != MACRO_ARG_TOKEN_STRINGIFIED
+			   && track_macro_exp_p);
       *loc = location;
     }
 }
@@ -1403,7 +1400,7 @@ macro_arg_token_iter_init (macro_arg_token_iter *iter,
   iter->location_ptr = NULL;
   if (track_macro_exp_p)
     iter->location_ptr = get_arg_token_location (arg, kind);
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
   iter->num_forwards = 0;
   if (track_macro_exp_p
       && token_ptr != NULL
@@ -1428,14 +1425,14 @@ macro_arg_token_iter_forward (macro_arg_token_iter *it)
 	it->location_ptr++;
       break;
     case MACRO_ARG_TOKEN_STRINGIFIED:
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
       if (it->num_forwards > 0)
 	abort ();
 #endif
       break;
     }
 
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
   it->num_forwards++;
 #endif
 }
@@ -1444,7 +1441,7 @@ macro_arg_token_iter_forward (macro_arg_token_iter *it)
 static const cpp_token *
 macro_arg_token_iter_get_token (const macro_arg_token_iter *it)
 {
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
   if (it->kind == MACRO_ARG_TOKEN_STRINGIFIED
       && it->num_forwards > 0)
     abort ();
@@ -1458,7 +1455,7 @@ macro_arg_token_iter_get_token (const macro_arg_token_iter *it)
 static source_location
 macro_arg_token_iter_get_location (const macro_arg_token_iter *it)
 {
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
   if (it->kind == MACRO_ARG_TOKEN_STRINGIFIED
       && it->num_forwards > 0)
     abort ();
@@ -2144,11 +2141,9 @@ tokens_buff_add_token (_cpp_buff *buffer,
 static void
 alloc_expanded_arg_mem (cpp_reader *pfile, macro_arg *arg, size_t capacity)
 {
-#ifdef ENABLE_CHECKING
-  if (arg->expanded != NULL
-      || arg->expanded_virt_locs != NULL)
-    abort ();
-#endif
+  gcc_checking_assert (arg->expanded == NULL
+		       && arg->expanded_virt_locs == NULL);
+
   arg->expanded = XNEWVEC (const cpp_token *, capacity);
   if (CPP_OPTION (pfile, track_macro_expansion))
     arg->expanded_virt_locs = XNEWVEC (source_location, capacity);
@@ -2709,10 +2704,7 @@ _cpp_backup_tokens (cpp_reader *pfile, unsigned int count)
 	    {
 	      macro_context *m = pfile->context->c.mc;
 	      m->cur_virt_loc--;
-#ifdef ENABLE_CHECKING
-	      if (m->cur_virt_loc < m->virt_locs)
-		abort ();
-#endif
+	      gcc_checking_assert (m->cur_virt_loc >= m->virt_locs);
 	    }
 	  else
 	    abort ();
diff --git a/libcpp/system.h b/libcpp/system.h
index e070bc9..aa336b4 100644
--- a/libcpp/system.h
+++ b/libcpp/system.h
@@ -391,6 +391,23 @@ extern void abort (void);
 #define __builtin_expect(a, b) (a)
 #endif
 
+/* Redefine abort to report an internal error w/o coredump, and
+   reporting the location of the error in the source file.  */
+extern void fancy_abort (const char *, int, const char *) ATTRIBUTE_NORETURN;
+#define abort() fancy_abort (__FILE__, __LINE__, __FUNCTION__)
+
+/* Use gcc_assert(EXPR) to test invariants.  */
+#if ENABLE_ASSERT_CHECKING
+#define gcc_assert(EXPR) 						\
+   ((void)(!(EXPR) ? fancy_abort (__FILE__, __LINE__, __FUNCTION__), 0 : 0))
+#elif (GCC_VERSION >= 4005)
+#define gcc_assert(EXPR) 						\
+  ((void)(__builtin_expect (!(EXPR), 0) ? __builtin_unreachable (), 0 : 0))
+#else
+/* Include EXPR, so that unused variable warnings do not occur.  */
+#define gcc_assert(EXPR) ((void)(0 && (EXPR)))
+#endif
+
 #ifdef ENABLE_CHECKING
 #define gcc_checking_assert(EXPR) gcc_assert (EXPR)
 #define CHECKING_P 1
-- 
2.1.4


^ permalink raw reply	[flat|nested] 77+ messages in thread

* [PATCH 3/9] ENABLE_CHECKING refactoring: Java and Ada
  2015-10-05 23:27 [PATCH 1/9] ENABLE_CHECKING refactoring Mikhail Maltsev
  2015-10-05 23:29 ` [PATCH 2/9] ENABLE_CHECKING refactoring: libcpp Mikhail Maltsev
@ 2015-10-05 23:30 ` Mikhail Maltsev
  2015-10-22 19:25   ` Jeff Law
  2015-10-05 23:31 ` [PATCH 4/9] ENABLE_CHECKING refactoring: Fortran Mikhail Maltsev
                   ` (9 subsequent siblings)
  11 siblings, 1 reply; 77+ messages in thread
From: Mikhail Maltsev @ 2015-10-05 23:30 UTC (permalink / raw)
  To: gcc-patches mailing list, Jeff Law, Richard Biener

[-- Attachment #1: Type: text/plain, Size: 509 bytes --]

gcc/java/ChangeLog:

2015-10-05  Mikhail Maltsev  <maltsevm@gmail.com>

	* decl.c (java_mark_decl_local): Use flag_checking instead of
	ENABLE_CHECKING.


gcc/ada/ChangeLog:

2015-10-05  Mikhail Maltsev  <maltsevm@gmail.com>

	* gcc-interface/decl.c (gnat_to_gnu_entity): Use gcc_checking_assert.
	* gcc-interface/trans.c (assoc_to_constructor): Use flag_checking.
	* gcc-interface/utils.c (relate_alias_sets): Likewise.
	* gcc-interface/utils2.c (build_binary_op, build_unary_op): Use
	gcc_checking_assert



[-- Attachment #2: 0003-Ada-and-Java-FE-s.patch --]
[-- Type: text/x-patch, Size: 5413 bytes --]

From e8de7d2dc24cff85b6c1e44157dad23c85e435e1 Mon Sep 17 00:00:00 2001
From: Mikhail Maltsev <maltsevm@gmail.com>
Date: Sun, 20 Sep 2015 05:06:01 +0300
Subject: [PATCH 3/9] Ada and Java FE's

---
 gcc/ada/gcc-interface/decl.c   |  4 +---
 gcc/ada/gcc-interface/trans.c  | 11 ++++++-----
 gcc/ada/gcc-interface/utils.c  |  4 +---
 gcc/ada/gcc-interface/utils2.c | 20 ++++++++------------
 gcc/java/decl.c                |  4 +---
 5 files changed, 17 insertions(+), 26 deletions(-)

diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c
index ca36ce5..3922bb8 100644
--- a/gcc/ada/gcc-interface/decl.c
+++ b/gcc/ada/gcc-interface/decl.c
@@ -2710,10 +2710,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
 
 		      TYPE_HAS_ACTUAL_BOUNDS_P (gnu_inner) = 1;
 
-#ifdef ENABLE_CHECKING
 		      /* Check for other cases of overloading.  */
-		      gcc_assert (!TYPE_ACTUAL_BOUNDS (gnu_inner));
-#endif
+		      gcc_checking_assert (!TYPE_ACTUAL_BOUNDS (gnu_inner));
 		    }
 
 		  for (gnat_index = First_Index (gnat_entity);
diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c
index 3252ea2..c5f560f 100644
--- a/gcc/ada/gcc-interface/trans.c
+++ b/gcc/ada/gcc-interface/trans.c
@@ -9411,11 +9411,12 @@ assoc_to_constructor (Entity_Id gnat_entity, Node_Id gnat_assoc, tree gnu_type)
 
   gnu_result = extract_values (gnu_list, gnu_type);
 
-#ifdef ENABLE_CHECKING
-  /* Verify that every entry in GNU_LIST was used.  */
-  for (; gnu_list; gnu_list = TREE_CHAIN (gnu_list))
-    gcc_assert (TREE_ADDRESSABLE (gnu_list));
-#endif
+  if (flag_checking)
+    {
+      /* Verify that every entry in GNU_LIST was used.  */
+      for (; gnu_list; gnu_list = TREE_CHAIN (gnu_list))
+	gcc_assert (TREE_ADDRESSABLE (gnu_list));
+    }
 
   return gnu_result;
 }
diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c
index 0f3087d..7906495 100644
--- a/gcc/ada/gcc-interface/utils.c
+++ b/gcc/ada/gcc-interface/utils.c
@@ -1499,9 +1499,7 @@ relate_alias_sets (tree gnu_new_type, tree gnu_old_type, enum alias_set_op op)
       /* The alias set shouldn't be copied between array types with different
 	 aliasing settings because this can break the aliasing relationship
 	 between the array type and its element type.  */
-#ifndef ENABLE_CHECKING
-      if (flag_strict_aliasing)
-#endif
+      if (flag_checking || flag_strict_aliasing)
 	gcc_assert (!(TREE_CODE (gnu_new_type) == ARRAY_TYPE
 		      && TREE_CODE (gnu_old_type) == ARRAY_TYPE
 		      && TYPE_NONALIASED_COMPONENT (gnu_new_type)
diff --git a/gcc/ada/gcc-interface/utils2.c b/gcc/ada/gcc-interface/utils2.c
index 70737a9..13421b4 100644
--- a/gcc/ada/gcc-interface/utils2.c
+++ b/gcc/ada/gcc-interface/utils2.c
@@ -854,9 +854,8 @@ build_binary_op (enum tree_code op_code, tree result_type,
     {
     case INIT_EXPR:
     case MODIFY_EXPR:
-#ifdef ENABLE_CHECKING
-      gcc_assert (result_type == NULL_TREE);
-#endif
+      gcc_checking_assert (result_type == NULL_TREE);
+
       /* If there were integral or pointer conversions on the LHS, remove
 	 them; we'll be putting them back below if needed.  Likewise for
 	 conversions between array and record types, except for justified
@@ -1039,9 +1038,8 @@ build_binary_op (enum tree_code op_code, tree result_type,
     case TRUTH_AND_EXPR:
     case TRUTH_OR_EXPR:
     case TRUTH_XOR_EXPR:
-#ifdef ENABLE_CHECKING
-      gcc_assert (TREE_CODE (get_base_type (result_type)) == BOOLEAN_TYPE);
-#endif
+      gcc_checking_assert (TREE_CODE (
+				get_base_type (result_type)) == BOOLEAN_TYPE);
       operation_type = left_base_type;
       left_operand = convert (operation_type, left_operand);
       right_operand = convert (operation_type, right_operand);
@@ -1053,9 +1051,8 @@ build_binary_op (enum tree_code op_code, tree result_type,
     case LT_EXPR:
     case EQ_EXPR:
     case NE_EXPR:
-#ifdef ENABLE_CHECKING
-      gcc_assert (TREE_CODE (get_base_type (result_type)) == BOOLEAN_TYPE);
-#endif
+      gcc_checking_assert (TREE_CODE (
+				get_base_type (result_type)) == BOOLEAN_TYPE);
       /* If either operand is a NULL_EXPR, just return a new one.  */
       if (TREE_CODE (left_operand) == NULL_EXPR)
 	return build2 (op_code, result_type,
@@ -1335,9 +1332,8 @@ build_unary_op (enum tree_code op_code, tree result_type, tree operand)
       break;
 
     case TRUTH_NOT_EXPR:
-#ifdef ENABLE_CHECKING
-      gcc_assert (TREE_CODE (get_base_type (result_type)) == BOOLEAN_TYPE);
-#endif
+      gcc_checking_assert (TREE_CODE (
+				get_base_type (result_type)) == BOOLEAN_TYPE);
       result = invert_truthvalue_loc (EXPR_LOCATION (operand), operand);
       /* When not optimizing, fold the result as invert_truthvalue_loc
 	 doesn't fold the result of comparisons.  This is intended to undo
diff --git a/gcc/java/decl.c b/gcc/java/decl.c
index c035fe0..2b33621 100644
--- a/gcc/java/decl.c
+++ b/gcc/java/decl.c
@@ -1905,14 +1905,12 @@ java_mark_decl_local (tree decl)
 {
   DECL_EXTERNAL (decl) = 0;
 
-#ifdef ENABLE_CHECKING
   /* Double check that we didn't pass the function to the callgraph early.  */
-  if (TREE_CODE (decl) == FUNCTION_DECL)
+  if (flag_checking && TREE_CODE (decl) == FUNCTION_DECL)
     {
       struct cgraph_node *node = cgraph_node::get (decl);
       gcc_assert (!node || !node->definition);
     }
-#endif
   gcc_assert (!DECL_RTL_SET_P (decl));
 }
 
-- 
2.1.4


^ permalink raw reply	[flat|nested] 77+ messages in thread

* [PATCH 4/9] ENABLE_CHECKING refactoring: Fortran
  2015-10-05 23:27 [PATCH 1/9] ENABLE_CHECKING refactoring Mikhail Maltsev
  2015-10-05 23:29 ` [PATCH 2/9] ENABLE_CHECKING refactoring: libcpp Mikhail Maltsev
  2015-10-05 23:30 ` [PATCH 3/9] ENABLE_CHECKING refactoring: Java and Ada Mikhail Maltsev
@ 2015-10-05 23:31 ` Mikhail Maltsev
  2015-10-23 22:38   ` Jeff Law
  2015-10-05 23:32 ` [PATCH 5/9] ENABLE_CHECKING refactoring: pool allocators Mikhail Maltsev
                   ` (8 subsequent siblings)
  11 siblings, 1 reply; 77+ messages in thread
From: Mikhail Maltsev @ 2015-10-05 23:31 UTC (permalink / raw)
  To: gcc-patches mailing list, Jeff Law, Richard Biener

[-- Attachment #1: Type: text/plain, Size: 199 bytes --]

gcc/fortran/ChangeLog:

2015-10-05  Mikhail Maltsev  <maltsevm@gmail.com>

	* trans-common.c (create_common): Adjust to use flag_checking.
	* trans.c (gfc_add_modify_loc): Use gcc_checking_assert.



[-- Attachment #2: 0004-Fortran.patch --]
[-- Type: text/x-patch, Size: 2012 bytes --]

From 8113b4d5bc943772145abdd6562d4af6093d9718 Mon Sep 17 00:00:00 2001
From: Mikhail Maltsev <maltsevm@gmail.com>
Date: Sat, 3 Oct 2015 10:02:21 +0300
Subject: [PATCH 4/9] Fortran

---
 gcc/fortran/trans-common.c | 15 +++++++--------
 gcc/fortran/trans.c        |  6 ++----
 2 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/gcc/fortran/trans-common.c b/gcc/fortran/trans-common.c
index 7f4bfe5..ae336c1 100644
--- a/gcc/fortran/trans-common.c
+++ b/gcc/fortran/trans-common.c
@@ -686,14 +686,13 @@ create_common (gfc_common_head *com, segment_info *head, bool saw_equiv)
       TREE_STATIC (ctor) = 1;
       DECL_INITIAL (decl) = ctor;
 
-#ifdef ENABLE_CHECKING
-      {
-	tree field, value;
-	unsigned HOST_WIDE_INT idx;
-	FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (ctor), idx, field, value)
-	  gcc_assert (TREE_CODE (field) == FIELD_DECL);
-      }
-#endif
+      if (flag_checking)
+	{
+	  tree field, value;
+	  unsigned HOST_WIDE_INT idx;
+	  FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (ctor), idx, field, value)
+	    gcc_assert (TREE_CODE (field) == FIELD_DECL);
+	}
     }
 
   /* Build component reference for each variable.  */
diff --git a/gcc/fortran/trans.c b/gcc/fortran/trans.c
index f30809a..4eaea53 100644
--- a/gcc/fortran/trans.c
+++ b/gcc/fortran/trans.c
@@ -151,7 +151,6 @@ gfc_add_modify_loc (location_t loc, stmtblock_t * pblock, tree lhs, tree rhs)
 {
   tree tmp;
 
-#ifdef ENABLE_CHECKING
   tree t1, t2;
   t1 = TREE_TYPE (rhs);
   t2 = TREE_TYPE (lhs);
@@ -159,9 +158,8 @@ gfc_add_modify_loc (location_t loc, stmtblock_t * pblock, tree lhs, tree rhs)
      for scalar assignments.  We should probably have something
      similar for aggregates, but right now removing that check just
      breaks everything.  */
-  gcc_assert (t1 == t2
-	      || AGGREGATE_TYPE_P (TREE_TYPE (lhs)));
-#endif
+  gcc_checking_assert (t1 == t2
+		       || AGGREGATE_TYPE_P (TREE_TYPE (lhs)));
 
   tmp = fold_build2_loc (loc, MODIFY_EXPR, void_type_node, lhs,
 			 rhs);
-- 
2.1.4


^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 5/9] ENABLE_CHECKING refactoring: pool allocators
  2015-10-05 23:27 [PATCH 1/9] ENABLE_CHECKING refactoring Mikhail Maltsev
                   ` (2 preceding siblings ...)
  2015-10-05 23:31 ` [PATCH 4/9] ENABLE_CHECKING refactoring: Fortran Mikhail Maltsev
@ 2015-10-05 23:32 ` Mikhail Maltsev
  2015-10-06 12:41   ` Bernd Schmidt
  2015-10-05 23:34 ` [PATCH 6/9] ENABLE_CHECKING refactoring: generators Mikhail Maltsev
                   ` (7 subsequent siblings)
  11 siblings, 1 reply; 77+ messages in thread
From: Mikhail Maltsev @ 2015-10-05 23:32 UTC (permalink / raw)
  To: gcc-patches mailing list, Jeff Law, Richard Biener

[-- Attachment #1: Type: text/plain, Size: 168 bytes --]

gcc/ChangeLog:

2015-10-05  Mikhail Maltsev  <maltsevm@gmail.com>

	* alloc-pool.h (base_pool_allocator::initialize, ::allocate,
	::remove): Adjust to use CHECKING_P.


[-- Attachment #2: 0005-Allocators.patch --]
[-- Type: text/x-patch, Size: 3069 bytes --]

From ed727b2279dd36e2fbf1ab6956270cbd487b1a01 Mon Sep 17 00:00:00 2001
From: Mikhail Maltsev <maltsevm@gmail.com>
Date: Sun, 4 Oct 2015 22:50:40 +0300
Subject: [PATCH 5/9] Allocators

---
 gcc/alloc-pool.h | 45 ++++++++++++++++++++++-----------------------
 1 file changed, 22 insertions(+), 23 deletions(-)

diff --git a/gcc/alloc-pool.h b/gcc/alloc-pool.h
index 70105ba..8477ee4 100644
--- a/gcc/alloc-pool.h
+++ b/gcc/alloc-pool.h
@@ -275,15 +275,16 @@ base_pool_allocator <TBlockAllocator>::initialize ()
   m_elts_per_block = (TBlockAllocator::block_size - header_size) / size;
   gcc_checking_assert (m_elts_per_block != 0);
 
-#ifdef ENABLE_CHECKING
-  /* Increase the last used ID and use it for this pool.
-     ID == 0 is used for free elements of pool so skip it.  */
-  last_id++;
-  if (last_id == 0)
-    last_id++;
-
-  m_id = last_id;
-#endif
+  if (CHECKING_P)
+    {
+      /* Increase the last used ID and use it for this pool.
+	 ID == 0 is used for free elements of pool so skip it.  */
+      last_id++;
+      if (last_id == 0)
+	last_id++;
+
+      m_id = last_id;
+    }
 }
 
 /* Free all memory allocated for the given memory pool.  */
@@ -387,10 +388,9 @@ base_pool_allocator <TBlockAllocator>::allocate ()
       block = m_virgin_free_list;
       header = (allocation_pool_list*) allocation_object::get_data (block);
       header->next = NULL;
-#ifdef ENABLE_CHECKING
-      /* Mark the element to be free.  */
-      ((allocation_object*) block)->id = 0;
-#endif
+      if (CHECKING_P)
+	/* Mark the element to be free.  */
+	((allocation_object*) block)->id = 0;
       VALGRIND_DISCARD (VALGRIND_MAKE_MEM_NOACCESS (header,size));
       m_returned_free_list = header;
       m_virgin_free_list += m_elt_size;
@@ -404,10 +404,9 @@ base_pool_allocator <TBlockAllocator>::allocate ()
   m_returned_free_list = header->next;
   m_elts_free--;
 
-#ifdef ENABLE_CHECKING
   /* Set the ID for element.  */
-  allocation_object::get_instance (header)->id = m_id;
-#endif
+  if (CHECKING_P)
+    allocation_object::get_instance (header)->id = m_id;
   VALGRIND_DISCARD (VALGRIND_MAKE_MEM_UNDEFINED (header, size));
 
   return (void *)(header);
@@ -424,18 +423,18 @@ base_pool_allocator <TBlockAllocator>::remove (void *object)
   int size ATTRIBUTE_UNUSED;
   size = m_elt_size - offsetof (allocation_object, u.data);
 
-#ifdef ENABLE_CHECKING
-  gcc_assert (object
+  gcc_checking_assert (object
 	      /* Check if we free more than we allocated, which is Bad (TM).  */
 	      && m_elts_free < m_elts_allocated
 	      /* Check whether the PTR was allocated from POOL.  */
 	      && m_id == allocation_object::get_instance (object)->id);
 
-  memset (object, 0xaf, size);
-
-  /* Mark the element to be free.  */
-  allocation_object::get_instance (object)->id = 0;
-#endif
+  if (CHECKING_P)
+    {
+      memset (object, 0xaf, size);
+      /* Mark the element to be free.  */
+      allocation_object::get_instance (object)->id = 0;
+    }
 
   header = (allocation_pool_list*) object;
   header->next = m_returned_free_list;
-- 
2.1.4


^ permalink raw reply	[flat|nested] 77+ messages in thread

* [PATCH 6/9] ENABLE_CHECKING refactoring: generators
  2015-10-05 23:27 [PATCH 1/9] ENABLE_CHECKING refactoring Mikhail Maltsev
                   ` (3 preceding siblings ...)
  2015-10-05 23:32 ` [PATCH 5/9] ENABLE_CHECKING refactoring: pool allocators Mikhail Maltsev
@ 2015-10-05 23:34 ` Mikhail Maltsev
  2015-10-06 12:57   ` Richard Biener
  2015-10-05 23:39 ` [PATCH 7/9] ENABLE_CHECKING refactoring: middle-end, LTO FE Mikhail Maltsev
                   ` (6 subsequent siblings)
  11 siblings, 1 reply; 77+ messages in thread
From: Mikhail Maltsev @ 2015-10-05 23:34 UTC (permalink / raw)
  To: gcc-patches mailing list, Jeff Law, Richard Biener

[-- Attachment #1: Type: text/plain, Size: 304 bytes --]

gcc/ChangeLog:

2015-10-05  Mikhail Maltsev  <maltsevm@gmail.com>

	* genautomata.c: Use CHECKING_P instead of ENABLE_CHECKING.
	* genconditions.c: Define CHECKING_P in generated code.
	* genextract.c: Use CHECKING_P instead of ENABLE_CHECKING.
	* gengtype.c (main): Likewise.
	* gengtype.h: Likewise.



[-- Attachment #2: 0006-Generators.patch --]
[-- Type: text/x-patch, Size: 3857 bytes --]

From 88463ec3319670875dfe47926f6e55d5fd6219ba Mon Sep 17 00:00:00 2001
From: Mikhail Maltsev <maltsevm@gmail.com>
Date: Sun, 4 Oct 2015 22:50:02 +0300
Subject: [PATCH 6/9] Generators

---
 gcc/genautomata.c   | 2 +-
 gcc/genconditions.c | 2 ++
 gcc/genextract.c    | 2 +-
 gcc/gengtype.c      | 8 +++-----
 gcc/gengtype.h      | 4 ++--
 5 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/gcc/genautomata.c b/gcc/genautomata.c
index 5196d68..beae5ef 100644
--- a/gcc/genautomata.c
+++ b/gcc/genautomata.c
@@ -879,7 +879,7 @@ struct state_ainsn_table
 /* Macros to access members of unions.  Use only them for access to
    union members of declarations and regexps.  */
 
-#if defined ENABLE_CHECKING && (GCC_VERSION >= 2007)
+#if CHECKING_P && (GCC_VERSION >= 2007)
 
 #define DECL_UNIT(d) __extension__					\
 (({ __typeof (d) const _decl = (d);					\
diff --git a/gcc/genconditions.c b/gcc/genconditions.c
index 001e58e..7481ab4 100644
--- a/gcc/genconditions.c
+++ b/gcc/genconditions.c
@@ -60,6 +60,8 @@ write_header (void)
 \n\
 /* Do not allow checking to confuse the issue.  */\n\
 #undef ENABLE_CHECKING\n\
+#undef CHECKING_P\n\
+#define CHECKING_P 0\n\
 #undef ENABLE_TREE_CHECKING\n\
 #undef ENABLE_RTL_CHECKING\n\
 #undef ENABLE_RTL_FLAG_CHECKING\n\
diff --git a/gcc/genextract.c b/gcc/genextract.c
index fe97701..7f1879f 100644
--- a/gcc/genextract.c
+++ b/gcc/genextract.c
@@ -373,7 +373,7 @@ insn_extract (rtx_insn *insn)\n{\n\
   rtx pat = PATTERN (insn);\n\
   int i ATTRIBUTE_UNUSED; /* only for peepholes */\n\
 \n\
-#ifdef ENABLE_CHECKING\n\
+#if CHECKING_P\n\
   memset (ro, 0xab, sizeof (*ro) * MAX_RECOG_OPERANDS);\n\
   memset (ro_loc, 0xab, sizeof (*ro_loc) * MAX_RECOG_OPERANDS);\n\
 #endif\n");
diff --git a/gcc/gengtype.c b/gcc/gengtype.c
index 866d809..777b52f 100644
--- a/gcc/gengtype.c
+++ b/gcc/gengtype.c
@@ -160,7 +160,7 @@ static outf_p *base_files;
 
 
 
-#if ENABLE_CHECKING
+#if CHECKING_P
 /* Utility debugging function, printing the various type counts within
    a list of types.  Called through the DBGPRINT_COUNT_TYPE macro.  */
 void
@@ -222,7 +222,7 @@ dbgprint_count_type_at (const char *fil, int lin, const char *msg, type_p t)
     fprintf (stderr, "@@%%@@ %d undefined types\n", nb_undefined);
   fprintf (stderr, "\n");
 }
-#endif /* ENABLE_CHECKING */
+#endif /* CHECKING_P */
 
 /* Scan the input file, LIST, and determine how much space we need to
    store strings in.  Also, count the number of language directories
@@ -5181,15 +5181,13 @@ main (int argc, char **argv)
 
   parse_program_options (argc, argv);
 
-#if ENABLE_CHECKING
-  if (do_debug)
+  if (CHECKING_P && do_debug)
     {
       time_t now = (time_t) 0;
       time (&now);
       DBGPRINTF ("gengtype started pid %d at %s",
 		 (int) getpid (), ctime (&now));
     }
-#endif	/* ENABLE_CHECKING */
 
   /* Parse the input list and the input files.  */
   DBGPRINTF ("inputlist %s", inputlist);
diff --git a/gcc/gengtype.h b/gcc/gengtype.h
index 83f3632..9c4eac3 100644
--- a/gcc/gengtype.h
+++ b/gcc/gengtype.h
@@ -492,7 +492,7 @@ extern int do_dump;		/* (-d) program argument. */
    gengtype source code).  Only useful to debug gengtype itself.  */
 extern int do_debug;		/* (-D) program argument. */
 
-#if ENABLE_CHECKING
+#if CHECKING_P
 #define DBGPRINTF(Fmt,...) do {if (do_debug)				\
       fprintf (stderr, "%s:%d: " Fmt "\n",				\
 	       lbasename (__FILE__),__LINE__, ##__VA_ARGS__);} while (0)
@@ -502,7 +502,7 @@ void dbgprint_count_type_at (const char *, int, const char *, type_p);
 #else
 #define DBGPRINTF(Fmt,...) do {/*nodbgrintf*/} while (0)
 #define DBGPRINT_COUNT_TYPE(Msg,Ty) do{/*nodbgprint_count_type*/}while (0)
-#endif /*ENABLE_CHECKING */
+#endif /* CHECKING_P */
 
 #define FOR_ALL_INHERITED_FIELDS(TYPE, FIELD_VAR) \
   for (type_p sub = (TYPE); sub; sub = sub->u.s.base_class) \
-- 
2.1.4


^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 7/9] ENABLE_CHECKING refactoring: middle-end, LTO FE
  2015-10-05 23:27 [PATCH 1/9] ENABLE_CHECKING refactoring Mikhail Maltsev
                   ` (4 preceding siblings ...)
  2015-10-05 23:34 ` [PATCH 6/9] ENABLE_CHECKING refactoring: generators Mikhail Maltsev
@ 2015-10-05 23:39 ` Mikhail Maltsev
  2015-10-06 12:46   ` Bernd Schmidt
  2015-10-05 23:40 ` [PATCH 8/9] ENABLE_CHECKING refactoring: target-specific parts Mikhail Maltsev
                   ` (5 subsequent siblings)
  11 siblings, 1 reply; 77+ messages in thread
From: Mikhail Maltsev @ 2015-10-05 23:39 UTC (permalink / raw)
  To: gcc-patches mailing list, Jeff Law, Richard Biener

[-- Attachment #1: Type: text/plain, Size: 9164 bytes --]

gcc/ChangeLog:

2015-10-05  Mikhail Maltsev  <maltsevm@gmail.com>

	* attribs.c (check_attribute_tables): Define new function.
	(init_attributes): Use it.
	* cfgcleanup.c (try_optimize_cfg): Use flag_checking.
	* cfgexpand.c (expand_goto, expand_debug_expr): Likewise.
	(pass_expand::execute): Use checking_verify_flow_info.
	* cfghooks.c (verify_flow_info): Remove DEBUG_FUNCTION.
	* cfghooks.h (checking_verify_flow_info): Define.
	* cfgloop.c (verify_loop_structure): Remove DEBUG_FUNCTION.
	* cfgloop.h (checking_verify_loop_structure): Define.
	* cfgrtl.c (commit_edge_insertions): Use checking_verify_flow_info.
	(fixup_reorder_chain): Use checking_verify_insn_chain.
	(checking_verify_insn_chain): Define.
	(cfg_layout_finalize): Use checking_verify_insn_chain/flow_info.
	(rtl_flow_call_edges_add): Use flag_checking.
	* cgraph.c (symbol_table::create_edge): Remove conditional compilation.
	(cgraph_edge::redirect_call_stmt_to_callee): Likewise; use
	flag_checking.
	* cgraph.h (symtab_node::checking_verify_symtab_nodes): Define.
	(cgraph_node::checking_verify_cgraph_nodes): Define.
	* cgraphclones.c (symbol_table::materialize_all_clones): Use
	checking_verify_cgraph_nodes, remove conditional compilation.
	* cgraphunit.c (mark_functions_to_output): Use flag_checking.
	(cgraph_node::expand_thunk): Use checking_verify_flow_info.
	(symbol_table::compile): Use checking_verify_*, remove conditional
	compilation.
	* ddg.c (add_cross_iteration_register_deps): Use flag_checking.
	(create_ddg_all_sccs): Likewise.
	* df-core.c (df_finish_pass, df_analyze): Likewise.
	* diagnostic-core.h: Adjust to use CHECKING_P.
	* diagnostic.c (diagnostic_report_diagnostic): Likewise.
	* dominance.c (calculate_dominance_info): Use
	checking_verify_dominators.
	* dominance.h (checking_verify_dominators): Define.
	* dwarf2out.c (add_AT_die_ref, const_ok_for_output_1,
	mem_loc_descriptor, loc_list_from_tree, gen_lexical_block_die,
	gen_type_die_with_usage, gen_type_die, dwarf2out_decl): Use
	flag_checking.
	* emit-rtl.c (verify_rtx_sharing, reorder_insns_nobb): Likewise.
	* et-forest.c: Fix comment.
	* except.c (duplicate_eh_regions): Use flag_checking.
	* fwprop.c (register_active_defs, update_df_init): Use CHECKING_P.
	(update_uses): Use gcc_checking_assert.
	(fwprop_init, fwprop_done): Use CHECKING_P.
	* ggc-page.c (ggc_grow): Likewise.
	* gimplify.c (gimplify_body): Use flag_checking.
	(gimplify_hasher::equal): Use CHECKING_P.
	* graphite-isl-ast-to-gimple.c (graphite_verify): Use
	checking_verify_* functions.
	* graphite-scop-detection.c (canonicalize_loop_closed_ssa_form):
	Likewise.
	* graphite-sese-to-poly.c (rewrite_reductions_out_of_ssa): Likewise.
	(rewrite_cross_bb_scalar_deps_out_of_ssa): Likewise.
	* hash-table.h (hash_table::find_empty_slot_for_expand): Remove
	conditional compilation.
	* ifcvt.c (if_convert): Use checking_verify_flow_info.
	* ipa-cp.c (ipcp_propagate_stage): Use flag_checking.
	* ipa-devirt.c (type_in_anonymous_namespace_p,
	odr_type_p, odr_types_equivalent_p): Use gcc_checking_assert.
	(add_type_duplicate, get_odr_type): Use flag_checking.
	* ipa-icf.c (sem_item_optimizer::verify_classes,
	sem_item_optimizer::traverse_congruence_split,
	sem_item_optimizer::do_congruence_step_for_index): Use flag_checking.
	* ipa-inline-analysis.c (compute_inline_parameters): Likewise.
	* ipa-inline-transform.c (save_inline_function_body): Likewise.
	* ipa-inline.c (inline_small_functions): Use CHECKING_P.
	(early_inliner): Use flag_checking.
	* ipa-inline.h (estimate_edge_growth): Remove conditional compilation.
	* ipa-visibility.c (function_and_variable_visibility): Use
	flag_checking.
	* ipa.c (symbol_table::remove_unreachable_nodes): Likewise.
	(ipa_single_use): Use gcc_checking_assert.
	* ira-int.h: Use CHECKING_P.
	* ira.c (ira): Use flag_checking.
	* loop-doloop.c (doloop_optimize_loops): Use
	checking_verify_loop_structure.
	* loop-init.c (loop_optimizer_init, fix_loop_structure): Likewise.
	* loop-invariant.c (move_loop_invariants): Use
	checking_verify_flow_info.
	* lra-assigns.c (lra_assign): Use CHECKING_P.
	* lra-constraints.c (lra_constraints): Use flag_checking.
	* lra-eliminations.c (lra_eliminate): Likewise.
	* lra-int.h (struct lra_reg): Use CHECKING_P.
	* lra-lives.c (check_pseudos_live_through_calls,
	lra_create_live_ranges_1): Use CHECKING_P.
	* lra-remat.c (create_remat_bb_data): Adjust to use gcc_checking_assert.
	* lra.c (lra_update_insn_recog_data, restore_scratches): Use
	flag_checking.
	(check_rtl): Always define. Remove incorrect guard around
	extract_constrain_insn call.
	(lra):
	* lto-cgraph.c (input_cgraph_1): Use flag_checking.
	* lto-streamer-out.c (DFS::DFS): Use gcc_checking_assert.
	(lto_output): Use CHECKING_P.
	* lto-streamer.c (lto_streamer_init): Likewise.
	* omp-low.c (scan_omp_target, expand_omp_taskreg, expand_omp_target,
	execute_expand_omp): Likewise.
	(lower_omp_target): Use CHECKING_P.
	* passes.c (execute_function_todo): Use flag_checking
	execute_todo, execute_one_pass): Likewise.
	(verify_curr_properties): Always define.
	* predict.c (tree_estimate_probability, propagate_freq): Use
	flag_checking.
	* pretty-print.c (pp_format): Use CHECKING_P.
	* real.c (real_to_decimal_for_mode): Likewise.
	* recog.c (split_all_insns): Use checking_verify_flow_info.
	* regcprop.c (kill_value_one_regno): Always call validate_value_data.
	(copy_value): Likewise.
	(validate_value_data): Define unconditionally. Use flag_checking.
	* reload.c: Fix comment.
	* sched-deps.c (CHECK): Remove unused macro.
	(add_or_update_dep_1, sd_add_dep): Use flag_checking.
	* sel-sched-ir.c (free_regset_pool, tidy_control_flow): Likewise.
	* sel-sched.c (struct moveop_static_params, find_best_reg_for_expr,
	move_cond_jump, move_op_orig_expr_not_found,
	code_motion_process_successors, move_op): Use CHECKING_P.
	* sese.h (bb_in_region): Comment checking-related issue.
	* ssa-iterators.h (first_readonly_imm_use,
	next_readonly_imm_use): Use CHECKING_P.
	* store-motion.c (compute_store_table): Use flag_checking.
	* symbol-summary.h (function_summary::function_summary): Likewise.
	* symtab.c: Remove DEBUG_FUNCTION.
	* target.h (cumulative_args_t): Guard by CHECKING_P
	(get_cumulative_args, pack_cumulative_args): Use CHECKING_P.
	* timevar.c (timer::print): Adjust condition.
	* trans-mem.c (ipa_tm_execute): Use checking_verify_cgraph_nodes.
	* tree-cfg.c (move_stmt_op): Use flag_checking.
	(move_sese_region_to_fn): Use flag_checking.
	(gimple_flow_call_edges_add): Likewise.
	* tree-cfgcleanup.c (cleanup_tree_cfg_noloop, repair_loop_structures):
	Use checking_verify_* functions.
	* tree-eh.c (remove_unreachable_handlers): Use flag_checking.
	* tree-if-conv.c (pass_if_conversion::execute): Likewise.
	* tree-inline.c (expand_call_inline, optimize_inline_calls): Likewise.
	* tree-into-ssa.c (update_ssa): Likewise.
	* tree-loop-distribution.c (pass_loop_distribution::execute): Likewise.
	* tree-outof-ssa.c (eliminate_useless_phis, rewrite_trees): Likewise.
	* tree-parloops.c (pass_parallelize_loops::execute): Use
	checking_verify_loop_structure.
	* tree-predcom.c (suitable_component_p): Use gcc_checking_assert.
	* tree-profile.c (gimple_gen_const_delta_profiler): Use flag_checking.
	* tree-ssa-alias.c (refs_may_alias_p_1): Use gcc_checking_assert.
	* tree-ssa-live.c (verify_live_on_entry): Define unconditionally.
	(calculate_live_ranges): Use flag_checking.
	* tree-ssa-live.h (register_ssa_partition): Likewise.
	* tree-ssa-loop-ivcanon.c (tree_unroll_loops_completely): Use
	flag_checking.
	* tree-ssa-loop-manip.c (add_exit_phi): Likewise.
	(tree_transform_and_unroll_loop): Use checking_* functions.
	* tree-ssa-loop-manip.h (checking_verify_loop_closed_ssa): Define.
	* tree-ssa-math-opts.c (pass_cse_reciprocals::execute): Use
	flag_checking.
	* tree-ssa-operands.c (get_expr_operands): Likewise.
	* tree-ssa-propagate.c (replace_exp_1): Likewise.
	* tree-ssa-structalias.c (rewrite_constraints): Likewise.
	* tree-ssa-ter.c (free_temp_expr_table): Likewise.
	* tree-ssa-threadupdate.c (duplicate_thread_path): Likewise.
	* tree-ssa.c (verify_ssa): Remove DEBUG_FUNCTION.
	* tree-ssa.h (checking_verify_ssa): Define.
	* tree-ssanames.c (release_ssa_name_fn): Use flag_checking.
	* tree-stdarg.c (expand_ifn_va_arg): Likewise.
	* tree-vect-loop-manip.c (slpeel_tree_duplicate_loop_to_edge_cfg): Use
	checking_verify_dominators.
	(slpeel_checking_verify_cfg_after_peeling): Guard by flag_checking.
	(vect_do_peeling_for_loop_bound): Always call
	slpeel_checking_verify_cfg_after_peeling.
	(vect_do_peeling_for_alignment): Likewise.
	* tree-vrp.c (supports_overflow_infinity): Use gcc_checking_assert.
	(set_value_range): Use flag_checking.
	* tree.c (free_lang_data_in_cgraph): Likewise.
	* value-prof.c (gimple_remove_histogram_value): Use CHECKING_P.
	(free_hist): Likewise.
	* var-tracking.c (canonicalize_values_star): Use flag_checking.
	(compute_bb_dataflow, vt_find_locations, vt_emit_notes): Likewise.


gcc/lto/ChangeLog:

2015-10-05  Mikhail Maltsev  <maltsevm@gmail.com>

	* lto.c (unify_scc): Use flag_checking
	(lto_fixup_state): Use CHECKING_P.
	(do_whole_program_analysis): Use
	symtab_node::checking_verify_symtab_nodes.


[-- Attachment #2: 0007-Backend.patch --]
[-- Type: text/x-patch, Size: 131112 bytes --]

From d7b5ee6da8c1a7ba0ce79d1937801d728a77560e Mon Sep 17 00:00:00 2001
From: Mikhail Maltsev <maltsevm@gmail.com>
Date: Sat, 3 Oct 2015 00:13:24 +0300
Subject: [PATCH 7/9] Backend

---
 gcc/attribs.c                    | 112 +++++++++++++++++++--------------------
 gcc/cfgcleanup.c                 |   5 +-
 gcc/cfgexpand.c                  |  27 +++++-----
 gcc/cfghooks.c                   |   4 +-
 gcc/cfghooks.h                   |  12 +++++
 gcc/cfgloop.c                    |   2 +-
 gcc/cfgloop.h                    |  10 ++++
 gcc/cfgrtl.c                     |  37 ++++++-------
 gcc/cgraph.c                     |  11 +---
 gcc/cgraph.h                     |  32 ++++++++---
 gcc/cgraphclones.c               |  11 ++--
 gcc/cgraphunit.c                 |  39 +++++---------
 gcc/ddg.c                        |  18 +++----
 gcc/df-core.c                    |  18 +++----
 gcc/diagnostic-core.h            |   2 +-
 gcc/diagnostic.c                 |   7 ++-
 gcc/dominance.c                  |  12 ++---
 gcc/dominance.h                  |  11 ++++
 gcc/dwarf2out.c                  |  76 ++++++++++++--------------
 gcc/emit-rtl.c                   |  16 +++---
 gcc/et-forest.c                  |   2 +-
 gcc/except.c                     |  12 ++---
 gcc/fwprop.c                     |  26 ++++-----
 gcc/ggc-page.c                   |  11 ++--
 gcc/gimplify.c                   |   8 +--
 gcc/graphite-isl-ast-to-gimple.c |   6 +--
 gcc/graphite-scop-detection.c    |  11 ++--
 gcc/graphite-sese-to-poly.c      |   8 +--
 gcc/hash-table.h                 |   4 --
 gcc/ifcvt.c                      |   4 +-
 gcc/ipa-cp.c                     |   7 ++-
 gcc/ipa-devirt.c                 |  36 ++++++-------
 gcc/ipa-icf.c                    |  28 +++++-----
 gcc/ipa-inline-analysis.c        |  10 ++--
 gcc/ipa-inline-transform.c       |   5 +-
 gcc/ipa-inline.c                 |   7 ++-
 gcc/ipa-inline.h                 |   2 -
 gcc/ipa-visibility.c             |  19 ++++---
 gcc/ipa.c                        |  22 ++++----
 gcc/ira-int.h                    |   2 +-
 gcc/ira.c                        |   6 +--
 gcc/loop-doloop.c                |   4 +-
 gcc/loop-init.c                  |  12 ++---
 gcc/loop-invariant.c             |   4 +-
 gcc/lra-assigns.c                |   2 +-
 gcc/lra-constraints.c            |   4 +-
 gcc/lra-eliminations.c           |  10 ++--
 gcc/lra-int.h                    |   2 +-
 gcc/lra-lives.c                  |   4 +-
 gcc/lra-remat.c                  |   6 +--
 gcc/lra.c                        |  31 +++--------
 gcc/lto-cgraph.c                 |   9 ++--
 gcc/lto-streamer-out.c           |  25 ++++-----
 gcc/lto-streamer.c               |   5 +-
 gcc/lto/lto.c                    |  34 ++++++------
 gcc/omp-low.c                    |  30 +++++------
 gcc/passes.c                     |  20 +++----
 gcc/predict.c                    |  20 ++++---
 gcc/pretty-print.c               |   9 ++--
 gcc/real.c                       |   4 +-
 gcc/recog.c                      |   4 +-
 gcc/regcprop.c                   |  13 ++---
 gcc/reload.c                     |   2 +-
 gcc/sched-deps.c                 |  20 ++-----
 gcc/sel-sched-ir.c               |  69 ++++++++++++------------
 gcc/sel-sched.c                  |  16 +++---
 gcc/sese.h                       |  24 +++++----
 gcc/ssa-iterators.h              |  14 ++---
 gcc/store-motion.c               |  14 +++--
 gcc/symbol-summary.h             |  14 +++--
 gcc/symtab.c                     |   4 +-
 gcc/target.h                     |  16 +++---
 gcc/timevar.c                    |  11 ++--
 gcc/trans-mem.c                  |   8 +--
 gcc/tree-cfg.c                   |  16 +++---
 gcc/tree-cfgcleanup.c            |  12 ++---
 gcc/tree-eh.c                    |   7 ++-
 gcc/tree-if-conv.c               |  13 +++--
 gcc/tree-inline.c                |  12 ++---
 gcc/tree-into-ssa.c              | 100 +++++++++++++++++-----------------
 gcc/tree-loop-distribution.c     |   4 +-
 gcc/tree-outof-ssa.c             |  38 ++++++-------
 gcc/tree-parloops.c              |   4 +-
 gcc/tree-predcom.c               |  10 ++--
 gcc/tree-profile.c               |   5 +-
 gcc/tree-ssa-alias.c             |   5 +-
 gcc/tree-ssa-live.c              |  11 ++--
 gcc/tree-ssa-live.h              |  10 ++--
 gcc/tree-ssa-loop-ivcanon.c      |   4 +-
 gcc/tree-ssa-loop-manip.c        |  32 ++++++-----
 gcc/tree-ssa-loop-manip.h        |   8 +++
 gcc/tree-ssa-math-opts.c         |   7 ++-
 gcc/tree-ssa-operands.c          |  13 ++---
 gcc/tree-ssa-propagate.c         |  16 +++---
 gcc/tree-ssa-structalias.c       |   9 ++--
 gcc/tree-ssa-ter.c               |  20 +++----
 gcc/tree-ssa-threadupdate.c      |   7 ++-
 gcc/tree-ssa.c                   |   2 +-
 gcc/tree-ssa.h                   |   8 +++
 gcc/tree-ssanames.c              |   5 +-
 gcc/tree-stdarg.c                |   5 +-
 gcc/tree-vect-loop-manip.c       |  21 +++-----
 gcc/tree-vrp.c                   |  20 ++++---
 gcc/tree.c                       |   9 ++--
 gcc/value-prof.c                 |  10 ++--
 gcc/var-tracking.c               |  56 ++++++++++----------
 106 files changed, 754 insertions(+), 907 deletions(-)

diff --git a/gcc/attribs.c b/gcc/attribs.c
index 6cbe011..87e9a52 100644
--- a/gcc/attribs.c
+++ b/gcc/attribs.c
@@ -174,8 +174,58 @@ find_attribute_namespace (const char* ns)
   return NULL;
 }
 
-/* Initialize attribute tables, and make some sanity checks
-   if --enable-checking.  */
+/* Make some sanity checks on the attribute tables.  */
+
+static void
+check_attribute_tables ()
+{
+  for (size_t i = 0; i < ARRAY_SIZE (attribute_tables); i++)
+    for (size_t j = 0; attribute_tables[i][j].name != NULL; j++)
+      {
+	/* The name must not begin and end with __.  */
+	const char *name = attribute_tables[i][j].name;
+	int len = strlen (name);
+
+	gcc_assert (!(name[0] == '_' && name[1] == '_'
+		      && name[len - 1] == '_' && name[len - 2] == '_'));
+
+	/* The minimum and maximum lengths must be consistent.  */
+	gcc_assert (attribute_tables[i][j].min_length >= 0);
+
+	gcc_assert (attribute_tables[i][j].max_length == -1
+		    || (attribute_tables[i][j].max_length
+			>= attribute_tables[i][j].min_length));
+
+	/* An attribute cannot require both a DECL and a TYPE.  */
+	gcc_assert (!attribute_tables[i][j].decl_required
+		    || !attribute_tables[i][j].type_required);
+
+	  /* If an attribute requires a function type, in particular
+	     it requires a type.  */
+	gcc_assert (!attribute_tables[i][j].function_type_required
+		    || attribute_tables[i][j].type_required);
+      }
+
+  /* Check that each name occurs just once in each table.  */
+  for (size_t i = 0; i < ARRAY_SIZE (attribute_tables); i++)
+    for (size_t j = 0; attribute_tables[i][j].name != NULL; j++)
+      for (size_t k = j + 1; attribute_tables[i][k].name != NULL; k++)
+	gcc_assert (strcmp (attribute_tables[i][j].name,
+			    attribute_tables[i][k].name));
+
+  /* Check that no name occurs in more than one table.  Names that
+     begin with '*' are exempt, and may be overridden.  */
+  for (size_t i = 0; i < ARRAY_SIZE (attribute_tables); i++)
+    for (size_t j = i + 1; j < ARRAY_SIZE (attribute_tables); j++)
+      for (size_t k = 0; attribute_tables[i][k].name != NULL; k++)
+	for (size_t l = 0; attribute_tables[j][l].name != NULL; l++)
+	  gcc_assert (attribute_tables[i][k].name[0] == '*'
+		      || strcmp (attribute_tables[i][k].name,
+				 attribute_tables[j][l].name));
+}
+
+/* Initialize attribute tables, and make some sanity checks if checking is
+   enabled.  */
 
 void
 init_attributes (void)
@@ -195,62 +245,8 @@ init_attributes (void)
     if (attribute_tables[i] == NULL)
       attribute_tables[i] = empty_attribute_table;
 
-#ifdef ENABLE_CHECKING
-  /* Make some sanity checks on the attribute tables.  */
-  for (i = 0; i < ARRAY_SIZE (attribute_tables); i++)
-    {
-      int j;
-
-      for (j = 0; attribute_tables[i][j].name != NULL; j++)
-	{
-	  /* The name must not begin and end with __.  */
-	  const char *name = attribute_tables[i][j].name;
-	  int len = strlen (name);
-
-	  gcc_assert (!(name[0] == '_' && name[1] == '_'
-			&& name[len - 1] == '_' && name[len - 2] == '_'));
-
-	  /* The minimum and maximum lengths must be consistent.  */
-	  gcc_assert (attribute_tables[i][j].min_length >= 0);
-
-	  gcc_assert (attribute_tables[i][j].max_length == -1
-		      || (attribute_tables[i][j].max_length
-			  >= attribute_tables[i][j].min_length));
-
-	  /* An attribute cannot require both a DECL and a TYPE.  */
-	  gcc_assert (!attribute_tables[i][j].decl_required
-		      || !attribute_tables[i][j].type_required);
-
-	  /* If an attribute requires a function type, in particular
-	     it requires a type.  */
-	  gcc_assert (!attribute_tables[i][j].function_type_required
-		      || attribute_tables[i][j].type_required);
-	}
-    }
-
-  /* Check that each name occurs just once in each table.  */
-  for (i = 0; i < ARRAY_SIZE (attribute_tables); i++)
-    {
-      int j, k;
-      for (j = 0; attribute_tables[i][j].name != NULL; j++)
-	for (k = j + 1; attribute_tables[i][k].name != NULL; k++)
-	  gcc_assert (strcmp (attribute_tables[i][j].name,
-			      attribute_tables[i][k].name));
-    }
-  /* Check that no name occurs in more than one table.  Names that
-     begin with '*' are exempt, and may be overridden.  */
-  for (i = 0; i < ARRAY_SIZE (attribute_tables); i++)
-    {
-      size_t j, k, l;
-
-      for (j = i + 1; j < ARRAY_SIZE (attribute_tables); j++)
-	for (k = 0; attribute_tables[i][k].name != NULL; k++)
-	  for (l = 0; attribute_tables[j][l].name != NULL; l++)
-	    gcc_assert (attribute_tables[i][k].name[0] == '*'
-			|| strcmp (attribute_tables[i][k].name,
-				   attribute_tables[j][l].name));
-    }
-#endif
+  if (flag_checking)
+    check_attribute_tables ();
 
   for (i = 0; i < ARRAY_SIZE (attribute_tables); ++i)
     /* Put all the GNU attributes into the "gnu" namespace.  */
diff --git a/gcc/cfgcleanup.c b/gcc/cfgcleanup.c
index 7e576bc..0ad4872 100644
--- a/gcc/cfgcleanup.c
+++ b/gcc/cfgcleanup.c
@@ -2874,10 +2874,7 @@ try_optimize_cfg (int mode)
                  is only visible after newly unreachable blocks are deleted,
                  which will be done in fixup_partitions.  */
               fixup_partitions ();
-
-#ifdef ENABLE_CHECKING
-              verify_flow_info ();
-#endif
+	      checking_verify_flow_info ();
             }
 
 	  changed_overall |= changed;
diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c
index 58e55d2..c1c584b 100644
--- a/gcc/cfgexpand.c
+++ b/gcc/cfgexpand.c
@@ -3272,12 +3272,13 @@ expand_computed_goto (tree exp)
 static void
 expand_goto (tree label)
 {
-#ifdef ENABLE_CHECKING
-  /* Check for a nonlocal goto to a containing function.  Should have
-     gotten translated to __builtin_nonlocal_goto.  */
-  tree context = decl_function_context (label);
-  gcc_assert (!context || context == current_function_decl);
-#endif
+  if (flag_checking)
+    {
+      /* Check for a nonlocal goto to a containing function.  Should have
+	 gotten translated to __builtin_nonlocal_goto.  */
+      tree context = decl_function_context (label);
+      gcc_assert (!context || context == current_function_decl);
+    }
 
   emit_jump (jump_target_rtx (label));
 }
@@ -5059,12 +5060,12 @@ expand_debug_expr (tree exp)
 
     default:
     flag_unsupported:
-#ifdef ENABLE_CHECKING
-      debug_tree (exp);
-      gcc_unreachable ();
-#else
+      if (flag_checking)
+	{
+	  debug_tree (exp);
+	  gcc_unreachable ();
+	}
       return NULL;
-#endif
     }
 }
 
@@ -6425,9 +6426,7 @@ pass_expand::execute (function *fun)
      gcc.c-torture/execute/ipa-sra-2.c execution, -Os -m32 fails otherwise.  */
   cleanup_cfg (CLEANUP_NO_INSN_DEL);
 
-#ifdef ENABLE_CHECKING
-  verify_flow_info ();
-#endif
+  checking_verify_flow_info ();
 
   /* Initialize pseudos allocated for hard registers.  */
   emit_initial_value_sets ();
diff --git a/gcc/cfghooks.c b/gcc/cfghooks.c
index 0cd8e62..47ac35b 100644
--- a/gcc/cfghooks.c
+++ b/gcc/cfghooks.c
@@ -91,8 +91,8 @@ current_ir_type (void)
    Currently it does following: checks edge and basic block list correctness
    and calls into IL dependent checking then.  */
 
-DEBUG_FUNCTION void
-verify_flow_info (void)
+void
+verify_flow_info ()
 {
   size_t *edge_checksum;
   int err = 0;
diff --git a/gcc/cfghooks.h b/gcc/cfghooks.h
index 0d25cf6..2c5b68e 100644
--- a/gcc/cfghooks.h
+++ b/gcc/cfghooks.h
@@ -186,6 +186,18 @@ struct cfg_hooks
 };
 
 extern void verify_flow_info (void);
+
+/* Check control flow invariants, if internal consistency checks are
+   enabled.  */
+
+static inline void
+checking_verify_flow_info ()
+{
+  /* TODO: Add a separate option for -fchecking=cfg.  */
+  if (flag_checking)
+    verify_flow_info ();
+}
+
 extern void dump_bb (FILE *, basic_block, int, int);
 extern void dump_bb_for_graph (pretty_printer *, basic_block);
 extern void dump_flow_info (FILE *, int);
diff --git a/gcc/cfgloop.c b/gcc/cfgloop.c
index b8a1244..8d58004 100644
--- a/gcc/cfgloop.c
+++ b/gcc/cfgloop.c
@@ -1306,7 +1306,7 @@ cancel_loop_tree (struct loop *loop)
      -- irreducible loops are correctly marked
      -- the cached loop depth and loop father of each bb is correct
   */
-DEBUG_FUNCTION void
+void
 verify_loop_structure (void)
 {
   unsigned *sizes, i, j;
diff --git a/gcc/cfgloop.h b/gcc/cfgloop.h
index 07b070b..08134de 100644
--- a/gcc/cfgloop.h
+++ b/gcc/cfgloop.h
@@ -311,6 +311,16 @@ extern void delete_loop (struct loop *);
 
 extern void verify_loop_structure (void);
 
+/* Check loop structure invariants, if internal consistency checks are
+   enabled.  */
+
+static inline void
+checking_verify_loop_structure ()
+{
+  if (flag_checking)
+    verify_loop_structure ();
+}
+
 /* Loop analysis.  */
 extern bool just_once_each_iteration_p (const struct loop *, const_basic_block);
 gcov_type expected_loop_iterations_unbounded (const struct loop *);
diff --git a/gcc/cfgrtl.c b/gcc/cfgrtl.c
index 15ce8a7..f763d1c 100644
--- a/gcc/cfgrtl.c
+++ b/gcc/cfgrtl.c
@@ -81,6 +81,7 @@ static void record_effective_endpoints (void);
 static void fixup_reorder_chain (void);
 
 void verify_insn_chain (void);
+static inline void checking_verify_insn_chain ();
 static void fixup_fallthru_exit_predecessor (void);
 static int can_delete_note_p (const rtx_note *);
 static int can_delete_label_p (const rtx_code_label *);
@@ -2097,9 +2098,7 @@ commit_edge_insertions (void)
      which will be done by fixup_partitions.  */
   fixup_partitions ();
 
-#ifdef ENABLE_CHECKING
-  verify_flow_info ();
-#endif
+  checking_verify_flow_info ();
 
   FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR_FOR_FN (cfun),
 		  EXIT_BLOCK_PTR_FOR_FN (cfun), next_bb)
@@ -3723,9 +3722,7 @@ fixup_reorder_chain (void)
     insn = NEXT_INSN (insn);
 
   set_last_insn (insn);
-#ifdef ENABLE_CHECKING
-  verify_insn_chain ();
-#endif
+  checking_verify_insn_chain ();
 
   /* Now add jumps and labels as needed to match the blocks new
      outgoing edges.  */
@@ -3970,8 +3967,8 @@ fixup_reorder_chain (void)
    2. Count insns in chain, going both directions, and check if equal.
    3. Check that get_last_insn () returns the actual end of chain.  */
 
-DEBUG_FUNCTION void
-verify_insn_chain (void)
+void
+verify_insn_chain ()
 {
   rtx_insn *x, *prevx, *nextx;
   int insn_cnt1, insn_cnt2;
@@ -3990,6 +3987,16 @@ verify_insn_chain (void)
 
   gcc_assert (insn_cnt1 == insn_cnt2);
 }
+
+/* Perform checks, if they were requested by corresponding flag.  */
+
+static inline void
+checking_verify_insn_chain ()
+{
+  if (flag_checking)
+    verify_insn_chain ();
+}
+
 \f
 /* If we have assembler epilogues, the block falling through to exit must
    be the last one in the reordered chain when we reach final.  Ensure
@@ -4313,9 +4320,7 @@ break_superblocks (void)
 void
 cfg_layout_finalize (void)
 {
-#ifdef ENABLE_CHECKING
-  verify_flow_info ();
-#endif
+  checking_verify_flow_info ();
   force_one_exit_fallthru ();
   rtl_register_cfg_hooks ();
   if (reload_completed && !targetm.have_epilogue ())
@@ -4325,10 +4330,8 @@ cfg_layout_finalize (void)
   rebuild_jump_labels (get_insns ());
   delete_dead_jumptables ();
 
-#ifdef ENABLE_CHECKING
-  verify_insn_chain ();
-  verify_flow_info ();
-#endif
+  checking_verify_insn_chain ();
+  checking_verify_flow_info ();
 }
 
 
@@ -4893,13 +4896,11 @@ rtl_flow_call_edges_add (sbitmap blocks)
 		 block in CFG already.  Calling make_edge in such case would
 		 cause us to mark that edge as fake and remove it later.  */
 
-#ifdef ENABLE_CHECKING
-	      if (split_at_insn == BB_END (bb))
+	      if (flag_checking && split_at_insn == BB_END (bb))
 		{
 		  e = find_edge (bb, EXIT_BLOCK_PTR_FOR_FN (cfun));
 		  gcc_assert (e == NULL);
 		}
-#endif
 
 	      /* Note that the following may create a new basic block
 		 and renumber the existing basic blocks.  */
diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index 1a64d789..1b6c5eb 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -832,11 +832,9 @@ symbol_table::create_edge (cgraph_node *caller, cgraph_node *callee,
     {
       /* This is a rather expensive check possibly triggering
 	 construction of call stmt hashtable.  */
-#ifdef ENABLE_CHECKING
       cgraph_edge *e;
       gcc_checking_assert (
 	!(e = caller->get_edge (call_stmt)) || e->speculative);
-#endif
 
       gcc_assert (is_gimple_call (call_stmt));
     }
@@ -1282,9 +1280,6 @@ cgraph_edge::redirect_call_stmt_to_callee (void)
   gcall *new_stmt;
   gimple_stmt_iterator gsi;
   bool skip_bounds = false;
-#ifdef ENABLE_CHECKING
-  cgraph_node *node;
-#endif
 
   if (e->speculative)
     {
@@ -1402,13 +1397,11 @@ cgraph_edge::redirect_call_stmt_to_callee (void)
 	  && !skip_bounds))
     return e->call_stmt;
 
-#ifdef ENABLE_CHECKING
-  if (decl)
+  if (flag_checking && decl)
     {
-      node = cgraph_node::get (decl);
+      cgraph_node *node = cgraph_node::get (decl);
       gcc_assert (!node || !node->clone.combined_args_to_skip);
     }
-#endif
 
   if (symtab->dump_file)
     {
diff --git a/gcc/cgraph.h b/gcc/cgraph.h
index 607aef7..1c84270 100644
--- a/gcc/cgraph.h
+++ b/gcc/cgraph.h
@@ -116,7 +116,7 @@ public:
   void DEBUG_FUNCTION debug (void);
 
   /* Verify consistency of node.  */
-  void DEBUG_FUNCTION verify (void);
+  void verify ();
 
   /* Return ipa reference from this symtab_node to
      REFERED_NODE or REFERED_VARPOOL_NODE. USE_TYPE specify type
@@ -362,7 +362,6 @@ public:
      and NULL otherwise.  */
   static inline symtab_node *get (const_tree decl)
   {
-#ifdef ENABLE_CHECKING
     /* Check that we are called for sane type of object - functions
        and static or external variables.  */
     gcc_checking_assert (TREE_CODE (decl) == FUNCTION_DECL
@@ -374,7 +373,6 @@ public:
        memcpy/memset on the tree nodes.  */
     gcc_checking_assert (!decl->decl_with_vis.symtab_node
 			 || decl->decl_with_vis.symtab_node->decl == decl);
-#endif
     return decl->decl_with_vis.symtab_node;
   }
 
@@ -396,7 +394,10 @@ public:
   }
 
   /* Verify symbol table for internal consistency.  */
-  static DEBUG_FUNCTION void verify_symtab_nodes (void);
+  static void verify_symtab_nodes ();
+
+  /* Perform internal consistency checks, if they are enabled.  */
+  static inline void checking_verify_symtab_nodes ();
 
   /* Type of the symbol.  */
   ENUM_BITFIELD (symtab_type) type : 8;
@@ -529,7 +530,7 @@ protected:
   void dump_base (FILE *);
 
   /* Verify common part of symtab node.  */
-  bool DEBUG_FUNCTION verify_base (void);
+  bool verify_base ();
 
   /* Remove node from symbol table.  This function is not used directly, but via
      cgraph/varpool node removal routines.  */
@@ -558,6 +559,13 @@ private:
   symtab_node *ultimate_alias_target_1 (enum availability *avail = NULL);
 };
 
+inline void
+symtab_node::checking_verify_symtab_nodes ()
+{
+  if (flag_checking)
+    symtab_node::verify_symtab_nodes ();
+}
+
 /* Walk all aliases for NODE.  */
 #define FOR_EACH_ALIAS(node, alias) \
   for (unsigned x_i = 0; node->iterate_direct_aliases (x_i, alias); x_i++)
@@ -1197,7 +1205,10 @@ public:
   static cgraph_node * create_same_body_alias (tree alias, tree decl);
 
   /* Verify whole cgraph structure.  */
-  static void DEBUG_FUNCTION verify_cgraph_nodes (void);
+  static void verify_cgraph_nodes ();
+
+  /* Verify cgraph, if consistency checking is enabled.  */
+  static inline void checking_verify_cgraph_nodes ();
 
   /* Worker to bring NODE local.  */
   static bool make_local (cgraph_node *node, void *);
@@ -2747,6 +2758,15 @@ cgraph_node::can_remove_if_no_direct_calls_and_refs_p (void)
   return true;
 }
 
+/* Verify cgraph, if consistency checking is enabled.  */
+
+inline void
+cgraph_node::checking_verify_cgraph_nodes ()
+{
+  if (flag_checking)
+    cgraph_node::verify_cgraph_nodes ();
+}
+
 /* Return true when variable can be removed from variable pool
    if all direct calls are eliminated.  */
 
diff --git a/gcc/cgraphclones.c b/gcc/cgraphclones.c
index e51431c..6bea9f7 100644
--- a/gcc/cgraphclones.c
+++ b/gcc/cgraphclones.c
@@ -1076,9 +1076,8 @@ symbol_table::materialize_all_clones (void)
 
   if (symtab->dump_file)
     fprintf (symtab->dump_file, "Materializing clones\n");
-#ifdef ENABLE_CHECKING
-  cgraph_node::verify_cgraph_nodes ();
-#endif
+
+  cgraph_node::checking_verify_cgraph_nodes ();
 
   /* We can also do topological order, but number of iterations should be
      bounded by number of IPA passes since single IPA pass is probably not
@@ -1147,9 +1146,9 @@ symbol_table::materialize_all_clones (void)
       node->clear_stmts_in_references ();
   if (symtab->dump_file)
     fprintf (symtab->dump_file, "Materialization Call site updates done.\n");
-#ifdef ENABLE_CHECKING
-  cgraph_node::verify_cgraph_nodes ();
-#endif
+
+  cgraph_node::checking_verify_cgraph_nodes ();
+
   symtab->remove_unreachable_nodes (symtab->dump_file);
 }
 
diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index 04a4d3f..42081c5 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -1325,13 +1325,12 @@ handle_alias_pairs (void)
 static void
 mark_functions_to_output (void)
 {
-  cgraph_node *node;
-#ifdef ENABLE_CHECKING
   bool check_same_comdat_groups = false;
+  cgraph_node *node;
 
-  FOR_EACH_FUNCTION (node)
-    gcc_assert (!node->process);
-#endif
+  if (flag_checking)
+    FOR_EACH_FUNCTION (node)
+      gcc_assert (!node->process);
 
   FOR_EACH_FUNCTION (node)
     {
@@ -1365,15 +1364,14 @@ mark_functions_to_output (void)
 	}
       else if (node->same_comdat_group)
 	{
-#ifdef ENABLE_CHECKING
-	  check_same_comdat_groups = true;
-#endif
+	  if (flag_checking)
+	    check_same_comdat_groups = true;
 	}
       else
 	{
 	  /* We should've reclaimed all functions that are not needed.  */
-#ifdef ENABLE_CHECKING
-	  if (!node->global.inlined_to
+	  if (flag_checking
+	      && !node->global.inlined_to
 	      && gimple_has_body_p (decl)
 	      /* FIXME: in ltrans unit when offline copy is outside partition but inline copies
 		 are inside partition, we can end up not removing the body since we no longer
@@ -1386,7 +1384,6 @@ mark_functions_to_output (void)
 	      node->debug ();
 	      internal_error ("failed to reclaim unneeded function");
 	    }
-#endif
 	  gcc_assert (node->global.inlined_to
 		      || !gimple_has_body_p (decl)
 		      || node->in_other_partition
@@ -1397,8 +1394,7 @@ mark_functions_to_output (void)
 	}
 
     }
-#ifdef ENABLE_CHECKING
-  if (check_same_comdat_groups)
+  if (CHECKING_P && check_same_comdat_groups)
     FOR_EACH_FUNCTION (node)
       if (node->same_comdat_group && !node->process)
 	{
@@ -1418,7 +1414,6 @@ mark_functions_to_output (void)
 			      "comdat group");
 	    }
 	}
-#endif
 }
 
 /* DECL is FUNCTION_DECL.  Initialize datastructures so DECL is a function
@@ -1887,9 +1882,7 @@ cgraph_node::expand_thunk (bool output_asm_thunks, bool force_gimple_thunk)
       TREE_ASM_WRITTEN (thunk_fndecl) = false;
       delete_unreachable_blocks ();
       update_ssa (TODO_update_ssa);
-#ifdef ENABLE_CHECKING
-      verify_flow_info ();
-#endif
+      checking_verify_flow_info ();
       free_dominance_info (CDI_DOMINATORS);
 
       /* Since we want to emit the thunk, we explicitly mark its name as
@@ -2373,9 +2366,7 @@ symbol_table::compile (void)
   if (seen_error ())
     return;
 
-#ifdef ENABLE_CHECKING
-  symtab_node::verify_symtab_nodes ();
-#endif
+  symtab_node::checking_verify_symtab_nodes ();
 
   timevar_push (TV_CGRAPHOPT);
   if (pre_ipa_mem_report)
@@ -2424,9 +2415,7 @@ symbol_table::compile (void)
   (*debug_hooks->assembly_start) ();
   if (!quiet_flag)
     fprintf (stderr, "Assembling functions:\n");
-#ifdef ENABLE_CHECKING
-  symtab_node::verify_symtab_nodes ();
-#endif
+  symtab_node::checking_verify_symtab_nodes ();
 
   materialize_all_clones ();
   bitmap_obstack_initialize (NULL);
@@ -2482,7 +2471,8 @@ symbol_table::compile (void)
       fprintf (dump_file, "\nFinal ");
       symtab_node::dump_table (dump_file);
     }
-#ifdef ENABLE_CHECKING
+  if (!flag_checking)
+    return;
   symtab_node::verify_symtab_nodes ();
   /* Double check that all inline clones are gone and that all
      function bodies have been released from memory.  */
@@ -2501,7 +2491,6 @@ symbol_table::compile (void)
       if (error_found)
 	internal_error ("nodes with unreleased memory found");
     }
-#endif
 }
 
 
diff --git a/gcc/ddg.c b/gcc/ddg.c
index ada4657..e6c9bbe 100644
--- a/gcc/ddg.c
+++ b/gcc/ddg.c
@@ -300,19 +300,16 @@ add_cross_iteration_register_deps (ddg_ptr g, df_ref last_def)
   rtx_insn *def_insn = DF_REF_INSN (last_def);
   ddg_node_ptr last_def_node = get_node_of_insn (g, def_insn);
   ddg_node_ptr use_node;
-#ifdef ENABLE_CHECKING
-  struct df_rd_bb_info *bb_info = DF_RD_BB_INFO (g->bb);
-#endif
+  struct df_rd_bb_info *bb_info = flag_checking ? DF_RD_BB_INFO (g->bb)
+						: NULL;
   df_ref first_def = df_bb_regno_first_def_find (g->bb, regno);
 
   gcc_assert (last_def_node);
   gcc_assert (first_def);
 
-#ifdef ENABLE_CHECKING
-  if (DF_REF_ID (last_def) != DF_REF_ID (first_def))
+  if (flag_checking && DF_REF_ID (last_def) != DF_REF_ID (first_def))
     gcc_assert (!bitmap_bit_p (&bb_info->gen,
 			       DF_REF_ID (first_def)));
-#endif
 
   /* Create inter-loop true dependences and anti dependences.  */
   for (r_use = DF_REF_CHAIN (last_def); r_use != NULL; r_use = r_use->next)
@@ -1013,7 +1010,6 @@ order_sccs (ddg_all_sccs_ptr g)
 	 (int (*) (const void *, const void *)) compare_sccs);
 }
 
-#ifdef ENABLE_CHECKING
 /* Check that every node in SCCS belongs to exactly one strongly connected
    component and that no element of SCCS is empty.  */
 static void
@@ -1033,7 +1029,6 @@ check_sccs (ddg_all_sccs_ptr sccs, int num_nodes)
     }
   sbitmap_free (tmp);
 }
-#endif
 
 /* Perform the Strongly Connected Components decomposing algorithm on the
    DDG and return DDG_ALL_SCCS structure that contains them.  */
@@ -1079,9 +1074,10 @@ create_ddg_all_sccs (ddg_ptr g)
   sbitmap_free (from);
   sbitmap_free (to);
   sbitmap_free (scc_nodes);
-#ifdef ENABLE_CHECKING
-  check_sccs (sccs, num_nodes);
-#endif
+
+  if (flag_checking)
+    check_sccs (sccs, num_nodes);
+
   return sccs;
 }
 
diff --git a/gcc/df-core.c b/gcc/df-core.c
index 8d2d7a1..72a5eb5 100644
--- a/gcc/df-core.c
+++ b/gcc/df-core.c
@@ -682,10 +682,8 @@ df_finish_pass (bool verify ATTRIBUTE_UNUSED)
 #endif
 #endif
 
-#ifdef ENABLE_CHECKING
-  if (verify)
+  if (flag_checking && verify)
     df->changeable_flags |= DF_VERIFY_SCHEDULED;
-#endif
 }
 
 
@@ -1273,12 +1271,14 @@ df_analyze (void)
   for (i = 0; i < df->n_blocks; i++)
     bitmap_set_bit (current_all_blocks, df->postorder[i]);
 
-#ifdef ENABLE_CHECKING
-  /* Verify that POSTORDER_INVERTED only contains blocks reachable from
-     the ENTRY block.  */
-  for (i = 0; i < df->n_blocks_inverted; i++)
-    gcc_assert (bitmap_bit_p (current_all_blocks, df->postorder_inverted[i]));
-#endif
+  if (flag_checking)
+    {
+      /* Verify that POSTORDER_INVERTED only contains blocks reachable from
+	 the ENTRY block.  */
+      for (i = 0; i < df->n_blocks_inverted; i++)
+	gcc_assert (bitmap_bit_p (current_all_blocks,
+				  df->postorder_inverted[i]));
+    }
 
   /* Make sure that we have pruned any unreachable blocks from these
      sets.  */
diff --git a/gcc/diagnostic-core.h b/gcc/diagnostic-core.h
index 66d2e42..6cc1e6b 100644
--- a/gcc/diagnostic-core.h
+++ b/gcc/diagnostic-core.h
@@ -48,7 +48,7 @@ extern const char *trim_filename (const char *);
 /* None of these functions are suitable for ATTRIBUTE_PRINTF, because
    each language front end can extend them with its own set of format
    specifiers.  We must use custom format checks.  */
-#if (ENABLE_CHECKING && GCC_VERSION >= 4001) || GCC_VERSION == BUILDING_GCC_VERSION
+#if (CHECKING_P && GCC_VERSION >= 4001) || GCC_VERSION == BUILDING_GCC_VERSION
 #define ATTRIBUTE_GCC_DIAG(m, n) __attribute__ ((__format__ (GCC_DIAG_STYLE, m, n))) ATTRIBUTE_NONNULL(m)
 #else
 #define ATTRIBUTE_GCC_DIAG(m, n) ATTRIBUTE_NONNULL(m)
diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c
index 831859a..11c369d 100644
--- a/gcc/diagnostic.c
+++ b/gcc/diagnostic.c
@@ -736,12 +736,12 @@ diagnostic_report_diagnostic (diagnostic_context *context,
 
   if (diagnostic->kind == DK_ICE || diagnostic->kind == DK_ICE_NOBT)
     {
-#ifndef ENABLE_CHECKING
       /* When not checking, ICEs are converted to fatal errors when an
 	 error has already occurred.  This is counteracted by
 	 abort_on_error.  */
-      if ((diagnostic_kind_count (context, DK_ERROR) > 0
-	   || diagnostic_kind_count (context, DK_SORRY) > 0)
+      if (!CHECKING_P
+	  && (diagnostic_kind_count (context, DK_ERROR) > 0
+	      || diagnostic_kind_count (context, DK_SORRY) > 0)
 	  && !context->abort_on_error)
 	{
 	  expanded_location s 
@@ -750,7 +750,6 @@ diagnostic_report_diagnostic (diagnostic_context *context,
 		   s.file, s.line);
 	  exit (ICE_EXIT_CODE);
 	}
-#endif
       if (context->internal_error)
 	(*context->internal_error) (context,
 				    diagnostic->message.format_spec,
diff --git a/gcc/dominance.c b/gcc/dominance.c
index 09645be..0dc4030 100644
--- a/gcc/dominance.c
+++ b/gcc/dominance.c
@@ -634,9 +634,7 @@ calculate_dominance_info (cdi_direction dir)
 
   if (dom_computed[dir_index] == DOM_OK)
     {
-#if ENABLE_CHECKING
-      verify_dominators (dir);
-#endif
+      checking_verify_dominators (dir);
       return;
     }
 
@@ -665,11 +663,7 @@ calculate_dominance_info (cdi_direction dir)
       dom_computed[dir_index] = DOM_NO_FAST_QUERY;
     }
   else
-    {
-#if ENABLE_CHECKING
-      verify_dominators (dir);
-#endif
-    }
+    checking_verify_dominators (dir);
 
   compute_dom_fast_query (dir);
 
@@ -1014,7 +1008,7 @@ bb_dom_dfs_out (enum cdi_direction dir, basic_block bb)
 }
 
 /* Verify invariants of dominator structure.  */
-DEBUG_FUNCTION void
+void
 verify_dominators (cdi_direction dir)
 {
   gcc_assert (dom_info_available_p (dir));
diff --git a/gcc/dominance.h b/gcc/dominance.h
index 37e138b..7254f2f 100644
--- a/gcc/dominance.h
+++ b/gcc/dominance.h
@@ -60,6 +60,17 @@ extern bool dominated_by_p (enum cdi_direction, const_basic_block,
 unsigned bb_dom_dfs_in (enum cdi_direction, basic_block);
 unsigned bb_dom_dfs_out (enum cdi_direction, basic_block);
 extern void verify_dominators (enum cdi_direction);
+
+/* Verify invariants of computed dominance information, if internal consistency
+   checks are enabled.  */
+
+static inline void
+checking_verify_dominators (cdi_direction dir)
+{
+  if (flag_checking)
+    verify_dominators (dir);
+}
+
 basic_block recompute_dominator (enum cdi_direction, basic_block);
 extern void iterate_fix_dominators (enum cdi_direction,
 				    vec<basic_block> , bool);
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 4edc2ae..9485719 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -4149,15 +4149,12 @@ static inline void
 add_AT_die_ref (dw_die_ref die, enum dwarf_attribute attr_kind, dw_die_ref targ_die)
 {
   dw_attr_node attr;
+  gcc_checking_assert (targ_die != NULL);
 
-#ifdef ENABLE_CHECKING
-  gcc_assert (targ_die != NULL);
-#else
   /* With LTO we can end up trying to reference something we didn't create
      a DIE for.  Avoid crashing later on a NULL referenced DIE.  */
   if (targ_die == NULL)
     return;
-#endif
 
   attr.dw_attr = attr_kind;
   attr.dw_attr_val.val_class = dw_val_class_die_ref;
@@ -5723,7 +5720,6 @@ debug_dwarf (void)
   print_die (comp_unit_die (), stderr);
 }
 
-#ifdef ENABLE_CHECKING
 /* Sanity checks on DIEs.  */
 
 static void
@@ -5786,7 +5782,7 @@ check_die (dw_die_ref die)
 		    && a->dw_attr != DW_AT_GNU_all_call_sites);
     }
 }
-#endif
+
 \f
 /* Start a new compilation unit DIE for an include file.  OLD_UNIT is the CU
    for the enclosing include file, if any.  BINCL_DIE is the DW_TAG_GNU_BINCL
@@ -11763,14 +11759,14 @@ const_ok_for_output_1 (rtx rtl)
     {
       /* If delegitimize_address couldn't do anything with the UNSPEC, assume
 	 we can't express it in the debug info.  */
-#ifdef ENABLE_CHECKING
       /* Don't complain about TLS UNSPECs, those are just too hard to
 	 delegitimize.  Note this could be a non-decl SYMBOL_REF such as
 	 one in a constant pool entry, so testing SYMBOL_REF_TLS_MODEL
 	 rather than DECL_THREAD_LOCAL_P is not just an optimization.  */
-      if (XVECLEN (rtl, 0) == 0
-	  || GET_CODE (XVECEXP (rtl, 0, 0)) != SYMBOL_REF
-	  || SYMBOL_REF_TLS_MODEL (XVECEXP (rtl, 0, 0)) == TLS_MODEL_NONE)
+      if (flag_checking
+	  && (XVECLEN (rtl, 0) == 0
+	      || GET_CODE (XVECEXP (rtl, 0, 0)) != SYMBOL_REF
+	      || SYMBOL_REF_TLS_MODEL (XVECEXP (rtl, 0, 0)) == TLS_MODEL_NONE))
 	inform (current_function_decl
 		? DECL_SOURCE_LOCATION (current_function_decl)
 		: UNKNOWN_LOCATION,
@@ -11783,7 +11779,6 @@ const_ok_for_output_1 (rtx rtl)
 		"non-delegitimized UNSPEC %d found in variable location",
 		XINT (rtl, 1));
 #endif
-#endif
       expansion_failed (NULL_TREE, rtl,
 			"UNSPEC hasn't been delegitimized.\n");
       return false;
@@ -13570,12 +13565,12 @@ mem_loc_descriptor (rtx rtl, machine_mode mode,
       goto symref;
 
     default:
-#ifdef ENABLE_CHECKING
-      print_rtl (stderr, rtl);
-      gcc_unreachable ();
-#else
+      if (flag_checking)
+	{
+	  print_rtl (stderr, rtl);
+	  gcc_unreachable ();
+	}
       break;
-#endif
     }
 
   if (mem_loc_result && initialized == VAR_INIT_STATUS_UNINITIALIZED)
@@ -15098,15 +15093,13 @@ loc_list_from_tree (tree loc, int want_address,
 	  return 0;
 	}
 
-#ifdef ENABLE_CHECKING
       /* Otherwise this is a generic code; we should just lists all of
 	 these explicitly.  We forgot one.  */
-      gcc_unreachable ();
-#else
+      gcc_checking_assert (false);
+
       /* In a release build, we want to degrade gracefully: better to
 	 generate incomplete debugging information than to crash.  */
       return NULL;
-#endif
     }
 
   if (!ret && !list_ret)
@@ -19910,18 +19903,17 @@ gen_lexical_block_die (tree stmt, dw_die_ref context_die)
     {
       if (old_die)
 	{
-#ifdef ENABLE_CHECKING
 	  /* This must have been generated early and it won't even
 	     need location information since it's a DW_AT_inline
 	     function.  */
-	  for (dw_die_ref c = context_die; c; c = c->die_parent)
-	    if (c->die_tag == DW_TAG_inlined_subroutine
-		|| c->die_tag == DW_TAG_subprogram)
-	      {
-		gcc_assert (get_AT (c, DW_AT_inline));
-		break;
-	      }
-#endif
+	  if (flag_checking)
+	    for (dw_die_ref c = context_die; c; c = c->die_parent)
+	      if (c->die_tag == DW_TAG_inlined_subroutine
+		  || c->die_tag == DW_TAG_subprogram)
+		{
+		  gcc_assert (get_AT (c, DW_AT_inline));
+		  break;
+		}
 	  return;
 	}
     }
@@ -20738,10 +20730,8 @@ gen_type_die_with_usage (tree type, dw_die_ref context_die,
   if (type == NULL_TREE || type == error_mark_node)
     return;
 
-#ifdef ENABLE_CHECKING
-  if (type)
+  if (flag_checking && type)
      verify_type (type);
-#endif
 
   if (TYPE_NAME (type) != NULL_TREE
       && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
@@ -20935,11 +20925,12 @@ gen_type_die (tree type, dw_die_ref context_die)
   if (type != error_mark_node)
     {
       gen_type_die_with_usage (type, context_die, DINFO_USAGE_DIR_USE);
-#ifdef ENABLE_CHECKING
-      dw_die_ref die = lookup_type_die (type);
-      if (die)
-	check_die (die);
-#endif
+      if (flag_checking)
+	{
+	  dw_die_ref die = lookup_type_die (type);
+	  if (die)
+	    check_die (die);
+	}
     }
 }
 
@@ -21977,11 +21968,12 @@ dwarf2out_decl (tree decl)
 
   gen_decl_die (decl, NULL, context_die);
 
-#ifdef ENABLE_CHECKING
-  dw_die_ref die = lookup_decl_die (decl);
-  if (die)
-    check_die (die);
-#endif
+  if (flag_checking)
+    {
+      dw_die_ref die = lookup_decl_die (decl);
+      if (die)
+	check_die (die);
+    }
 }
 
 /* Write the debugging output for DECL.  */
diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c
index a6ef154..5355cac 100644
--- a/gcc/emit-rtl.c
+++ b/gcc/emit-rtl.c
@@ -2733,8 +2733,7 @@ verify_rtx_sharing (rtx orig, rtx insn)
 
   /* This rtx may not be shared.  If it has already been seen,
      replace it with a copy of itself.  */
-#ifdef ENABLE_CHECKING
-  if (RTX_FLAG (x, used))
+  if (flag_checking && RTX_FLAG (x, used))
     {
       error ("invalid rtl sharing found in the insn");
       debug_rtx (insn);
@@ -2742,7 +2741,6 @@ verify_rtx_sharing (rtx orig, rtx insn)
       debug_rtx (x);
       internal_error ("internal consistency failure");
     }
-#endif
   gcc_assert (!RTX_FLAG (x, used));
 
   RTX_FLAG (x, used) = 1;
@@ -4259,12 +4257,12 @@ delete_insns_since (rtx_insn *from)
 void
 reorder_insns_nobb (rtx_insn *from, rtx_insn *to, rtx_insn *after)
 {
-#ifdef ENABLE_CHECKING
-  rtx_insn *x;
-  for (x = from; x != to; x = NEXT_INSN (x))
-    gcc_assert (after != x);
-  gcc_assert (after != to);
-#endif
+  if (flag_checking)
+    {
+      for (rtx_insn *x = from; x != to; x = NEXT_INSN (x))
+	gcc_assert (after != x);
+      gcc_assert (after != to);
+    }
 
   /* Splice this bunch out of where it is now.  */
   if (PREV_INSN (from))
diff --git a/gcc/et-forest.c b/gcc/et-forest.c
index 4f919d4..bf2f765 100644
--- a/gcc/et-forest.c
+++ b/gcc/et-forest.c
@@ -28,7 +28,7 @@ License along with libiberty; see the file COPYING3.  If not see
 #include "alloc-pool.h"
 #include "et-forest.h"
 
-/* We do not enable this with ENABLE_CHECKING, since it is awfully slow.  */
+/* We do not enable this with CHECKING_P, since it is awfully slow.  */
 #undef DEBUG_ET
 
 #ifdef DEBUG_ET
diff --git a/gcc/except.c b/gcc/except.c
index fed18ee..97a8dc1 100644
--- a/gcc/except.c
+++ b/gcc/except.c
@@ -612,9 +612,8 @@ duplicate_eh_regions (struct function *ifun,
   struct duplicate_eh_regions_data data;
   eh_region outer_region;
 
-#ifdef ENABLE_CHECKING
-  verify_eh_tree (ifun);
-#endif
+  if (flag_checking)
+    verify_eh_tree (ifun);
 
   data.label_map = map;
   data.label_map_data = map_data;
@@ -632,9 +631,8 @@ duplicate_eh_regions (struct function *ifun,
 	duplicate_eh_regions_1 (&data, r, outer_region);
     }
 
-#ifdef ENABLE_CHECKING
-  verify_eh_tree (cfun);
-#endif
+  if (flag_checking)
+    verify_eh_tree (cfun);
 
   return data.eh_map;
 }
@@ -3309,7 +3307,7 @@ debug_eh_tree (struct function *fn)
 
 /* Verify invariants on EH datastructures.  */
 
-DEBUG_FUNCTION void
+void
 verify_eh_tree (struct function *fun)
 {
   eh_region r, outer;
diff --git a/gcc/fwprop.c b/gcc/fwprop.c
index 16c7981..67808bc 100644
--- a/gcc/fwprop.c
+++ b/gcc/fwprop.c
@@ -843,9 +843,7 @@ all_uses_available_at (rtx_insn *def_insn, rtx_insn *target_insn)
 
 \f
 static df_ref *active_defs;
-#ifdef ENABLE_CHECKING
 static sparseset active_defs_check;
-#endif
 
 /* Fill the ACTIVE_DEFS array with the use->def link for the registers
    mentioned in USE_REC.  Register the valid entries in ACTIVE_DEFS_CHECK
@@ -859,9 +857,8 @@ register_active_defs (df_ref use)
       df_ref def = get_def_for_use (use);
       int regno = DF_REF_REGNO (use);
 
-#ifdef ENABLE_CHECKING
-      sparseset_set_bit (active_defs_check, regno);
-#endif
+      if (CHECKING_P)
+	sparseset_set_bit (active_defs_check, regno);
       active_defs[regno] = def;
     }
 }
@@ -876,9 +873,8 @@ register_active_defs (df_ref use)
 static void
 update_df_init (rtx_insn *def_insn, rtx_insn *insn)
 {
-#ifdef ENABLE_CHECKING
-  sparseset_clear (active_defs_check);
-#endif
+  if (CHECKING_P)
+    sparseset_clear (active_defs_check);
   register_active_defs (DF_INSN_USES (def_insn));
   register_active_defs (DF_INSN_USES (insn));
   register_active_defs (DF_INSN_EQ_USES (insn));
@@ -899,9 +895,7 @@ update_uses (df_ref use)
       if (DF_REF_ID (use) >= (int) use_def_ref.length ())
         use_def_ref.safe_grow_cleared (DF_REF_ID (use) + 1);
 
-#ifdef ENABLE_CHECKING
-      gcc_assert (sparseset_bit_p (active_defs_check, regno));
-#endif
+      gcc_checking_assert (sparseset_bit_p (active_defs_check, regno));
       use_def_ref[DF_REF_ID (use)] = active_defs[regno];
     }
 }
@@ -1407,9 +1401,8 @@ fwprop_init (void)
   df_set_flags (DF_DEFER_INSN_RESCAN);
 
   active_defs = XNEWVEC (df_ref, max_reg_num ());
-#ifdef ENABLE_CHECKING
-  active_defs_check = sparseset_alloc (max_reg_num ());
-#endif
+  if (CHECKING_P)
+    active_defs_check = sparseset_alloc (max_reg_num ());
 }
 
 static void
@@ -1419,9 +1412,8 @@ fwprop_done (void)
 
   use_def_ref.release ();
   free (active_defs);
-#ifdef ENABLE_CHECKING
-  sparseset_free (active_defs_check);
-#endif
+  if (CHECKING_P)
+    sparseset_free (active_defs_check);
 
   free_dominance_info (CDI_DOMINATORS);
   cleanup_cfg (0);
diff --git a/gcc/ggc-page.c b/gcc/ggc-page.c
index 34e9e24..1fa8cd1 100644
--- a/gcc/ggc-page.c
+++ b/gcc/ggc-page.c
@@ -2201,12 +2201,11 @@ ggc_collect (void)
 void
 ggc_grow (void)
 {
-#ifndef ENABLE_CHECKING
-  G.allocated_last_gc = MAX (G.allocated_last_gc,
-			     G.allocated);
-#else
-  ggc_collect ();
-#endif
+  if (!CHECKING_P)
+    G.allocated_last_gc = MAX (G.allocated_last_gc,
+			       G.allocated);
+  else
+    ggc_collect ();
   if (!quiet_flag)
     fprintf (stderr, " {GC start %luk} ", (unsigned long) G.allocated / 1024);
 }
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 25a81f6..ff00f5a 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -9314,10 +9314,8 @@ gimplify_body (tree fndecl, bool do_parms)
   pop_gimplify_context (outer_bind);
   gcc_assert (gimplify_ctxp == NULL);
 
-#ifdef ENABLE_CHECKING
-  if (!seen_error ())
+  if (flag_checking && !seen_error ())
     verify_gimple_in_seq (gimple_bind_body (outer_bind));
-#endif
 
   timevar_pop (TV_TREE_GIMPLIFY);
   input_location = saved_location;
@@ -9609,11 +9607,9 @@ gimplify_hasher::equal (const elt_t *p1, const elt_t *p2)
   if (!operand_equal_p (t1, t2, 0))
     return false;
 
-#ifdef ENABLE_CHECKING
   /* Only allow them to compare equal if they also hash equal; otherwise
      results are nondeterminate, and we fail bootstrap comparison.  */
-  gcc_assert (hash (p1) == hash (p2));
-#endif
+  gcc_checking_assert (hash (p1) == hash (p2));
 
   return true;
 }
diff --git a/gcc/graphite-isl-ast-to-gimple.c b/gcc/graphite-isl-ast-to-gimple.c
index 18342d0..a08ba0f 100644
--- a/gcc/graphite-isl-ast-to-gimple.c
+++ b/gcc/graphite-isl-ast-to-gimple.c
@@ -106,10 +106,8 @@ gmp_cst_to_tree (tree type, mpz_t val)
 static inline void
 graphite_verify (void)
 {
-#ifdef ENABLE_CHECKING
-  verify_loop_structure ();
-  verify_loop_closed_ssa (true);
-#endif
+  checking_verify_loop_structure ();
+  checking_verify_loop_closed_ssa (true);
 }
 
 /* IVS_PARAMS maps ISL's scattering and parameter identifiers
diff --git a/gcc/graphite-scop-detection.c b/gcc/graphite-scop-detection.c
index d6a6705..d25d75b 100644
--- a/gcc/graphite-scop-detection.c
+++ b/gcc/graphite-scop-detection.c
@@ -598,21 +598,16 @@ canonicalize_loop_closed_ssa (loop_p loop)
 static void
 canonicalize_loop_closed_ssa_form (void)
 {
-  loop_p loop;
-
-#ifdef ENABLE_CHECKING
-  verify_loop_closed_ssa (true);
-#endif
+  checking_verify_loop_closed_ssa (true);
 
+  loop_p loop;
   FOR_EACH_LOOP (loop, 0)
     canonicalize_loop_closed_ssa (loop);
 
   rewrite_into_loop_closed_ssa (NULL, TODO_update_ssa);
   update_ssa (TODO_update_ssa);
 
-#ifdef ENABLE_CHECKING
-  verify_loop_closed_ssa (true);
-#endif
+  checking_verify_loop_closed_ssa (true);
 }
 
 /* Pretty print to FILE all the SCoPs in DOT format and mark them with
diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c
index 158de1f..774bb0a 100644
--- a/gcc/graphite-sese-to-poly.c
+++ b/gcc/graphite-sese-to-poly.c
@@ -2267,9 +2267,7 @@ rewrite_reductions_out_of_ssa (scop_p scop)
 	}
 
   update_ssa (TODO_update_ssa);
-#ifdef ENABLE_CHECKING
-  verify_loop_closed_ssa (true);
-#endif
+  checking_verify_loop_closed_ssa (true);
 }
 
 /* Rewrite the scalar dependence of DEF used in USE_STMT with a memory
@@ -2448,9 +2446,7 @@ rewrite_cross_bb_scalar_deps_out_of_ssa (scop_p scop)
     {
       scev_reset_htab ();
       update_ssa (TODO_update_ssa);
-#ifdef ENABLE_CHECKING
-      verify_loop_closed_ssa (true);
-#endif
+      checking_verify_loop_closed_ssa (true);
     }
 }
 
diff --git a/gcc/hash-table.h b/gcc/hash-table.h
index 8e3c2ca..192be30 100644
--- a/gcc/hash-table.h
+++ b/gcc/hash-table.h
@@ -638,9 +638,7 @@ hash_table<Descriptor, Allocator>::find_empty_slot_for_expand (hashval_t hash)
 
   if (is_empty (*slot))
     return slot;
-#ifdef ENABLE_CHECKING
   gcc_checking_assert (!is_deleted (*slot));
-#endif
 
   hash2 = hash_table_mod2 (hash, m_size_prime_index);
   for (;;)
@@ -652,9 +650,7 @@ hash_table<Descriptor, Allocator>::find_empty_slot_for_expand (hashval_t hash)
       slot = m_entries + index;
       if (is_empty (*slot))
         return slot;
-#ifdef ENABLE_CHECKING
       gcc_checking_assert (!is_deleted (*slot));
-#endif
     }
 }
 
diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c
index d0ae494..ca53755 100644
--- a/gcc/ifcvt.c
+++ b/gcc/ifcvt.c
@@ -5093,9 +5093,7 @@ if_convert (bool after_combine)
   if (optimize == 1)
     df_remove_problem (df_live);
 
-#ifdef ENABLE_CHECKING
-  verify_flow_info ();
-#endif
+  checking_verify_flow_info ();
 }
 \f
 /* If-conversion and CFG cleanup.  */
diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c
index 69a181d..93e279c 100644
--- a/gcc/ipa-cp.c
+++ b/gcc/ipa-cp.c
@@ -1063,7 +1063,7 @@ ipa_context_from_jfunc (ipa_node_params *info, cgraph_edge *cs, int csidx,
    bottom, not containing a variable component and without any known value at
    the same time.  */
 
-DEBUG_FUNCTION void
+void
 ipcp_verify_propagated_values (void)
 {
   struct cgraph_node *node;
@@ -2816,9 +2816,8 @@ ipcp_propagate_stage (struct ipa_topo_info *topo)
 	     overall_size, max_new_size);
 
   propagate_constants_topo (topo);
-#ifdef ENABLE_CHECKING
-  ipcp_verify_propagated_values ();
-#endif
+  if (flag_checking)
+    ipcp_verify_propagated_values ();
   topo->constants.propagate_effects ();
   topo->contexts.propagate_effects ();
 
diff --git a/gcc/ipa-devirt.c b/gcc/ipa-devirt.c
index a7a8e8e..69dec05 100644
--- a/gcc/ipa-devirt.c
+++ b/gcc/ipa-devirt.c
@@ -272,11 +272,10 @@ type_in_anonymous_namespace_p (const_tree t)
     {
       /* C++ FE uses magic <anon> as assembler names of anonymous types.
  	 verify that this match with type_in_anonymous_namespace_p.  */
-#ifdef ENABLE_CHECKING
       if (in_lto_p)
-	gcc_assert (!strcmp ("<anon>",
-		    IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (TYPE_NAME (t)))));
-#endif
+	gcc_checking_assert (!strcmp ("<anon>",
+				      IDENTIFIER_POINTER
+					(DECL_ASSEMBLER_NAME (TYPE_NAME (t)))));
       return true;
     }
   return false;
@@ -300,15 +299,13 @@ odr_type_p (const_tree t)
   if (TYPE_NAME (t) && TREE_CODE (TYPE_NAME (t)) == TYPE_DECL
       && (DECL_ASSEMBLER_NAME_SET_P (TYPE_NAME (t))))
     {
-#ifdef ENABLE_CHECKING
       /* C++ FE uses magic <anon> as assembler names of anonymous types.
  	 verify that this match with type_in_anonymous_namespace_p.  */
-      gcc_assert (!type_with_linkage_p (t)
-		  || strcmp ("<anon>",
-			     IDENTIFIER_POINTER
-			        (DECL_ASSEMBLER_NAME (TYPE_NAME (t))))
-		  || type_in_anonymous_namespace_p (t));
-#endif
+      gcc_checking_assert (!type_with_linkage_p (t)
+			   || strcmp ("<anon>",
+				      IDENTIFIER_POINTER
+					(DECL_ASSEMBLER_NAME (TYPE_NAME (t))))
+			   || type_in_anonymous_namespace_p (t));
       return true;
     }
   return false;
@@ -1777,11 +1774,10 @@ odr_types_equivalent_p (tree t1, tree t2, bool warn, bool *warned,
 bool
 odr_types_equivalent_p (tree type1, tree type2)
 {
-  hash_set<type_pair> visited;
+  gcc_checking_assert (odr_or_derived_type_p (type1)
+		       && odr_or_derived_type_p (type2));
 
-#ifdef ENABLE_CHECKING
-  gcc_assert (odr_or_derived_type_p (type1) && odr_or_derived_type_p (type2));
-#endif
+  hash_set<type_pair> visited;
   return odr_types_equivalent_p (type1, type2, false, NULL,
 			         &visited, UNKNOWN_LOCATION, UNKNOWN_LOCATION);
 }
@@ -2000,8 +1996,8 @@ add_type_duplicate (odr_type val, tree type)
     }
   gcc_assert (val->odr_violated || !odr_must_violate);
   /* Sanity check that all bases will be build same way again.  */
-#ifdef ENABLE_CHECKING
-  if (COMPLETE_TYPE_P (type) && COMPLETE_TYPE_P (val->type)
+  if (flag_checking
+      && COMPLETE_TYPE_P (type) && COMPLETE_TYPE_P (val->type)
       && TREE_CODE (val->type) == RECORD_TYPE
       && TREE_CODE (type) == RECORD_TYPE
       && TYPE_BINFO (val->type) && TYPE_BINFO (type)
@@ -2030,7 +2026,6 @@ add_type_duplicate (odr_type val, tree type)
 	    j++;
 	  }
     }
-#endif
 
 
   /* Regularize things a little.  During LTO same types may come with
@@ -2136,8 +2131,8 @@ get_odr_type (tree type, bool insert)
       if (slot && *slot)
 	{
 	  val = *slot;
-#ifdef ENABLE_CHECKING
-	  if (in_lto_p && can_be_vtable_hashed_p (type))
+	  if (flag_checking
+	      && in_lto_p && can_be_vtable_hashed_p (type))
 	    {
 	      hash = hash_odr_vtable (type);
 	      vtable_slot = odr_vtable_hash->find_slot_with_hash (type, hash,
@@ -2145,7 +2140,6 @@ get_odr_type (tree type, bool insert)
 	      gcc_assert (!vtable_slot || *vtable_slot == *slot);
 	      vtable_slot = NULL;
 	    }
-#endif
 	}
       else if (*vtable_slot)
 	val = *vtable_slot;
diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c
index d39a3c1..9412e71 100644
--- a/gcc/ipa-icf.c
+++ b/gcc/ipa-icf.c
@@ -2982,7 +2982,9 @@ sem_item_optimizer::subdivide_classes_by_sensitive_refs ()
 void
 sem_item_optimizer::verify_classes (void)
 {
-#if ENABLE_CHECKING
+  if (!flag_checking)
+    return;
+
   for (hash_table <congruence_class_group_hash>::iterator it = m_classes.begin ();
        it != m_classes.end (); ++it)
     {
@@ -2990,26 +2992,25 @@ sem_item_optimizer::verify_classes (void)
 	{
 	  congruence_class *cls = (*it)->classes[i];
 
-	  gcc_checking_assert (cls);
-	  gcc_checking_assert (cls->members.length () > 0);
+	  gcc_assert (cls);
+	  gcc_assert (cls->members.length () > 0);
 
 	  for (unsigned int j = 0; j < cls->members.length (); j++)
 	    {
 	      sem_item *item = cls->members[j];
 
-	      gcc_checking_assert (item);
-	      gcc_checking_assert (item->cls == cls);
+	      gcc_assert (item);
+	      gcc_assert (item->cls == cls);
 
 	      for (unsigned k = 0; k < item->usages.length (); k++)
 		{
 		  sem_usage_pair *usage = item->usages[k];
-		  gcc_checking_assert (usage->item->index_in_class <
-				       usage->item->cls->members.length ());
+		  gcc_assert (usage->item->index_in_class <
+			      usage->item->cls->members.length ());
 		}
 	    }
 	}
     }
-#endif
 }
 
 /* Disposes split map traverse function. CLS_PTR is pointer to congruence
@@ -3054,10 +3055,11 @@ sem_item_optimizer::traverse_congruence_split (congruence_class * const &cls,
 	  add_item_to_class (tc, cls->members[i]);
 	}
 
-#ifdef ENABLE_CHECKING
-      for (unsigned int i = 0; i < 2; i++)
-	gcc_checking_assert (newclasses[i]->members.length ());
-#endif
+      if (flag_checking)
+	{
+	  for (unsigned int i = 0; i < 2; i++)
+	    gcc_assert (newclasses[i]->members.length ());
+	}
 
       if (splitter_cls == cls)
 	optimizer->splitter_class_removed = true;
@@ -3152,11 +3154,9 @@ sem_item_optimizer::do_congruence_step_for_index (congruence_class *cls,
 	  else
 	    b = *slot;
 
-#if ENABLE_CHECKING
 	  gcc_checking_assert (usage->item->cls);
 	  gcc_checking_assert (usage->item->index_in_class <
 			       usage->item->cls->members.length ());
-#endif
 
 	  bitmap_set_bit (b, usage->item->index_in_class);
 	}
diff --git a/gcc/ipa-inline-analysis.c b/gcc/ipa-inline-analysis.c
index 108ff3e..7718d2d 100644
--- a/gcc/ipa-inline-analysis.c
+++ b/gcc/ipa-inline-analysis.c
@@ -2956,10 +2956,12 @@ compute_inline_parameters (struct cgraph_node *node, bool early)
   info->size = info->self_size;
   info->stack_frame_offset = 0;
   info->estimated_stack_size = info->estimated_self_stack_size;
-#ifdef ENABLE_CHECKING
-  inline_update_overall_summary (node);
-  gcc_assert (info->time == info->self_time && info->size == info->self_size);
-#endif
+  if (flag_checking)
+    {
+      inline_update_overall_summary (node);
+      gcc_assert (info->time == info->self_time
+		  && info->size == info->self_size);
+    }
 
   pop_cfun ();
 }
diff --git a/gcc/ipa-inline-transform.c b/gcc/ipa-inline-transform.c
index 12f701a..1d7bcaa 100644
--- a/gcc/ipa-inline-transform.c
+++ b/gcc/ipa-inline-transform.c
@@ -491,10 +491,9 @@ save_inline_function_body (struct cgraph_node *node)
       first_clone->remove_symbol_and_inline_clones ();
       first_clone = NULL;
     }
-#ifdef ENABLE_CHECKING
-  else
+  else if (flag_checking)
     first_clone->verify ();
-#endif
+
   return first_clone;
 }
 
diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c
index 8f3919c..db98755 100644
--- a/gcc/ipa-inline.c
+++ b/gcc/ipa-inline.c
@@ -1878,7 +1878,7 @@ inline_small_functions (void)
       if (!edge->inline_failed || !edge->callee->analyzed)
 	continue;
 
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
       /* Be sure that caches are maintained consistent.  */
       sreal cached_badness = edge_badness (edge, false);
  
@@ -2632,9 +2632,8 @@ early_inliner (function *fun)
   if (ipa_node_params_sum)
     return 0;
 
-#ifdef ENABLE_CHECKING
-  node->verify ();
-#endif
+  if (flag_checking)
+    node->verify ();
   node->remove_all_references ();
 
   /* Rebuild this reference because it dosn't depend on
diff --git a/gcc/ipa-inline.h b/gcc/ipa-inline.h
index 85041f6..323d117 100644
--- a/gcc/ipa-inline.h
+++ b/gcc/ipa-inline.h
@@ -299,10 +299,8 @@ estimate_edge_size (struct cgraph_edge *edge)
 static inline int
 estimate_edge_growth (struct cgraph_edge *edge)
 {
-#ifdef ENABLE_CHECKING
   gcc_checking_assert (inline_edge_summary (edge)->call_stmt_size
 		       || !edge->callee->analyzed);
-#endif
   return (estimate_edge_size (edge)
 	  - inline_edge_summary (edge)->call_stmt_size);
 }
diff --git a/gcc/ipa-visibility.c b/gcc/ipa-visibility.c
index 93073d8..0ae4388 100644
--- a/gcc/ipa-visibility.c
+++ b/gcc/ipa-visibility.c
@@ -464,16 +464,15 @@ function_and_variable_visibility (bool whole_program)
 	 what comdat group they are in when they won't be emitted in this TU.  */
       if (node->same_comdat_group && DECL_EXTERNAL (node->decl))
 	{
-#ifdef ENABLE_CHECKING
-	  symtab_node *n;
-
-	  for (n = node->same_comdat_group;
-	       n != node;
-	       n = n->same_comdat_group)
-	      /* If at least one of same comdat group functions is external,
-		 all of them have to be, otherwise it is a front-end bug.  */
-	      gcc_assert (DECL_EXTERNAL (n->decl));
-#endif
+	  if (flag_checking)
+	    {
+	      for (symtab_node *n = node->same_comdat_group;
+		   n != node;
+		   n = n->same_comdat_group)
+		/* If at least one of same comdat group functions is external,
+		   all of them have to be, otherwise it is a front-end bug.  */
+		gcc_assert (DECL_EXTERNAL (n->decl));
+	    }
 	  node->dissolve_same_comdat_group_list ();
 	}
       gcc_assert ((!DECL_WEAK (node->decl)
diff --git a/gcc/ipa.c b/gcc/ipa.c
index 6847305..6dc23ae 100644
--- a/gcc/ipa.c
+++ b/gcc/ipa.c
@@ -319,12 +319,13 @@ symbol_table::remove_unreachable_nodes (FILE *file)
   build_type_inheritance_graph ();
   if (file)
     fprintf (file, "\nReclaiming functions:");
-#ifdef ENABLE_CHECKING
-  FOR_EACH_FUNCTION (node)
-    gcc_assert (!node->aux);
-  FOR_EACH_VARIABLE (vnode)
-    gcc_assert (!vnode->aux);
-#endif
+  if (flag_checking)
+    {
+      FOR_EACH_FUNCTION (node)
+	gcc_assert (!node->aux);
+      FOR_EACH_VARIABLE (vnode)
+	gcc_assert (!vnode->aux);
+    }
   /* Mark functions whose bodies are obviously needed.
      This is mostly when they can be referenced externally.  Inline clones
      are special since their declarations are shared with master clone and thus
@@ -678,9 +679,7 @@ symbol_table::remove_unreachable_nodes (FILE *file)
   if (file)
     fprintf (file, "\n");
 
-#ifdef ENABLE_CHECKING
-  symtab_node::verify_symtab_nodes ();
-#endif
+  symtab_node::checking_verify_symtab_nodes ();
 
   /* If we removed something, perhaps profile could be improved.  */
   if (changed && optimize && inline_edge_summary_vec.exists ())
@@ -1370,13 +1369,12 @@ ipa_single_use (void)
     {
       if (var->aux != BOTTOM)
 	{
-#ifdef ENABLE_CHECKING
 	  /* Not having the single user known means that the VAR is
 	     unreachable.  Either someone forgot to remove unreachable
 	     variables or the reachability here is wrong.  */
 
-          gcc_assert (single_user_map.get (var));
-#endif
+	  gcc_checking_assert (single_user_map.get (var));
+
 	  if (dump_file)
 	    {
 	      fprintf (dump_file, "Variable %s/%i is used by single function\n",
diff --git a/gcc/ira-int.h b/gcc/ira-int.h
index af6c92f..d4160d3 100644
--- a/gcc/ira-int.h
+++ b/gcc/ira-int.h
@@ -26,7 +26,7 @@ along with GCC; see the file COPYING3.  If not see
 /* To provide consistency in naming, all IRA external variables,
    functions, common typedefs start with prefix ira_.  */
 
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
 #define ENABLE_IRA_CHECKING
 #endif
 
diff --git a/gcc/ira.c b/gcc/ira.c
index 28517c1..88c297e 100644
--- a/gcc/ira.c
+++ b/gcc/ira.c
@@ -5152,9 +5152,9 @@ ira (FILE *f)
     df_remove_problem (df_live);
   gcc_checking_assert (df_live == NULL);
 
-#ifdef ENABLE_CHECKING
-  df->changeable_flags |= DF_VERIFY_SCHEDULED;
-#endif
+  if (flag_checking)
+    df->changeable_flags |= DF_VERIFY_SCHEDULED;
+
   df_analyze ();
 
   init_reg_equiv ();
diff --git a/gcc/loop-doloop.c b/gcc/loop-doloop.c
index 6554597..592ae1f 100644
--- a/gcc/loop-doloop.c
+++ b/gcc/loop-doloop.c
@@ -734,7 +734,5 @@ doloop_optimize_loops (void)
 
   iv_analysis_done ();
 
-#ifdef ENABLE_CHECKING
-  verify_loop_structure ();
-#endif
+  checking_verify_loop_structure ();
 }
diff --git a/gcc/loop-init.c b/gcc/loop-init.c
index a9a3d6fa..9c545df 100644
--- a/gcc/loop-init.c
+++ b/gcc/loop-init.c
@@ -104,10 +104,8 @@ loop_optimizer_init (unsigned flags)
       /* Ensure that the dominators are computed, like flow_loops_find does.  */
       calculate_dominance_info (CDI_DOMINATORS);
 
-#ifdef ENABLE_CHECKING
       if (!needs_fixup)
-	verify_loop_structure ();
-#endif
+	checking_verify_loop_structure ();
 
       /* Clear all flags.  */
       if (recorded_exits)
@@ -129,9 +127,7 @@ loop_optimizer_init (unsigned flags)
   /* Dump loops.  */
   flow_loops_dump (dump_file, NULL, 1);
 
-#ifdef ENABLE_CHECKING
-  verify_loop_structure ();
-#endif
+  checking_verify_loop_structure ();
 
   timevar_pop (TV_LOOP_INIT);
 }
@@ -325,9 +321,7 @@ fix_loop_structure (bitmap changed_bbs)
   /* Apply flags to loops.  */
   apply_loop_flags (current_loops->state | record_exits);
 
-#ifdef ENABLE_CHECKING
-  verify_loop_structure ();
-#endif
+  checking_verify_loop_structure ();
 
   timevar_pop (TV_LOOP_INIT);
 
diff --git a/gcc/loop-invariant.c b/gcc/loop-invariant.c
index 52c8ae8..e7c6cb4 100644
--- a/gcc/loop-invariant.c
+++ b/gcc/loop-invariant.c
@@ -2096,7 +2096,5 @@ move_loop_invariants (void)
   invariant_table = NULL;
   invariant_table_size = 0;
 
-#ifdef ENABLE_CHECKING
-  verify_flow_info ();
-#endif
+  checking_verify_flow_info ();
 }
diff --git a/gcc/lra-assigns.c b/gcc/lra-assigns.c
index 2986f57..941a829 100644
--- a/gcc/lra-assigns.c
+++ b/gcc/lra-assigns.c
@@ -1591,7 +1591,7 @@ lra_assign (void)
   bitmap_initialize (&all_spilled_pseudos, &reg_obstack);
   create_live_range_start_chains ();
   setup_live_pseudos_and_spill_after_risky_transforms (&all_spilled_pseudos);
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
   if (!flag_ipa_ra)
     for (i = FIRST_PSEUDO_REGISTER; i < max_regno; i++)
       if (lra_reg_info[i].nrefs != 0 && reg_renumber[i] >= 0
diff --git a/gcc/lra-constraints.c b/gcc/lra-constraints.c
index 2c27f1a..c70b018 100644
--- a/gcc/lra-constraints.c
+++ b/gcc/lra-constraints.c
@@ -4454,8 +4454,7 @@ lra_constraints (bool first_p)
   bitmap_clear (&equiv_insn_bitmap);
   /* If we used a new hard regno, changed_p should be true because the
      hard reg is assigned to a new pseudo.  */
-#ifdef ENABLE_CHECKING
-  if (! changed_p)
+  if (flag_checking && !changed_p)
     {
       for (i = FIRST_PSEUDO_REGISTER; i < new_regno_start; i++)
 	if (lra_reg_info[i].nrefs != 0
@@ -4467,7 +4466,6 @@ lra_constraints (bool first_p)
 	      lra_assert (df_regs_ever_live_p (hard_regno + j));
 	  }
     }
-#endif
   return changed_p;
 }
 
diff --git a/gcc/lra-eliminations.c b/gcc/lra-eliminations.c
index fdf4179..448e645 100644
--- a/gcc/lra-eliminations.c
+++ b/gcc/lra-eliminations.c
@@ -1436,11 +1436,11 @@ lra_eliminate (bool final_p, bool first_p)
   bitmap_initialize (&insns_with_changed_offsets, &reg_obstack);
   if (final_p)
     {
-#ifdef ENABLE_CHECKING
-      update_reg_eliminate (&insns_with_changed_offsets);
-      if (! bitmap_empty_p (&insns_with_changed_offsets))
-	gcc_unreachable ();
-#endif
+      if (flag_checking)
+	{
+	  update_reg_eliminate (&insns_with_changed_offsets);
+	  gcc_assert (bitmap_empty_p (&insns_with_changed_offsets));
+	}
       /* We change eliminable hard registers in insns so we should do
 	 this for all insns containing any eliminable hard
 	 register.  */
diff --git a/gcc/lra-int.h b/gcc/lra-int.h
index 5e78604..570f210 100644
--- a/gcc/lra-int.h
+++ b/gcc/lra-int.h
@@ -91,7 +91,7 @@ struct lra_reg
   /* True if the pseudo should not be assigned to a stack register.  */
   bool no_stack_p;
 #endif
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
   /* True if the pseudo crosses a call.	 It is setup in lra-lives.c
      and used to check that the pseudo crossing a call did not get a
      call used hard register.  */
diff --git a/gcc/lra-lives.c b/gcc/lra-lives.c
index 253bc18..cf7bc2c 100644
--- a/gcc/lra-lives.c
+++ b/gcc/lra-lives.c
@@ -590,7 +590,7 @@ check_pseudos_live_through_calls (int regno)
   for (hr = 0; hr < FIRST_PSEUDO_REGISTER; hr++)
     if (HARD_REGNO_CALL_PART_CLOBBERED (hr, PSEUDO_REGNO_MODE (regno)))
       SET_HARD_REG_BIT (lra_reg_info[regno].conflict_hard_regs, hr);
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
   lra_reg_info[regno].call_p = true;
 #endif
   if (! sparseset_bit_p (pseudos_live_through_setjumps, regno))
@@ -1229,7 +1229,7 @@ lra_create_live_ranges_1 (bool all_p, bool dead_insn_p)
 	lra_reg_info[i].biggest_mode = GET_MODE (regno_reg_rtx[i]);
       else
 	lra_reg_info[i].biggest_mode = VOIDmode;
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
       lra_reg_info[i].call_p = false;
 #endif
       if (i >= FIRST_PSEUDO_REGISTER
diff --git a/gcc/lra-remat.c b/gcc/lra-remat.c
index 66532b8..68ce502 100644
--- a/gcc/lra-remat.c
+++ b/gcc/lra-remat.c
@@ -578,10 +578,8 @@ create_remat_bb_data (void)
 			   last_basic_block_for_fn (cfun));
   FOR_ALL_BB_FN (bb, cfun)
     {
-#ifdef ENABLE_CHECKING
-      if (bb->index < 0 || bb->index >= last_basic_block_for_fn (cfun))
-	abort ();
-#endif
+      gcc_checking_assert (bb->index >= 0
+			   && bb->index < last_basic_block_for_fn (cfun));
       bb_info = get_remat_bb_data (bb);
       bb_info->bb = bb;
       bitmap_initialize (&bb_info->changed_regs, &reg_obstack);
diff --git a/gcc/lra.c b/gcc/lra.c
index bdbfe51..cf08c27 100644
--- a/gcc/lra.c
+++ b/gcc/lra.c
@@ -1198,30 +1198,22 @@ lra_update_insn_recog_data (rtx_insn *insn)
 	  decode_asm_operands (PATTERN (insn), NULL,
 			       data->operand_loc,
 			       constraints, operand_mode, NULL);
-#ifdef ENABLE_CHECKING
-	  {
-	    int i;
 
-	    for (i = 0; i < nop; i++)
+	  if (flag_checking)
+	    for (int i = 0; i < nop; i++)
 	      lra_assert
 		(insn_static_data->operand[i].mode == operand_mode[i]
 		 && insn_static_data->operand[i].constraint == constraints[i]
 		 && ! insn_static_data->operand[i].is_operator);
-	  }
-#endif
 	}
-#ifdef ENABLE_CHECKING
-      {
-	int i;
 
-	for (i = 0; i < insn_static_data->n_operands; i++)
+      if (flag_checking)
+	for (int i = 0; i < insn_static_data->n_operands; i++)
 	  lra_assert
 	    (insn_static_data->operand[i].type
 	     == (insn_static_data->operand[i].constraint[0] == '=' ? OP_OUT
 		 : insn_static_data->operand[i].constraint[0] == '+' ? OP_INOUT
 		 : OP_IN));
-      }
-#endif
     }
   else
     {
@@ -2003,8 +1995,6 @@ restore_scratches (void)
 
 \f
 
-#ifdef ENABLE_CHECKING
-
 /* Function checks RTL for correctness.	 If FINAL_P is true, it is
    done at the end of LRA and the check is more rigorous.  */
 static void
@@ -2023,9 +2013,7 @@ check_rtl (bool final_p)
       {
 	if (final_p)
 	  {
-#ifdef ENABLED_CHECKING
 	    extract_constrain_insn (insn);
-#endif
 	    continue;
 	  }
 	/* LRA code is based on assumption that all addresses can be
@@ -2038,7 +2026,6 @@ check_rtl (bool final_p)
 	  fatal_insn_not_found (insn);
       }
 }
-#endif /* #ifdef ENABLE_CHECKING */
 
 /* Determine if the current function has an exception receiver block
    that reaches the exit block via non-exceptional edges  */
@@ -2232,10 +2219,9 @@ lra (FILE *f)
 
   init_insn_recog_data ();
 
-#ifdef ENABLE_CHECKING
   /* Some quick check on RTL generated by previous passes.  */
-  check_rtl (false);
-#endif
+  if (flag_checking)
+    check_rtl (/*final_p=*/false);
 
   lra_in_progress = 1;
 
@@ -2436,9 +2422,8 @@ lra (FILE *f)
      by this, so unshare everything here.  */
   unshare_all_rtl_again (get_insns ());
 
-#ifdef ENABLE_CHECKING
-  check_rtl (true);
-#endif
+  if (flag_checking)
+    check_rtl (/*final_p=*/true);
 
   timevar_pop (TV_LRA);
 }
diff --git a/gcc/lto-cgraph.c b/gcc/lto-cgraph.c
index 51f31c8..eb6f7b6 100644
--- a/gcc/lto-cgraph.c
+++ b/gcc/lto-cgraph.c
@@ -1560,10 +1560,11 @@ input_cgraph_1 (struct lto_file_decl_data *file_data,
   lto_input_toplevel_asms (file_data, order_base);
 
   /* AUX pointers should be all non-zero for function nodes read from the stream.  */
-#ifdef ENABLE_CHECKING
-  FOR_EACH_VEC_ELT (nodes, i, node)
-    gcc_assert (node->aux || !is_a <cgraph_node *> (node));
-#endif
+  if (flag_checking)
+    {
+      FOR_EACH_VEC_ELT (nodes, i, node)
+	gcc_assert (node->aux || !is_a <cgraph_node *> (node));
+    }
   FOR_EACH_VEC_ELT (nodes, i, node)
     {
       int ref;
diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c
index 11daf7a..8fc7e95 100644
--- a/gcc/lto-streamer-out.c
+++ b/gcc/lto-streamer-out.c
@@ -607,17 +607,12 @@ DFS::DFS (struct output_block *ob, tree expr, bool ref_p, bool this_ref_p,
 		std::swap (sccstack[first + i],
 			   sccstack[first + entry_start + i]);
 
-	      if (scc_entry_len == 1)
-		; /* We already sorted SCC deterministically in hash_scc.  */
-	      else
-		/* Check that we have only one SCC.
-		   Naturally we may have conflicts if hash function is not
- 		   strong enough.  Lets see how far this gets.  */
-		{
-#ifdef ENABLE_CHECKING
-		  gcc_unreachable ();
-#endif
-		}
+	      /* We already sorted SCC deterministically in hash_scc.  */
+
+	      /* Check that we have only one SCC.
+		 Naturally we may have conflicts if hash function is not
+		 strong enough.  Lets see how far this gets.  */
+	      gcc_checking_assert (scc_entry_len == 1);
 	    }
 
 	  /* Write LTO_tree_scc.  */
@@ -2277,7 +2272,7 @@ void
 lto_output (void)
 {
   struct lto_out_decl_state *decl_state;
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
   bitmap output = lto_bitmap_alloc ();
 #endif
   int i, n_nodes;
@@ -2296,7 +2291,7 @@ lto_output (void)
 	  if (lto_symtab_encoder_encode_body_p (encoder, node)
 	      && !node->alias)
 	    {
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
 	      gcc_assert (!bitmap_bit_p (output, DECL_UID (node->decl)));
 	      bitmap_set_bit (output, DECL_UID (node->decl));
 #endif
@@ -2326,7 +2321,7 @@ lto_output (void)
 	      && !node->alias)
 	    {
 	      timevar_push (TV_IPA_LTO_CTORS_OUT);
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
 	      gcc_assert (!bitmap_bit_p (output, DECL_UID (node->decl)));
 	      bitmap_set_bit (output, DECL_UID (node->decl));
 #endif
@@ -2353,7 +2348,7 @@ lto_output (void)
 
   output_offload_tables ();
 
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
   lto_bitmap_free (output);
 #endif
 }
diff --git a/gcc/lto-streamer.c b/gcc/lto-streamer.c
index b34ab8b..92b313a 100644
--- a/gcc/lto-streamer.c
+++ b/gcc/lto-streamer.c
@@ -297,13 +297,12 @@ static hash_table<tree_hash_entry> *tree_htab;
 void
 lto_streamer_init (void)
 {
-#ifdef ENABLE_CHECKING
   /* Check that all the TS_* handled by the reader and writer routines
      match exactly the structures defined in treestruct.def.  When a
      new TS_* astructure is added, the streamer should be updated to
      handle it.  */
-  streamer_check_handled_ts_structures ();
-#endif
+  if (flag_checking)
+    streamer_check_handled_ts_structures ();
 
 #ifdef LTO_STREAMER_DEBUG
   tree_htab = new hash_table<tree_hash_entry> (31);
diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c
index 4bb0aaf..fbc8f96 100644
--- a/gcc/lto/lto.c
+++ b/gcc/lto/lto.c
@@ -1583,19 +1583,18 @@ unify_scc (struct data_in *data_in, unsigned from,
 	  num_sccs_merged++;
 	  total_scc_size_merged += len;
 
-#ifdef ENABLE_CHECKING
-	  for (unsigned i = 0; i < len; ++i)
-	    {
-	      tree t = map[2*i+1];
-	      enum tree_code code = TREE_CODE (t);
-	      /* IDENTIFIER_NODEs should be singletons and are merged by the
-		 streamer.  The others should be singletons, too, and we
-		 should not merge them in any way.  */
-	      gcc_assert (code != TRANSLATION_UNIT_DECL
-			  && code != IDENTIFIER_NODE
-			  && !streamer_handle_as_builtin_p (t));
-	    }
-#endif
+	  if (flag_checking)
+	    for (unsigned i = 0; i < len; ++i)
+	      {
+		tree t = map[2*i+1];
+		enum tree_code code = TREE_CODE (t);
+		/* IDENTIFIER_NODEs should be singletons and are merged by the
+		   streamer.  The others should be singletons, too, and we
+		   should not merge them in any way.  */
+		gcc_assert (code != TRANSLATION_UNIT_DECL
+			    && code != IDENTIFIER_NODE
+			    && !streamer_handle_as_builtin_p (t));
+	      }
 
 	  /* Fixup the streamer cache with the prevailing nodes according
 	     to the tree node mapping computed by compare_tree_sccs.  */
@@ -2633,10 +2632,8 @@ lto_fixup_state (struct lto_in_decl_state *state)
       for (i = 0; i < vec_safe_length (trees); i++)
 	{
 	  tree t = (*trees)[i];
-#ifdef ENABLE_CHECKING
-	  if (TYPE_P (t))
+	  if (CHECKING_P && TYPE_P (t))
 	    verify_type (t);
-#endif
 	  if (VAR_OR_FUNCTION_DECL_P (t)
 	      && (TREE_PUBLIC (t) || DECL_EXTERNAL (t)))
 	    (*trees)[i] = lto_symtab_prevailing_decl (t);
@@ -3098,9 +3095,8 @@ do_whole_program_analysis (void)
       fprintf (symtab->dump_file, "Optimized ");
       symtab_node::dump_table (symtab->dump_file);
     }
-#ifdef ENABLE_CHECKING
-  symtab_node::verify_symtab_nodes ();
-#endif
+
+  symtab_node::checking_verify_symtab_nodes ();
   bitmap_obstack_release (NULL);
 
   /* We are about to launch the final LTRANS phase, stop the WPA timer.  */
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index cdcf9d6..8b30dc1 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -2681,14 +2681,14 @@ scan_omp_target (gomp_target *stmt, omp_context *outer_ctx)
     {
       TYPE_FIELDS (ctx->record_type)
 	= nreverse (TYPE_FIELDS (ctx->record_type));
-#ifdef ENABLE_CHECKING
-      tree field;
-      unsigned int align = DECL_ALIGN (TYPE_FIELDS (ctx->record_type));
-      for (field = TYPE_FIELDS (ctx->record_type);
-	   field;
-	   field = DECL_CHAIN (field))
-	gcc_assert (DECL_ALIGN (field) == align);
-#endif
+      if (flag_checking)
+	{
+	  unsigned int align = DECL_ALIGN (TYPE_FIELDS (ctx->record_type));
+	  for (tree field = TYPE_FIELDS (ctx->record_type);
+	       field;
+	       field = DECL_CHAIN (field))
+	    gcc_assert (DECL_ALIGN (field) == align);
+	}
       layout_type (ctx->record_type);
       if (offloaded)
 	fixup_child_record_type (ctx);
@@ -5623,10 +5623,8 @@ expand_omp_taskreg (struct omp_region *region)
 	}
       if (gimple_in_ssa_p (cfun))
 	update_ssa (TODO_update_ssa);
-#ifdef ENABLE_CHECKING
-      if (!loops_state_satisfies_p (LOOPS_NEED_FIXUP))
+      if (flag_checking && !loops_state_satisfies_p (LOOPS_NEED_FIXUP))
 	verify_loop_structure ();
-#endif
       pop_cfun ();
     }
 
@@ -9186,10 +9184,8 @@ expand_omp_target (struct omp_region *region)
 	  if (changed)
 	    cleanup_tree_cfg ();
 	}
-#ifdef ENABLE_CHECKING
-      if (!loops_state_satisfies_p (LOOPS_NEED_FIXUP))
+      if (flag_checking && !loops_state_satisfies_p (LOOPS_NEED_FIXUP))
 	verify_loop_structure ();
-#endif
       pop_cfun ();
     }
 
@@ -9698,10 +9694,8 @@ execute_expand_omp (void)
 
   expand_omp (root_omp_region);
 
-#ifdef ENABLE_CHECKING
-  if (!loops_state_satisfies_p (LOOPS_NEED_FIXUP))
+  if (flag_checking && !loops_state_satisfies_p (LOOPS_NEED_FIXUP))
     verify_loop_structure ();
-#endif
   cleanup_tree_cfg ();
 
   free_omp_regions ();
@@ -11461,7 +11455,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx)
       default:
 	break;
       case OMP_CLAUSE_MAP:
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
 	/* First check what we're prepared to handle in the following.  */
 	switch (OMP_CLAUSE_MAP_KIND (c))
 	  {
diff --git a/gcc/passes.c b/gcc/passes.c
index 5b41102..010af1d 100644
--- a/gcc/passes.c
+++ b/gcc/passes.c
@@ -1955,9 +1955,8 @@ execute_function_todo (function *fn, void *data)
 
   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 (flag_checking && !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);
 
@@ -1991,7 +1990,6 @@ execute_function_todo (function *fn, void *data)
       /* 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;
@@ -2011,11 +2009,10 @@ execute_function_todo (function *fn, void *data)
 static void
 execute_todo (unsigned int flags)
 {
-#if defined ENABLE_CHECKING
-  if (cfun
+  if (flag_checking
+      && cfun
       && need_ssa_update_p (cfun))
     gcc_assert (flags & TODO_update_ssa_any);
-#endif
 
   timevar_push (TV_TODO);
 
@@ -2074,14 +2071,12 @@ clear_last_verified (function *fn, void *data ATTRIBUTE_UNUSED)
 /* Helper function. Verify that the properties has been turn into the
    properties expected by the pass.  */
 
-#ifdef ENABLE_CHECKING
-static void
+static void DEBUG_FUNCTION
 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.  */
@@ -2329,10 +2324,9 @@ execute_one_pass (opt_pass *pass)
   /* 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 (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)
diff --git a/gcc/predict.c b/gcc/predict.c
index 0b3016c..0fe2eb5 100644
--- a/gcc/predict.c
+++ b/gcc/predict.c
@@ -2205,8 +2205,6 @@ tree_bb_level_predictions (void)
     }
 }
 
-#ifdef ENABLE_CHECKING
-
 /* Callback for hash_map::traverse, asserts that the pointer map is
    empty.  */
 
@@ -2217,7 +2215,6 @@ assert_is_empty (const_basic_block const &, edge_prediction *const &value,
   gcc_assert (!value);
   return false;
 }
-#endif
 
 /* Predict branch probabilities and estimate profile for basic block BB.  */
 
@@ -2352,9 +2349,9 @@ tree_estimate_probability (void)
   FOR_EACH_BB_FN (bb, cfun)
     combine_predictions_for_bb (bb);
 
-#ifdef ENABLE_CHECKING
-  bb_predictions->traverse<void *, assert_is_empty> (NULL);
-#endif
+  if (flag_checking)
+    bb_predictions->traverse<void *, assert_is_empty> (NULL);
+
   delete bb_predictions;
   bb_predictions = NULL;
 
@@ -2545,11 +2542,12 @@ propagate_freq (basic_block head, bitmap tovisit)
       /* Compute frequency of basic block.  */
       if (bb != head)
 	{
-#ifdef ENABLE_CHECKING
-	  FOR_EACH_EDGE (e, ei, bb->preds)
-	    gcc_assert (!bitmap_bit_p (tovisit, e->src->index)
-			|| (e->flags & EDGE_DFS_BACK));
-#endif
+	  if (flag_checking)
+	    {
+	      FOR_EACH_EDGE (e, ei, bb->preds)
+		gcc_assert (!bitmap_bit_p (tovisit, e->src->index)
+			    || (e->flags & EDGE_DFS_BACK));
+	    }
 
 	  FOR_EACH_EDGE (e, ei, bb->preds)
 	    if (EDGE_INFO (e)->back_edge)
diff --git a/gcc/pretty-print.c b/gcc/pretty-print.c
index 5889015..8cfcee3 100644
--- a/gcc/pretty-print.c
+++ b/gcc/pretty-print.c
@@ -625,10 +625,11 @@ pp_format (pretty_printer *pp, text_info *text)
       *formatters[argno] = XOBFINISH (&buffer->chunk_obstack, const char *);
     }
 
-#ifdef ENABLE_CHECKING
-  for (; argno < PP_NL_ARGMAX; argno++)
-    gcc_assert (!formatters[argno]);
-#endif
+  if (CHECKING_P)
+    {
+      for (; argno < PP_NL_ARGMAX; argno++)
+	gcc_assert (!formatters[argno]);
+    }
 
   /* Revert to normal obstack and wrapping mode.  */
   buffer->obstack = &buffer->formatted_obstack;
diff --git a/gcc/real.c b/gcc/real.c
index c1ff78d..80a0c83 100644
--- a/gcc/real.c
+++ b/gcc/real.c
@@ -1792,15 +1792,13 @@ real_to_decimal_for_mode (char *str, const REAL_VALUE_TYPE *r_orig,
   /* Append the exponent.  */
   sprintf (last, "e%+d", dec_exp);
 
-#ifdef ENABLE_CHECKING
   /* Verify that we can read the original value back in.  */
-  if (mode != VOIDmode)
+  if (CHECKING_P && mode != VOIDmode)
     {
       real_from_string (&r, str);
       real_convert (&r, mode, &r);
       gcc_assert (real_identical (&r, r_orig));
     }
-#endif
 }
 
 /* Likewise, except always uses round-to-nearest.  */
diff --git a/gcc/recog.c b/gcc/recog.c
index c032424..2cd06f5 100644
--- a/gcc/recog.c
+++ b/gcc/recog.c
@@ -2975,9 +2975,7 @@ split_all_insns (void)
   if (changed)
     find_many_sub_basic_blocks (blocks);
 
-#ifdef ENABLE_CHECKING
-  verify_flow_info ();
-#endif
+  checking_verify_flow_info ();
 
   sbitmap_free (blocks);
 }
diff --git a/gcc/regcprop.c b/gcc/regcprop.c
index 6f7d01e..b0dc61b 100644
--- a/gcc/regcprop.c
+++ b/gcc/regcprop.c
@@ -100,9 +100,8 @@ static bool replace_oldest_value_addr (rtx *, enum reg_class,
 static bool replace_oldest_value_mem (rtx, rtx_insn *, struct value_data *);
 static bool copyprop_hardreg_forward_1 (basic_block, struct value_data *);
 extern void debug_value_data (struct value_data *);
-#ifdef ENABLE_CHECKING
+
 static void validate_value_data (struct value_data *);
-#endif
 
 /* Free all queued updates for DEBUG_INSNs that change some reg to
    register REGNO.  */
@@ -150,9 +149,7 @@ kill_value_one_regno (unsigned int regno, struct value_data *vd)
   if (vd->e[regno].debug_insn_changes)
     free_debug_insn_changes (vd, regno);
 
-#ifdef ENABLE_CHECKING
   validate_value_data (vd);
-#endif
 }
 
 /* Kill the value in register REGNO for NREGS, and any other registers
@@ -365,9 +362,7 @@ copy_value (rtx dest, rtx src, struct value_data *vd)
     continue;
   vd->e[i].next_regno = dr;
 
-#ifdef ENABLE_CHECKING
   validate_value_data (vd);
-#endif
 }
 
 /* Return true if a mode change from ORIG to NEW is allowed for REGNO.  */
@@ -1141,10 +1136,12 @@ copyprop_hardreg_forward_bb_without_debug_insn (basic_block bb)
   skip_debug_insn_p = false;
 }
 
-#ifdef ENABLE_CHECKING
 static void
 validate_value_data (struct value_data *vd)
 {
+  if (!flag_checking)
+    return;
+
   HARD_REG_SET set;
   unsigned int i, j;
 
@@ -1187,7 +1184,7 @@ validate_value_data (struct value_data *vd)
 		      i, GET_MODE_NAME (vd->e[i].mode), vd->e[i].oldest_regno,
 		      vd->e[i].next_regno);
 }
-#endif
+
 \f
 namespace {
 
diff --git a/gcc/reload.c b/gcc/reload.c
index cc61d77..32eec02 100644
--- a/gcc/reload.c
+++ b/gcc/reload.c
@@ -85,7 +85,7 @@ a register with any other reload.  */
 
 #define REG_OK_STRICT
 
-/* We do not enable this with ENABLE_CHECKING, since it is awfully slow.  */
+/* We do not enable this with CHECKING_P, since it is awfully slow.  */
 #undef DEBUG_RELOAD
 
 #include "config.h"
diff --git a/gcc/sched-deps.c b/gcc/sched-deps.c
index 9683055..27dd357 100644
--- a/gcc/sched-deps.c
+++ b/gcc/sched-deps.c
@@ -47,12 +47,6 @@ along with GCC; see the file COPYING3.  If not see
 
 #ifdef INSN_SCHEDULING
 
-#ifdef ENABLE_CHECKING
-#define CHECK (true)
-#else
-#define CHECK (false)
-#endif
-
 /* Holds current parameters for the dependency analyzer.  */
 struct sched_deps_info_def *sched_deps_info;
 
@@ -505,9 +499,7 @@ static enum DEPS_ADJUST_RESULT maybe_add_or_update_dep_1 (dep_t, bool,
 							  rtx, rtx);
 static enum DEPS_ADJUST_RESULT add_or_update_dep_1 (dep_t, bool, rtx, rtx);
 
-#ifdef ENABLE_CHECKING
 static void check_dep (dep_t, bool);
-#endif
 \f
 /* Return nonzero if a load of the memory reference MEM can cause a trap.  */
 
@@ -1228,9 +1220,8 @@ add_or_update_dep_1 (dep_t new_dep, bool resolved_p,
   gcc_assert (INSN_P (DEP_PRO (new_dep)) && INSN_P (DEP_CON (new_dep))
 	      && DEP_PRO (new_dep) != DEP_CON (new_dep));
 
-#ifdef ENABLE_CHECKING
-  check_dep (new_dep, mem1 != NULL);
-#endif
+  if (flag_checking)
+    check_dep (new_dep, mem1 != NULL);
 
   if (true_dependency_cache != NULL)
     {
@@ -1348,9 +1339,8 @@ sd_add_dep (dep_t dep, bool resolved_p)
 
   add_to_deps_list (DEP_NODE_BACK (n), con_back_deps);
 
-#ifdef ENABLE_CHECKING
-  check_dep (dep, false);
-#endif
+  if (flag_checking)
+    check_dep (dep, false);
 
   add_to_deps_list (DEP_NODE_FORW (n), pro_forw_deps);
 
@@ -4515,7 +4505,6 @@ debug_ds (ds_t s)
   fprintf (stderr, "\n");
 }
 
-#ifdef ENABLE_CHECKING
 /* Verify that dependence type and status are consistent.
    If RELAXED_P is true, then skip dep_weakness checks.  */
 static void
@@ -4600,7 +4589,6 @@ check_dep (dep_t dep, bool relaxed_p)
 	gcc_assert (ds & BEGIN_CONTROL);
     }
 }
-#endif /* ENABLE_CHECKING */
 
 /* The following code discovers opportunities to switch a memory reference
    and an increment by modifying the address.  We ensure that this is done
diff --git a/gcc/sel-sched-ir.c b/gcc/sel-sched-ir.c
index 8ea4dce..8000178 100644
--- a/gcc/sel-sched-ir.c
+++ b/gcc/sel-sched-ir.c
@@ -954,7 +954,6 @@ return_regset_to_pool (regset rs)
   regset_pool.v[regset_pool.n++] = rs;
 }
 
-#ifdef ENABLE_CHECKING
 /* This is used as a qsort callback for sorting regset pool stacks.
    X and XX are addresses of two regsets.  They are never equal.  */
 static int
@@ -968,44 +967,42 @@ cmp_v_in_regset_pool (const void *x, const void *xx)
     return -1;
   gcc_unreachable ();
 }
-#endif
 
-/*  Free the regset pool possibly checking for memory leaks.  */
+/* Free the regset pool possibly checking for memory leaks.  */
 void
-free_regset_pool (void)
+free_regset_pool ()
 {
-#ifdef ENABLE_CHECKING
-  {
-    regset *v = regset_pool.v;
-    int i = 0;
-    int n = regset_pool.n;
+  if (flag_checking)
+    {
+      regset *v = regset_pool.v;
+      int i = 0;
+      int n = regset_pool.n;
 
-    regset *vv = regset_pool.vv;
-    int ii = 0;
-    int nn = regset_pool.nn;
+      regset *vv = regset_pool.vv;
+      int ii = 0;
+      int nn = regset_pool.nn;
 
-    int diff = 0;
+      int diff = 0;
 
-    gcc_assert (n <= nn);
+      gcc_assert (n <= nn);
 
-    /* Sort both vectors so it will be possible to compare them.  */
-    qsort (v, n, sizeof (*v), cmp_v_in_regset_pool);
-    qsort (vv, nn, sizeof (*vv), cmp_v_in_regset_pool);
+      /* Sort both vectors so it will be possible to compare them.  */
+      qsort (v, n, sizeof (*v), cmp_v_in_regset_pool);
+      qsort (vv, nn, sizeof (*vv), cmp_v_in_regset_pool);
 
-    while (ii < nn)
-      {
-        if (v[i] == vv[ii])
-          i++;
-        else
-          /* VV[II] was lost.  */
-          diff++;
+      while (ii < nn)
+	{
+	  if (v[i] == vv[ii])
+	    i++;
+	  else
+	    /* VV[II] was lost.  */
+	    diff++;
 
-        ii++;
-      }
+	  ii++;
+	}
 
-    gcc_assert (diff == regset_pool.diff);
-  }
-#endif
+      gcc_assert (diff == regset_pool.diff);
+    }
 
   /* If not true - we have a memory leak.  */
   gcc_assert (regset_pool.diff == 0);
@@ -3623,7 +3620,6 @@ insn_is_the_only_one_in_bb_p (insn_t insn)
   return sel_bb_head_p (insn) && sel_bb_end_p (insn);
 }
 
-#ifdef ENABLE_CHECKING
 /* Check that the region we're scheduling still has at most one
    backedge.  */
 static void
@@ -3644,9 +3640,8 @@ verify_backedges (void)
       gcc_assert (n <= 1);
     }
 }
-#endif
-\f
 
+\f
 /* Functions to work with control flow.  */
 
 /* Recompute BLOCK_TO_BB and BB_FOR_BLOCK for current region so that blocks
@@ -3889,10 +3884,12 @@ tidy_control_flow (basic_block xbb, bool full_tidying)
 	sel_recompute_toporder ();
     }
 
-#ifdef ENABLE_CHECKING
-  verify_backedges ();
-  verify_dominators (CDI_DOMINATORS);
-#endif
+  /* TODO: use separate flag for CFG checking.  */
+  if (flag_checking)
+    {
+      verify_backedges ();
+      verify_dominators (CDI_DOMINATORS);
+    }
 
   return changed;
 }
diff --git a/gcc/sel-sched.c b/gcc/sel-sched.c
index 721013f..fcf9ba8 100644
--- a/gcc/sel-sched.c
+++ b/gcc/sel-sched.c
@@ -378,7 +378,7 @@ struct moveop_static_params
      they are to be removed.  */
   int uid;
 
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
   /* This is initialized to the insn on which the driver stopped its traversal.  */
   insn_t failed_insn;
 #endif
@@ -1655,7 +1655,7 @@ find_best_reg_for_expr (expr_t expr, blist_t bnds, bool *is_orig_reg_p)
   collect_unavailable_regs_from_bnds (expr, bnds, used_regs, &reg_rename_data,
 				      &original_insns);
 
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
   /* If after reload, make sure we're working with hard regs here.  */
   if (reload_completed)
     {
@@ -3593,7 +3593,7 @@ vinsn_vec_has_expr_p (vinsn_vec_t vinsn_vec, expr_t expr)
   return false;
 }
 
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
 /* Return true if either of expressions from ORIG_OPS can be blocked
    by previously created bookkeeping code.  STATIC_PARAMS points to static
    parameters of move_op.  */
@@ -4889,11 +4889,10 @@ move_cond_jump (rtx_insn *insn, bnd_t bnd)
   block_bnd = BLOCK_FOR_INSN (BND_TO (bnd));
   prev = BND_TO (bnd);
 
-#ifdef ENABLE_CHECKING
   /* Moving of jump should not cross any other jumps or beginnings of new
      basic blocks.  The only exception is when we move a jump through
      mutually exclusive insns along fallthru edges.  */
-  if (block_from != block_bnd)
+  if (CHECKING_P && block_from != block_bnd)
     {
       bb = block_from;
       for (link = PREV_INSN (insn); link != PREV_INSN (prev);
@@ -4908,7 +4907,6 @@ move_cond_jump (rtx_insn *insn, bnd_t bnd)
             }
         }
     }
-#endif
 
   /* Jump is moved to the boundary.  */
   next = PREV_INSN (insn);
@@ -6205,7 +6203,7 @@ move_op_orig_expr_not_found (insn_t insn, av_set_t orig_ops ATTRIBUTE_UNUSED,
 {
   moveop_static_params_p sparams = (moveop_static_params_p) static_params;
 
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
   sparams->failed_insn = insn;
 #endif
 
@@ -6380,7 +6378,6 @@ code_motion_process_successors (insn_t insn, av_set_t orig_ops,
         }
     }
 
-#ifdef ENABLE_CHECKING
   /* Here, RES==1 if original expr was found at least for one of the
      successors.  After the loop, RES may happen to have zero value
      only if at some point the expr searched is present in av_set, but is
@@ -6388,6 +6385,7 @@ code_motion_process_successors (insn_t insn, av_set_t orig_ops,
      The exception is when the original operation is blocked by
      bookkeeping generated for another fence or for another path in current
      move_op.  */
+#if CHECKING_P
   gcc_assert (res == 1
 	      || (res == 0
 		  && av_set_could_be_blocked_by_bookkeeping_p (orig_ops,
@@ -6695,7 +6693,7 @@ move_op (insn_t insn, av_set_t orig_ops, expr_t expr_vliw,
   sparams.dest = dest;
   sparams.c_expr = c_expr;
   sparams.uid = INSN_UID (EXPR_INSN_RTX (expr_vliw));
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
   sparams.failed_insn = NULL;
 #endif
   sparams.was_renamed = false;
diff --git a/gcc/sese.h b/gcc/sese.h
index 0b2db8d..6b852ae 100644
--- a/gcc/sese.h
+++ b/gcc/sese.h
@@ -88,16 +88,20 @@ sese_nb_params (sese region)
 static inline bool
 bb_in_region (basic_block bb, basic_block entry, basic_block exit)
 {
-#ifdef ENABLE_CHECKING
-  {
-    edge e;
-    edge_iterator ei;
-
-    /* Check that there are no edges coming in the region: all the
-       predecessors of EXIT are dominated by ENTRY.  */
-    FOR_EACH_EDGE (e, ei, exit->preds)
-      dominated_by_p (CDI_DOMINATORS, e->src, entry);
-  }
+/* FIXME: (PR 67842) this check is incorrect.  dominated_by_p has no effect,
+   but changing it to gcc_assert (dominated_by_p (...)) causes regressions,
+   e.g., gcc.dg/graphite/block-1.c.  */
+#if 0
+  if (flag_checking)
+    {
+      edge e;
+      edge_iterator ei;
+
+      /* Check that there are no edges coming in the region: all the
+	 predecessors of EXIT are dominated by ENTRY.  */
+      FOR_EACH_EDGE (e, ei, exit->preds)
+	dominated_by_p (CDI_DOMINATORS, e->src, entry);
+    }
 #endif
 
   return dominated_by_p (CDI_DOMINATORS, bb, entry)
diff --git a/gcc/ssa-iterators.h b/gcc/ssa-iterators.h
index e04b630..1bf93bd 100644
--- a/gcc/ssa-iterators.h
+++ b/gcc/ssa-iterators.h
@@ -344,9 +344,8 @@ first_readonly_imm_use (imm_use_iterator *imm, tree var)
 {
   imm->end_p = &(SSA_NAME_IMM_USE_NODE (var));
   imm->imm_use = imm->end_p->next;
-#ifdef ENABLE_CHECKING
-  imm->iter_node.next = imm->imm_use->next;
-#endif
+  if (CHECKING_P)
+    imm->iter_node.next = imm->imm_use->next;
   if (end_readonly_imm_use_p (imm))
     return NULL_USE_OPERAND_P;
   return imm->imm_use;
@@ -358,14 +357,15 @@ next_readonly_imm_use (imm_use_iterator *imm)
 {
   use_operand_p old = imm->imm_use;
 
-#ifdef ENABLE_CHECKING
   /* If this assertion fails, it indicates the 'next' pointer has changed
      since the last bump.  This indicates that the list is being modified
      via stmt changes, or SET_USE, or somesuch thing, and you need to be
      using the SAFE version of the iterator.  */
-  gcc_assert (imm->iter_node.next == old->next);
-  imm->iter_node.next = old->next->next;
-#endif
+  if (CHECKING_P)
+    {
+      gcc_assert (imm->iter_node.next == old->next);
+      imm->iter_node.next = old->next->next;
+    }
 
   imm->imm_use = old->next;
   if (end_readonly_imm_use_p (imm))
diff --git a/gcc/store-motion.c b/gcc/store-motion.c
index ec3faa2..ed1a399 100644
--- a/gcc/store-motion.c
+++ b/gcc/store-motion.c
@@ -644,9 +644,6 @@ compute_store_table (void)
 {
   int ret;
   basic_block bb;
-#ifdef ENABLE_CHECKING
-  unsigned regno;
-#endif
   rtx_insn *insn;
   rtx_insn *tmp;
   df_ref def;
@@ -692,11 +689,12 @@ compute_store_table (void)
 	      last_set_in[DF_REF_REGNO (def)] = 0;
 	}
 
-#ifdef ENABLE_CHECKING
-      /* last_set_in should now be all-zero.  */
-      for (regno = 0; regno < max_gcse_regno; regno++)
-	gcc_assert (!last_set_in[regno]);
-#endif
+      if (flag_checking)
+	{
+	  /* last_set_in should now be all-zero.  */
+	  for (unsigned regno = 0; regno < max_gcse_regno; regno++)
+	    gcc_assert (!last_set_in[regno]);
+	}
 
       /* Clear temporary marks.  */
       for (ptr = first_st_expr (); ptr != NULL; ptr = next_st_expr (ptr))
diff --git a/gcc/symbol-summary.h b/gcc/symbol-summary.h
index eefbfd9..4a1a510 100644
--- a/gcc/symbol-summary.h
+++ b/gcc/symbol-summary.h
@@ -39,14 +39,12 @@ public:
   function_summary (symbol_table *symtab, bool ggc = false): m_ggc (ggc),
     m_map (13, ggc), m_insertion_enabled (true), m_symtab (symtab)
   {
-#ifdef ENABLE_CHECKING
-    cgraph_node *node;
-
-    FOR_EACH_FUNCTION (node)
-    {
-      gcc_checking_assert (node->summary_uid > 0);
-    }
-#endif
+    if (flag_checking)
+      {
+	cgraph_node *node;
+	FOR_EACH_FUNCTION (node)
+	  gcc_assert (node->summary_uid > 0);
+      }
 
     m_symtab_insertion_hook =
       symtab->add_cgraph_insertion_hook
diff --git a/gcc/symtab.c b/gcc/symtab.c
index c33aa01..5a9ff54 100644
--- a/gcc/symtab.c
+++ b/gcc/symtab.c
@@ -1093,8 +1093,8 @@ symtab_node::verify (void)
 
 /* Verify symbol table for internal consistency.  */
 
-DEBUG_FUNCTION void
-symtab_node::verify_symtab_nodes (void)
+void
+symtab_node::verify_symtab_nodes ()
 {
   symtab_node *node;
   hash_map<tree, symtab_node *> comdat_head_map (251);
diff --git a/gcc/target.h b/gcc/target.h
index a79f424..ffc4d6a 100644
--- a/gcc/target.h
+++ b/gcc/target.h
@@ -52,21 +52,21 @@
 #include "tm.h"
 #include "hard-reg-set.h"
 
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
 
 struct cumulative_args_t { void *magic; void *p; };
 
-#else /* !ENABLE_CHECKING */
+#else /* !CHECKING_P */
 
 /* When using a GCC build compiler, we could use
    __attribute__((transparent_union)) to get cumulative_args_t function
    arguments passed like scalars where the ABI would mandate a less
    efficient way of argument passing otherwise.  However, that would come
-   at the cost of less type-safe !ENABLE_CHECKING compilation.  */
+   at the cost of less type-safe !CHECKING_P compilation.  */
 
 union cumulative_args_t { void *p; };
 
-#endif /* !ENABLE_CHECKING */
+#endif /* !CHECKING_P */
 
 /* Types used by the record_gcc_switches() target function.  */
 enum print_switch_type
@@ -200,9 +200,9 @@ extern struct gcc_target targetm;
 static inline CUMULATIVE_ARGS *
 get_cumulative_args (cumulative_args_t arg)
 {
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
   gcc_assert (arg.magic == CUMULATIVE_ARGS_MAGIC);
-#endif /* ENABLE_CHECKING */
+#endif /* CHECKING_P */
   return (CUMULATIVE_ARGS *) arg.p;
 }
 
@@ -211,9 +211,9 @@ pack_cumulative_args (CUMULATIVE_ARGS *arg)
 {
   cumulative_args_t ret;
 
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
   ret.magic = CUMULATIVE_ARGS_MAGIC;
-#endif /* ENABLE_CHECKING */
+#endif /* CHECKING_P */
   ret.p = (void *) arg;
   return ret;
 }
diff --git a/gcc/timevar.c b/gcc/timevar.c
index 8249727..02b8113 100644
--- a/gcc/timevar.c
+++ b/gcc/timevar.c
@@ -727,10 +727,13 @@ timer::print (FILE *fp)
 #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
+  if (CHECKING_P)
+    {
+      fprintf (fp, "Extra diagnostic checks enabled; "
+		   "compiler may run slowly.\n");
+      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");
diff --git a/gcc/trans-mem.c b/gcc/trans-mem.c
index 488c20e..d0b54ef 100644
--- a/gcc/trans-mem.c
+++ b/gcc/trans-mem.c
@@ -5341,9 +5341,7 @@ ipa_tm_execute (void)
   enum availability a;
   unsigned int i;
 
-#ifdef ENABLE_CHECKING
-  cgraph_node::verify_cgraph_nodes ();
-#endif
+  cgraph_node::checking_verify_cgraph_nodes ();
 
   bitmap_obstack_initialize (&tm_obstack);
   initialize_original_copy_tables ();
@@ -5589,9 +5587,7 @@ ipa_tm_execute (void)
   FOR_EACH_FUNCTION (node)
     node->aux = NULL;
 
-#ifdef ENABLE_CHECKING
-  cgraph_node::verify_cgraph_nodes ();
-#endif
+  cgraph_node::checking_verify_cgraph_nodes ();
 
   return 0;
 }
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 735ac46..ac4ccf3 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -6472,14 +6472,12 @@ move_stmt_op (tree *tp, int *walk_subtrees, void *data)
 	  || (p->orig_block == NULL_TREE
 	      && block != NULL_TREE))
 	TREE_SET_BLOCK (t, p->new_block);
-#ifdef ENABLE_CHECKING
-      else if (block != NULL_TREE)
+      else if (flag_checking && block != NULL_TREE)
 	{
 	  while (block && TREE_CODE (block) == BLOCK && block != p->orig_block)
 	    block = BLOCK_SUPERCONTEXT (block);
 	  gcc_assert (block == p->orig_block);
 	}
-#endif
     }
   else if (DECL_P (t) || TREE_CODE (t) == SSA_NAME)
     {
@@ -6947,7 +6945,7 @@ fixup_loop_arrays_after_move (struct function *fn1, struct function *fn2,
 /* Verify that the blocks in BBS_P are a single-entry, single-exit region
    delimited by ENTRY_BB and EXIT_BB, possibly containing noreturn blocks.  */
 
-DEBUG_FUNCTION void
+void
 verify_sese (basic_block entry, basic_block exit, vec<basic_block> *bbs_p)
 {
   basic_block bb;
@@ -7064,9 +7062,9 @@ move_sese_region_to_fn (struct function *dest_cfun, basic_block entry_bb,
   bbs.create (0);
   bbs.safe_push (entry_bb);
   gather_blocks_in_sese_region (entry_bb, exit_bb, &bbs);
-#ifdef ENABLE_CHECKING
-  verify_sese (entry_bb, exit_bb, &bbs);
-#endif
+
+  if (flag_checking)
+    verify_sese (entry_bb, exit_bb, &bbs);
 
   /* The blocks that used to be dominated by something in BBS will now be
      dominated by the new block.  */
@@ -7908,13 +7906,11 @@ gimple_flow_call_edges_add (sbitmap blocks)
 		     no edge to the exit block in CFG already.
 		     Calling make_edge in such case would cause us to
 		     mark that edge as fake and remove it later.  */
-#ifdef ENABLE_CHECKING
-		  if (stmt == last_stmt)
+		  if (flag_checking && stmt == last_stmt)
 		    {
 		      e = find_edge (bb, EXIT_BLOCK_PTR_FOR_FN (cfun));
 		      gcc_assert (e == NULL);
 		    }
-#endif
 
 		  /* Note that the following may create a new basic block
 		     and renumber the existing basic blocks.  */
diff --git a/gcc/tree-cfgcleanup.c b/gcc/tree-cfgcleanup.c
index 40e1456..33e5317 100644
--- a/gcc/tree-cfgcleanup.c
+++ b/gcc/tree-cfgcleanup.c
@@ -724,9 +724,7 @@ cleanup_tree_cfg_noloop (void)
     }
   else
     {
-#ifdef ENABLE_CHECKING
-      verify_dominators (CDI_DOMINATORS);
-#endif
+      checking_verify_dominators (CDI_DOMINATORS);
       changed = false;
     }
 
@@ -735,9 +733,7 @@ cleanup_tree_cfg_noloop (void)
   gcc_assert (dom_info_available_p (CDI_DOMINATORS));
   compact_blocks ();
 
-#ifdef ENABLE_CHECKING
-  verify_flow_info ();
-#endif
+  checking_verify_flow_info ();
 
   timevar_pop (TV_TREE_CLEANUP_CFG);
 
@@ -772,9 +768,7 @@ repair_loop_structures (void)
 
   BITMAP_FREE (changed_bbs);
 
-#ifdef ENABLE_CHECKING
-  verify_loop_structure ();
-#endif
+  checking_verify_loop_structure ();
   scev_reset ();
 
   timevar_pop (TV_REPAIR_LOOPS);
diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c
index cb1f08a..f6c2d06 100644
--- a/gcc/tree-eh.c
+++ b/gcc/tree-eh.c
@@ -703,7 +703,7 @@ maybe_record_in_goto_queue (struct leh_state *state, gimple *stmt)
 }
 
 
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
 /* We do not process GIMPLE_SWITCHes for now.  As long as the original source
    was in fact structured, and we've not yet done jump threading, then none
    of the labels will leave outer GIMPLE_TRY_FINALLY nodes. Verify this.  */
@@ -3921,9 +3921,8 @@ remove_unreachable_handlers (void)
   sbitmap_free (r_reachable);
   sbitmap_free (lp_reachable);
 
-#ifdef ENABLE_CHECKING
-  verify_eh_tree (cfun);
-#endif
+  if (flag_checking)
+    verify_eh_tree (cfun);
 }
 
 /* Remove unreachable handlers if any landing pads have been removed after
diff --git a/gcc/tree-if-conv.c b/gcc/tree-if-conv.c
index f201ab5..ae79f0e 100644
--- a/gcc/tree-if-conv.c
+++ b/gcc/tree-if-conv.c
@@ -2787,13 +2787,12 @@ pass_if_conversion::execute (function *fun)
 	    && !loop->dont_vectorize))
       todo |= tree_if_conversion (loop);
 
-#ifdef ENABLE_CHECKING
-  {
-    basic_block bb;
-    FOR_EACH_BB_FN (bb, fun)
-      gcc_assert (!bb->aux);
-  }
-#endif
+  if (flag_checking)
+    {
+      basic_block bb;
+      FOR_EACH_BB_FN (bb, fun)
+	gcc_assert (!bb->aux);
+    }
 
   return todo;
 }
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index ac9586e..a1e30cc 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -4471,10 +4471,8 @@ expand_call_inline (basic_block bb, gimple *stmt, copy_body_data *id)
   fn = cg_edge->callee->decl;
   cg_edge->callee->get_untransformed_body ();
 
-#ifdef ENABLE_CHECKING
-  if (cg_edge->callee->decl != id->dst_node->decl)
+  if (flag_checking && cg_edge->callee->decl != id->dst_node->decl)
     cg_edge->callee->verify ();
-#endif
 
   /* We will be inlining this callee.  */
   id->eh_lp_nr = lookup_stmt_eh_lp (stmt);
@@ -4963,7 +4961,7 @@ optimize_inline_calls (tree fn)
 
   pop_gimplify_context (NULL);
 
-#ifdef ENABLE_CHECKING
+  if (flag_checking)
     {
       struct cgraph_edge *e;
 
@@ -4973,7 +4971,6 @@ optimize_inline_calls (tree fn)
       for (e = id.dst_node->callees; e; e = e->next_callee)
 	gcc_assert (e->inline_failed);
     }
-#endif
 
   /* Fold queued statements.  */
   fold_marked_statements (last, id.statements_to_fold);
@@ -4989,9 +4986,8 @@ optimize_inline_calls (tree fn)
   number_blocks (fn);
 
   delete_unreachable_blocks_update_callgraph (&id);
-#ifdef ENABLE_CHECKING
-  id.dst_node->verify ();
-#endif
+  if (flag_checking)
+    id.dst_node->verify ();
 
   /* It would be nice to check SSA/CFG/statement consistency here, but it is
      not possible yet - the IPA passes might make various functions to not
diff --git a/gcc/tree-into-ssa.c b/gcc/tree-into-ssa.c
index 9fd698d..732a571 100644
--- a/gcc/tree-into-ssa.c
+++ b/gcc/tree-into-ssa.c
@@ -3169,44 +3169,45 @@ update_ssa (unsigned update_flags)
   if (!need_ssa_update_p (cfun))
     return;
 
-#ifdef ENABLE_CHECKING
-  timevar_push (TV_TREE_STMT_VERIFY);
+  if (flag_checking)
+    {
+      timevar_push (TV_TREE_STMT_VERIFY);
 
-  bool err = false;
+      bool err = false;
 
-  FOR_EACH_BB_FN (bb, cfun)
-    {
-      gimple_stmt_iterator gsi;
-      for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+      FOR_EACH_BB_FN (bb, cfun)
 	{
-	  gimple *stmt = gsi_stmt (gsi);
-
-	  ssa_op_iter i;
-	  use_operand_p use_p;
-	  FOR_EACH_SSA_USE_OPERAND (use_p, stmt, i, SSA_OP_ALL_USES)
+	  gimple_stmt_iterator gsi;
+	  for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
 	    {
-	      tree use = USE_FROM_PTR (use_p);
-	      if (TREE_CODE (use) != SSA_NAME)
-		continue;
+	      gimple *stmt = gsi_stmt (gsi);
 
-	      if (SSA_NAME_IN_FREE_LIST (use))
+	      ssa_op_iter i;
+	      use_operand_p use_p;
+	      FOR_EACH_SSA_USE_OPERAND (use_p, stmt, i, SSA_OP_ALL_USES)
 		{
-		  error ("statement uses released SSA name:");
-		  debug_gimple_stmt (stmt);
-		  fprintf (stderr, "The use of ");
-		  print_generic_expr (stderr, use, 0);
-		  fprintf (stderr," should have been replaced\n");
-		  err = true;
+		  tree use = USE_FROM_PTR (use_p);
+		  if (TREE_CODE (use) != SSA_NAME)
+		    continue;
+
+		  if (SSA_NAME_IN_FREE_LIST (use))
+		    {
+		      error ("statement uses released SSA name:");
+		      debug_gimple_stmt (stmt);
+		      fprintf (stderr, "The use of ");
+		      print_generic_expr (stderr, use, 0);
+		      fprintf (stderr," should have been replaced\n");
+		      err = true;
+		    }
 		}
 	    }
 	}
-    }
 
-  if (err)
-    internal_error ("cannot update SSA form");
+      if (err)
+	internal_error ("cannot update SSA form");
 
-  timevar_pop (TV_TREE_STMT_VERIFY);
-#endif
+      timevar_pop (TV_TREE_STMT_VERIFY);
+    }
 
   timevar_push (TV_TREE_SSA_INCREMENTAL);
 
@@ -3271,29 +3272,28 @@ update_ssa (unsigned update_flags)
 	 placement heuristics.  */
       prepare_block_for_update (start_bb, insert_phi_p);
 
-#ifdef ENABLE_CHECKING
-      for (i = 1; i < num_ssa_names; ++i)
-	{
-	  tree name = ssa_name (i);
-	  if (!name
-	      || virtual_operand_p (name))
-	    continue;
-
-	  /* For all but virtual operands, which do not have SSA names
-	     with overlapping life ranges, ensure that symbols marked
-	     for renaming do not have existing SSA names associated with
-	     them as we do not re-write them out-of-SSA before going
-	     into SSA for the remaining symbol uses.  */
-	  if (marked_for_renaming (SSA_NAME_VAR (name)))
-	    {
-	      fprintf (stderr, "Existing SSA name for symbol marked for "
-		       "renaming: ");
-	      print_generic_expr (stderr, name, TDF_SLIM);
-	      fprintf (stderr, "\n");
-	      internal_error ("SSA corruption");
-	    }
-	}
-#endif
+      if (flag_checking)
+	for (i = 1; i < num_ssa_names; ++i)
+	  {
+	    tree name = ssa_name (i);
+	    if (!name
+		|| virtual_operand_p (name))
+	      continue;
+
+	    /* For all but virtual operands, which do not have SSA names
+	       with overlapping life ranges, ensure that symbols marked
+	       for renaming do not have existing SSA names associated with
+	       them as we do not re-write them out-of-SSA before going
+	       into SSA for the remaining symbol uses.  */
+	    if (marked_for_renaming (SSA_NAME_VAR (name)))
+	      {
+		fprintf (stderr, "Existing SSA name for symbol marked for "
+			 "renaming: ");
+		print_generic_expr (stderr, name, TDF_SLIM);
+		fprintf (stderr, "\n");
+		internal_error ("SSA corruption");
+	      }
+	  }
     }
   else
     {
diff --git a/gcc/tree-loop-distribution.c b/gcc/tree-loop-distribution.c
index 6f86d53..18025c8 100644
--- a/gcc/tree-loop-distribution.c
+++ b/gcc/tree-loop-distribution.c
@@ -1821,9 +1821,7 @@ out:
       rewrite_into_loop_closed_ssa (NULL, TODO_update_ssa);
     }
 
-#ifdef ENABLE_CHECKING
-  verify_loop_structure ();
-#endif
+  checking_verify_loop_structure ();
 
   return 0;
 }
diff --git a/gcc/tree-outof-ssa.c b/gcc/tree-outof-ssa.c
index 8dc4908..1c4c63c 100644
--- a/gcc/tree-outof-ssa.c
+++ b/gcc/tree-outof-ssa.c
@@ -841,24 +841,23 @@ eliminate_useless_phis (void)
 	  result = gimple_phi_result (phi);
 	  if (virtual_operand_p (result))
 	    {
-#ifdef ENABLE_CHECKING
-	      size_t i;
 	      /* There should be no arguments which are not virtual, or the
 	         results will be incorrect.  */
-	      for (i = 0; i < gimple_phi_num_args (phi); i++)
-	        {
-		  tree arg = PHI_ARG_DEF (phi, i);
-		  if (TREE_CODE (arg) == SSA_NAME
-		      && !virtual_operand_p (arg))
-		    {
-		      fprintf (stderr, "Argument of PHI is not virtual (");
-		      print_generic_expr (stderr, arg, TDF_SLIM);
-		      fprintf (stderr, "), but the result is :");
-		      print_gimple_stmt (stderr, phi, 0, TDF_SLIM);
-		      internal_error ("SSA corruption");
-		    }
-		}
-#endif
+	      if (flag_checking)
+		for (size_t i = 0; i < gimple_phi_num_args (phi); i++)
+		  {
+		    tree arg = PHI_ARG_DEF (phi, i);
+		    if (TREE_CODE (arg) == SSA_NAME
+			&& !virtual_operand_p (arg))
+		      {
+			fprintf (stderr, "Argument of PHI is not virtual (");
+			print_generic_expr (stderr, arg, TDF_SLIM);
+			fprintf (stderr, "), but the result is :");
+			print_gimple_stmt (stderr, phi, 0, TDF_SLIM);
+			internal_error ("SSA corruption");
+		      }
+		  }
+
 	      remove_phi_node (&gsi, true);
 	    }
           else
@@ -884,9 +883,11 @@ eliminate_useless_phis (void)
    variable.  */
 
 static void
-rewrite_trees (var_map map ATTRIBUTE_UNUSED)
+rewrite_trees (var_map map)
 {
-#ifdef ENABLE_CHECKING
+  if (!flag_checking)
+    return;
+
   basic_block bb;
   /* Search for PHIs where the destination has no partition, but one
      or more arguments has a partition.  This should not happen and can
@@ -918,7 +919,6 @@ rewrite_trees (var_map map ATTRIBUTE_UNUSED)
 	    }
 	}
     }
-#endif
 }
 
 /* Given the out-of-ssa info object SA (with prepared partitions)
diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c
index 741392b..7f7a1a5 100644
--- a/gcc/tree-parloops.c
+++ b/gcc/tree-parloops.c
@@ -2747,9 +2747,7 @@ pass_parallelize_loops::execute (function *fun)
     {
       fun->curr_properties &= ~(PROP_gimple_eomp);
 
-#ifdef ENABLE_CHECKING
-      verify_loop_structure ();
-#endif
+      checking_verify_loop_structure ();
 
       return TODO_update_ssa;
     }
diff --git a/gcc/tree-predcom.c b/gcc/tree-predcom.c
index 4abac13..5f6e1b0 100644
--- a/gcc/tree-predcom.c
+++ b/gcc/tree-predcom.c
@@ -896,13 +896,9 @@ suitable_component_p (struct loop *loop, struct component *comp)
       if (!determine_offset (first->ref, a->ref, &a->offset))
 	return false;
 
-#ifdef ENABLE_CHECKING
-      {
-	enum ref_step_type a_step;
-	ok = suitable_reference_p (a->ref, &a_step);
-	gcc_assert (ok && a_step == comp->comp_step);
-      }
-#endif
+      enum ref_step_type a_step;
+      gcc_checking_assert (suitable_reference_p (a->ref, &a_step)
+			   && a_step == comp->comp_step);
     }
 
   /* If there is a write inside the component, we must know whether the
diff --git a/gcc/tree-profile.c b/gcc/tree-profile.c
index b4b3ae1..8d82934 100644
--- a/gcc/tree-profile.c
+++ b/gcc/tree-profile.c
@@ -462,9 +462,8 @@ gimple_gen_const_delta_profiler (histogram_value value ATTRIBUTE_UNUSED,
 			       unsigned base ATTRIBUTE_UNUSED)
 {
   /* FIXME implement this.  */
-#ifdef ENABLE_CHECKING
-  internal_error ("unimplemented functionality");
-#endif
+  if (flag_checking)
+    internal_error ("unimplemented functionality");
   gcc_unreachable ();
 }
 
diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c
index 3b8d594..7771514 100644
--- a/gcc/tree-ssa-alias.c
+++ b/gcc/tree-ssa-alias.c
@@ -1443,11 +1443,8 @@ refs_may_alias_p_1 (ao_ref *ref1, ao_ref *ref2, bool tbaa_p)
 				      tbaa_p);
 
   /* We really do not want to end up here, but returning true is safe.  */
-#ifdef ENABLE_CHECKING
-  gcc_unreachable ();
-#else
+  gcc_checking_assert (false);
   return true;
-#endif
 }
 
 static bool
diff --git a/gcc/tree-ssa-live.c b/gcc/tree-ssa-live.c
index 25b548b..a61026d 100644
--- a/gcc/tree-ssa-live.c
+++ b/gcc/tree-ssa-live.c
@@ -52,9 +52,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "ipa-utils.h"
 #include "cfgloop.h"
 
-#ifdef ENABLE_CHECKING
-static void  verify_live_on_entry (tree_live_info_p);
-#endif
+static void verify_live_on_entry (tree_live_info_p);
 
 
 /* VARMAP maintains a mapping from SSA version number to real variables.
@@ -1153,9 +1151,8 @@ calculate_live_ranges (var_map map, bool want_livein)
 
   live_worklist (live);
 
-#ifdef ENABLE_CHECKING
-  verify_live_on_entry (live);
-#endif
+  if (flag_checking)
+    verify_live_on_entry (live);
 
   calculate_live_on_exit (live);
 
@@ -1292,7 +1289,6 @@ debug (tree_live_info_d *ptr)
 }
 
 
-#ifdef ENABLE_CHECKING
 /* Verify that SSA_VAR is a non-virtual SSA_NAME.  */
 
 void
@@ -1422,4 +1418,3 @@ verify_live_on_entry (tree_live_info_p live)
     }
   gcc_assert (num <= 0);
 }
-#endif
diff --git a/gcc/tree-ssa-live.h b/gcc/tree-ssa-live.h
index 1f88358..0cb3a1a 100644
--- a/gcc/tree-ssa-live.h
+++ b/gcc/tree-ssa-live.h
@@ -80,9 +80,7 @@ extern void remove_unused_locals (void);
 extern void dump_var_map (FILE *, var_map);
 extern void debug (_var_map &ref);
 extern void debug (_var_map *ptr);
-#ifdef ENABLE_CHECKING
 extern void register_ssa_partition_check (tree ssa_var);
-#endif
 
 
 /* Return number of partitions in MAP.  */
@@ -181,12 +179,10 @@ num_basevars (var_map map)
    partitions may be filtered out by a view later.  */
 
 static inline void
-register_ssa_partition (var_map map ATTRIBUTE_UNUSED,
-			tree ssa_var ATTRIBUTE_UNUSED)
+register_ssa_partition (var_map map ATTRIBUTE_UNUSED, tree ssa_var)
 {
-#if defined ENABLE_CHECKING
-  register_ssa_partition_check (ssa_var);
-#endif
+  if (flag_checking)
+    register_ssa_partition_check (ssa_var);
 }
 
 
diff --git a/gcc/tree-ssa-loop-ivcanon.c b/gcc/tree-ssa-loop-ivcanon.c
index 6599ffc..0d5f56e 100644
--- a/gcc/tree-ssa-loop-ivcanon.c
+++ b/gcc/tree-ssa-loop-ivcanon.c
@@ -1376,10 +1376,8 @@ tree_unroll_loops_completely (bool may_increase_size, bool unroll_outer)
 	  /* Clean up the information about numbers of iterations, since
 	     complete unrolling might have invalidated it.  */
 	  scev_reset ();
-#ifdef ENABLE_CHECKING
-	  if (loops_state_satisfies_p (LOOP_CLOSED_SSA))
+	  if (flag_checking && loops_state_satisfies_p (LOOP_CLOSED_SSA))
 	    verify_loop_closed_ssa (true);
-#endif
 	}
       if (loop_closed_ssa_invalidated)
         BITMAP_FREE (loop_closed_ssa_invalidated);
diff --git a/gcc/tree-ssa-loop-manip.c b/gcc/tree-ssa-loop-manip.c
index 27ba275..e6befc6 100644
--- a/gcc/tree-ssa-loop-manip.c
+++ b/gcc/tree-ssa-loop-manip.c
@@ -278,22 +278,22 @@ add_exit_phi (basic_block exit, tree var)
   edge e;
   edge_iterator ei;
 
-#ifdef ENABLE_CHECKING
   /* Check that at least one of the edges entering the EXIT block exits
      the loop, or a superloop of that loop, that VAR is defined in.  */
-  gimple *def_stmt = SSA_NAME_DEF_STMT (var);
-  basic_block def_bb = gimple_bb (def_stmt);
-  FOR_EACH_EDGE (e, ei, exit->preds)
+  if (flag_checking)
     {
-      struct loop *aloop = find_common_loop (def_bb->loop_father,
-					     e->src->loop_father);
-      if (!flow_bb_inside_loop_p (aloop, e->dest))
-	break;
+      gimple *def_stmt = SSA_NAME_DEF_STMT (var);
+      basic_block def_bb = gimple_bb (def_stmt);
+      FOR_EACH_EDGE (e, ei, exit->preds)
+	{
+	  struct loop *aloop = find_common_loop (def_bb->loop_father,
+						 e->src->loop_father);
+	  if (!flow_bb_inside_loop_p (aloop, e->dest))
+	    break;
+	}
+      gcc_assert (e);
     }
 
-  gcc_checking_assert (e);
-#endif
-
   phi = create_phi_node (NULL_TREE, exit);
   create_new_def_for (var, phi, gimple_phi_result_ptr (phi));
   FOR_EACH_EDGE (e, ei, exit->preds)
@@ -729,7 +729,7 @@ check_loop_closed_ssa_stmt (basic_block bb, gimple *stmt)
 /* Checks that invariants of the loop closed ssa form are preserved.
    Call verify_ssa when VERIFY_SSA_P is true.  */
 
-DEBUG_FUNCTION void
+void
 verify_loop_closed_ssa (bool verify_ssa_p)
 {
   basic_block bb;
@@ -1368,11 +1368,9 @@ tree_transform_and_unroll_loop (struct loop *loop, unsigned factor,
   gimple_cond_set_rhs (exit_if, exit_bound);
   update_stmt (exit_if);
 
-#ifdef ENABLE_CHECKING
-  verify_flow_info ();
-  verify_loop_structure ();
-  verify_loop_closed_ssa (true);
-#endif
+  checking_verify_flow_info ();
+  checking_verify_loop_structure ();
+  checking_verify_loop_closed_ssa (true);
 }
 
 /* Wrapper over tree_transform_and_unroll_loop for case we do not
diff --git a/gcc/tree-ssa-loop-manip.h b/gcc/tree-ssa-loop-manip.h
index 9285718..96b02a6 100644
--- a/gcc/tree-ssa-loop-manip.h
+++ b/gcc/tree-ssa-loop-manip.h
@@ -27,6 +27,14 @@ extern void create_iv (tree, tree, tree, struct loop *, gimple_stmt_iterator *,
 extern void rewrite_into_loop_closed_ssa (bitmap, unsigned);
 extern void rewrite_virtuals_into_loop_closed_ssa (struct loop *);
 extern void verify_loop_closed_ssa (bool);
+
+static inline void
+checking_verify_loop_closed_ssa (bool verify_ssa_p)
+{
+  if (flag_checking)
+    verify_loop_closed_ssa (verify_ssa_p);
+}
+
 extern basic_block split_loop_exit_edge (edge);
 extern basic_block ip_end_pos (struct loop *);
 extern basic_block ip_normal_pos (struct loop *);
diff --git a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c
index 9747739..231928b 100644
--- a/gcc/tree-ssa-math-opts.c
+++ b/gcc/tree-ssa-math-opts.c
@@ -541,10 +541,9 @@ pass_cse_reciprocals::execute (function *fun)
   calculate_dominance_info (CDI_DOMINATORS);
   calculate_dominance_info (CDI_POST_DOMINATORS);
 
-#ifdef ENABLE_CHECKING
-  FOR_EACH_BB_FN (bb, fun)
-    gcc_assert (!bb->aux);
-#endif
+  if (flag_checking)
+    FOR_EACH_BB_FN (bb, fun)
+      gcc_assert (!bb->aux);
 
   for (arg = DECL_ARGUMENTS (fun->decl); arg; arg = DECL_CHAIN (arg))
     if (FLOAT_TYPE_P (TREE_TYPE (arg))
diff --git a/gcc/tree-ssa-operands.c b/gcc/tree-ssa-operands.c
index 85f9cca..2889e9f 100644
--- a/gcc/tree-ssa-operands.c
+++ b/gcc/tree-ssa-operands.c
@@ -882,12 +882,13 @@ get_expr_operands (struct function *fn, gimple *stmt, tree *expr_p, int flags)
     }
 
   /* If we get here, something has gone wrong.  */
-#ifdef ENABLE_CHECKING
-  fprintf (stderr, "unhandled expression in get_expr_operands():\n");
-  debug_tree (expr);
-  fputs ("\n", stderr);
-#endif
-  gcc_unreachable ();
+  if (flag_checking)
+    {
+      fprintf (stderr, "unhandled expression in get_expr_operands():\n");
+      debug_tree (expr);
+      fputs ("\n", stderr);
+      gcc_unreachable ();
+    }
 }
 
 
diff --git a/gcc/tree-ssa-propagate.c b/gcc/tree-ssa-propagate.c
index fbe41f9..363f439 100644
--- a/gcc/tree-ssa-propagate.c
+++ b/gcc/tree-ssa-propagate.c
@@ -1501,14 +1501,14 @@ static void
 replace_exp_1 (use_operand_p op_p, tree val,
     	       bool for_propagation ATTRIBUTE_UNUSED)
 {
-#if defined ENABLE_CHECKING
-  tree op = USE_FROM_PTR (op_p);
-
-  gcc_assert (!(for_propagation
-		&& TREE_CODE (op) == SSA_NAME
-		&& TREE_CODE (val) == SSA_NAME
-		&& !may_propagate_copy (op, val)));
-#endif
+  if (flag_checking)
+    {
+      tree op = USE_FROM_PTR (op_p);
+      gcc_assert (!(for_propagation
+		  && TREE_CODE (op) == SSA_NAME
+		  && TREE_CODE (val) == SSA_NAME
+		  && !may_propagate_copy (op, val)));
+    }
 
   if (TREE_CODE (val) == SSA_NAME)
     SET_USE (op_p, val);
diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c
index 8d86dcb..ab2becc 100644
--- a/gcc/tree-ssa-structalias.c
+++ b/gcc/tree-ssa-structalias.c
@@ -2544,10 +2544,11 @@ rewrite_constraints (constraint_graph_t graph,
   int i;
   constraint_t c;
 
-#ifdef ENABLE_CHECKING
-  for (unsigned int j = 0; j < graph->size; j++)
-    gcc_assert (find (j) == j);
-#endif
+  if (flag_checking)
+    {
+      for (unsigned int j = 0; j < graph->size; j++)
+	gcc_assert (find (j) == j);
+    }
 
   FOR_EACH_VEC_ELT (constraints, i, c)
     {
diff --git a/gcc/tree-ssa-ter.c b/gcc/tree-ssa-ter.c
index 7a7bcc9..b2d19ed 100644
--- a/gcc/tree-ssa-ter.c
+++ b/gcc/tree-ssa-ter.c
@@ -182,9 +182,7 @@ struct temp_expr_table
 /* A place for the many, many bitmaps we create.  */
 static bitmap_obstack ter_bitmap_obstack;
 
-#ifdef ENABLE_CHECKING
 extern void debug_ter (FILE *, temp_expr_table *);
-#endif
 
 
 /* Create a new TER table for MAP.  */
@@ -232,16 +230,16 @@ free_temp_expr_table (temp_expr_table *t)
 {
   bitmap ret = NULL;
 
-#ifdef ENABLE_CHECKING
-  unsigned x;
-  for (x = 0; x <= num_var_partitions (t->map); x++)
-    gcc_assert (!t->kill_list[x]);
-  for (x = 0; x < num_ssa_names; x++)
+  if (flag_checking)
     {
-      gcc_assert (t->expr_decl_uids[x] == NULL);
-      gcc_assert (t->partition_dependencies[x] == NULL);
+      for (unsigned x = 0; x <= num_var_partitions (t->map); x++)
+	gcc_assert (!t->kill_list[x]);
+      for (unsigned x = 0; x < num_ssa_names; x++)
+	{
+	  gcc_assert (t->expr_decl_uids[x] == NULL);
+	  gcc_assert (t->partition_dependencies[x] == NULL);
+	}
     }
-#endif
 
   BITMAP_FREE (t->partition_in_use);
   BITMAP_FREE (t->new_replaceable_dependencies);
@@ -748,7 +746,6 @@ dump_replaceable_exprs (FILE *f, bitmap expr)
 }
 
 
-#ifdef ENABLE_CHECKING
 /* Dump the status of the various tables in the expression table.  This is used
    exclusively to debug TER.  F is the place to send debug info and T is the
    table being debugged.  */
@@ -796,4 +793,3 @@ debug_ter (FILE *f, temp_expr_table *t)
 
   fprintf (f, "\n----------\n");
 }
-#endif
diff --git a/gcc/tree-ssa-threadupdate.c b/gcc/tree-ssa-threadupdate.c
index 4a147bb..49ec462 100644
--- a/gcc/tree-ssa-threadupdate.c
+++ b/gcc/tree-ssa-threadupdate.c
@@ -2334,7 +2334,7 @@ bb_ends_with_multiway_branch (basic_block bb ATTRIBUTE_UNUSED)
    REGION have exactly one incoming edge.  The only exception is the first block
    that may not have been connected to the rest of the cfg yet.  */
 
-DEBUG_FUNCTION void
+void
 verify_jump_thread (basic_block *region, unsigned n_region)
 {
   for (unsigned i = 0; i < n_region; i++)
@@ -2487,9 +2487,8 @@ duplicate_thread_path (edge entry, edge exit,
       scale_bbs_frequencies_int (region_copy, n_region, entry_freq, total_freq);
     }
 
-#ifdef ENABLE_CHECKING
-  verify_jump_thread (region_copy, n_region);
-#endif
+  if (flag_checking)
+    verify_jump_thread (region_copy, n_region);
 
   /* Remove the last branch in the jump thread path.  */
   remove_ctrl_stmt_and_useless_edges (region_copy[n_region - 1], exit->dest);
diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c
index 4b869be..b425b2c 100644
--- a/gcc/tree-ssa.c
+++ b/gcc/tree-ssa.c
@@ -910,7 +910,7 @@ error:
 /* Verify common invariants in the SSA web.
    TODO: verify the variable annotations.  */
 
-DEBUG_FUNCTION void
+void
 verify_ssa (bool check_modified_stmt, bool check_ssa_operands)
 {
   size_t i;
diff --git a/gcc/tree-ssa.h b/gcc/tree-ssa.h
index a3b9bed..570ac9c 100644
--- a/gcc/tree-ssa.h
+++ b/gcc/tree-ssa.h
@@ -77,5 +77,13 @@ redirect_edge_var_map_location (edge_var_map *v)
   return v->locus;
 }
 
+/* Verify SSA invariants, if internal consistency checks are enabled.  */
+
+static inline void
+checking_verify_ssa (bool check_modified_stmt, bool check_ssa_operands)
+{
+  if (flag_checking)
+    verify_ssa (check_modified_stmt, check_ssa_operands);
+}
 
 #endif /* GCC_TREE_SSA_H */
diff --git a/gcc/tree-ssanames.c b/gcc/tree-ssanames.c
index 64e2379..45ab6dc 100644
--- a/gcc/tree-ssanames.c
+++ b/gcc/tree-ssanames.c
@@ -341,9 +341,8 @@ release_ssa_name_fn (struct function *fn, tree var)
       if (MAY_HAVE_DEBUG_STMTS)
 	insert_debug_temp_for_var_def (NULL, var);
 
-#ifdef ENABLE_CHECKING
-      verify_imm_links (stderr, var);
-#endif
+      if (flag_checking)
+	verify_imm_links (stderr, var);
       while (imm->next != imm)
 	delink_imm_use (imm->next);
 
diff --git a/gcc/tree-stdarg.c b/gcc/tree-stdarg.c
index d69fa06..b602e2a 100644
--- a/gcc/tree-stdarg.c
+++ b/gcc/tree-stdarg.c
@@ -1105,13 +1105,14 @@ expand_ifn_va_arg (function *fun)
   if ((fun->curr_properties & PROP_gimple_lva) == 0)
     expand_ifn_va_arg_1 (fun);
 
-#if ENABLE_CHECKING
+  if (!flag_checking)
+    return;
+
   basic_block bb;
   gimple_stmt_iterator i;
   FOR_EACH_BB_FN (bb, fun)
     for (i = gsi_start_bb (bb); !gsi_end_p (i); gsi_next (&i))
       gcc_assert (!gimple_call_ifn_va_arg_p (gsi_stmt (i)));
-#endif
 }
 
 namespace {
diff --git a/gcc/tree-vect-loop-manip.c b/gcc/tree-vect-loop-manip.c
index 11c3ae2..e90bb33 100644
--- a/gcc/tree-vect-loop-manip.c
+++ b/gcc/tree-vect-loop-manip.c
@@ -919,9 +919,7 @@ slpeel_tree_duplicate_loop_to_edge_cfg (struct loop *loop,
   free (new_bbs);
   free (bbs);
 
-#ifdef ENABLE_CHECKING
-  verify_dominators (CDI_DOMINATORS);
-#endif
+  checking_verify_dominators (CDI_DOMINATORS);
 
   return new_loop;
 }
@@ -1003,11 +1001,13 @@ slpeel_can_duplicate_loop_p (const struct loop *loop, const_edge e)
   return true;
 }
 
-#ifdef ENABLE_CHECKING
 static void
-slpeel_verify_cfg_after_peeling (struct loop *first_loop,
-                                 struct loop *second_loop)
+slpeel_checking_verify_cfg_after_peeling (struct loop *first_loop,
+	                                  struct loop *second_loop)
 {
+  if (!flag_checking)
+    return;
+
   basic_block loop1_exit_bb = single_exit (first_loop)->dest;
   basic_block loop2_entry_bb = loop_preheader_edge (second_loop)->src;
   basic_block loop1_entry_bb = loop_preheader_edge (first_loop)->src;
@@ -1035,7 +1035,6 @@ slpeel_verify_cfg_after_peeling (struct loop *first_loop,
      second_loop.  */
   /* TODO */
 }
-#endif
 
 /* If the run time cost model check determines that vectorization is
    not profitable and hence scalar loop should be generated then set
@@ -1773,9 +1772,7 @@ vect_do_peeling_for_loop_bound (loop_vec_info loop_vinfo,
 				     0, LOOP_VINFO_VECT_FACTOR (loop_vinfo));
   gcc_assert (new_loop);
   gcc_assert (loop_num == loop->num);
-#ifdef ENABLE_CHECKING
-  slpeel_verify_cfg_after_peeling (loop, new_loop);
-#endif
+  slpeel_checking_verify_cfg_after_peeling (loop, new_loop);
 
   /* A guard that controls whether the new_loop is to be executed or skipped
      is placed in LOOP->exit.  LOOP->exit therefore has two successors - one
@@ -2032,9 +2029,7 @@ vect_do_peeling_for_alignment (loop_vec_info loop_vinfo, tree ni_name,
 				   bound, 0);
 
   gcc_assert (new_loop);
-#ifdef ENABLE_CHECKING
-  slpeel_verify_cfg_after_peeling (new_loop, loop);
-#endif
+  slpeel_checking_verify_cfg_after_peeling (new_loop, loop);
   /* For vectorization factor N, we need to copy at most N-1 values 
      for alignment and this means N-2 loopback edge executions.  */
   max_iter = LOOP_VINFO_VECT_FACTOR (loop_vinfo) - 2;
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index 3bc3b03..62c7622 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -242,9 +242,7 @@ static inline bool
 supports_overflow_infinity (const_tree type)
 {
   tree min = vrp_val_min (type), max = vrp_val_max (type);
-#ifdef ENABLE_CHECKING
-  gcc_assert (needs_overflow_infinity (type));
-#endif
+  gcc_checking_assert (needs_overflow_infinity (type));
   return (min != NULL_TREE
 	  && CONSTANT_CLASS_P (min)
 	  && max != NULL_TREE
@@ -373,9 +371,9 @@ static void
 set_value_range (value_range *vr, enum value_range_type t, tree min,
 		 tree max, bitmap equiv)
 {
-#if defined ENABLE_CHECKING
   /* Check the validity of the range.  */
-  if (t == VR_RANGE || t == VR_ANTI_RANGE)
+  if (flag_checking
+      && (t == VR_RANGE || t == VR_ANTI_RANGE))
     {
       int cmp;
 
@@ -395,12 +393,12 @@ set_value_range (value_range *vr, enum value_range_type t, tree min,
 		    || !is_overflow_infinity (max));
     }
 
-  if (t == VR_UNDEFINED || t == VR_VARYING)
-    gcc_assert (min == NULL_TREE && max == NULL_TREE);
-
-  if (t == VR_UNDEFINED || t == VR_VARYING)
-    gcc_assert (equiv == NULL || bitmap_empty_p (equiv));
-#endif
+  if (flag_checking
+      && (t == VR_UNDEFINED || t == VR_VARYING))
+    {
+      gcc_assert (min == NULL_TREE && max == NULL_TREE);
+      gcc_assert (equiv == NULL || bitmap_empty_p (equiv));
+    }
 
   vr->type = t;
   vr->min = min;
diff --git a/gcc/tree.c b/gcc/tree.c
index af31849..9893c98 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -5903,10 +5903,11 @@ free_lang_data_in_cgraph (void)
   /* Traverse every type found freeing its language data.  */
   FOR_EACH_VEC_ELT (fld.types, i, t)
     free_lang_data_in_type (t);
-#ifdef ENABLE_CHECKING
-  FOR_EACH_VEC_ELT (fld.types, i, t)
-    verify_type (t);
-#endif
+  if (flag_checking)
+    {
+      FOR_EACH_VEC_ELT (fld.types, i, t)
+	verify_type (t);
+    }
 
   delete fld.pset;
   fld.worklist.release ();
diff --git a/gcc/value-prof.c b/gcc/value-prof.c
index 90211ef..0c25470 100644
--- a/gcc/value-prof.c
+++ b/gcc/value-prof.c
@@ -230,9 +230,8 @@ gimple_remove_histogram_value (struct function *fun, gimple *stmt,
       hist2->hvalue.next = hist->hvalue.next;
     }
   free (hist->hvalue.counters);
-#ifdef ENABLE_CHECKING
-  memset (hist, 0xab, sizeof (*hist));
-#endif
+  if (CHECKING_P)
+    memset (hist, 0xab, sizeof (*hist));
   free (hist);
 }
 
@@ -595,9 +594,8 @@ free_hist (void **slot, void *data ATTRIBUTE_UNUSED)
 {
   histogram_value hist = *(histogram_value *) slot;
   free (hist->hvalue.counters);
-#ifdef ENABLE_CHECKING
-  memset (hist, 0xab, sizeof (*hist));
-#endif
+  if (CHECKING_P)
+    memset (hist, 0xab, sizeof (*hist));
   free (hist);
   return 1;
 }
diff --git a/gcc/var-tracking.c b/gcc/var-tracking.c
index 8010ce1..60c0320 100644
--- a/gcc/var-tracking.c
+++ b/gcc/var-tracking.c
@@ -399,7 +399,7 @@ struct variable
 /* Macro to access MEM_OFFSET as an HOST_WIDE_INT.  Evaluates MEM twice.  */
 #define INT_MEM_OFFSET(mem) (MEM_OFFSET_KNOWN_P (mem) ? MEM_OFFSET (mem) : 0)
 
-#if ENABLE_CHECKING && (GCC_VERSION >= 2007)
+#if CHECKING_P && (GCC_VERSION >= 2007)
 
 /* Access VAR's Ith part's offset, checking that it's not a one-part
    variable.  */
@@ -3571,7 +3571,6 @@ loc_cmp (rtx x, rtx y)
   return 0;
 }
 
-#if ENABLE_CHECKING
 /* Check the order of entries in one-part variables.   */
 
 int
@@ -3603,7 +3602,6 @@ canonicalize_loc_order_check (variable **slot,
 
   return 1;
 }
-#endif
 
 /* Mark with VALUE_RECURSED_INTO values that have neighbors that are
    more likely to be chosen as canonical for an equivalence set.
@@ -3832,17 +3830,16 @@ canonicalize_values_star (variable **slot, dataflow_set *set)
 	    else
 	      gcc_unreachable ();
 
-#if ENABLE_CHECKING
-	    while (list)
-	      {
-		if (list->offset == 0
-		    && (dv_as_opaque (list->dv) == dv_as_opaque (dv)
-			|| dv_as_opaque (list->dv) == dv_as_opaque (cdv)))
-		  gcc_unreachable ();
+	    if (flag_checking)
+	      while (list)
+		{
+		  if (list->offset == 0
+		      && (dv_as_opaque (list->dv) == dv_as_opaque (dv)
+			  || dv_as_opaque (list->dv) == dv_as_opaque (cdv)))
+		    gcc_unreachable ();
 
-		list = list->next;
-	      }
-#endif
+		  list = list->next;
+		}
 	  }
       }
 
@@ -6930,10 +6927,9 @@ compute_bb_dataflow (basic_block bb)
 	->traverse <dataflow_set *, canonicalize_values_mark> (out);
       shared_hash_htab (out->vars)
 	->traverse <dataflow_set *, canonicalize_values_star> (out);
-#if ENABLE_CHECKING
-      shared_hash_htab (out->vars)
-	->traverse <dataflow_set *, canonicalize_loc_order_check> (out);
-#endif
+      if (flag_checking)
+	shared_hash_htab (out->vars)
+	  ->traverse <dataflow_set *, canonicalize_loc_order_check> (out);
     }
   changed = dataflow_set_different (&old_out, out);
   dataflow_set_destroy (&old_out);
@@ -7038,13 +7034,14 @@ vt_find_locations (void)
 		  if (adjust)
 		    {
 		      dataflow_post_merge_adjust (in, &VTI (bb)->permp);
-#if ENABLE_CHECKING
-		      /* Merge and merge_adjust should keep entries in
-			 canonical order.  */
-		      shared_hash_htab (in->vars)
-			->traverse <dataflow_set *,
-				    canonicalize_loc_order_check> (in);
-#endif
+
+		      if (flag_checking)
+			/* Merge and merge_adjust should keep entries in
+			   canonical order.  */
+			shared_hash_htab (in->vars)
+			  ->traverse <dataflow_set *,
+				      canonicalize_loc_order_check> (in);
+
 		      if (dst_can_be_shared)
 			{
 			  shared_hash_destroy (in->vars);
@@ -9465,11 +9462,12 @@ vt_emit_notes (void)
 	 again.  */
       dataflow_set_clear (&VTI (bb)->in);
     }
-#ifdef ENABLE_CHECKING
-  shared_hash_htab (cur.vars)
-    ->traverse <variable_table_type *, emit_notes_for_differences_1>
-      (shared_hash_htab (empty_shared_hash));
-#endif
+
+  if (flag_checking)
+    shared_hash_htab (cur.vars)
+      ->traverse <variable_table_type *, emit_notes_for_differences_1>
+	(shared_hash_htab (empty_shared_hash));
+
   dataflow_set_destroy (&cur);
 
   if (MAY_HAVE_DEBUG_INSNS)
-- 
2.1.4


^ permalink raw reply	[flat|nested] 77+ messages in thread

* [PATCH 8/9] ENABLE_CHECKING refactoring: target-specific parts
  2015-10-05 23:27 [PATCH 1/9] ENABLE_CHECKING refactoring Mikhail Maltsev
                   ` (5 preceding siblings ...)
  2015-10-05 23:39 ` [PATCH 7/9] ENABLE_CHECKING refactoring: middle-end, LTO FE Mikhail Maltsev
@ 2015-10-05 23:40 ` Mikhail Maltsev
  2015-10-06 12:48   ` Bernd Schmidt
                     ` (2 more replies)
  2015-10-06 12:53 ` [PATCH 1/9] ENABLE_CHECKING refactoring Richard Biener
                   ` (4 subsequent siblings)
  11 siblings, 3 replies; 77+ messages in thread
From: Mikhail Maltsev @ 2015-10-05 23:40 UTC (permalink / raw)
  To: gcc-patches mailing list, Jeff Law, Richard Biener

[-- Attachment #1: Type: text/plain, Size: 658 bytes --]

gcc/ChangeLog:

2015-10-05  Mikhail Maltsev  <maltsevm@gmail.com>

	* config/alpha/alpha.c (alpha_function_arg): Use gcc_checking_assert.
	* config/arm/arm.c (arm_unwind_emit_sequence): Adjust to use CHECKING_P.
	* config/bfin/bfin.c (hwloop_optimize): Likewise.
	* config/i386/i386.c (ix86_print_operand_address,
	output_387_binary_op): Likewise.
	* config/ia64/ia64.c (ia64_sched_init, bundling): Likewise.
	* config/m68k/m68k.c (m68k_sched_md_init_global): Likewise.
	* config/rs6000/rs6000.c (htm_expand_builtin, rs6000_emit_prologue):
	Likewise.
	* config/rs6000/rs6000.h: Likewise.
	* config/visium/visium.c (visium_setup_incoming_varargs): Likewise.


[-- Attachment #2: 0008-Target-related-parts.patch --]
[-- Type: text/x-patch, Size: 8076 bytes --]

From 4e7a33c81b2435765b661c189171f2ce9a65c5ac Mon Sep 17 00:00:00 2001
From: Mikhail Maltsev <maltsevm@gmail.com>
Date: Sun, 4 Oct 2015 22:51:03 +0300
Subject: [PATCH 8/9] Target-related parts

---
 gcc/config/alpha/alpha.c   |  4 +---
 gcc/config/arm/arm.c       |  2 +-
 gcc/config/bfin/bfin.c     |  4 +---
 gcc/config/i386/i386.c     |  9 ++++-----
 gcc/config/ia64/ia64.c     | 20 +++++++++-----------
 gcc/config/m68k/m68k.c     |  2 +-
 gcc/config/rs6000/rs6000.c | 14 ++++++--------
 gcc/config/rs6000/rs6000.h |  2 +-
 gcc/config/visium/visium.c |  2 +-
 9 files changed, 25 insertions(+), 34 deletions(-)

diff --git a/gcc/config/alpha/alpha.c b/gcc/config/alpha/alpha.c
index eb2ae5f..b5e0bc4 100644
--- a/gcc/config/alpha/alpha.c
+++ b/gcc/config/alpha/alpha.c
@@ -5574,11 +5574,9 @@ alpha_function_arg (cumulative_args_t cum_v, machine_mode mode,
     basereg = 16;
   else
     {
-#ifdef ENABLE_CHECKING
       /* With alpha_split_complex_arg, we shouldn't see any raw complex
 	 values here.  */
-      gcc_assert (!COMPLEX_MODE_P (mode));
-#endif
+      gcc_checking_assert (!COMPLEX_MODE_P (mode));
 
       /* Set up defaults for FP operands passed in FP registers, and
 	 integral operands passed in integer registers.  */
diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 02f5dc3..73210bc 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -26854,7 +26854,7 @@ arm_unwind_emit_sequence (FILE * asm_out_file, rtx p)
       else
 	asm_fprintf (asm_out_file, "%r", reg);
 
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
       /* Check that the addresses are consecutive.  */
       e = XEXP (SET_DEST (e), 0);
       if (GET_CODE (e) == PLUS)
diff --git a/gcc/config/bfin/bfin.c b/gcc/config/bfin/bfin.c
index a131053..e53fe6d 100644
--- a/gcc/config/bfin/bfin.c
+++ b/gcc/config/bfin/bfin.c
@@ -3811,8 +3811,7 @@ hwloop_optimize (hwloop_info loop)
       edge e;
       edge_iterator ei;
 
-#ifdef ENABLE_CHECKING
-      if (loop->head != loop->incoming_dest)
+      if (CHECKING_P && loop->head != loop->incoming_dest)
 	{
 	  /* We aren't entering the loop at the top.  Since we've established
 	     that the loop is entered only at one point, this means there
@@ -3822,7 +3821,6 @@ hwloop_optimize (hwloop_info loop)
 	  FOR_EACH_EDGE (e, ei, loop->head->preds)
 	    gcc_assert (!(e->flags & EDGE_FALLTHRU));
 	}
-#endif
 
       emit_insn_before (seq, BB_HEAD (loop->head));
       seq = emit_label_before (gen_label_rtx (), seq);
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 9c4cfbd..2e98bb1 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -17209,7 +17209,7 @@ ix86_print_operand_address (FILE *file, rtx addr)
       /* Print SImode register names to force addr32 prefix.  */
       if (SImode_address_operand (addr, VOIDmode))
 	{
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
 	  gcc_assert (TARGET_64BIT);
 	  switch (GET_CODE (addr))
 	    {
@@ -17481,10 +17481,10 @@ output_387_binary_op (rtx insn, rtx *operands)
   const char *ssep;
   int is_sse = SSE_REG_P (operands[0]) || SSE_REG_P (operands[1]) || SSE_REG_P (operands[2]);
 
-#ifdef ENABLE_CHECKING
   /* Even if we do not want to check the inputs, this documents input
      constraints.  Which helps in understanding the following code.  */
-  if (STACK_REG_P (operands[0])
+  if (CHECKING_P
+      && STACK_REG_P (operands[0])
       && ((REG_P (operands[1])
 	   && REGNO (operands[0]) == REGNO (operands[1])
 	   && (STACK_REG_P (operands[2]) || MEM_P (operands[2])))
@@ -17494,8 +17494,7 @@ output_387_binary_op (rtx insn, rtx *operands)
       && (STACK_TOP_P (operands[1]) || STACK_TOP_P (operands[2])))
     ; /* ok */
   else
-    gcc_assert (is_sse);
-#endif
+    gcc_checking_assert (is_sse);
 
   switch (GET_CODE (operands[3]))
     {
diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c
index 779fc58..1f40ba2 100644
--- a/gcc/config/ia64/ia64.c
+++ b/gcc/config/ia64/ia64.c
@@ -6145,7 +6145,7 @@ struct reg_write_state
 
 /* Cumulative info for the current instruction group.  */
 struct reg_write_state rws_sum[NUM_REGS];
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
 /* Bitmap whether a register has been written in the current insn.  */
 HARD_REG_ELT_TYPE rws_insn[(NUM_REGS + HOST_BITS_PER_WIDEST_FAST_INT - 1)
 			   / HOST_BITS_PER_WIDEST_FAST_INT];
@@ -7313,15 +7313,13 @@ ia64_sched_init (FILE *dump ATTRIBUTE_UNUSED,
 		 int sched_verbose ATTRIBUTE_UNUSED,
 		 int max_ready ATTRIBUTE_UNUSED)
 {
-#ifdef ENABLE_CHECKING
-  rtx_insn *insn;
-
-  if (!sel_sched_p () && reload_completed)
-    for (insn = NEXT_INSN (current_sched_info->prev_head);
-	 insn != current_sched_info->next_tail;
-	 insn = NEXT_INSN (insn))
-      gcc_assert (!SCHED_GROUP_P (insn));
-#endif
+  if (CHECKING_P && !sel_sched_p () && reload_completed)
+    {
+      for (rtx_insn *insn = NEXT_INSN (current_sched_info->prev_head);
+	   insn != current_sched_info->next_tail;
+	   insn = NEXT_INSN (insn))
+	gcc_assert (!SCHED_GROUP_P (insn));
+    }
   last_scheduled_insn = NULL;
   init_insn_group_barriers ();
 
@@ -9319,7 +9317,7 @@ bundling (FILE *dump, int verbose, rtx_insn *prev_head_insn, rtx_insn *tail)
 	}
     }
 
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
   {
     /* Assert right calculation of middle_bundle_stops.  */
     int num = best_state->middle_bundle_stops;
diff --git a/gcc/config/m68k/m68k.c b/gcc/config/m68k/m68k.c
index c26f37b..35f5a20 100644
--- a/gcc/config/m68k/m68k.c
+++ b/gcc/config/m68k/m68k.c
@@ -6125,7 +6125,7 @@ m68k_sched_md_init_global (FILE *sched_dump ATTRIBUTE_UNUSED,
 			   int sched_verbose ATTRIBUTE_UNUSED,
 			   int n_insns ATTRIBUTE_UNUSED)
 {
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
   /* Check that all instructions have DFA reservations and
      that all instructions can be issued from a clean state.  */
   {
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index e408295..ddfca7c 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -12884,15 +12884,13 @@ htm_expand_builtin (tree exp, rtx target, bool * expandedp)
 	  case HTM_BUILTIN_TENDALL:  /* Alias for: tend. 1  */
 	  case HTM_BUILTIN_TRESUME:  /* Alias for: tsr. 1  */
 	    op[nopnds++] = GEN_INT (1);
-#ifdef ENABLE_CHECKING
-	    attr |= RS6000_BTC_UNARY;
-#endif
+	    if (CHECKING_P)
+	      attr |= RS6000_BTC_UNARY;
 	    break;
 	  case HTM_BUILTIN_TSUSPEND: /* Alias for: tsr. 0  */
 	    op[nopnds++] = GEN_INT (0);
-#ifdef ENABLE_CHECKING
-	    attr |= RS6000_BTC_UNARY;
-#endif
+	    if (CHECKING_P)
+	      attr |= RS6000_BTC_UNARY;
 	    break;
 	  default:
 	    break;
@@ -12913,7 +12911,7 @@ htm_expand_builtin (tree exp, rtx target, bool * expandedp)
 	    op[nopnds++] = cr;
 	  }
 
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
 	int expected_nopnds = 0;
 	if ((attr & RS6000_BTC_TYPE_MASK) == RS6000_BTC_UNARY)
 	  expected_nopnds = 1;
@@ -24097,7 +24095,7 @@ rs6000_emit_prologue (void)
      prior to it, when r12 is not used here for other purposes.  */
   rtx_insn *sp_adjust = 0;
 
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
   /* Track and check usage of r0, r11, r12.  */
   int reg_inuse = using_static_chain_p ? 1 << 11 : 0;
 #define START_USE(R) do \
diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h
index e4f2937..437be0f 100644
--- a/gcc/config/rs6000/rs6000.h
+++ b/gcc/config/rs6000/rs6000.h
@@ -1471,7 +1471,7 @@ enum reg_class
 
 extern enum reg_class rs6000_regno_regclass[FIRST_PSEUDO_REGISTER];
 
-#if ENABLE_CHECKING
+#if CHECKING_P
 #define REGNO_REG_CLASS(REGNO) 						\
   (gcc_assert (IN_RANGE ((REGNO), 0, FIRST_PSEUDO_REGISTER-1)),		\
    rs6000_regno_regclass[(REGNO)])
diff --git a/gcc/config/visium/visium.c b/gcc/config/visium/visium.c
index 41b7964..a8d1f22 100644
--- a/gcc/config/visium/visium.c
+++ b/gcc/config/visium/visium.c
@@ -1345,7 +1345,7 @@ visium_setup_incoming_varargs (cumulative_args_t pcum_v,
   local_args_so_far.p = &local_copy;
   locargs = get_cumulative_args (pcum_v);
 
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
   local_args_so_far.magic = CUMULATIVE_ARGS_MAGIC;
 #endif
 
-- 
2.1.4


^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 2/9] ENABLE_CHECKING refactoring: libcpp
  2015-10-05 23:29 ` [PATCH 2/9] ENABLE_CHECKING refactoring: libcpp Mikhail Maltsev
@ 2015-10-06 12:40   ` Bernd Schmidt
  2015-10-12 20:57     ` Jeff Law
  2015-10-21 21:19     ` Jeff Law
  0 siblings, 2 replies; 77+ messages in thread
From: Bernd Schmidt @ 2015-10-06 12:40 UTC (permalink / raw)
  To: Mikhail Maltsev, gcc-patches mailing list, Jeff Law, Richard Biener

I'm not entirely sure what to make of this series. There seem to be good 
bits in there but also some things I find questionable. I'll add some 
comments on things that occur to me.

On 10/06/2015 01:28 AM, Mikhail Maltsev wrote:
>
> 	* include/line-map.h: Fix use of ENABLE_CHECKING.

Fix how? What's wrong with it?

>   /* Sanity-checks are dependent on command-line options, so it is
>      called as a subroutine of cpp_read_main_file ().  */
> -#if ENABLE_CHECKING
> +#if CHECKING_P
>   static void sanity_checks (cpp_reader *);
>   static void sanity_checks (cpp_reader *pfile)
>   {

Ok, this one seems to be a real problem (should have been #ifdef), but...

> -#ifdef ENABLE_CHECKING
> +#if CHECKING_P

I fail to see the point of this change.

> -#ifdef ENABLE_CHECKING
> -      if (kind == MACRO_ARG_TOKEN_STRINGIFIED
> -	  || !track_macro_exp_p)
> -	/* We can't set the location of a stringified argument
> -	   token and we can't set any location if we aren't tracking
> -	   macro expansion locations.   */
> -	abort ();
> -#endif
> +      /* We can't set the location of a stringified argument
> +	 token and we can't set any location if we aren't tracking
> +	 macro expansion locations.   */
> +      gcc_checking_assert (kind != MACRO_ARG_TOKEN_STRINGIFIED
> +			   && track_macro_exp_p);

This kind of change seems good. I think the patch series would benefit 
if it was separated thematically rather than by sets of files. I.e., 
merge all changes like this one into one patch or maybe a few if it 
grows too large.

> +/* Redefine abort to report an internal error w/o coredump, and
> +   reporting the location of the error in the source file.  */
> +extern void fancy_abort (const char *, int, const char *) ATTRIBUTE_NORETURN;
> +#define abort() fancy_abort (__FILE__, __LINE__, __FUNCTION__)
> +
> +/* Use gcc_assert(EXPR) to test invariants.  */
> +#if ENABLE_ASSERT_CHECKING
> +#define gcc_assert(EXPR) 						\
> +   ((void)(!(EXPR) ? fancy_abort (__FILE__, __LINE__, __FUNCTION__), 0 : 0))
> +#elif (GCC_VERSION >= 4005)
> +#define gcc_assert(EXPR) 						\
> +  ((void)(__builtin_expect (!(EXPR), 0) ? __builtin_unreachable (), 0 : 0))
> +#else
> +/* Include EXPR, so that unused variable warnings do not occur.  */
> +#define gcc_assert(EXPR) ((void)(0 && (EXPR)))
> +#endif

Probably a good thing, but it looks like libcpp has grown its own 
variant linemap_assert; we should check whether that can be replaced.

Also, the previous patch already introduces a use of gcc_assert, or at 
least a reference to it, and it's only defined here. The two 
modifications of libcpp/system.h should probably be merged into one.


Bernd

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 5/9] ENABLE_CHECKING refactoring: pool allocators
  2015-10-05 23:32 ` [PATCH 5/9] ENABLE_CHECKING refactoring: pool allocators Mikhail Maltsev
@ 2015-10-06 12:41   ` Bernd Schmidt
  2015-10-06 12:45     ` Richard Biener
  0 siblings, 1 reply; 77+ messages in thread
From: Bernd Schmidt @ 2015-10-06 12:41 UTC (permalink / raw)
  To: Mikhail Maltsev, gcc-patches mailing list, Jeff Law, Richard Biener

On 10/06/2015 01:32 AM, Mikhail Maltsev wrote:
> gcc/ChangeLog:
>
> 2015-10-05  Mikhail Maltsev  <maltsevm@gmail.com>
>
> 	* alloc-pool.h (base_pool_allocator::initialize, ::allocate,
> 	::remove): Adjust to use CHECKING_P.

Why CHECKING_P for these and not flag_checking as elsewhere?


Bernd

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 5/9] ENABLE_CHECKING refactoring: pool allocators
  2015-10-06 12:41   ` Bernd Schmidt
@ 2015-10-06 12:45     ` Richard Biener
  2015-10-19  0:47       ` Mikhail Maltsev
  0 siblings, 1 reply; 77+ messages in thread
From: Richard Biener @ 2015-10-06 12:45 UTC (permalink / raw)
  To: Bernd Schmidt; +Cc: Mikhail Maltsev, gcc-patches mailing list, Jeff Law

On Tue, Oct 6, 2015 at 2:41 PM, Bernd Schmidt <bschmidt@redhat.com> wrote:
> On 10/06/2015 01:32 AM, Mikhail Maltsev wrote:
>>
>> gcc/ChangeLog:
>>
>> 2015-10-05  Mikhail Maltsev  <maltsevm@gmail.com>
>>
>>         * alloc-pool.h (base_pool_allocator::initialize, ::allocate,
>>         ::remove): Adjust to use CHECKING_P.
>
>
> Why CHECKING_P for these and not flag_checking as elsewhere?

Probably because they are in inline functions and thus possibly would
affect optimization.  Not sure why they are inline functions in the
first place...  I'd agree to using flag_checking here.

Richard.

>
> Bernd

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 7/9] ENABLE_CHECKING refactoring: middle-end, LTO FE
  2015-10-05 23:39 ` [PATCH 7/9] ENABLE_CHECKING refactoring: middle-end, LTO FE Mikhail Maltsev
@ 2015-10-06 12:46   ` Bernd Schmidt
  2015-10-06 12:59     ` Richard Biener
  2015-10-06 12:59     ` Richard Biener
  0 siblings, 2 replies; 77+ messages in thread
From: Bernd Schmidt @ 2015-10-06 12:46 UTC (permalink / raw)
  To: Mikhail Maltsev, gcc-patches mailing list, Jeff Law, Richard Biener

On 10/06/2015 01:39 AM, Mikhail Maltsev wrote:
>   void verify_insn_chain (void);
> +static inline void checking_verify_insn_chain ();
>   static void fixup_fallthru_exit_predecessor (void);
>   static int can_delete_note_p (const rtx_note *);
>   static int can_delete_label_p (const rtx_code_label *);
[...]
> @@ -3990,6 +3987,16 @@ verify_insn_chain (void)
>
>     gcc_assert (insn_cnt1 == insn_cnt2);
>   }
> +
> +/* Perform checks, if they were requested by corresponding flag.  */
> +
> +static inline void
> +checking_verify_insn_chain ()
> +{
> +  if (flag_checking)
> +    verify_insn_chain ();
> +}
> +

There are many new such small inline functions, and I don't think they 
buy us much over just writing out the pattern where they are called. 
Also, just defined the function before its first use rather than writing 
a forward declaration.

> diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c
> index 3b8d594..7771514 100644
> --- a/gcc/tree-ssa-alias.c
> +++ b/gcc/tree-ssa-alias.c
> @@ -1443,11 +1443,8 @@ refs_may_alias_p_1 (ao_ref *ref1, ao_ref *ref2, bool tbaa_p)
>  				      tbaa_p);
>
>    /* We really do not want to end up here, but returning true is safe.  */
> -#ifdef ENABLE_CHECKING
> -  gcc_unreachable ();
> -#else
> +  gcc_checking_assert (false);
>    return true;
> -#endif
>  }

I think the consensus has been to avoid assert (false), so this would be

if (checking)
   gcc_unreachable ();

but maybe we really just want to do the gcc_unreachable unconditionally.


Bernd

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 8/9] ENABLE_CHECKING refactoring: target-specific parts
  2015-10-05 23:40 ` [PATCH 8/9] ENABLE_CHECKING refactoring: target-specific parts Mikhail Maltsev
@ 2015-10-06 12:48   ` Bernd Schmidt
  2015-10-29 19:43     ` Jeff Law
  2015-10-29 21:23   ` Jeff Law
  2015-10-30  4:13   ` Jeff Law
  2 siblings, 1 reply; 77+ messages in thread
From: Bernd Schmidt @ 2015-10-06 12:48 UTC (permalink / raw)
  To: Mikhail Maltsev, gcc-patches mailing list, Jeff Law, Richard Biener

On 10/06/2015 01:40 AM, Mikhail Maltsev wrote:
>
> -#ifdef ENABLE_CHECKING
> +#if CHECKING_P
>         /* Check that the addresses are consecutive.  */
>         e = XEXP (SET_DEST (e), 0);
>         if (GET_CODE (e) == PLUS)
> diff --git a/gcc/config/bfin/bfin.c b/gcc/config/bfin/bfin.c
> index a131053..e53fe6d 100644
> --- a/gcc/config/bfin/bfin.c
> +++ b/gcc/config/bfin/bfin.c
> @@ -3811,8 +3811,7 @@ hwloop_optimize (hwloop_info loop)
>         edge e;
>         edge_iterator ei;
>
> -#ifdef ENABLE_CHECKING
> -      if (loop->head != loop->incoming_dest)
> +      if (CHECKING_P && loop->head != loop->incoming_dest)
>   	{

This stuff also seems inconsistent. Why use CHECKING_P instead of 
flag_checking? Why use #if sometimes and if in other cases?


Bernd

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 1/9] ENABLE_CHECKING refactoring
  2015-10-05 23:27 [PATCH 1/9] ENABLE_CHECKING refactoring Mikhail Maltsev
                   ` (6 preceding siblings ...)
  2015-10-05 23:40 ` [PATCH 8/9] ENABLE_CHECKING refactoring: target-specific parts Mikhail Maltsev
@ 2015-10-06 12:53 ` Richard Biener
  2015-10-12 20:48 ` Jeff Law
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 77+ messages in thread
From: Richard Biener @ 2015-10-06 12:53 UTC (permalink / raw)
  To: Mikhail Maltsev; +Cc: gcc-patches mailing list, Jeff Law

On Tue, Oct 6, 2015 at 1:27 AM, Mikhail Maltsev <maltsevm@gmail.com> wrote:
> Hi!
>
> This is an updated series of patches which converts 'ENABLE_CHECKING' macro into
> a flag, 'flag_checking' (and 'CHECKING_P' macro in several cases). For now
> flag_checking is always initialized with the value of 'CHECKING_P', but later it
> can be turned into a proper command-line flag and probably split into several
> checks. I also added several function which verify internal data structures when
> flag_checking is enabled (e.g. checking_verify_flow_info which calls
> verify_flow_info). These functions make their callers look somewhat cleaner.
>
> The cases where I left 'CHECKING_P' are:
> 1. libcpp (turn ICE after an error into fatal error) and pretty-printers (that
> would require to pass flag_checking to libcpp just for this single case).
> 2. Code which fills memory in the pools with some predefined patterns in
> deallocation methods (this would add some overhead to each deallocation), though
> I have not measured performance impact yet.
> 3. Generators and generated code.
> 4. Target-specific code
> 5. 'struct lra_reg' which has an additional field in checking build
> 6. Likewise, 'struct moveop_static_params' in insn scheduler and
> 'cumulative_args_t' in target.h.
> 7. macro-related code in libcpp (for the same reason)
> 8. real.c and fwprop.c - I'll profile these and also fix to use flag_checking if
> there won't be any measurable overhead.
>
> There are 9 patches:
> 1. Add flag_checking and CHECKING_P macros
> 2. Use CHECKING_P in libcpp
> 3. Ada and Java frontends
> 4. Fortran frontend
> 5. Pool allocators
> 6. Generator programs
> 7. Most of middle-end (GIMPLE, IPA, RTL) - it can be split further, if needed.
> 8. Target-specific code
> 9. C++ frontend - in progress (I will send this part soon).
>
> Some issues related to checking builds:
> 1. Useless check in graphite: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67842
> 2. I found a test which fails only on release builds:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58583 (reopened)
> 3. Another one: gcc.c-torture/compile/pr52073.c which is, I guess, caused by
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67816 (the backtrace is the same,
> at least).
>
> Each patch (when applied on top of all the previous ones) compiles in both
> checking and release builds. The combined patch passes bootstrap and regression
> tests in checking an release builds (apart from 2 issues mentioned above) on
> x86_64-linux. I'll also run it through config-list.mk.

This looks ok to me, though I'd have defined CHECKING_P from configure.ac where
we define ENABLE_CHECKING.

Index: gcc/configure.ac
===================================================================
--- gcc/configure.ac    (revision 228519)
+++ gcc/configure.ac    (working copy)
@@ -569,7 +569,10 @@ if test x$ac_checking != x ; then
   AC_DEFINE(ENABLE_CHECKING, 1,
 [Define if you want more run-time sanity checks.  This one gets a grab
    bag of miscellaneous but relatively cheap checks.])
+  AC_DEFINE(CHECKING_P, 1)
   nocommon_flag=-fno-common
+else
+  AC_DEFINE(CHECKING_P, 0)
 fi
 AC_SUBST(nocommon_flag)
 if test x$ac_df_checking != x ; then

should do that?

Richard.


> --
> Regards,
>     Mikhail Maltsev
>
>
> gcc/ChangeLog:
>
> 2015-10-05  Mikhail Maltsev  <maltsevm@gmail.com>
>
>         * common.opt: Add flag_checking.
>         * system.h (CHECKING_P): Define.
>
> libcpp/ChangeLog:
>
> 2015-10-05  Mikhail Maltsev  <maltsevm@gmail.com>
>
>         * system.h (CHECKING_P, gcc_checking_assert): Define.

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 6/9] ENABLE_CHECKING refactoring: generators
  2015-10-05 23:34 ` [PATCH 6/9] ENABLE_CHECKING refactoring: generators Mikhail Maltsev
@ 2015-10-06 12:57   ` Richard Biener
  2015-10-19  0:09     ` Mikhail Maltsev
  0 siblings, 1 reply; 77+ messages in thread
From: Richard Biener @ 2015-10-06 12:57 UTC (permalink / raw)
  To: Mikhail Maltsev; +Cc: gcc-patches mailing list, Jeff Law

On Tue, Oct 6, 2015 at 1:34 AM, Mikhail Maltsev <maltsevm@gmail.com> wrote:
> gcc/ChangeLog:
>
> 2015-10-05  Mikhail Maltsev  <maltsevm@gmail.com>
>
>         * genautomata.c: Use CHECKING_P instead of ENABLE_CHECKING.
>         * genconditions.c: Define CHECKING_P in generated code.
>         * genextract.c: Use CHECKING_P instead of ENABLE_CHECKING.
>         * gengtype.c (main): Likewise.
>         * gengtype.h: Likewise.

The generators should simply unconditionally check (not in generated
files, of course).
And the generated code parts should use flag_checking.

Richard.

>

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 7/9] ENABLE_CHECKING refactoring: middle-end, LTO FE
  2015-10-06 12:46   ` Bernd Schmidt
  2015-10-06 12:59     ` Richard Biener
@ 2015-10-06 12:59     ` Richard Biener
  2015-10-19  0:56       ` Mikhail Maltsev
  1 sibling, 1 reply; 77+ messages in thread
From: Richard Biener @ 2015-10-06 12:59 UTC (permalink / raw)
  To: Bernd Schmidt; +Cc: Mikhail Maltsev, gcc-patches mailing list, Jeff Law

On Tue, Oct 6, 2015 at 2:46 PM, Bernd Schmidt <bschmidt@redhat.com> wrote:
> On 10/06/2015 01:39 AM, Mikhail Maltsev wrote:
>>
>>   void verify_insn_chain (void);
>> +static inline void checking_verify_insn_chain ();
>>   static void fixup_fallthru_exit_predecessor (void);
>>   static int can_delete_note_p (const rtx_note *);
>>   static int can_delete_label_p (const rtx_code_label *);
>
> [...]
>>
>> @@ -3990,6 +3987,16 @@ verify_insn_chain (void)
>>
>>     gcc_assert (insn_cnt1 == insn_cnt2);
>>   }
>> +
>> +/* Perform checks, if they were requested by corresponding flag.  */
>> +
>> +static inline void
>> +checking_verify_insn_chain ()
>> +{
>> +  if (flag_checking)
>> +    verify_insn_chain ();
>> +}
>> +
>
>
> There are many new such small inline functions, and I don't think they buy
> us much over just writing out the pattern where they are called. Also, just
> defined the function before its first use rather than writing a forward
> declaration.
>
>> diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c
>> index 3b8d594..7771514 100644
>> --- a/gcc/tree-ssa-alias.c
>> +++ b/gcc/tree-ssa-alias.c
>> @@ -1443,11 +1443,8 @@ refs_may_alias_p_1 (ao_ref *ref1, ao_ref *ref2,
>> bool tbaa_p)
>>                                       tbaa_p);
>>
>>    /* We really do not want to end up here, but returning true is safe.
>> */
>> -#ifdef ENABLE_CHECKING
>> -  gcc_unreachable ();
>> -#else
>> +  gcc_checking_assert (false);
>>    return true;
>> -#endif
>>  }
>
>
> I think the consensus has been to avoid assert (false), so this would be
>
> if (checking)
>   gcc_unreachable ();
>
> but maybe we really just want to do the gcc_unreachable unconditionally.

I'm fine with unconditional gcc_unreachable - the code is old enough now
that we shouldn't hit this anymore.

Richard.

>
> Bernd

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 7/9] ENABLE_CHECKING refactoring: middle-end, LTO FE
  2015-10-06 12:46   ` Bernd Schmidt
@ 2015-10-06 12:59     ` Richard Biener
  2015-10-06 12:59     ` Richard Biener
  1 sibling, 0 replies; 77+ messages in thread
From: Richard Biener @ 2015-10-06 12:59 UTC (permalink / raw)
  To: Bernd Schmidt; +Cc: Mikhail Maltsev, gcc-patches mailing list, Jeff Law

On Tue, Oct 6, 2015 at 2:46 PM, Bernd Schmidt <bschmidt@redhat.com> wrote:
> On 10/06/2015 01:39 AM, Mikhail Maltsev wrote:
>>
>>   void verify_insn_chain (void);
>> +static inline void checking_verify_insn_chain ();
>>   static void fixup_fallthru_exit_predecessor (void);
>>   static int can_delete_note_p (const rtx_note *);
>>   static int can_delete_label_p (const rtx_code_label *);
>
> [...]
>>
>> @@ -3990,6 +3987,16 @@ verify_insn_chain (void)
>>
>>     gcc_assert (insn_cnt1 == insn_cnt2);
>>   }
>> +
>> +/* Perform checks, if they were requested by corresponding flag.  */
>> +
>> +static inline void
>> +checking_verify_insn_chain ()
>> +{
>> +  if (flag_checking)
>> +    verify_insn_chain ();
>> +}
>> +
>
>
> There are many new such small inline functions, and I don't think they buy
> us much over just writing out the pattern where they are called. Also, just
> defined the function before its first use rather than writing a forward
> declaration.
>
>> diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c
>> index 3b8d594..7771514 100644
>> --- a/gcc/tree-ssa-alias.c
>> +++ b/gcc/tree-ssa-alias.c
>> @@ -1443,11 +1443,8 @@ refs_may_alias_p_1 (ao_ref *ref1, ao_ref *ref2,
>> bool tbaa_p)
>>                                       tbaa_p);
>>
>>    /* We really do not want to end up here, but returning true is safe.
>> */
>> -#ifdef ENABLE_CHECKING
>> -  gcc_unreachable ();
>> -#else
>> +  gcc_checking_assert (false);
>>    return true;
>> -#endif
>>  }
>
>
> I think the consensus has been to avoid assert (false), so this would be
>
> if (checking)
>   gcc_unreachable ();
>
> but maybe we really just want to do the gcc_unreachable unconditionally.

I'm fine with unconditional gcc_unreachable - the code is old enough now
that we shouldn't hit this anymore.

Richard.

>
> Bernd

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 1/9] ENABLE_CHECKING refactoring
  2015-10-05 23:27 [PATCH 1/9] ENABLE_CHECKING refactoring Mikhail Maltsev
                   ` (7 preceding siblings ...)
  2015-10-06 12:53 ` [PATCH 1/9] ENABLE_CHECKING refactoring Richard Biener
@ 2015-10-12 20:48 ` Jeff Law
  2015-10-13 21:33 ` Jeff Law
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 77+ messages in thread
From: Jeff Law @ 2015-10-12 20:48 UTC (permalink / raw)
  To: Mikhail Maltsev, gcc-patches mailing list, Richard Biener

On 10/05/2015 05:27 PM, Mikhail Maltsev wrote:
> 3. Another one: gcc.c-torture/compile/pr52073.c which is, I guess, caused by
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67816 (the backtrace is the same,
> at least).
FYI, this is fixed on the trunk.

jeff

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 2/9] ENABLE_CHECKING refactoring: libcpp
  2015-10-06 12:40   ` Bernd Schmidt
@ 2015-10-12 20:57     ` Jeff Law
  2015-10-19  1:18       ` Mikhail Maltsev
  2015-10-21 21:19     ` Jeff Law
  1 sibling, 1 reply; 77+ messages in thread
From: Jeff Law @ 2015-10-12 20:57 UTC (permalink / raw)
  To: Bernd Schmidt, Mikhail Maltsev, gcc-patches mailing list, Richard Biener

On 10/06/2015 06:40 AM, Bernd Schmidt wrote:
> I'm not entirely sure what to make of this series. There seem to be good
> bits in there but also some things I find questionable. I'll add some
> comments on things that occur to me.
Maybe we should start pulling out the bits that we think are ready & 
good and start installing them independently.

I'm less concerned about getting conditional compilation out of the lib* 
directories right now than I am the core of the compiler.  So I wouldn't 
lose any sleep if we extracted the obviously good bits for libcpp tested 
& installed those, then table the rest of the libcpp stuff and focused 
on the core compiler.

Thoughts?


>
> On 10/06/2015 01:28 AM, Mikhail Maltsev wrote:
>>
>>     * include/line-map.h: Fix use of ENABLE_CHECKING.
>
> Fix how? What's wrong with it?
>
>>   /* Sanity-checks are dependent on command-line options, so it is
>>      called as a subroutine of cpp_read_main_file ().  */
>> -#if ENABLE_CHECKING
>> +#if CHECKING_P
>>   static void sanity_checks (cpp_reader *);
>>   static void sanity_checks (cpp_reader *pfile)
>>   {
>
> Ok, this one seems to be a real problem (should have been #ifdef), but...
Agreed.

>
>> -#ifdef ENABLE_CHECKING
>> +#if CHECKING_P
>
> I fail to see the point of this change.
I'm guessing (and Mikhail, please correct me if I'm wrong), but I think 
he's trying to get away from ENABLE_CHECKING and instead use a macro 
which is always defined to a value.


>
>> -#ifdef ENABLE_CHECKING
>> -      if (kind == MACRO_ARG_TOKEN_STRINGIFIED
>> -      || !track_macro_exp_p)
>> -    /* We can't set the location of a stringified argument
>> -       token and we can't set any location if we aren't tracking
>> -       macro expansion locations.   */
>> -    abort ();
>> -#endif
>> +      /* We can't set the location of a stringified argument
>> +     token and we can't set any location if we aren't tracking
>> +     macro expansion locations.   */
>> +      gcc_checking_assert (kind != MACRO_ARG_TOKEN_STRINGIFIED
>> +               && track_macro_exp_p);
>
> This kind of change seems good. I think the patch series would benefit
> if it was separated thematically rather than by sets of files. I.e.,
> merge all changes like this one into one patch or maybe a few if it
> grows too large.
That would work for me.  I just asked Mikhail to try and break down the 
monster patch into something that could be digested.  Ultimately my goal 
was to make it possible to start reviewing and installing these bits and 
keep making progress on removing the conditionally compiled code.

>
>> +/* Redefine abort to report an internal error w/o coredump, and
>> +   reporting the location of the error in the source file.  */
>> +extern void fancy_abort (const char *, int, const char *)
>> ATTRIBUTE_NORETURN;
>> +#define abort() fancy_abort (__FILE__, __LINE__, __FUNCTION__)
>> +
>> +/* Use gcc_assert(EXPR) to test invariants.  */
>> +#if ENABLE_ASSERT_CHECKING
>> +#define gcc_assert(EXPR)                         \
>> +   ((void)(!(EXPR) ? fancy_abort (__FILE__, __LINE__, __FUNCTION__),
>> 0 : 0))
>> +#elif (GCC_VERSION >= 4005)
>> +#define gcc_assert(EXPR)                         \
>> +  ((void)(__builtin_expect (!(EXPR), 0) ? __builtin_unreachable (), 0
>> : 0))
>> +#else
>> +/* Include EXPR, so that unused variable warnings do not occur.  */
>> +#define gcc_assert(EXPR) ((void)(0 && (EXPR)))
>> +#endif
>
> Probably a good thing, but it looks like libcpp has grown its own
> variant linemap_assert; we should check whether that can be replaced.
>
> Also, the previous patch already introduces a use of gcc_assert, or at
> least a reference to it, and it's only defined here. The two
> modifications of libcpp/system.h should probably be merged into one.
Agreed.

jeff

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 1/9] ENABLE_CHECKING refactoring
  2015-10-05 23:27 [PATCH 1/9] ENABLE_CHECKING refactoring Mikhail Maltsev
                   ` (8 preceding siblings ...)
  2015-10-12 20:48 ` Jeff Law
@ 2015-10-13 21:33 ` Jeff Law
  2015-10-18  8:25   ` Mikhail Maltsev
  2015-11-01 14:58 ` [PATCH 9/9] ENABLE_CHECKING refactoring: C family front ends Mikhail Maltsev
  2015-11-01 20:19 ` [PATCH 10/9] ENABLE_CHECKING refactoring: remove remaining occurrences Mikhail Maltsev
  11 siblings, 1 reply; 77+ messages in thread
From: Jeff Law @ 2015-10-13 21:33 UTC (permalink / raw)
  To: Mikhail Maltsev, gcc-patches mailing list, Richard Biener

On 10/05/2015 05:27 PM, Mikhail Maltsev wrote:
> Hi!
>
> This is an updated series of patches which converts 'ENABLE_CHECKING' macro into
> a flag, 'flag_checking' (and 'CHECKING_P' macro in several cases). For now
> flag_checking is always initialized with the value of 'CHECKING_P', but later it
> can be turned into a proper command-line flag and probably split into several
> checks. I also added several function which verify internal data structures when
> flag_checking is enabled (e.g. checking_verify_flow_info which calls
> verify_flow_info). These functions make their callers look somewhat cleaner.
>
> The cases where I left 'CHECKING_P' are:
> 1. libcpp (turn ICE after an error into fatal error) and pretty-printers (that
> would require to pass flag_checking to libcpp just for this single case).
> 2. Code which fills memory in the pools with some predefined patterns in
> deallocation methods (this would add some overhead to each deallocation), though
> I have not measured performance impact yet.
> 3. Generators and generated code.
> 4. Target-specific code
> 5. 'struct lra_reg' which has an additional field in checking build
> 6. Likewise, 'struct moveop_static_params' in insn scheduler and
> 'cumulative_args_t' in target.h.
> 7. macro-related code in libcpp (for the same reason)
> 8. real.c and fwprop.c - I'll profile these and also fix to use flag_checking if
> there won't be any measurable overhead.
>
> There are 9 patches:
> 1. Add flag_checking and CHECKING_P macros
> 2. Use CHECKING_P in libcpp
> 3. Ada and Java frontends
> 4. Fortran frontend
> 5. Pool allocators
> 6. Generator programs
> 7. Most of middle-end (GIMPLE, IPA, RTL) - it can be split further, if needed.
> 8. Target-specific code
> 9. C++ frontend - in progress (I will send this part soon).
>
> Some issues related to checking builds:
> 1. Useless check in graphite:https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67842
> 2. I found a test which fails only on release builds:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58583  (reopened)
> 3. Another one: gcc.c-torture/compile/pr52073.c which is, I guess, caused by
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67816  (the backtrace is the same,
> at least).
>
> Each patch (when applied on top of all the previous ones) compiles in both
> checking and release builds. The combined patch passes bootstrap and regression
> tests in checking an release builds (apart from 2 issues mentioned above) on
> x86_64-linux. I'll also run it through config-list.mk.
>
> -- Regards, Mikhail Maltsev gcc/ChangeLog: 2015-10-05 Mikhail Maltsev
> <maltsevm@gmail.com> * common.opt: Add flag_checking. * system.h
> (CHECKING_P): Define. libcpp/ChangeLog: 2015-10-05 Mikhail Maltsev
> <maltsevm@gmail.com> * system.h (CHECKING_P, gcc_checking_assert): Define.
>
>
> 0001-Prerequisites-for-ENABLE_CHECKING-conversion.patch
>
>
>  From 8096ea4714b3b7a96b414a70fd0de34e5e5a707a Mon Sep 17 00:00:00 2001
> From: Mikhail Maltsev<maltsevm@gmail.com>
> Date: Sun, 20 Sep 2015 04:30:42 +0300
> Subject: [PATCH 1/9] Prerequisites for ENABLE_CHECKING conversion
>
> Define CHECKING_P macros. Add flag_checking.
> Define gcc_checking_assert in libcpp
> ---
>   gcc/common.opt  | 5 +++++
>   gcc/system.h    | 3 +++
>   libcpp/system.h | 8 ++++++++
>   3 files changed, 16 insertions(+)
I committed this prerequisite patch to the trunk.

jeff

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 1/9] ENABLE_CHECKING refactoring
  2015-10-13 21:33 ` Jeff Law
@ 2015-10-18  8:25   ` Mikhail Maltsev
  2015-10-19 11:14     ` Bernd Schmidt
                       ` (2 more replies)
  0 siblings, 3 replies; 77+ messages in thread
From: Mikhail Maltsev @ 2015-10-18  8:25 UTC (permalink / raw)
  To: Jeff Law, gcc-patches mailing list, Richard Biener

[-- Attachment #1: Type: text/plain, Size: 2348 bytes --]

On 10/12/2015 11:57 PM, Jeff Law wrote:
>>> -#ifdef ENABLE_CHECKING
>>> +#if CHECKING_P
>>
>> I fail to see the point of this change.
> I'm guessing (and Mikhail, please correct me if I'm wrong), but I think he's
> trying to get away from ENABLE_CHECKING and instead use a macro which is
> always defined to a value.
Yes, exactly. Such macro is better because it can be used both for conditional
compilation (if needed) and normal if-s (unlike ENABLE_CHECKING).

On 10/14/2015 12:33 AM, Jeff Law wrote:
>>   gcc/common.opt  | 5 +++++
>>   gcc/system.h    | 3 +++
>>   libcpp/system.h | 8 ++++++++
>>   3 files changed, 16 insertions(+)
> I committed this prerequisite patch to the trunk.
> 
> jeff
> 

There is a typo here:

> #ifdef ENABLE_CHECKING
> #define gcc_checking_assert(EXPR) gcc_assert (EXPR)
>+#define CHECKING_P 1
> #else
>+/* N.B.: in release build EXPR is not evaluated.  */
> #define gcc_checking_assert(EXPR) ((void)(0 && (EXPR)))
>+#define CHECKING_P 1
> #endif

In my original patch the second definition actually was
'+#define CHECKING_P 0'

Also, gcc_checking_assert in libcpp requires gcc_assert to be defined. That was
missing in my original patch (and was added in patch 2/9), but I think it would
be better to fix it here, as Bernd noticed (in the last paragraph of [1]).

Besides, I like Richard's proposal [2] about moving CHECKING_P macros into
configure.ac.

[1] https://gcc.gnu.org/ml/gcc-patches/2015-10/msg00550.html
[2] https://gcc.gnu.org/ml/gcc-patches/2015-10/msg00555.html

It required minor tweaking in order to silence autotools' warnings. I attached
the modified patch.

OK for trunk (after bootstrap/regtest)?

P.S. I am planning to post at least some of the other updated parts today, and I
also hope to get in time with the whole series (before stage1 ends).

-- 
Regards,
    Mikhail Maltsev

gcc/ChangeLog:

2015-10-18  Mikhail Maltsev  <maltsevm@gmail.com>

        * config.in: Regenerate.
        * configure: Regenerate.
        * configure.ac (CHECKING_P): Define.
        * system.h: Use CHECKING_P.

libcpp/ChangeLog:

2015-10-18  Mikhail Maltsev  <maltsevm@gmail.com>

        * config.in: Regenerate.
        * configure: Regenerate.
        * configure.ac (CHECKING_P): Define.
        * system.h (fancy_abort): Declare.
        (abort): Define.
        (gcc_assert): Define. Use CHECKING_P.


[-- Attachment #2: prereq.patch --]
[-- Type: text/x-patch, Size: 5194 bytes --]

diff --git a/gcc/config.in b/gcc/config.in
index 093478c..48d7e64 100644
--- a/gcc/config.in
+++ b/gcc/config.in
@@ -30,6 +30,13 @@
 #endif
 
 
+/* Define to 1 if you want more run-time sanity checks. This one gets a grab
+   bag of miscellaneous but relatively cheap checks. */
+#ifndef USED_FOR_TARGET
+#undef CHECKING_P
+#endif
+
+
 /* Define 0/1 to force the choice for exception handling model. */
 #ifndef USED_FOR_TARGET
 #undef CONFIG_SJLJ_EXCEPTIONS
diff --git a/gcc/configure b/gcc/configure
index 6b160ae..3122499 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -7096,7 +7096,12 @@ if test x$ac_checking != x ; then
 
 $as_echo "#define ENABLE_CHECKING 1" >>confdefs.h
 
+  $as_echo "#define CHECKING_P 1" >>confdefs.h
+
   nocommon_flag=-fno-common
+else
+  $as_echo "#define CHECKING_P 0" >>confdefs.h
+
 fi
 
 if test x$ac_df_checking != x ; then
@@ -18385,7 +18390,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 18388 "configure"
+#line 18393 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -18491,7 +18496,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 18494 "configure"
+#line 18499 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/gcc/configure.ac b/gcc/configure.ac
index be721e6..a30bb3b 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -569,7 +569,12 @@ if test x$ac_checking != x ; then
   AC_DEFINE(ENABLE_CHECKING, 1,
 [Define if you want more run-time sanity checks.  This one gets a grab
    bag of miscellaneous but relatively cheap checks.])
+  AC_DEFINE(CHECKING_P, 1,
+[Define to 1 if you want more run-time sanity checks.  This one gets a grab
+   bag of miscellaneous but relatively cheap checks.])
   nocommon_flag=-fno-common
+else
+  AC_DEFINE(CHECKING_P, 0)
 fi
 AC_SUBST(nocommon_flag)
 if test x$ac_df_checking != x ; then
diff --git a/gcc/system.h b/gcc/system.h
index 61790d7..f9c7e2a 100644
--- a/gcc/system.h
+++ b/gcc/system.h
@@ -714,13 +714,11 @@ extern void fancy_abort (const char *, int, const char *) ATTRIBUTE_NORETURN;
 #define gcc_assert(EXPR) ((void)(0 && (EXPR)))
 #endif
 
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
 #define gcc_checking_assert(EXPR) gcc_assert (EXPR)
-#define CHECKING_P 1
 #else
 /* N.B.: in release build EXPR is not evaluated.  */
 #define gcc_checking_assert(EXPR) ((void)(0 && (EXPR)))
-#define CHECKING_P 1
 #endif
 
 /* Use gcc_unreachable() to mark unreachable locations (like an
diff --git a/libcpp/config.in b/libcpp/config.in
index 8df00ec..5865eb3 100644
--- a/libcpp/config.in
+++ b/libcpp/config.in
@@ -3,6 +3,9 @@
 /* Define if building universal (internal helper macro) */
 #undef AC_APPLE_UNIVERSAL_BUILD
 
+/* Define to 1 if you want more run-time sanity checks. */
+#undef CHECKING_P
+
 /* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
    systems. This function is required for `alloca.c' support on those systems.
    */
diff --git a/libcpp/configure b/libcpp/configure
index 8cf2f77..1c70c75 100755
--- a/libcpp/configure
+++ b/libcpp/configure
@@ -7300,6 +7300,11 @@ if test x$ac_checking != x ; then
 
 $as_echo "#define ENABLE_CHECKING 1" >>confdefs.h
 
+  $as_echo "#define CHECKING_P 1" >>confdefs.h
+
+else
+  $as_echo "#define CHECKING_P 0" >>confdefs.h
+
 fi
 
 if test x$ac_valgrind_checking != x ; then
diff --git a/libcpp/configure.ac b/libcpp/configure.ac
index 5f008a4..3fcbe84 100644
--- a/libcpp/configure.ac
+++ b/libcpp/configure.ac
@@ -166,6 +166,10 @@ IFS="$ac_save_IFS"
 if test x$ac_checking != x ; then
   AC_DEFINE(ENABLE_CHECKING, 1,
 [Define if you want more run-time sanity checks.])
+  AC_DEFINE(CHECKING_P, 1,
+[Define to 1 if you want more run-time sanity checks.])
+else
+  AC_DEFINE(CHECKING_P, 0)
 fi
 
 if test x$ac_valgrind_checking != x ; then
diff --git a/libcpp/system.h b/libcpp/system.h
index 20f07bb..2250f10 100644
--- a/libcpp/system.h
+++ b/libcpp/system.h
@@ -391,13 +391,28 @@ extern void abort (void);
 #define __builtin_expect(a, b) (a)
 #endif
 
-#ifdef ENABLE_CHECKING
+/* Redefine abort to report an internal error w/o coredump, and
+   reporting the location of the error in the source file.  */
+extern void fancy_abort (const char *, int, const char *) ATTRIBUTE_NORETURN;
+#define abort() fancy_abort (__FILE__, __LINE__, __FUNCTION__)
+
+/* Use gcc_assert(EXPR) to test invariants.  */
+#if ENABLE_ASSERT_CHECKING
+#define gcc_assert(EXPR) 						\
+   ((void)(!(EXPR) ? fancy_abort (__FILE__, __LINE__, __FUNCTION__), 0 : 0))
+#elif (GCC_VERSION >= 4005)
+#define gcc_assert(EXPR) 						\
+  ((void)(__builtin_expect (!(EXPR), 0) ? __builtin_unreachable (), 0 : 0))
+#else
+/* Include EXPR, so that unused variable warnings do not occur.  */
+#define gcc_assert(EXPR) ((void)(0 && (EXPR)))
+#endif
+
+#if CHECKING_P
 #define gcc_checking_assert(EXPR) gcc_assert (EXPR)
-#define CHECKING_P 1
 #else
 /* N.B.: in release build EXPR is not evaluated.  */
 #define gcc_checking_assert(EXPR) ((void)(0 && (EXPR)))
-#define CHECKING_P 1
 #endif
 
 /* Provide a fake boolean type.  We make no attempt to use the


^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 6/9] ENABLE_CHECKING refactoring: generators
  2015-10-06 12:57   ` Richard Biener
@ 2015-10-19  0:09     ` Mikhail Maltsev
  2015-10-21 10:57       ` Richard Biener
  2015-10-29 16:31       ` Jeff Law
  0 siblings, 2 replies; 77+ messages in thread
From: Mikhail Maltsev @ 2015-10-19  0:09 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc-patches mailing list, Jeff Law

[-- Attachment #1: Type: text/plain, Size: 1036 bytes --]

On 10/06/2015 03:56 PM, Richard Biener wrote:
> The generators should simply unconditionally check (not in generated
> files, of course).
> And the generated code parts should use flag_checking.
> 
> Richard.

genautomata has some macros similar to tree checks, so I avoided changing them.
genconditions for some reason #undef-s ENABLE_CHECKING in the generated code. I
did not look at it in details, but decided to simply #define CHECKING_P to 0 for
consistency.

As for genextract and gengtype, I followed your recommendations, that is, used
flag_checking instead of CHECKING_P in genextract, and always enable debugging
functions in gengtype.

-- 
Regards,
    Mikhail Maltsev

gcc/ChangeLog:

2015-10-19  Mikhail Maltsev  <maltsevm@gmail.com>

        * genautomata.c: Use CHECKING_P instead of ENABLE_CHECKING.
        * genconditions.c: Define CHECKING_P in the generated code.
        * genextract.c: Use flag_checking in insn_extract.
        * gengtype.c (main): Remove conditional compilation.
        * gengtype.h: Likewise.

[-- Attachment #2: 0006-Generators-v2.patch --]
[-- Type: text/x-patch, Size: 4177 bytes --]

From df421545d314192e9a4ac2868754f34590d73027 Mon Sep 17 00:00:00 2001
From: Mikhail Maltsev <maltsevm@gmail.com>
Date: Sun, 4 Oct 2015 22:50:02 +0300
Subject: [PATCH 5/7] Generators - v2

---
 gcc/genautomata.c   | 2 +-
 gcc/genconditions.c | 2 ++
 gcc/genextract.c    | 9 +++++----
 gcc/gengtype.c      | 6 ------
 gcc/gengtype.h      | 5 -----
 5 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/gcc/genautomata.c b/gcc/genautomata.c
index 5196d68..beae5ef 100644
--- a/gcc/genautomata.c
+++ b/gcc/genautomata.c
@@ -879,7 +879,7 @@ struct state_ainsn_table
 /* Macros to access members of unions.  Use only them for access to
    union members of declarations and regexps.  */
 
-#if defined ENABLE_CHECKING && (GCC_VERSION >= 2007)
+#if CHECKING_P && (GCC_VERSION >= 2007)
 
 #define DECL_UNIT(d) __extension__					\
 (({ __typeof (d) const _decl = (d);					\
diff --git a/gcc/genconditions.c b/gcc/genconditions.c
index 001e58e..7481ab4 100644
--- a/gcc/genconditions.c
+++ b/gcc/genconditions.c
@@ -60,6 +60,8 @@ write_header (void)
 \n\
 /* Do not allow checking to confuse the issue.  */\n\
 #undef ENABLE_CHECKING\n\
+#undef CHECKING_P\n\
+#define CHECKING_P 0\n\
 #undef ENABLE_TREE_CHECKING\n\
 #undef ENABLE_RTL_CHECKING\n\
 #undef ENABLE_RTL_FLAG_CHECKING\n\
diff --git a/gcc/genextract.c b/gcc/genextract.c
index fe97701..a03ac97 100644
--- a/gcc/genextract.c
+++ b/gcc/genextract.c
@@ -373,10 +373,11 @@ insn_extract (rtx_insn *insn)\n{\n\
   rtx pat = PATTERN (insn);\n\
   int i ATTRIBUTE_UNUSED; /* only for peepholes */\n\
 \n\
-#ifdef ENABLE_CHECKING\n\
-  memset (ro, 0xab, sizeof (*ro) * MAX_RECOG_OPERANDS);\n\
-  memset (ro_loc, 0xab, sizeof (*ro_loc) * MAX_RECOG_OPERANDS);\n\
-#endif\n");
+  if (flag_checking)\n\
+    {\n\
+      memset (ro, 0xab, sizeof (*ro) * MAX_RECOG_OPERANDS);\n\
+      memset (ro_loc, 0xab, sizeof (*ro_loc) * MAX_RECOG_OPERANDS);\n\
+    }\n");
 
   puts ("\
   switch (INSN_CODE (insn))\n\
diff --git a/gcc/gengtype.c b/gcc/gengtype.c
index 866d809..b7a33c6 100644
--- a/gcc/gengtype.c
+++ b/gcc/gengtype.c
@@ -158,9 +158,6 @@ size_t num_lang_dirs;
    BASE_FILES entry for each language.  */
 static outf_p *base_files;
 
-
-
-#if ENABLE_CHECKING
 /* Utility debugging function, printing the various type counts within
    a list of types.  Called through the DBGPRINT_COUNT_TYPE macro.  */
 void
@@ -222,7 +219,6 @@ dbgprint_count_type_at (const char *fil, int lin, const char *msg, type_p t)
     fprintf (stderr, "@@%%@@ %d undefined types\n", nb_undefined);
   fprintf (stderr, "\n");
 }
-#endif /* ENABLE_CHECKING */
 
 /* Scan the input file, LIST, and determine how much space we need to
    store strings in.  Also, count the number of language directories
@@ -5181,7 +5177,6 @@ main (int argc, char **argv)
 
   parse_program_options (argc, argv);
 
-#if ENABLE_CHECKING
   if (do_debug)
     {
       time_t now = (time_t) 0;
@@ -5189,7 +5184,6 @@ main (int argc, char **argv)
       DBGPRINTF ("gengtype started pid %d at %s",
 		 (int) getpid (), ctime (&now));
     }
-#endif	/* ENABLE_CHECKING */
 
   /* Parse the input list and the input files.  */
   DBGPRINTF ("inputlist %s", inputlist);
diff --git a/gcc/gengtype.h b/gcc/gengtype.h
index 83f3632..b8ce7ce 100644
--- a/gcc/gengtype.h
+++ b/gcc/gengtype.h
@@ -492,17 +492,12 @@ extern int do_dump;		/* (-d) program argument. */
    gengtype source code).  Only useful to debug gengtype itself.  */
 extern int do_debug;		/* (-D) program argument. */
 
-#if ENABLE_CHECKING
 #define DBGPRINTF(Fmt,...) do {if (do_debug)				\
       fprintf (stderr, "%s:%d: " Fmt "\n",				\
 	       lbasename (__FILE__),__LINE__, ##__VA_ARGS__);} while (0)
 void dbgprint_count_type_at (const char *, int, const char *, type_p);
 #define DBGPRINT_COUNT_TYPE(Msg,Ty) do {if (do_debug)			\
       dbgprint_count_type_at (__FILE__, __LINE__, Msg, Ty);}while (0)
-#else
-#define DBGPRINTF(Fmt,...) do {/*nodbgrintf*/} while (0)
-#define DBGPRINT_COUNT_TYPE(Msg,Ty) do{/*nodbgprint_count_type*/}while (0)
-#endif /*ENABLE_CHECKING */
 
 #define FOR_ALL_INHERITED_FIELDS(TYPE, FIELD_VAR) \
   for (type_p sub = (TYPE); sub; sub = sub->u.s.base_class) \
-- 
2.1.4


^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 5/9] ENABLE_CHECKING refactoring: pool allocators
  2015-10-06 12:45     ` Richard Biener
@ 2015-10-19  0:47       ` Mikhail Maltsev
  2015-10-21 11:02         ` Richard Biener
  0 siblings, 1 reply; 77+ messages in thread
From: Mikhail Maltsev @ 2015-10-19  0:47 UTC (permalink / raw)
  To: Richard Biener, Bernd Schmidt; +Cc: gcc-patches mailing list, Jeff Law

[-- Attachment #1: Type: text/plain, Size: 982 bytes --]

On 10/06/2015 03:45 PM, Richard Biener wrote:
> On Tue, Oct 6, 2015 at 2:41 PM, Bernd Schmidt <bschmidt@redhat.com> wrote:
>> On 10/06/2015 01:32 AM, Mikhail Maltsev wrote:
>>>
>>> gcc/ChangeLog:
>>>
>>> 2015-10-05  Mikhail Maltsev  <maltsevm@gmail.com>
>>>
>>>         * alloc-pool.h (base_pool_allocator::initialize, ::allocate,
>>>         ::remove): Adjust to use CHECKING_P.
>>
>>
>> Why CHECKING_P for these and not flag_checking as elsewhere?
> 
> Probably because they are in inline functions and thus possibly would
> affect optimization.  Not sure why they are inline functions in the
> first place...  I'd agree to using flag_checking here.
> 
> Richard.
> 
>>
>> Bernd

Adjusted. Note: I had to include 'options.h' into 'alloc-pool.h' in order to use
flag_checking.

-- 
Regards,
    Mikhail Maltsev

2015-10-19  Mikhail Maltsev  <maltsevm@gmail.com>

        * alloc-pool.h (base_pool_allocator ::initialize, ::allocate,
        ::remove): Adjust to use flag_checking.

[-- Attachment #2: 0005-Allocators-v2.patch --]
[-- Type: text/x-patch, Size: 2943 bytes --]

diff --git a/gcc/alloc-pool.h b/gcc/alloc-pool.h
index 70105ba..a15c25e 100644
--- a/gcc/alloc-pool.h
+++ b/gcc/alloc-pool.h
@@ -21,6 +21,7 @@ along with GCC; see the file COPYING3.  If not see
 #define ALLOC_POOL_H
 
 #include "memory-block.h"
+#include "options.h"	    // for flag_checking
 
 extern void dump_alloc_pool_statistics (void);
 
@@ -275,15 +276,16 @@ base_pool_allocator <TBlockAllocator>::initialize ()
   m_elts_per_block = (TBlockAllocator::block_size - header_size) / size;
   gcc_checking_assert (m_elts_per_block != 0);
 
-#ifdef ENABLE_CHECKING
-  /* Increase the last used ID and use it for this pool.
-     ID == 0 is used for free elements of pool so skip it.  */
-  last_id++;
-  if (last_id == 0)
-    last_id++;
+  if (flag_checking)
+    {
+      /* Increase the last used ID and use it for this pool.
+	 ID == 0 is used for free elements of pool so skip it.  */
+      last_id++;
+      if (last_id == 0)
+	last_id++;
 
-  m_id = last_id;
-#endif
+      m_id = last_id;
+    }
 }
 
 /* Free all memory allocated for the given memory pool.  */
@@ -387,10 +389,10 @@ base_pool_allocator <TBlockAllocator>::allocate ()
       block = m_virgin_free_list;
       header = (allocation_pool_list*) allocation_object::get_data (block);
       header->next = NULL;
-#ifdef ENABLE_CHECKING
+
       /* Mark the element to be free.  */
-      ((allocation_object*) block)->id = 0;
-#endif
+      if (flag_checking)
+	((allocation_object*) block)->id = 0;
       VALGRIND_DISCARD (VALGRIND_MAKE_MEM_NOACCESS (header,size));
       m_returned_free_list = header;
       m_virgin_free_list += m_elt_size;
@@ -404,10 +406,9 @@ base_pool_allocator <TBlockAllocator>::allocate ()
   m_returned_free_list = header->next;
   m_elts_free--;
 
-#ifdef ENABLE_CHECKING
   /* Set the ID for element.  */
-  allocation_object::get_instance (header)->id = m_id;
-#endif
+  if (flag_checking)
+    allocation_object::get_instance (header)->id = m_id;
   VALGRIND_DISCARD (VALGRIND_MAKE_MEM_UNDEFINED (header, size));
 
   return (void *)(header);
@@ -424,18 +425,18 @@ base_pool_allocator <TBlockAllocator>::remove (void *object)
   int size ATTRIBUTE_UNUSED;
   size = m_elt_size - offsetof (allocation_object, u.data);
 
-#ifdef ENABLE_CHECKING
-  gcc_assert (object
+  gcc_checking_assert (object
 	      /* Check if we free more than we allocated, which is Bad (TM).  */
 	      && m_elts_free < m_elts_allocated
 	      /* Check whether the PTR was allocated from POOL.  */
 	      && m_id == allocation_object::get_instance (object)->id);
 
-  memset (object, 0xaf, size);
-
-  /* Mark the element to be free.  */
-  allocation_object::get_instance (object)->id = 0;
-#endif
+  if (flag_checking)
+    {
+      memset (object, 0xaf, size);
+      /* Mark the element to be free.  */
+      allocation_object::get_instance (object)->id = 0;
+    }
 
   header = (allocation_pool_list*) object;
   header->next = m_returned_free_list;

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 7/9] ENABLE_CHECKING refactoring: middle-end, LTO FE
  2015-10-06 12:59     ` Richard Biener
@ 2015-10-19  0:56       ` Mikhail Maltsev
  2015-10-19 12:19         ` Bernd Schmidt
  0 siblings, 1 reply; 77+ messages in thread
From: Mikhail Maltsev @ 2015-10-19  0:56 UTC (permalink / raw)
  To: Richard Biener, Bernd Schmidt; +Cc: gcc-patches mailing list, Jeff Law

[-- Attachment #1: Type: text/plain, Size: 12447 bytes --]

On 10/06/2015 03:59 PM, Richard Biener wrote:
> On Tue, Oct 6, 2015 at 2:46 PM, Bernd Schmidt <bschmidt@redhat.com> wrote:
>> On 10/06/2015 01:39 AM, Mikhail Maltsev wrote:
>>>
>>>   void verify_insn_chain (void);
>>> +static inline void checking_verify_insn_chain ();
>>>   static void fixup_fallthru_exit_predecessor (void);
>>>   static int can_delete_note_p (const rtx_note *);
>>>   static int can_delete_label_p (const rtx_code_label *);
>>
>> [...]
>>>
>>> @@ -3990,6 +3987,16 @@ verify_insn_chain (void)
>>>
>>>     gcc_assert (insn_cnt1 == insn_cnt2);
>>>   }
>>> +
>>> +/* Perform checks, if they were requested by corresponding flag.  */
>>> +
>>> +static inline void
>>> +checking_verify_insn_chain ()
>>> +{
>>> +  if (flag_checking)
>>> +    verify_insn_chain ();
>>> +}
>>> +
>>
>>
>> There are many new such small inline functions, and I don't think they buy
>> us much over just writing out the pattern where they are called. Also, just
>> defined the function before its first use rather than writing a forward
>> declaration.
I agree, that checking_verify_insn_chain is indeed superfluous, so I replaced it
with the pattern.

But I think some of these functions are still useful (they make the code look
cleaner, because we don't need to put those 'if (flag_checking) ...;' checks
everywhere). For example, 'checking_verify_flow' is called 11 times and
'checking_verify_loop_structure' is called 9 times. Furthermore, Richard
suggested [1] that we might want to split checks into several groups. It will be
easier to assign different flags to them in this case.

[1] https://gcc.gnu.org/ml/gcc-patches/2015-08/msg01866.html

>>
>> I think the consensus has been to avoid assert (false), so this would be
>>
>> if (checking)
>>   gcc_unreachable ();
>>
>> but maybe we really just want to do the gcc_unreachable unconditionally.
> 
> I'm fine with unconditional gcc_unreachable - the code is old enough now
> that we shouldn't hit this anymore.
> 
> Richard.

Fixed.

There were one or two other places where I used 'gcc_checking_assert (false)'. I
replaced them with

if (flag_checking)
  gcc_unreachable ();

-- 
Regards,
    Mikhail Maltsev

gcc/lto/ChangeLog:

2015-10-19  Mikhail Maltsev  <maltsevm@gmail.com>

        * lto.c (unify_scc): Use flag_checking
        (lto_fixup_state): Use CHECKING_P.
        (do_whole_program_analysis): Use
        symtab_node::checking_verify_symtab_nodes.

gcc/ChangeLog:

2015-10-19  Mikhail Maltsev  <maltsevm@gmail.com>

        * attribs.c (check_attribute_tables): Define new function.
        (init_attributes): Use it.
        * cfgcleanup.c (try_optimize_cfg): Use flag_checking.
        * cfgexpand.c (expand_goto, expand_debug_expr): Likewise.
        (pass_expand::execute): Use checking_verify_flow_info.
        * cfghooks.c (verify_flow_info): Remove DEBUG_FUNCTION.
        * cfghooks.h (checking_verify_flow_info): Define.
        * cfgloop.c (verify_loop_structure): Remove DEBUG_FUNCTION.
        * cfgloop.h (checking_verify_loop_structure): Define.
        * cfgrtl.c (commit_edge_insertions): Use checking_verify_flow_info.
        (fixup_reorder_chain): Use checking_verify_insn_chain.
        (checking_verify_insn_chain): Define.
        (cfg_layout_finalize): Use checking_verify_insn_chain/flow_info.
        (rtl_flow_call_edges_add): Use flag_checking.
        * cgraph.c (symbol_table::create_edge): Remove conditional compilation.
        (cgraph_edge::redirect_call_stmt_to_callee): Likewise; use
        flag_checking.
        * cgraph.h (symtab_node::checking_verify_symtab_nodes): Define.
        (cgraph_node::checking_verify_cgraph_nodes): Define.
        * cgraphclones.c (symbol_table::materialize_all_clones): Use
        checking_verify_cgraph_nodes, remove conditional compilation.
        * cgraphunit.c (mark_functions_to_output): Use flag_checking.
        (cgraph_node::expand_thunk): Use checking_verify_flow_info.
        (symbol_table::compile): Use checking_verify_*, remove conditional
        compilation.
        * ddg.c (add_cross_iteration_register_deps): Use flag_checking.
        (create_ddg_all_sccs): Likewise.
        * df-core.c (df_finish_pass, df_analyze): Likewise.
        * diagnostic-core.h: Adjust to use CHECKING_P.
        * diagnostic.c (diagnostic_report_diagnostic): Likewise.
        * dominance.c (calculate_dominance_info): Use
        checking_verify_dominators.
        * dominance.h (checking_verify_dominators): Define.
        * dwarf2out.c (add_AT_die_ref, const_ok_for_output_1,
        mem_loc_descriptor, loc_list_from_tree, gen_lexical_block_die,
        gen_type_die_with_usage, gen_type_die, dwarf2out_decl): Use
        flag_checking.
        * emit-rtl.c (verify_rtx_sharing, reorder_insns_nobb): Likewise.
        * et-forest.c: Fix comment.
        * except.c (duplicate_eh_regions): Use flag_checking.
        * fwprop.c (register_active_defs, update_df_init): Use CHECKING_P.
        (update_uses): Use gcc_checking_assert.
        (fwprop_init, fwprop_done): Use CHECKING_P.
        * ggc-page.c (ggc_grow): Likewise.
        * gimplify.c (gimplify_body): Use flag_checking.
        (gimplify_hasher::equal): Use CHECKING_P.
        * graphite-isl-ast-to-gimple.c (graphite_verify): Use
        checking_verify_* functions.
        * graphite-scop-detection.c (canonicalize_loop_closed_ssa_form):
        Likewise.
        * graphite-sese-to-poly.c (rewrite_reductions_out_of_ssa,
        (rewrite_cross_bb_scalar_deps_out_of_ssa): Likwise.
        * ifcvt.c (if_convert): Use checking_verify_flow_info.
        * ipa-cp.c (ipcp_propagate_stage): Use flag_checking.
        * ipa-devirt.c (type_in_anonymous_namespace_p,
        odr_type_p, odr_types_equivalent_p): Use gcc_checking_assert.
        (add_type_duplicate, get_odr_type): Use flag_checking.
        * ipa-icf.c (sem_item_optimizer::verify_classes,
        sem_item_optimizer::traverse_congruence_split,
        sem_item_optimizer::do_congruence_step_for_index): Use flag_checking.
        * ipa-inline-analysis.c (compute_inline_parameters): Likewise.
        * ipa-inline-transform.c (save_inline_function_body): Likewise.
        * ipa-inline.c (inline_small_functions): Use CHECKING_P.
        (early_inliner): Use flag_checking.
        * ipa-inline.h (estimate_edge_growth): Remove conditional compilation.
        * ipa-visibility.c (function_and_variable_visibility): Use
        flag_checking.
        * ipa.c (symbol_table::remove_unreachable_nodes): Likewise.
        (ipa_single_use): Use gcc_checking_assert.
        * ira-int.h: Use CHECKING_P.
        * ira.c (ira): Use flag_checking.
        * loop-doloop.c (doloop_optimize_loops): Use
        checking_verify_loop_structure.
        * loop-init.c (loop_optimizer_init, fix_loop_structure): Likewise.
        * loop-invariant.c (move_loop_invariants): Use
        checking_verify_flow_info.
        * lra-assigns.c (lra_assign): Use CHECKING_P.
        * lra-constraints.c (lra_constraints): Use flag_checking.
        * lra-eliminations.c (lra_eliminate): Likewise.
        * lra-int.h (struct lra_reg): Use CHECKING_P.
        * lra-lives.c (check_pseudos_live_through_calls,
        lra_create_live_ranges_1): Use CHECKING_P.
        * lra-remat.c (create_remat_bb_data): Adjust to use gcc_checking_assert.
        * lra.c (lra_update_insn_recog_data, restore_scratches): Use
        flag_checking.
        (check_rtl): Always define. Remove incorrect guard around
        extract_constrain_insn call.
        (lra):
        * lto-cgraph.c (input_cgraph_1): Use flag_checking.
        * lto-streamer-out.c (DFS::DFS): Use gcc_checking_assert.
        (lto_output): Use CHECKING_P.
        * lto-streamer.c (lto_streamer_init): Likewise.
        * omp-low.c (scan_omp_target, expand_omp_taskreg, expand_omp_target,
        execute_expand_omp): Likewise.
        (lower_omp_target): Use CHECKING_P.
        * passes.c (execute_function_todo): Use flag_checking
        execute_todo, execute_one_pass): Likewise.
        (verify_curr_properties): Always define.
        * predict.c (tree_estimate_probability, propagate_freq): Use
        flag_checking.
        * pretty-print.c (pp_format): Use CHECKING_P.
        * real.c (real_to_decimal_for_mode): Likewise.
        * recog.c (split_all_insns): Use checking_verify_flow_info.
        * regcprop.c (kill_value_one_regno): Always call validate_value_data.
        (copy_value): Likewise.
        (validate_value_data): Define unconditionally. Use flag_checking.
        * reload.c: Fix comment.
        * sched-deps.c (CHECK): Remove unused macro.
        (add_or_update_dep_1, sd_add_dep): Use flag_checking.
        * sel-sched-ir.c (free_regset_pool, tidy_control_flow): Likewise.
        * sel-sched.c (struct moveop_static_params, find_best_reg_for_expr,
        move_cond_jump, move_op_orig_expr_not_found,
        code_motion_process_successors, move_op): Use CHECKING_P.
        * sese.h (bb_in_region): Comment checking-related issue.
        * ssa-iterators.h (first_readonly_imm_use,
        next_readonly_imm_use): Use CHECKING_P.
        * store-motion.c (compute_store_table): Use flag_checking.
        * symbol-summary.h (function_summary::function_summary): Likewise.
        * symtab.c: Remove DEBUG_FUNCTION.
        * target.h (cumulative_args_t): Guard by CHECKING_P
        (get_cumulative_args, pack_cumulative_args): Use CHECKING_P.
        * timevar.c (timer::print): Adjust condition.
        * trans-mem.c (ipa_tm_execute): Use checking_verify_cgraph_nodes.
        * tree-cfg.c (move_stmt_op): Use flag_checking.
        (move_sese_region_to_fn): Use flag_checking.
        (gimple_flow_call_edges_add): Likewise.
        * tree-cfgcleanup.c (cleanup_tree_cfg_noloop, repair_loop_structures):
        Use checking_verify_* functions.
        * tree-eh.c (remove_unreachable_handlers): Use flag_checking.
        * tree-if-conv.c (pass_if_conversion::execute): Likewise.
        * tree-inline.c (expand_call_inline, optimize_inline_calls): Likewise.
        * tree-into-ssa.c (update_ssa): Likewise.
        * tree-loop-distribution.c (pass_loop_distribution::execute): Likewise.
        * tree-outof-ssa.c (eliminate_useless_phis, rewrite_trees): Likewise.
        * tree-parloops.c (pass_parallelize_loops::execute): Use
        checking_verify_loop_structure.
        * tree-predcom.c (suitable_component_p): Use gcc_checking_assert.
        * tree-profile.c (gimple_gen_const_delta_profiler): Use flag_checking.
        * tree-ssa-alias.c (refs_may_alias_p_1): Use gcc_checking_assert.
        * tree-ssa-live.c (verify_live_on_entry): Define unconditionally.
        (calculate_live_ranges): Use flag_checking.
        * tree-ssa-live.h (register_ssa_partition): Likewise.
        * tree-ssa-loop-ivcanon.c (tree_unroll_loops_completely): Use
        flag_checking.
        * tree-ssa-loop-manip.c (add_exit_phi): Likewise.
        (tree_transform_and_unroll_loop): Use checking_* functions.
        * tree-ssa-loop-manip.h (checking_verify_loop_closed_ssa): Define.
        * tree-ssa-math-opts.c (pass_cse_reciprocals::execute): Use
        flag_checking.
        * tree-ssa-operands.c (get_expr_operands): Likewise.
        * tree-ssa-propagate.c (replace_exp_1): Likewise.
        * tree-ssa-structalias.c (rewrite_constraints): Likewise.
        * tree-ssa-ter.c (free_temp_expr_table): Likewise.
        * tree-ssa-threadupdate.c (duplicate_thread_path): Likewise.
        * tree-ssa.c (verify_ssa): Remove DEBUG_FUNCTION.
        * tree-ssa.h (checking_verify_ssa): Define.
        * tree-ssanames.c (release_ssa_name_fn): Use flag_checking.
        * tree-stdarg.c (expand_ifn_va_arg): Likewise.
        * tree-vect-loop-manip.c (slpeel_tree_duplicate_loop_to_edge_cfg): Use
        checking_verify_dominators.
        (slpeel_checking_verify_cfg_after_peeling): Guard by flag_checking.
        (vect_do_peeling_for_loop_bound): Always call
        slpeel_checking_verify_cfg_after_peeling.
        (vect_do_peeling_for_alignment): Likewise.
        * tree-vrp.c (supports_overflow_infinity): Use gcc_checking_assert.
        (set_value_range): Use flag_checking.
        * tree.c (free_lang_data_in_cgraph): Likewise.
        * value-prof.c (gimple_remove_histogram_value): Use CHECKING_P.
        (free_hist): Likewise.
        * var-tracking.c (canonicalize_values_star): Use flag_checking.
        (compute_bb_dataflow, vt_find_locations, vt_emit_notes): Likewise.

[-- Attachment #2: 0007-Backend-v2a.patch --]
[-- Type: text/x-patch, Size: 125370 bytes --]

diff --git a/gcc/attribs.c b/gcc/attribs.c
index 6cbe011..87e9a52 100644
--- a/gcc/attribs.c
+++ b/gcc/attribs.c
@@ -174,8 +174,58 @@ find_attribute_namespace (const char* ns)
   return NULL;
 }
 
-/* Initialize attribute tables, and make some sanity checks
-   if --enable-checking.  */
+/* Make some sanity checks on the attribute tables.  */
+
+static void
+check_attribute_tables ()
+{
+  for (size_t i = 0; i < ARRAY_SIZE (attribute_tables); i++)
+    for (size_t j = 0; attribute_tables[i][j].name != NULL; j++)
+      {
+	/* The name must not begin and end with __.  */
+	const char *name = attribute_tables[i][j].name;
+	int len = strlen (name);
+
+	gcc_assert (!(name[0] == '_' && name[1] == '_'
+		      && name[len - 1] == '_' && name[len - 2] == '_'));
+
+	/* The minimum and maximum lengths must be consistent.  */
+	gcc_assert (attribute_tables[i][j].min_length >= 0);
+
+	gcc_assert (attribute_tables[i][j].max_length == -1
+		    || (attribute_tables[i][j].max_length
+			>= attribute_tables[i][j].min_length));
+
+	/* An attribute cannot require both a DECL and a TYPE.  */
+	gcc_assert (!attribute_tables[i][j].decl_required
+		    || !attribute_tables[i][j].type_required);
+
+	  /* If an attribute requires a function type, in particular
+	     it requires a type.  */
+	gcc_assert (!attribute_tables[i][j].function_type_required
+		    || attribute_tables[i][j].type_required);
+      }
+
+  /* Check that each name occurs just once in each table.  */
+  for (size_t i = 0; i < ARRAY_SIZE (attribute_tables); i++)
+    for (size_t j = 0; attribute_tables[i][j].name != NULL; j++)
+      for (size_t k = j + 1; attribute_tables[i][k].name != NULL; k++)
+	gcc_assert (strcmp (attribute_tables[i][j].name,
+			    attribute_tables[i][k].name));
+
+  /* Check that no name occurs in more than one table.  Names that
+     begin with '*' are exempt, and may be overridden.  */
+  for (size_t i = 0; i < ARRAY_SIZE (attribute_tables); i++)
+    for (size_t j = i + 1; j < ARRAY_SIZE (attribute_tables); j++)
+      for (size_t k = 0; attribute_tables[i][k].name != NULL; k++)
+	for (size_t l = 0; attribute_tables[j][l].name != NULL; l++)
+	  gcc_assert (attribute_tables[i][k].name[0] == '*'
+		      || strcmp (attribute_tables[i][k].name,
+				 attribute_tables[j][l].name));
+}
+
+/* Initialize attribute tables, and make some sanity checks if checking is
+   enabled.  */
 
 void
 init_attributes (void)
@@ -195,62 +245,8 @@ init_attributes (void)
     if (attribute_tables[i] == NULL)
       attribute_tables[i] = empty_attribute_table;
 
-#ifdef ENABLE_CHECKING
-  /* Make some sanity checks on the attribute tables.  */
-  for (i = 0; i < ARRAY_SIZE (attribute_tables); i++)
-    {
-      int j;
-
-      for (j = 0; attribute_tables[i][j].name != NULL; j++)
-	{
-	  /* The name must not begin and end with __.  */
-	  const char *name = attribute_tables[i][j].name;
-	  int len = strlen (name);
-
-	  gcc_assert (!(name[0] == '_' && name[1] == '_'
-			&& name[len - 1] == '_' && name[len - 2] == '_'));
-
-	  /* The minimum and maximum lengths must be consistent.  */
-	  gcc_assert (attribute_tables[i][j].min_length >= 0);
-
-	  gcc_assert (attribute_tables[i][j].max_length == -1
-		      || (attribute_tables[i][j].max_length
-			  >= attribute_tables[i][j].min_length));
-
-	  /* An attribute cannot require both a DECL and a TYPE.  */
-	  gcc_assert (!attribute_tables[i][j].decl_required
-		      || !attribute_tables[i][j].type_required);
-
-	  /* If an attribute requires a function type, in particular
-	     it requires a type.  */
-	  gcc_assert (!attribute_tables[i][j].function_type_required
-		      || attribute_tables[i][j].type_required);
-	}
-    }
-
-  /* Check that each name occurs just once in each table.  */
-  for (i = 0; i < ARRAY_SIZE (attribute_tables); i++)
-    {
-      int j, k;
-      for (j = 0; attribute_tables[i][j].name != NULL; j++)
-	for (k = j + 1; attribute_tables[i][k].name != NULL; k++)
-	  gcc_assert (strcmp (attribute_tables[i][j].name,
-			      attribute_tables[i][k].name));
-    }
-  /* Check that no name occurs in more than one table.  Names that
-     begin with '*' are exempt, and may be overridden.  */
-  for (i = 0; i < ARRAY_SIZE (attribute_tables); i++)
-    {
-      size_t j, k, l;
-
-      for (j = i + 1; j < ARRAY_SIZE (attribute_tables); j++)
-	for (k = 0; attribute_tables[i][k].name != NULL; k++)
-	  for (l = 0; attribute_tables[j][l].name != NULL; l++)
-	    gcc_assert (attribute_tables[i][k].name[0] == '*'
-			|| strcmp (attribute_tables[i][k].name,
-				   attribute_tables[j][l].name));
-    }
-#endif
+  if (flag_checking)
+    check_attribute_tables ();
 
   for (i = 0; i < ARRAY_SIZE (attribute_tables); ++i)
     /* Put all the GNU attributes into the "gnu" namespace.  */
diff --git a/gcc/cfgcleanup.c b/gcc/cfgcleanup.c
index 7e576bc..0ad4872 100644
--- a/gcc/cfgcleanup.c
+++ b/gcc/cfgcleanup.c
@@ -2874,10 +2874,7 @@ try_optimize_cfg (int mode)
                  is only visible after newly unreachable blocks are deleted,
                  which will be done in fixup_partitions.  */
               fixup_partitions ();
-
-#ifdef ENABLE_CHECKING
-              verify_flow_info ();
-#endif
+	      checking_verify_flow_info ();
             }
 
 	  changed_overall |= changed;
diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c
index eaad859..048a53b 100644
--- a/gcc/cfgexpand.c
+++ b/gcc/cfgexpand.c
@@ -3269,12 +3269,13 @@ expand_computed_goto (tree exp)
 static void
 expand_goto (tree label)
 {
-#ifdef ENABLE_CHECKING
-  /* Check for a nonlocal goto to a containing function.  Should have
-     gotten translated to __builtin_nonlocal_goto.  */
-  tree context = decl_function_context (label);
-  gcc_assert (!context || context == current_function_decl);
-#endif
+  if (flag_checking)
+    {
+      /* Check for a nonlocal goto to a containing function.  Should have
+	 gotten translated to __builtin_nonlocal_goto.  */
+      tree context = decl_function_context (label);
+      gcc_assert (!context || context == current_function_decl);
+    }
 
   emit_jump (jump_target_rtx (label));
 }
@@ -5056,12 +5057,12 @@ expand_debug_expr (tree exp)
 
     default:
     flag_unsupported:
-#ifdef ENABLE_CHECKING
-      debug_tree (exp);
-      gcc_unreachable ();
-#else
+      if (flag_checking)
+	{
+	  debug_tree (exp);
+	  gcc_unreachable ();
+	}
       return NULL;
-#endif
     }
 }
 
@@ -6422,9 +6423,7 @@ pass_expand::execute (function *fun)
      gcc.c-torture/execute/ipa-sra-2.c execution, -Os -m32 fails otherwise.  */
   cleanup_cfg (CLEANUP_NO_INSN_DEL);
 
-#ifdef ENABLE_CHECKING
-  verify_flow_info ();
-#endif
+  checking_verify_flow_info ();
 
   /* Initialize pseudos allocated for hard registers.  */
   emit_initial_value_sets ();
diff --git a/gcc/cfghooks.c b/gcc/cfghooks.c
index 0cd8e62..47ac35b 100644
--- a/gcc/cfghooks.c
+++ b/gcc/cfghooks.c
@@ -91,8 +91,8 @@ current_ir_type (void)
    Currently it does following: checks edge and basic block list correctness
    and calls into IL dependent checking then.  */
 
-DEBUG_FUNCTION void
-verify_flow_info (void)
+void
+verify_flow_info ()
 {
   size_t *edge_checksum;
   int err = 0;
diff --git a/gcc/cfghooks.h b/gcc/cfghooks.h
index 0d25cf6..2c5b68e 100644
--- a/gcc/cfghooks.h
+++ b/gcc/cfghooks.h
@@ -186,6 +186,18 @@ struct cfg_hooks
 };
 
 extern void verify_flow_info (void);
+
+/* Check control flow invariants, if internal consistency checks are
+   enabled.  */
+
+static inline void
+checking_verify_flow_info ()
+{
+  /* TODO: Add a separate option for -fchecking=cfg.  */
+  if (flag_checking)
+    verify_flow_info ();
+}
+
 extern void dump_bb (FILE *, basic_block, int, int);
 extern void dump_bb_for_graph (pretty_printer *, basic_block);
 extern void dump_flow_info (FILE *, int);
diff --git a/gcc/cfgloop.c b/gcc/cfgloop.c
index b8a1244..8d58004 100644
--- a/gcc/cfgloop.c
+++ b/gcc/cfgloop.c
@@ -1306,7 +1306,7 @@ cancel_loop_tree (struct loop *loop)
      -- irreducible loops are correctly marked
      -- the cached loop depth and loop father of each bb is correct
   */
-DEBUG_FUNCTION void
+void
 verify_loop_structure (void)
 {
   unsigned *sizes, i, j;
diff --git a/gcc/cfgloop.h b/gcc/cfgloop.h
index 07b070b..08134de 100644
--- a/gcc/cfgloop.h
+++ b/gcc/cfgloop.h
@@ -311,6 +311,16 @@ extern void delete_loop (struct loop *);
 
 extern void verify_loop_structure (void);
 
+/* Check loop structure invariants, if internal consistency checks are
+   enabled.  */
+
+static inline void
+checking_verify_loop_structure ()
+{
+  if (flag_checking)
+    verify_loop_structure ();
+}
+
 /* Loop analysis.  */
 extern bool just_once_each_iteration_p (const struct loop *, const_basic_block);
 gcov_type expected_loop_iterations_unbounded (const struct loop *);
diff --git a/gcc/cfgrtl.c b/gcc/cfgrtl.c
index 15ce8a7..5167d81 100644
--- a/gcc/cfgrtl.c
+++ b/gcc/cfgrtl.c
@@ -2097,9 +2097,7 @@ commit_edge_insertions (void)
      which will be done by fixup_partitions.  */
   fixup_partitions ();
 
-#ifdef ENABLE_CHECKING
-  verify_flow_info ();
-#endif
+  checking_verify_flow_info ();
 
   FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR_FOR_FN (cfun),
 		  EXIT_BLOCK_PTR_FOR_FN (cfun), next_bb)
@@ -3723,9 +3721,8 @@ fixup_reorder_chain (void)
     insn = NEXT_INSN (insn);
 
   set_last_insn (insn);
-#ifdef ENABLE_CHECKING
-  verify_insn_chain ();
-#endif
+  if (flag_checking)
+    verify_insn_chain ();
 
   /* Now add jumps and labels as needed to match the blocks new
      outgoing edges.  */
@@ -3970,8 +3967,8 @@ fixup_reorder_chain (void)
    2. Count insns in chain, going both directions, and check if equal.
    3. Check that get_last_insn () returns the actual end of chain.  */
 
-DEBUG_FUNCTION void
-verify_insn_chain (void)
+void
+verify_insn_chain ()
 {
   rtx_insn *x, *prevx, *nextx;
   int insn_cnt1, insn_cnt2;
@@ -3990,6 +3987,7 @@ verify_insn_chain (void)
 
   gcc_assert (insn_cnt1 == insn_cnt2);
 }
+
 \f
 /* If we have assembler epilogues, the block falling through to exit must
    be the last one in the reordered chain when we reach final.  Ensure
@@ -4313,9 +4311,7 @@ break_superblocks (void)
 void
 cfg_layout_finalize (void)
 {
-#ifdef ENABLE_CHECKING
-  verify_flow_info ();
-#endif
+  checking_verify_flow_info ();
   force_one_exit_fallthru ();
   rtl_register_cfg_hooks ();
   if (reload_completed && !targetm.have_epilogue ())
@@ -4325,10 +4321,9 @@ cfg_layout_finalize (void)
   rebuild_jump_labels (get_insns ());
   delete_dead_jumptables ();
 
-#ifdef ENABLE_CHECKING
-  verify_insn_chain ();
-  verify_flow_info ();
-#endif
+  if (flag_checking)
+    verify_insn_chain ();
+  checking_verify_flow_info ();
 }
 
 
@@ -4893,13 +4888,11 @@ rtl_flow_call_edges_add (sbitmap blocks)
 		 block in CFG already.  Calling make_edge in such case would
 		 cause us to mark that edge as fake and remove it later.  */
 
-#ifdef ENABLE_CHECKING
-	      if (split_at_insn == BB_END (bb))
+	      if (flag_checking && split_at_insn == BB_END (bb))
 		{
 		  e = find_edge (bb, EXIT_BLOCK_PTR_FOR_FN (cfun));
 		  gcc_assert (e == NULL);
 		}
-#endif
 
 	      /* Note that the following may create a new basic block
 		 and renumber the existing basic blocks.  */
diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index 1a64d789..1b6c5eb 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -832,11 +832,9 @@ symbol_table::create_edge (cgraph_node *caller, cgraph_node *callee,
     {
       /* This is a rather expensive check possibly triggering
 	 construction of call stmt hashtable.  */
-#ifdef ENABLE_CHECKING
       cgraph_edge *e;
       gcc_checking_assert (
 	!(e = caller->get_edge (call_stmt)) || e->speculative);
-#endif
 
       gcc_assert (is_gimple_call (call_stmt));
     }
@@ -1282,9 +1280,6 @@ cgraph_edge::redirect_call_stmt_to_callee (void)
   gcall *new_stmt;
   gimple_stmt_iterator gsi;
   bool skip_bounds = false;
-#ifdef ENABLE_CHECKING
-  cgraph_node *node;
-#endif
 
   if (e->speculative)
     {
@@ -1402,13 +1397,11 @@ cgraph_edge::redirect_call_stmt_to_callee (void)
 	  && !skip_bounds))
     return e->call_stmt;
 
-#ifdef ENABLE_CHECKING
-  if (decl)
+  if (flag_checking && decl)
     {
-      node = cgraph_node::get (decl);
+      cgraph_node *node = cgraph_node::get (decl);
       gcc_assert (!node || !node->clone.combined_args_to_skip);
     }
-#endif
 
   if (symtab->dump_file)
     {
diff --git a/gcc/cgraph.h b/gcc/cgraph.h
index 7c54f24..a1aab33 100644
--- a/gcc/cgraph.h
+++ b/gcc/cgraph.h
@@ -116,7 +116,7 @@ public:
   void DEBUG_FUNCTION debug (void);
 
   /* Verify consistency of node.  */
-  void DEBUG_FUNCTION verify (void);
+  void verify ();
 
   /* Return ipa reference from this symtab_node to
      REFERED_NODE or REFERED_VARPOOL_NODE. USE_TYPE specify type
@@ -362,7 +362,6 @@ public:
      and NULL otherwise.  */
   static inline symtab_node *get (const_tree decl)
   {
-#ifdef ENABLE_CHECKING
     /* Check that we are called for sane type of object - functions
        and static or external variables.  */
     gcc_checking_assert (TREE_CODE (decl) == FUNCTION_DECL
@@ -374,7 +373,6 @@ public:
        memcpy/memset on the tree nodes.  */
     gcc_checking_assert (!decl->decl_with_vis.symtab_node
 			 || decl->decl_with_vis.symtab_node->decl == decl);
-#endif
     return decl->decl_with_vis.symtab_node;
   }
 
@@ -396,7 +394,10 @@ public:
   }
 
   /* Verify symbol table for internal consistency.  */
-  static DEBUG_FUNCTION void verify_symtab_nodes (void);
+  static void verify_symtab_nodes ();
+
+  /* Perform internal consistency checks, if they are enabled.  */
+  static inline void checking_verify_symtab_nodes ();
 
   /* Type of the symbol.  */
   ENUM_BITFIELD (symtab_type) type : 8;
@@ -529,7 +530,7 @@ protected:
   void dump_base (FILE *);
 
   /* Verify common part of symtab node.  */
-  bool DEBUG_FUNCTION verify_base (void);
+  bool verify_base ();
 
   /* Remove node from symbol table.  This function is not used directly, but via
      cgraph/varpool node removal routines.  */
@@ -558,6 +559,13 @@ private:
   symtab_node *ultimate_alias_target_1 (enum availability *avail = NULL);
 };
 
+inline void
+symtab_node::checking_verify_symtab_nodes ()
+{
+  if (flag_checking)
+    symtab_node::verify_symtab_nodes ();
+}
+
 /* Walk all aliases for NODE.  */
 #define FOR_EACH_ALIAS(node, alias) \
   for (unsigned x_i = 0; node->iterate_direct_aliases (x_i, alias); x_i++)
@@ -1203,7 +1211,10 @@ public:
   static cgraph_node * create_same_body_alias (tree alias, tree decl);
 
   /* Verify whole cgraph structure.  */
-  static void DEBUG_FUNCTION verify_cgraph_nodes (void);
+  static void verify_cgraph_nodes ();
+
+  /* Verify cgraph, if consistency checking is enabled.  */
+  static inline void checking_verify_cgraph_nodes ();
 
   /* Worker to bring NODE local.  */
   static bool make_local (cgraph_node *node, void *);
@@ -2753,6 +2764,15 @@ cgraph_node::can_remove_if_no_direct_calls_and_refs_p (void)
   return true;
 }
 
+/* Verify cgraph, if consistency checking is enabled.  */
+
+inline void
+cgraph_node::checking_verify_cgraph_nodes ()
+{
+  if (flag_checking)
+    cgraph_node::verify_cgraph_nodes ();
+}
+
 /* Return true when variable can be removed from variable pool
    if all direct calls are eliminated.  */
 
diff --git a/gcc/cgraphclones.c b/gcc/cgraphclones.c
index e51431c..6bea9f7 100644
--- a/gcc/cgraphclones.c
+++ b/gcc/cgraphclones.c
@@ -1076,9 +1076,8 @@ symbol_table::materialize_all_clones (void)
 
   if (symtab->dump_file)
     fprintf (symtab->dump_file, "Materializing clones\n");
-#ifdef ENABLE_CHECKING
-  cgraph_node::verify_cgraph_nodes ();
-#endif
+
+  cgraph_node::checking_verify_cgraph_nodes ();
 
   /* We can also do topological order, but number of iterations should be
      bounded by number of IPA passes since single IPA pass is probably not
@@ -1147,9 +1146,9 @@ symbol_table::materialize_all_clones (void)
       node->clear_stmts_in_references ();
   if (symtab->dump_file)
     fprintf (symtab->dump_file, "Materialization Call site updates done.\n");
-#ifdef ENABLE_CHECKING
-  cgraph_node::verify_cgraph_nodes ();
-#endif
+
+  cgraph_node::checking_verify_cgraph_nodes ();
+
   symtab->remove_unreachable_nodes (symtab->dump_file);
 }
 
diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index 04a4d3f..42081c5 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -1325,13 +1325,12 @@ handle_alias_pairs (void)
 static void
 mark_functions_to_output (void)
 {
-  cgraph_node *node;
-#ifdef ENABLE_CHECKING
   bool check_same_comdat_groups = false;
+  cgraph_node *node;
 
-  FOR_EACH_FUNCTION (node)
-    gcc_assert (!node->process);
-#endif
+  if (flag_checking)
+    FOR_EACH_FUNCTION (node)
+      gcc_assert (!node->process);
 
   FOR_EACH_FUNCTION (node)
     {
@@ -1365,15 +1364,14 @@ mark_functions_to_output (void)
 	}
       else if (node->same_comdat_group)
 	{
-#ifdef ENABLE_CHECKING
-	  check_same_comdat_groups = true;
-#endif
+	  if (flag_checking)
+	    check_same_comdat_groups = true;
 	}
       else
 	{
 	  /* We should've reclaimed all functions that are not needed.  */
-#ifdef ENABLE_CHECKING
-	  if (!node->global.inlined_to
+	  if (flag_checking
+	      && !node->global.inlined_to
 	      && gimple_has_body_p (decl)
 	      /* FIXME: in ltrans unit when offline copy is outside partition but inline copies
 		 are inside partition, we can end up not removing the body since we no longer
@@ -1386,7 +1384,6 @@ mark_functions_to_output (void)
 	      node->debug ();
 	      internal_error ("failed to reclaim unneeded function");
 	    }
-#endif
 	  gcc_assert (node->global.inlined_to
 		      || !gimple_has_body_p (decl)
 		      || node->in_other_partition
@@ -1397,8 +1394,7 @@ mark_functions_to_output (void)
 	}
 
     }
-#ifdef ENABLE_CHECKING
-  if (check_same_comdat_groups)
+  if (CHECKING_P && check_same_comdat_groups)
     FOR_EACH_FUNCTION (node)
       if (node->same_comdat_group && !node->process)
 	{
@@ -1418,7 +1414,6 @@ mark_functions_to_output (void)
 			      "comdat group");
 	    }
 	}
-#endif
 }
 
 /* DECL is FUNCTION_DECL.  Initialize datastructures so DECL is a function
@@ -1887,9 +1882,7 @@ cgraph_node::expand_thunk (bool output_asm_thunks, bool force_gimple_thunk)
       TREE_ASM_WRITTEN (thunk_fndecl) = false;
       delete_unreachable_blocks ();
       update_ssa (TODO_update_ssa);
-#ifdef ENABLE_CHECKING
-      verify_flow_info ();
-#endif
+      checking_verify_flow_info ();
       free_dominance_info (CDI_DOMINATORS);
 
       /* Since we want to emit the thunk, we explicitly mark its name as
@@ -2373,9 +2366,7 @@ symbol_table::compile (void)
   if (seen_error ())
     return;
 
-#ifdef ENABLE_CHECKING
-  symtab_node::verify_symtab_nodes ();
-#endif
+  symtab_node::checking_verify_symtab_nodes ();
 
   timevar_push (TV_CGRAPHOPT);
   if (pre_ipa_mem_report)
@@ -2424,9 +2415,7 @@ symbol_table::compile (void)
   (*debug_hooks->assembly_start) ();
   if (!quiet_flag)
     fprintf (stderr, "Assembling functions:\n");
-#ifdef ENABLE_CHECKING
-  symtab_node::verify_symtab_nodes ();
-#endif
+  symtab_node::checking_verify_symtab_nodes ();
 
   materialize_all_clones ();
   bitmap_obstack_initialize (NULL);
@@ -2482,7 +2471,8 @@ symbol_table::compile (void)
       fprintf (dump_file, "\nFinal ");
       symtab_node::dump_table (dump_file);
     }
-#ifdef ENABLE_CHECKING
+  if (!flag_checking)
+    return;
   symtab_node::verify_symtab_nodes ();
   /* Double check that all inline clones are gone and that all
      function bodies have been released from memory.  */
@@ -2501,7 +2491,6 @@ symbol_table::compile (void)
       if (error_found)
 	internal_error ("nodes with unreleased memory found");
     }
-#endif
 }
 
 
diff --git a/gcc/ddg.c b/gcc/ddg.c
index ada4657..e6c9bbe 100644
--- a/gcc/ddg.c
+++ b/gcc/ddg.c
@@ -300,19 +300,16 @@ add_cross_iteration_register_deps (ddg_ptr g, df_ref last_def)
   rtx_insn *def_insn = DF_REF_INSN (last_def);
   ddg_node_ptr last_def_node = get_node_of_insn (g, def_insn);
   ddg_node_ptr use_node;
-#ifdef ENABLE_CHECKING
-  struct df_rd_bb_info *bb_info = DF_RD_BB_INFO (g->bb);
-#endif
+  struct df_rd_bb_info *bb_info = flag_checking ? DF_RD_BB_INFO (g->bb)
+						: NULL;
   df_ref first_def = df_bb_regno_first_def_find (g->bb, regno);
 
   gcc_assert (last_def_node);
   gcc_assert (first_def);
 
-#ifdef ENABLE_CHECKING
-  if (DF_REF_ID (last_def) != DF_REF_ID (first_def))
+  if (flag_checking && DF_REF_ID (last_def) != DF_REF_ID (first_def))
     gcc_assert (!bitmap_bit_p (&bb_info->gen,
 			       DF_REF_ID (first_def)));
-#endif
 
   /* Create inter-loop true dependences and anti dependences.  */
   for (r_use = DF_REF_CHAIN (last_def); r_use != NULL; r_use = r_use->next)
@@ -1013,7 +1010,6 @@ order_sccs (ddg_all_sccs_ptr g)
 	 (int (*) (const void *, const void *)) compare_sccs);
 }
 
-#ifdef ENABLE_CHECKING
 /* Check that every node in SCCS belongs to exactly one strongly connected
    component and that no element of SCCS is empty.  */
 static void
@@ -1033,7 +1029,6 @@ check_sccs (ddg_all_sccs_ptr sccs, int num_nodes)
     }
   sbitmap_free (tmp);
 }
-#endif
 
 /* Perform the Strongly Connected Components decomposing algorithm on the
    DDG and return DDG_ALL_SCCS structure that contains them.  */
@@ -1079,9 +1074,10 @@ create_ddg_all_sccs (ddg_ptr g)
   sbitmap_free (from);
   sbitmap_free (to);
   sbitmap_free (scc_nodes);
-#ifdef ENABLE_CHECKING
-  check_sccs (sccs, num_nodes);
-#endif
+
+  if (flag_checking)
+    check_sccs (sccs, num_nodes);
+
   return sccs;
 }
 
diff --git a/gcc/df-core.c b/gcc/df-core.c
index 8d2d7a1..72a5eb5 100644
--- a/gcc/df-core.c
+++ b/gcc/df-core.c
@@ -682,10 +682,8 @@ df_finish_pass (bool verify ATTRIBUTE_UNUSED)
 #endif
 #endif
 
-#ifdef ENABLE_CHECKING
-  if (verify)
+  if (flag_checking && verify)
     df->changeable_flags |= DF_VERIFY_SCHEDULED;
-#endif
 }
 
 
@@ -1273,12 +1271,14 @@ df_analyze (void)
   for (i = 0; i < df->n_blocks; i++)
     bitmap_set_bit (current_all_blocks, df->postorder[i]);
 
-#ifdef ENABLE_CHECKING
-  /* Verify that POSTORDER_INVERTED only contains blocks reachable from
-     the ENTRY block.  */
-  for (i = 0; i < df->n_blocks_inverted; i++)
-    gcc_assert (bitmap_bit_p (current_all_blocks, df->postorder_inverted[i]));
-#endif
+  if (flag_checking)
+    {
+      /* Verify that POSTORDER_INVERTED only contains blocks reachable from
+	 the ENTRY block.  */
+      for (i = 0; i < df->n_blocks_inverted; i++)
+	gcc_assert (bitmap_bit_p (current_all_blocks,
+				  df->postorder_inverted[i]));
+    }
 
   /* Make sure that we have pruned any unreachable blocks from these
      sets.  */
diff --git a/gcc/diagnostic-core.h b/gcc/diagnostic-core.h
index 66d2e42..6cc1e6b 100644
--- a/gcc/diagnostic-core.h
+++ b/gcc/diagnostic-core.h
@@ -48,7 +48,7 @@ extern const char *trim_filename (const char *);
 /* None of these functions are suitable for ATTRIBUTE_PRINTF, because
    each language front end can extend them with its own set of format
    specifiers.  We must use custom format checks.  */
-#if (ENABLE_CHECKING && GCC_VERSION >= 4001) || GCC_VERSION == BUILDING_GCC_VERSION
+#if (CHECKING_P && GCC_VERSION >= 4001) || GCC_VERSION == BUILDING_GCC_VERSION
 #define ATTRIBUTE_GCC_DIAG(m, n) __attribute__ ((__format__ (GCC_DIAG_STYLE, m, n))) ATTRIBUTE_NONNULL(m)
 #else
 #define ATTRIBUTE_GCC_DIAG(m, n) ATTRIBUTE_NONNULL(m)
diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c
index 831859a..11c369d 100644
--- a/gcc/diagnostic.c
+++ b/gcc/diagnostic.c
@@ -736,12 +736,12 @@ diagnostic_report_diagnostic (diagnostic_context *context,
 
   if (diagnostic->kind == DK_ICE || diagnostic->kind == DK_ICE_NOBT)
     {
-#ifndef ENABLE_CHECKING
       /* When not checking, ICEs are converted to fatal errors when an
 	 error has already occurred.  This is counteracted by
 	 abort_on_error.  */
-      if ((diagnostic_kind_count (context, DK_ERROR) > 0
-	   || diagnostic_kind_count (context, DK_SORRY) > 0)
+      if (!CHECKING_P
+	  && (diagnostic_kind_count (context, DK_ERROR) > 0
+	      || diagnostic_kind_count (context, DK_SORRY) > 0)
 	  && !context->abort_on_error)
 	{
 	  expanded_location s 
@@ -750,7 +750,6 @@ diagnostic_report_diagnostic (diagnostic_context *context,
 		   s.file, s.line);
 	  exit (ICE_EXIT_CODE);
 	}
-#endif
       if (context->internal_error)
 	(*context->internal_error) (context,
 				    diagnostic->message.format_spec,
diff --git a/gcc/dominance.c b/gcc/dominance.c
index 09645be..0dc4030 100644
--- a/gcc/dominance.c
+++ b/gcc/dominance.c
@@ -634,9 +634,7 @@ calculate_dominance_info (cdi_direction dir)
 
   if (dom_computed[dir_index] == DOM_OK)
     {
-#if ENABLE_CHECKING
-      verify_dominators (dir);
-#endif
+      checking_verify_dominators (dir);
       return;
     }
 
@@ -665,11 +663,7 @@ calculate_dominance_info (cdi_direction dir)
       dom_computed[dir_index] = DOM_NO_FAST_QUERY;
     }
   else
-    {
-#if ENABLE_CHECKING
-      verify_dominators (dir);
-#endif
-    }
+    checking_verify_dominators (dir);
 
   compute_dom_fast_query (dir);
 
@@ -1014,7 +1008,7 @@ bb_dom_dfs_out (enum cdi_direction dir, basic_block bb)
 }
 
 /* Verify invariants of dominator structure.  */
-DEBUG_FUNCTION void
+void
 verify_dominators (cdi_direction dir)
 {
   gcc_assert (dom_info_available_p (dir));
diff --git a/gcc/dominance.h b/gcc/dominance.h
index 37e138b..7254f2f 100644
--- a/gcc/dominance.h
+++ b/gcc/dominance.h
@@ -60,6 +60,17 @@ extern bool dominated_by_p (enum cdi_direction, const_basic_block,
 unsigned bb_dom_dfs_in (enum cdi_direction, basic_block);
 unsigned bb_dom_dfs_out (enum cdi_direction, basic_block);
 extern void verify_dominators (enum cdi_direction);
+
+/* Verify invariants of computed dominance information, if internal consistency
+   checks are enabled.  */
+
+static inline void
+checking_verify_dominators (cdi_direction dir)
+{
+  if (flag_checking)
+    verify_dominators (dir);
+}
+
 basic_block recompute_dominator (enum cdi_direction, basic_block);
 extern void iterate_fix_dominators (enum cdi_direction,
 				    vec<basic_block> , bool);
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index c1b7c7b..83cc74a 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -4149,15 +4149,12 @@ static inline void
 add_AT_die_ref (dw_die_ref die, enum dwarf_attribute attr_kind, dw_die_ref targ_die)
 {
   dw_attr_node attr;
+  gcc_checking_assert (targ_die != NULL);
 
-#ifdef ENABLE_CHECKING
-  gcc_assert (targ_die != NULL);
-#else
   /* With LTO we can end up trying to reference something we didn't create
      a DIE for.  Avoid crashing later on a NULL referenced DIE.  */
   if (targ_die == NULL)
     return;
-#endif
 
   attr.dw_attr = attr_kind;
   attr.dw_attr_val.val_class = dw_val_class_die_ref;
@@ -5723,7 +5720,6 @@ debug_dwarf (void)
   print_die (comp_unit_die (), stderr);
 }
 
-#ifdef ENABLE_CHECKING
 /* Sanity checks on DIEs.  */
 
 static void
@@ -5786,7 +5782,7 @@ check_die (dw_die_ref die)
 		    && a->dw_attr != DW_AT_GNU_all_call_sites);
     }
 }
-#endif
+
 \f
 /* Start a new compilation unit DIE for an include file.  OLD_UNIT is the CU
    for the enclosing include file, if any.  BINCL_DIE is the DW_TAG_GNU_BINCL
@@ -11763,14 +11759,14 @@ const_ok_for_output_1 (rtx rtl)
     {
       /* If delegitimize_address couldn't do anything with the UNSPEC, assume
 	 we can't express it in the debug info.  */
-#ifdef ENABLE_CHECKING
       /* Don't complain about TLS UNSPECs, those are just too hard to
 	 delegitimize.  Note this could be a non-decl SYMBOL_REF such as
 	 one in a constant pool entry, so testing SYMBOL_REF_TLS_MODEL
 	 rather than DECL_THREAD_LOCAL_P is not just an optimization.  */
-      if (XVECLEN (rtl, 0) == 0
-	  || GET_CODE (XVECEXP (rtl, 0, 0)) != SYMBOL_REF
-	  || SYMBOL_REF_TLS_MODEL (XVECEXP (rtl, 0, 0)) == TLS_MODEL_NONE)
+      if (flag_checking
+	  && (XVECLEN (rtl, 0) == 0
+	      || GET_CODE (XVECEXP (rtl, 0, 0)) != SYMBOL_REF
+	      || SYMBOL_REF_TLS_MODEL (XVECEXP (rtl, 0, 0)) == TLS_MODEL_NONE))
 	inform (current_function_decl
 		? DECL_SOURCE_LOCATION (current_function_decl)
 		: UNKNOWN_LOCATION,
@@ -11783,7 +11779,6 @@ const_ok_for_output_1 (rtx rtl)
 		"non-delegitimized UNSPEC %d found in variable location",
 		XINT (rtl, 1));
 #endif
-#endif
       expansion_failed (NULL_TREE, rtl,
 			"UNSPEC hasn't been delegitimized.\n");
       return false;
@@ -13570,12 +13565,12 @@ mem_loc_descriptor (rtx rtl, machine_mode mode,
       goto symref;
 
     default:
-#ifdef ENABLE_CHECKING
-      print_rtl (stderr, rtl);
-      gcc_unreachable ();
-#else
+      if (flag_checking)
+	{
+	  print_rtl (stderr, rtl);
+	  gcc_unreachable ();
+	}
       break;
-#endif
     }
 
   if (mem_loc_result && initialized == VAR_INIT_STATUS_UNINITIALIZED)
@@ -15098,15 +15093,14 @@ loc_list_from_tree (tree loc, int want_address,
 	  return 0;
 	}
 
-#ifdef ENABLE_CHECKING
       /* Otherwise this is a generic code; we should just lists all of
 	 these explicitly.  We forgot one.  */
-      gcc_unreachable ();
-#else
+      if (flag_checking)
+	gcc_unreachable ();
+
       /* In a release build, we want to degrade gracefully: better to
 	 generate incomplete debugging information than to crash.  */
       return NULL;
-#endif
     }
 
   if (!ret && !list_ret)
@@ -19908,18 +19902,17 @@ gen_lexical_block_die (tree stmt, dw_die_ref context_die)
     {
       if (old_die)
 	{
-#ifdef ENABLE_CHECKING
 	  /* This must have been generated early and it won't even
 	     need location information since it's a DW_AT_inline
 	     function.  */
-	  for (dw_die_ref c = context_die; c; c = c->die_parent)
-	    if (c->die_tag == DW_TAG_inlined_subroutine
-		|| c->die_tag == DW_TAG_subprogram)
-	      {
-		gcc_assert (get_AT (c, DW_AT_inline));
-		break;
-	      }
-#endif
+	  if (flag_checking)
+	    for (dw_die_ref c = context_die; c; c = c->die_parent)
+	      if (c->die_tag == DW_TAG_inlined_subroutine
+		  || c->die_tag == DW_TAG_subprogram)
+		{
+		  gcc_assert (get_AT (c, DW_AT_inline));
+		  break;
+		}
 	  return;
 	}
     }
@@ -20736,10 +20729,8 @@ gen_type_die_with_usage (tree type, dw_die_ref context_die,
   if (type == NULL_TREE || type == error_mark_node)
     return;
 
-#ifdef ENABLE_CHECKING
-  if (type)
+  if (flag_checking && type)
      verify_type (type);
-#endif
 
   if (TYPE_NAME (type) != NULL_TREE
       && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
@@ -20933,11 +20924,12 @@ gen_type_die (tree type, dw_die_ref context_die)
   if (type != error_mark_node)
     {
       gen_type_die_with_usage (type, context_die, DINFO_USAGE_DIR_USE);
-#ifdef ENABLE_CHECKING
-      dw_die_ref die = lookup_type_die (type);
-      if (die)
-	check_die (die);
-#endif
+      if (flag_checking)
+	{
+	  dw_die_ref die = lookup_type_die (type);
+	  if (die)
+	    check_die (die);
+	}
     }
 }
 
@@ -21975,11 +21967,12 @@ dwarf2out_decl (tree decl)
 
   gen_decl_die (decl, NULL, context_die);
 
-#ifdef ENABLE_CHECKING
-  dw_die_ref die = lookup_decl_die (decl);
-  if (die)
-    check_die (die);
-#endif
+  if (flag_checking)
+    {
+      dw_die_ref die = lookup_decl_die (decl);
+      if (die)
+	check_die (die);
+    }
 }
 
 /* Write the debugging output for DECL.  */
diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c
index c418c24..8d2e81c 100644
--- a/gcc/emit-rtl.c
+++ b/gcc/emit-rtl.c
@@ -2733,8 +2733,7 @@ verify_rtx_sharing (rtx orig, rtx insn)
 
   /* This rtx may not be shared.  If it has already been seen,
      replace it with a copy of itself.  */
-#ifdef ENABLE_CHECKING
-  if (RTX_FLAG (x, used))
+  if (flag_checking && RTX_FLAG (x, used))
     {
       error ("invalid rtl sharing found in the insn");
       debug_rtx (insn);
@@ -2742,7 +2741,6 @@ verify_rtx_sharing (rtx orig, rtx insn)
       debug_rtx (x);
       internal_error ("internal consistency failure");
     }
-#endif
   gcc_assert (!RTX_FLAG (x, used));
 
   RTX_FLAG (x, used) = 1;
@@ -4259,12 +4257,12 @@ delete_insns_since (rtx_insn *from)
 void
 reorder_insns_nobb (rtx_insn *from, rtx_insn *to, rtx_insn *after)
 {
-#ifdef ENABLE_CHECKING
-  rtx_insn *x;
-  for (x = from; x != to; x = NEXT_INSN (x))
-    gcc_assert (after != x);
-  gcc_assert (after != to);
-#endif
+  if (flag_checking)
+    {
+      for (rtx_insn *x = from; x != to; x = NEXT_INSN (x))
+	gcc_assert (after != x);
+      gcc_assert (after != to);
+    }
 
   /* Splice this bunch out of where it is now.  */
   if (PREV_INSN (from))
diff --git a/gcc/et-forest.c b/gcc/et-forest.c
index 4f919d4..bf2f765 100644
--- a/gcc/et-forest.c
+++ b/gcc/et-forest.c
@@ -28,7 +28,7 @@ License along with libiberty; see the file COPYING3.  If not see
 #include "alloc-pool.h"
 #include "et-forest.h"
 
-/* We do not enable this with ENABLE_CHECKING, since it is awfully slow.  */
+/* We do not enable this with CHECKING_P, since it is awfully slow.  */
 #undef DEBUG_ET
 
 #ifdef DEBUG_ET
diff --git a/gcc/except.c b/gcc/except.c
index 8f77653..282854e 100644
--- a/gcc/except.c
+++ b/gcc/except.c
@@ -612,9 +612,8 @@ duplicate_eh_regions (struct function *ifun,
   struct duplicate_eh_regions_data data;
   eh_region outer_region;
 
-#ifdef ENABLE_CHECKING
-  verify_eh_tree (ifun);
-#endif
+  if (flag_checking)
+    verify_eh_tree (ifun);
 
   data.label_map = map;
   data.label_map_data = map_data;
@@ -632,9 +631,8 @@ duplicate_eh_regions (struct function *ifun,
 	duplicate_eh_regions_1 (&data, r, outer_region);
     }
 
-#ifdef ENABLE_CHECKING
-  verify_eh_tree (cfun);
-#endif
+  if (flag_checking)
+    verify_eh_tree (cfun);
 
   return data.eh_map;
 }
@@ -3307,7 +3305,7 @@ debug_eh_tree (struct function *fn)
 
 /* Verify invariants on EH datastructures.  */
 
-DEBUG_FUNCTION void
+void
 verify_eh_tree (struct function *fun)
 {
   eh_region r, outer;
diff --git a/gcc/fwprop.c b/gcc/fwprop.c
index 16c7981..67808bc 100644
--- a/gcc/fwprop.c
+++ b/gcc/fwprop.c
@@ -843,9 +843,7 @@ all_uses_available_at (rtx_insn *def_insn, rtx_insn *target_insn)
 
 \f
 static df_ref *active_defs;
-#ifdef ENABLE_CHECKING
 static sparseset active_defs_check;
-#endif
 
 /* Fill the ACTIVE_DEFS array with the use->def link for the registers
    mentioned in USE_REC.  Register the valid entries in ACTIVE_DEFS_CHECK
@@ -859,9 +857,8 @@ register_active_defs (df_ref use)
       df_ref def = get_def_for_use (use);
       int regno = DF_REF_REGNO (use);
 
-#ifdef ENABLE_CHECKING
-      sparseset_set_bit (active_defs_check, regno);
-#endif
+      if (CHECKING_P)
+	sparseset_set_bit (active_defs_check, regno);
       active_defs[regno] = def;
     }
 }
@@ -876,9 +873,8 @@ register_active_defs (df_ref use)
 static void
 update_df_init (rtx_insn *def_insn, rtx_insn *insn)
 {
-#ifdef ENABLE_CHECKING
-  sparseset_clear (active_defs_check);
-#endif
+  if (CHECKING_P)
+    sparseset_clear (active_defs_check);
   register_active_defs (DF_INSN_USES (def_insn));
   register_active_defs (DF_INSN_USES (insn));
   register_active_defs (DF_INSN_EQ_USES (insn));
@@ -899,9 +895,7 @@ update_uses (df_ref use)
       if (DF_REF_ID (use) >= (int) use_def_ref.length ())
         use_def_ref.safe_grow_cleared (DF_REF_ID (use) + 1);
 
-#ifdef ENABLE_CHECKING
-      gcc_assert (sparseset_bit_p (active_defs_check, regno));
-#endif
+      gcc_checking_assert (sparseset_bit_p (active_defs_check, regno));
       use_def_ref[DF_REF_ID (use)] = active_defs[regno];
     }
 }
@@ -1407,9 +1401,8 @@ fwprop_init (void)
   df_set_flags (DF_DEFER_INSN_RESCAN);
 
   active_defs = XNEWVEC (df_ref, max_reg_num ());
-#ifdef ENABLE_CHECKING
-  active_defs_check = sparseset_alloc (max_reg_num ());
-#endif
+  if (CHECKING_P)
+    active_defs_check = sparseset_alloc (max_reg_num ());
 }
 
 static void
@@ -1419,9 +1412,8 @@ fwprop_done (void)
 
   use_def_ref.release ();
   free (active_defs);
-#ifdef ENABLE_CHECKING
-  sparseset_free (active_defs_check);
-#endif
+  if (CHECKING_P)
+    sparseset_free (active_defs_check);
 
   free_dominance_info (CDI_DOMINATORS);
   cleanup_cfg (0);
diff --git a/gcc/ggc-page.c b/gcc/ggc-page.c
index 34e9e24..1fa8cd1 100644
--- a/gcc/ggc-page.c
+++ b/gcc/ggc-page.c
@@ -2201,12 +2201,11 @@ ggc_collect (void)
 void
 ggc_grow (void)
 {
-#ifndef ENABLE_CHECKING
-  G.allocated_last_gc = MAX (G.allocated_last_gc,
-			     G.allocated);
-#else
-  ggc_collect ();
-#endif
+  if (!CHECKING_P)
+    G.allocated_last_gc = MAX (G.allocated_last_gc,
+			       G.allocated);
+  else
+    ggc_collect ();
   if (!quiet_flag)
     fprintf (stderr, " {GC start %luk} ", (unsigned long) G.allocated / 1024);
 }
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 071645f..61048c9 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -10327,10 +10327,8 @@ gimplify_body (tree fndecl, bool do_parms)
   pop_gimplify_context (outer_bind);
   gcc_assert (gimplify_ctxp == NULL);
 
-#ifdef ENABLE_CHECKING
-  if (!seen_error ())
+  if (flag_checking && !seen_error ())
     verify_gimple_in_seq (gimple_bind_body (outer_bind));
-#endif
 
   timevar_pop (TV_TREE_GIMPLIFY);
   input_location = saved_location;
@@ -10622,11 +10620,9 @@ gimplify_hasher::equal (const elt_t *p1, const elt_t *p2)
   if (!operand_equal_p (t1, t2, 0))
     return false;
 
-#ifdef ENABLE_CHECKING
   /* Only allow them to compare equal if they also hash equal; otherwise
      results are nondeterminate, and we fail bootstrap comparison.  */
-  gcc_assert (hash (p1) == hash (p2));
-#endif
+  gcc_checking_assert (hash (p1) == hash (p2));
 
   return true;
 }
diff --git a/gcc/graphite-isl-ast-to-gimple.c b/gcc/graphite-isl-ast-to-gimple.c
index 2f2e2ba..f125cc0 100644
--- a/gcc/graphite-isl-ast-to-gimple.c
+++ b/gcc/graphite-isl-ast-to-gimple.c
@@ -106,10 +106,8 @@ gmp_cst_to_tree (tree type, mpz_t val)
 static inline void
 graphite_verify (void)
 {
-#ifdef ENABLE_CHECKING
-  verify_loop_structure ();
-  verify_loop_closed_ssa (true);
-#endif
+  checking_verify_loop_structure ();
+  checking_verify_loop_closed_ssa (true);
 }
 
 /* IVS_PARAMS maps ISL's scattering and parameter identifiers
diff --git a/gcc/graphite-scop-detection.c b/gcc/graphite-scop-detection.c
index 6c0987d..ef7696d 100644
--- a/gcc/graphite-scop-detection.c
+++ b/gcc/graphite-scop-detection.c
@@ -259,21 +259,16 @@ canonicalize_loop_closed_ssa (loop_p loop)
 static void
 canonicalize_loop_closed_ssa_form (void)
 {
-  loop_p loop;
-
-#ifdef ENABLE_CHECKING
-  verify_loop_closed_ssa (true);
-#endif
+  checking_verify_loop_closed_ssa (true);
 
+  loop_p loop;
   FOR_EACH_LOOP (loop, 0)
     canonicalize_loop_closed_ssa (loop);
 
   rewrite_into_loop_closed_ssa (NULL, TODO_update_ssa);
   update_ssa (TODO_update_ssa);
 
-#ifdef ENABLE_CHECKING
-  verify_loop_closed_ssa (true);
-#endif
+  checking_verify_loop_closed_ssa (true);
 }
 
 /* Can all ivs be represented by a signed integer?
diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c
index 261e67d..47c0c2e 100644
--- a/gcc/graphite-sese-to-poly.c
+++ b/gcc/graphite-sese-to-poly.c
@@ -1524,9 +1524,7 @@ rewrite_reductions_out_of_ssa (scop_p scop)
 	}
 
   update_ssa (TODO_update_ssa);
-#ifdef ENABLE_CHECKING
-  verify_loop_closed_ssa (true);
-#endif
+  checking_verify_loop_closed_ssa (true);
 }
 
 /* Rewrite the scalar dependence of DEF used in USE_STMT with a memory
@@ -1701,9 +1699,7 @@ rewrite_cross_bb_scalar_deps_out_of_ssa (scop_p scop)
     {
       scev_reset_htab ();
       update_ssa (TODO_update_ssa);
-#ifdef ENABLE_CHECKING
-      verify_loop_closed_ssa (true);
-#endif
+      checking_verify_loop_closed_ssa (true);
     }
 }
 
diff --git a/gcc/hash-table.h b/gcc/hash-table.h
index 8e3c2ca..192be30 100644
--- a/gcc/hash-table.h
+++ b/gcc/hash-table.h
@@ -638,9 +638,7 @@ hash_table<Descriptor, Allocator>::find_empty_slot_for_expand (hashval_t hash)
 
   if (is_empty (*slot))
     return slot;
-#ifdef ENABLE_CHECKING
   gcc_checking_assert (!is_deleted (*slot));
-#endif
 
   hash2 = hash_table_mod2 (hash, m_size_prime_index);
   for (;;)
@@ -652,9 +650,7 @@ hash_table<Descriptor, Allocator>::find_empty_slot_for_expand (hashval_t hash)
       slot = m_entries + index;
       if (is_empty (*slot))
         return slot;
-#ifdef ENABLE_CHECKING
       gcc_checking_assert (!is_deleted (*slot));
-#endif
     }
 }
 
diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c
index d0ae494..ca53755 100644
--- a/gcc/ifcvt.c
+++ b/gcc/ifcvt.c
@@ -5093,9 +5093,7 @@ if_convert (bool after_combine)
   if (optimize == 1)
     df_remove_problem (df_live);
 
-#ifdef ENABLE_CHECKING
-  verify_flow_info ();
-#endif
+  checking_verify_flow_info ();
 }
 \f
 /* If-conversion and CFG cleanup.  */
diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c
index d9d81f1..899fa6d 100644
--- a/gcc/ipa-cp.c
+++ b/gcc/ipa-cp.c
@@ -1183,7 +1183,7 @@ ipa_context_from_jfunc (ipa_node_params *info, cgraph_edge *cs, int csidx,
    bottom, not containing a variable component and without any known value at
    the same time.  */
 
-DEBUG_FUNCTION void
+void
 ipcp_verify_propagated_values (void)
 {
   struct cgraph_node *node;
@@ -2919,9 +2919,8 @@ ipcp_propagate_stage (struct ipa_topo_info *topo)
 	     overall_size, max_new_size);
 
   propagate_constants_topo (topo);
-#ifdef ENABLE_CHECKING
-  ipcp_verify_propagated_values ();
-#endif
+  if (flag_checking)
+    ipcp_verify_propagated_values ();
   topo->constants.propagate_effects ();
   topo->contexts.propagate_effects ();
 
diff --git a/gcc/ipa-devirt.c b/gcc/ipa-devirt.c
index a7a8e8e..69dec05 100644
--- a/gcc/ipa-devirt.c
+++ b/gcc/ipa-devirt.c
@@ -272,11 +272,10 @@ type_in_anonymous_namespace_p (const_tree t)
     {
       /* C++ FE uses magic <anon> as assembler names of anonymous types.
  	 verify that this match with type_in_anonymous_namespace_p.  */
-#ifdef ENABLE_CHECKING
       if (in_lto_p)
-	gcc_assert (!strcmp ("<anon>",
-		    IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (TYPE_NAME (t)))));
-#endif
+	gcc_checking_assert (!strcmp ("<anon>",
+				      IDENTIFIER_POINTER
+					(DECL_ASSEMBLER_NAME (TYPE_NAME (t)))));
       return true;
     }
   return false;
@@ -300,15 +299,13 @@ odr_type_p (const_tree t)
   if (TYPE_NAME (t) && TREE_CODE (TYPE_NAME (t)) == TYPE_DECL
       && (DECL_ASSEMBLER_NAME_SET_P (TYPE_NAME (t))))
     {
-#ifdef ENABLE_CHECKING
       /* C++ FE uses magic <anon> as assembler names of anonymous types.
  	 verify that this match with type_in_anonymous_namespace_p.  */
-      gcc_assert (!type_with_linkage_p (t)
-		  || strcmp ("<anon>",
-			     IDENTIFIER_POINTER
-			        (DECL_ASSEMBLER_NAME (TYPE_NAME (t))))
-		  || type_in_anonymous_namespace_p (t));
-#endif
+      gcc_checking_assert (!type_with_linkage_p (t)
+			   || strcmp ("<anon>",
+				      IDENTIFIER_POINTER
+					(DECL_ASSEMBLER_NAME (TYPE_NAME (t))))
+			   || type_in_anonymous_namespace_p (t));
       return true;
     }
   return false;
@@ -1777,11 +1774,10 @@ odr_types_equivalent_p (tree t1, tree t2, bool warn, bool *warned,
 bool
 odr_types_equivalent_p (tree type1, tree type2)
 {
-  hash_set<type_pair> visited;
+  gcc_checking_assert (odr_or_derived_type_p (type1)
+		       && odr_or_derived_type_p (type2));
 
-#ifdef ENABLE_CHECKING
-  gcc_assert (odr_or_derived_type_p (type1) && odr_or_derived_type_p (type2));
-#endif
+  hash_set<type_pair> visited;
   return odr_types_equivalent_p (type1, type2, false, NULL,
 			         &visited, UNKNOWN_LOCATION, UNKNOWN_LOCATION);
 }
@@ -2000,8 +1996,8 @@ add_type_duplicate (odr_type val, tree type)
     }
   gcc_assert (val->odr_violated || !odr_must_violate);
   /* Sanity check that all bases will be build same way again.  */
-#ifdef ENABLE_CHECKING
-  if (COMPLETE_TYPE_P (type) && COMPLETE_TYPE_P (val->type)
+  if (flag_checking
+      && COMPLETE_TYPE_P (type) && COMPLETE_TYPE_P (val->type)
       && TREE_CODE (val->type) == RECORD_TYPE
       && TREE_CODE (type) == RECORD_TYPE
       && TYPE_BINFO (val->type) && TYPE_BINFO (type)
@@ -2030,7 +2026,6 @@ add_type_duplicate (odr_type val, tree type)
 	    j++;
 	  }
     }
-#endif
 
 
   /* Regularize things a little.  During LTO same types may come with
@@ -2136,8 +2131,8 @@ get_odr_type (tree type, bool insert)
       if (slot && *slot)
 	{
 	  val = *slot;
-#ifdef ENABLE_CHECKING
-	  if (in_lto_p && can_be_vtable_hashed_p (type))
+	  if (flag_checking
+	      && in_lto_p && can_be_vtable_hashed_p (type))
 	    {
 	      hash = hash_odr_vtable (type);
 	      vtable_slot = odr_vtable_hash->find_slot_with_hash (type, hash,
@@ -2145,7 +2140,6 @@ get_odr_type (tree type, bool insert)
 	      gcc_assert (!vtable_slot || *vtable_slot == *slot);
 	      vtable_slot = NULL;
 	    }
-#endif
 	}
       else if (*vtable_slot)
 	val = *vtable_slot;
diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c
index b0ef9f1..a90c0a8 100644
--- a/gcc/ipa-icf.c
+++ b/gcc/ipa-icf.c
@@ -2982,7 +2982,9 @@ sem_item_optimizer::subdivide_classes_by_sensitive_refs ()
 void
 sem_item_optimizer::verify_classes (void)
 {
-#if ENABLE_CHECKING
+  if (!flag_checking)
+    return;
+
   for (hash_table <congruence_class_group_hash>::iterator it = m_classes.begin ();
        it != m_classes.end (); ++it)
     {
@@ -2990,26 +2992,25 @@ sem_item_optimizer::verify_classes (void)
 	{
 	  congruence_class *cls = (*it)->classes[i];
 
-	  gcc_checking_assert (cls);
-	  gcc_checking_assert (cls->members.length () > 0);
+	  gcc_assert (cls);
+	  gcc_assert (cls->members.length () > 0);
 
 	  for (unsigned int j = 0; j < cls->members.length (); j++)
 	    {
 	      sem_item *item = cls->members[j];
 
-	      gcc_checking_assert (item);
-	      gcc_checking_assert (item->cls == cls);
+	      gcc_assert (item);
+	      gcc_assert (item->cls == cls);
 
 	      for (unsigned k = 0; k < item->usages.length (); k++)
 		{
 		  sem_usage_pair *usage = item->usages[k];
-		  gcc_checking_assert (usage->item->index_in_class <
-				       usage->item->cls->members.length ());
+		  gcc_assert (usage->item->index_in_class <
+			      usage->item->cls->members.length ());
 		}
 	    }
 	}
     }
-#endif
 }
 
 /* Disposes split map traverse function. CLS_PTR is pointer to congruence
@@ -3054,10 +3055,11 @@ sem_item_optimizer::traverse_congruence_split (congruence_class * const &cls,
 	  add_item_to_class (tc, cls->members[i]);
 	}
 
-#ifdef ENABLE_CHECKING
-      for (unsigned int i = 0; i < 2; i++)
-	gcc_checking_assert (newclasses[i]->members.length ());
-#endif
+      if (flag_checking)
+	{
+	  for (unsigned int i = 0; i < 2; i++)
+	    gcc_assert (newclasses[i]->members.length ());
+	}
 
       if (splitter_cls == cls)
 	optimizer->splitter_class_removed = true;
@@ -3152,11 +3154,9 @@ sem_item_optimizer::do_congruence_step_for_index (congruence_class *cls,
 	  else
 	    b = *slot;
 
-#if ENABLE_CHECKING
 	  gcc_checking_assert (usage->item->cls);
 	  gcc_checking_assert (usage->item->index_in_class <
 			       usage->item->cls->members.length ());
-#endif
 
 	  bitmap_set_bit (b, usage->item->index_in_class);
 	}
diff --git a/gcc/ipa-inline-analysis.c b/gcc/ipa-inline-analysis.c
index 38e1ec0..89cba2c 100644
--- a/gcc/ipa-inline-analysis.c
+++ b/gcc/ipa-inline-analysis.c
@@ -2964,10 +2964,12 @@ compute_inline_parameters (struct cgraph_node *node, bool early)
   info->size = info->self_size;
   info->stack_frame_offset = 0;
   info->estimated_stack_size = info->estimated_self_stack_size;
-#ifdef ENABLE_CHECKING
-  inline_update_overall_summary (node);
-  gcc_assert (info->time == info->self_time && info->size == info->self_size);
-#endif
+  if (flag_checking)
+    {
+      inline_update_overall_summary (node);
+      gcc_assert (info->time == info->self_time
+		  && info->size == info->self_size);
+    }
 
   pop_cfun ();
 }
diff --git a/gcc/ipa-inline-transform.c b/gcc/ipa-inline-transform.c
index 12f701a..1d7bcaa 100644
--- a/gcc/ipa-inline-transform.c
+++ b/gcc/ipa-inline-transform.c
@@ -491,10 +491,9 @@ save_inline_function_body (struct cgraph_node *node)
       first_clone->remove_symbol_and_inline_clones ();
       first_clone = NULL;
     }
-#ifdef ENABLE_CHECKING
-  else
+  else if (flag_checking)
     first_clone->verify ();
-#endif
+
   return first_clone;
 }
 
diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c
index 8f3919c..db98755 100644
--- a/gcc/ipa-inline.c
+++ b/gcc/ipa-inline.c
@@ -1878,7 +1878,7 @@ inline_small_functions (void)
       if (!edge->inline_failed || !edge->callee->analyzed)
 	continue;
 
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
       /* Be sure that caches are maintained consistent.  */
       sreal cached_badness = edge_badness (edge, false);
  
@@ -2632,9 +2632,8 @@ early_inliner (function *fun)
   if (ipa_node_params_sum)
     return 0;
 
-#ifdef ENABLE_CHECKING
-  node->verify ();
-#endif
+  if (flag_checking)
+    node->verify ();
   node->remove_all_references ();
 
   /* Rebuild this reference because it dosn't depend on
diff --git a/gcc/ipa-inline.h b/gcc/ipa-inline.h
index 85041f6..323d117 100644
--- a/gcc/ipa-inline.h
+++ b/gcc/ipa-inline.h
@@ -299,10 +299,8 @@ estimate_edge_size (struct cgraph_edge *edge)
 static inline int
 estimate_edge_growth (struct cgraph_edge *edge)
 {
-#ifdef ENABLE_CHECKING
   gcc_checking_assert (inline_edge_summary (edge)->call_stmt_size
 		       || !edge->callee->analyzed);
-#endif
   return (estimate_edge_size (edge)
 	  - inline_edge_summary (edge)->call_stmt_size);
 }
diff --git a/gcc/ipa-visibility.c b/gcc/ipa-visibility.c
index 93073d8..0ae4388 100644
--- a/gcc/ipa-visibility.c
+++ b/gcc/ipa-visibility.c
@@ -464,16 +464,15 @@ function_and_variable_visibility (bool whole_program)
 	 what comdat group they are in when they won't be emitted in this TU.  */
       if (node->same_comdat_group && DECL_EXTERNAL (node->decl))
 	{
-#ifdef ENABLE_CHECKING
-	  symtab_node *n;
-
-	  for (n = node->same_comdat_group;
-	       n != node;
-	       n = n->same_comdat_group)
-	      /* If at least one of same comdat group functions is external,
-		 all of them have to be, otherwise it is a front-end bug.  */
-	      gcc_assert (DECL_EXTERNAL (n->decl));
-#endif
+	  if (flag_checking)
+	    {
+	      for (symtab_node *n = node->same_comdat_group;
+		   n != node;
+		   n = n->same_comdat_group)
+		/* If at least one of same comdat group functions is external,
+		   all of them have to be, otherwise it is a front-end bug.  */
+		gcc_assert (DECL_EXTERNAL (n->decl));
+	    }
 	  node->dissolve_same_comdat_group_list ();
 	}
       gcc_assert ((!DECL_WEAK (node->decl)
diff --git a/gcc/ipa.c b/gcc/ipa.c
index 6847305..6dc23ae 100644
--- a/gcc/ipa.c
+++ b/gcc/ipa.c
@@ -319,12 +319,13 @@ symbol_table::remove_unreachable_nodes (FILE *file)
   build_type_inheritance_graph ();
   if (file)
     fprintf (file, "\nReclaiming functions:");
-#ifdef ENABLE_CHECKING
-  FOR_EACH_FUNCTION (node)
-    gcc_assert (!node->aux);
-  FOR_EACH_VARIABLE (vnode)
-    gcc_assert (!vnode->aux);
-#endif
+  if (flag_checking)
+    {
+      FOR_EACH_FUNCTION (node)
+	gcc_assert (!node->aux);
+      FOR_EACH_VARIABLE (vnode)
+	gcc_assert (!vnode->aux);
+    }
   /* Mark functions whose bodies are obviously needed.
      This is mostly when they can be referenced externally.  Inline clones
      are special since their declarations are shared with master clone and thus
@@ -678,9 +679,7 @@ symbol_table::remove_unreachable_nodes (FILE *file)
   if (file)
     fprintf (file, "\n");
 
-#ifdef ENABLE_CHECKING
-  symtab_node::verify_symtab_nodes ();
-#endif
+  symtab_node::checking_verify_symtab_nodes ();
 
   /* If we removed something, perhaps profile could be improved.  */
   if (changed && optimize && inline_edge_summary_vec.exists ())
@@ -1370,13 +1369,12 @@ ipa_single_use (void)
     {
       if (var->aux != BOTTOM)
 	{
-#ifdef ENABLE_CHECKING
 	  /* Not having the single user known means that the VAR is
 	     unreachable.  Either someone forgot to remove unreachable
 	     variables or the reachability here is wrong.  */
 
-          gcc_assert (single_user_map.get (var));
-#endif
+	  gcc_checking_assert (single_user_map.get (var));
+
 	  if (dump_file)
 	    {
 	      fprintf (dump_file, "Variable %s/%i is used by single function\n",
diff --git a/gcc/ira-int.h b/gcc/ira-int.h
index af6c92f..d4160d3 100644
--- a/gcc/ira-int.h
+++ b/gcc/ira-int.h
@@ -26,7 +26,7 @@ along with GCC; see the file COPYING3.  If not see
 /* To provide consistency in naming, all IRA external variables,
    functions, common typedefs start with prefix ira_.  */
 
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
 #define ENABLE_IRA_CHECKING
 #endif
 
diff --git a/gcc/ira.c b/gcc/ira.c
index 28517c1..88c297e 100644
--- a/gcc/ira.c
+++ b/gcc/ira.c
@@ -5152,9 +5152,9 @@ ira (FILE *f)
     df_remove_problem (df_live);
   gcc_checking_assert (df_live == NULL);
 
-#ifdef ENABLE_CHECKING
-  df->changeable_flags |= DF_VERIFY_SCHEDULED;
-#endif
+  if (flag_checking)
+    df->changeable_flags |= DF_VERIFY_SCHEDULED;
+
   df_analyze ();
 
   init_reg_equiv ();
diff --git a/gcc/loop-doloop.c b/gcc/loop-doloop.c
index 6554597..592ae1f 100644
--- a/gcc/loop-doloop.c
+++ b/gcc/loop-doloop.c
@@ -734,7 +734,5 @@ doloop_optimize_loops (void)
 
   iv_analysis_done ();
 
-#ifdef ENABLE_CHECKING
-  verify_loop_structure ();
-#endif
+  checking_verify_loop_structure ();
 }
diff --git a/gcc/loop-init.c b/gcc/loop-init.c
index a9a3d6fa..9c545df 100644
--- a/gcc/loop-init.c
+++ b/gcc/loop-init.c
@@ -104,10 +104,8 @@ loop_optimizer_init (unsigned flags)
       /* Ensure that the dominators are computed, like flow_loops_find does.  */
       calculate_dominance_info (CDI_DOMINATORS);
 
-#ifdef ENABLE_CHECKING
       if (!needs_fixup)
-	verify_loop_structure ();
-#endif
+	checking_verify_loop_structure ();
 
       /* Clear all flags.  */
       if (recorded_exits)
@@ -129,9 +127,7 @@ loop_optimizer_init (unsigned flags)
   /* Dump loops.  */
   flow_loops_dump (dump_file, NULL, 1);
 
-#ifdef ENABLE_CHECKING
-  verify_loop_structure ();
-#endif
+  checking_verify_loop_structure ();
 
   timevar_pop (TV_LOOP_INIT);
 }
@@ -325,9 +321,7 @@ fix_loop_structure (bitmap changed_bbs)
   /* Apply flags to loops.  */
   apply_loop_flags (current_loops->state | record_exits);
 
-#ifdef ENABLE_CHECKING
-  verify_loop_structure ();
-#endif
+  checking_verify_loop_structure ();
 
   timevar_pop (TV_LOOP_INIT);
 
diff --git a/gcc/loop-invariant.c b/gcc/loop-invariant.c
index 52c8ae8..e7c6cb4 100644
--- a/gcc/loop-invariant.c
+++ b/gcc/loop-invariant.c
@@ -2096,7 +2096,5 @@ move_loop_invariants (void)
   invariant_table = NULL;
   invariant_table_size = 0;
 
-#ifdef ENABLE_CHECKING
-  verify_flow_info ();
-#endif
+  checking_verify_flow_info ();
 }
diff --git a/gcc/lra-assigns.c b/gcc/lra-assigns.c
index 2986f57..941a829 100644
--- a/gcc/lra-assigns.c
+++ b/gcc/lra-assigns.c
@@ -1591,7 +1591,7 @@ lra_assign (void)
   bitmap_initialize (&all_spilled_pseudos, &reg_obstack);
   create_live_range_start_chains ();
   setup_live_pseudos_and_spill_after_risky_transforms (&all_spilled_pseudos);
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
   if (!flag_ipa_ra)
     for (i = FIRST_PSEUDO_REGISTER; i < max_regno; i++)
       if (lra_reg_info[i].nrefs != 0 && reg_renumber[i] >= 0
diff --git a/gcc/lra-constraints.c b/gcc/lra-constraints.c
index 2c27f1a..c70b018 100644
--- a/gcc/lra-constraints.c
+++ b/gcc/lra-constraints.c
@@ -4454,8 +4454,7 @@ lra_constraints (bool first_p)
   bitmap_clear (&equiv_insn_bitmap);
   /* If we used a new hard regno, changed_p should be true because the
      hard reg is assigned to a new pseudo.  */
-#ifdef ENABLE_CHECKING
-  if (! changed_p)
+  if (flag_checking && !changed_p)
     {
       for (i = FIRST_PSEUDO_REGISTER; i < new_regno_start; i++)
 	if (lra_reg_info[i].nrefs != 0
@@ -4467,7 +4466,6 @@ lra_constraints (bool first_p)
 	      lra_assert (df_regs_ever_live_p (hard_regno + j));
 	  }
     }
-#endif
   return changed_p;
 }
 
diff --git a/gcc/lra-eliminations.c b/gcc/lra-eliminations.c
index fdf4179..448e645 100644
--- a/gcc/lra-eliminations.c
+++ b/gcc/lra-eliminations.c
@@ -1436,11 +1436,11 @@ lra_eliminate (bool final_p, bool first_p)
   bitmap_initialize (&insns_with_changed_offsets, &reg_obstack);
   if (final_p)
     {
-#ifdef ENABLE_CHECKING
-      update_reg_eliminate (&insns_with_changed_offsets);
-      if (! bitmap_empty_p (&insns_with_changed_offsets))
-	gcc_unreachable ();
-#endif
+      if (flag_checking)
+	{
+	  update_reg_eliminate (&insns_with_changed_offsets);
+	  gcc_assert (bitmap_empty_p (&insns_with_changed_offsets));
+	}
       /* We change eliminable hard registers in insns so we should do
 	 this for all insns containing any eliminable hard
 	 register.  */
diff --git a/gcc/lra-int.h b/gcc/lra-int.h
index 5e78604..570f210 100644
--- a/gcc/lra-int.h
+++ b/gcc/lra-int.h
@@ -91,7 +91,7 @@ struct lra_reg
   /* True if the pseudo should not be assigned to a stack register.  */
   bool no_stack_p;
 #endif
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
   /* True if the pseudo crosses a call.	 It is setup in lra-lives.c
      and used to check that the pseudo crossing a call did not get a
      call used hard register.  */
diff --git a/gcc/lra-lives.c b/gcc/lra-lives.c
index 253bc18..cf7bc2c 100644
--- a/gcc/lra-lives.c
+++ b/gcc/lra-lives.c
@@ -590,7 +590,7 @@ check_pseudos_live_through_calls (int regno)
   for (hr = 0; hr < FIRST_PSEUDO_REGISTER; hr++)
     if (HARD_REGNO_CALL_PART_CLOBBERED (hr, PSEUDO_REGNO_MODE (regno)))
       SET_HARD_REG_BIT (lra_reg_info[regno].conflict_hard_regs, hr);
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
   lra_reg_info[regno].call_p = true;
 #endif
   if (! sparseset_bit_p (pseudos_live_through_setjumps, regno))
@@ -1229,7 +1229,7 @@ lra_create_live_ranges_1 (bool all_p, bool dead_insn_p)
 	lra_reg_info[i].biggest_mode = GET_MODE (regno_reg_rtx[i]);
       else
 	lra_reg_info[i].biggest_mode = VOIDmode;
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
       lra_reg_info[i].call_p = false;
 #endif
       if (i >= FIRST_PSEUDO_REGISTER
diff --git a/gcc/lra-remat.c b/gcc/lra-remat.c
index 66532b8..68ce502 100644
--- a/gcc/lra-remat.c
+++ b/gcc/lra-remat.c
@@ -578,10 +578,8 @@ create_remat_bb_data (void)
 			   last_basic_block_for_fn (cfun));
   FOR_ALL_BB_FN (bb, cfun)
     {
-#ifdef ENABLE_CHECKING
-      if (bb->index < 0 || bb->index >= last_basic_block_for_fn (cfun))
-	abort ();
-#endif
+      gcc_checking_assert (bb->index >= 0
+			   && bb->index < last_basic_block_for_fn (cfun));
       bb_info = get_remat_bb_data (bb);
       bb_info->bb = bb;
       bitmap_initialize (&bb_info->changed_regs, &reg_obstack);
diff --git a/gcc/lra.c b/gcc/lra.c
index bdbfe51..cf08c27 100644
--- a/gcc/lra.c
+++ b/gcc/lra.c
@@ -1198,30 +1198,22 @@ lra_update_insn_recog_data (rtx_insn *insn)
 	  decode_asm_operands (PATTERN (insn), NULL,
 			       data->operand_loc,
 			       constraints, operand_mode, NULL);
-#ifdef ENABLE_CHECKING
-	  {
-	    int i;
 
-	    for (i = 0; i < nop; i++)
+	  if (flag_checking)
+	    for (int i = 0; i < nop; i++)
 	      lra_assert
 		(insn_static_data->operand[i].mode == operand_mode[i]
 		 && insn_static_data->operand[i].constraint == constraints[i]
 		 && ! insn_static_data->operand[i].is_operator);
-	  }
-#endif
 	}
-#ifdef ENABLE_CHECKING
-      {
-	int i;
 
-	for (i = 0; i < insn_static_data->n_operands; i++)
+      if (flag_checking)
+	for (int i = 0; i < insn_static_data->n_operands; i++)
 	  lra_assert
 	    (insn_static_data->operand[i].type
 	     == (insn_static_data->operand[i].constraint[0] == '=' ? OP_OUT
 		 : insn_static_data->operand[i].constraint[0] == '+' ? OP_INOUT
 		 : OP_IN));
-      }
-#endif
     }
   else
     {
@@ -2003,8 +1995,6 @@ restore_scratches (void)
 
 \f
 
-#ifdef ENABLE_CHECKING
-
 /* Function checks RTL for correctness.	 If FINAL_P is true, it is
    done at the end of LRA and the check is more rigorous.  */
 static void
@@ -2023,9 +2013,7 @@ check_rtl (bool final_p)
       {
 	if (final_p)
 	  {
-#ifdef ENABLED_CHECKING
 	    extract_constrain_insn (insn);
-#endif
 	    continue;
 	  }
 	/* LRA code is based on assumption that all addresses can be
@@ -2038,7 +2026,6 @@ check_rtl (bool final_p)
 	  fatal_insn_not_found (insn);
       }
 }
-#endif /* #ifdef ENABLE_CHECKING */
 
 /* Determine if the current function has an exception receiver block
    that reaches the exit block via non-exceptional edges  */
@@ -2232,10 +2219,9 @@ lra (FILE *f)
 
   init_insn_recog_data ();
 
-#ifdef ENABLE_CHECKING
   /* Some quick check on RTL generated by previous passes.  */
-  check_rtl (false);
-#endif
+  if (flag_checking)
+    check_rtl (/*final_p=*/false);
 
   lra_in_progress = 1;
 
@@ -2436,9 +2422,8 @@ lra (FILE *f)
      by this, so unshare everything here.  */
   unshare_all_rtl_again (get_insns ());
 
-#ifdef ENABLE_CHECKING
-  check_rtl (true);
-#endif
+  if (flag_checking)
+    check_rtl (/*final_p=*/true);
 
   timevar_pop (TV_LRA);
 }
diff --git a/gcc/lto-cgraph.c b/gcc/lto-cgraph.c
index 51f31c8..eb6f7b6 100644
--- a/gcc/lto-cgraph.c
+++ b/gcc/lto-cgraph.c
@@ -1560,10 +1560,11 @@ input_cgraph_1 (struct lto_file_decl_data *file_data,
   lto_input_toplevel_asms (file_data, order_base);
 
   /* AUX pointers should be all non-zero for function nodes read from the stream.  */
-#ifdef ENABLE_CHECKING
-  FOR_EACH_VEC_ELT (nodes, i, node)
-    gcc_assert (node->aux || !is_a <cgraph_node *> (node));
-#endif
+  if (flag_checking)
+    {
+      FOR_EACH_VEC_ELT (nodes, i, node)
+	gcc_assert (node->aux || !is_a <cgraph_node *> (node));
+    }
   FOR_EACH_VEC_ELT (nodes, i, node)
     {
       int ref;
diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c
index 11daf7a..8fc7e95 100644
--- a/gcc/lto-streamer-out.c
+++ b/gcc/lto-streamer-out.c
@@ -607,17 +607,12 @@ DFS::DFS (struct output_block *ob, tree expr, bool ref_p, bool this_ref_p,
 		std::swap (sccstack[first + i],
 			   sccstack[first + entry_start + i]);
 
-	      if (scc_entry_len == 1)
-		; /* We already sorted SCC deterministically in hash_scc.  */
-	      else
-		/* Check that we have only one SCC.
-		   Naturally we may have conflicts if hash function is not
- 		   strong enough.  Lets see how far this gets.  */
-		{
-#ifdef ENABLE_CHECKING
-		  gcc_unreachable ();
-#endif
-		}
+	      /* We already sorted SCC deterministically in hash_scc.  */
+
+	      /* Check that we have only one SCC.
+		 Naturally we may have conflicts if hash function is not
+		 strong enough.  Lets see how far this gets.  */
+	      gcc_checking_assert (scc_entry_len == 1);
 	    }
 
 	  /* Write LTO_tree_scc.  */
@@ -2277,7 +2272,7 @@ void
 lto_output (void)
 {
   struct lto_out_decl_state *decl_state;
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
   bitmap output = lto_bitmap_alloc ();
 #endif
   int i, n_nodes;
@@ -2296,7 +2291,7 @@ lto_output (void)
 	  if (lto_symtab_encoder_encode_body_p (encoder, node)
 	      && !node->alias)
 	    {
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
 	      gcc_assert (!bitmap_bit_p (output, DECL_UID (node->decl)));
 	      bitmap_set_bit (output, DECL_UID (node->decl));
 #endif
@@ -2326,7 +2321,7 @@ lto_output (void)
 	      && !node->alias)
 	    {
 	      timevar_push (TV_IPA_LTO_CTORS_OUT);
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
 	      gcc_assert (!bitmap_bit_p (output, DECL_UID (node->decl)));
 	      bitmap_set_bit (output, DECL_UID (node->decl));
 #endif
@@ -2353,7 +2348,7 @@ lto_output (void)
 
   output_offload_tables ();
 
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
   lto_bitmap_free (output);
 #endif
 }
diff --git a/gcc/lto-streamer.c b/gcc/lto-streamer.c
index b34ab8b..92b313a 100644
--- a/gcc/lto-streamer.c
+++ b/gcc/lto-streamer.c
@@ -297,13 +297,12 @@ static hash_table<tree_hash_entry> *tree_htab;
 void
 lto_streamer_init (void)
 {
-#ifdef ENABLE_CHECKING
   /* Check that all the TS_* handled by the reader and writer routines
      match exactly the structures defined in treestruct.def.  When a
      new TS_* astructure is added, the streamer should be updated to
      handle it.  */
-  streamer_check_handled_ts_structures ();
-#endif
+  if (flag_checking)
+    streamer_check_handled_ts_structures ();
 
 #ifdef LTO_STREAMER_DEBUG
   tree_htab = new hash_table<tree_hash_entry> (31);
diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c
index 76f8e07..4b917f8 100644
--- a/gcc/lto/lto.c
+++ b/gcc/lto/lto.c
@@ -1586,19 +1586,18 @@ unify_scc (struct data_in *data_in, unsigned from,
 	  num_sccs_merged++;
 	  total_scc_size_merged += len;
 
-#ifdef ENABLE_CHECKING
-	  for (unsigned i = 0; i < len; ++i)
-	    {
-	      tree t = map[2*i+1];
-	      enum tree_code code = TREE_CODE (t);
-	      /* IDENTIFIER_NODEs should be singletons and are merged by the
-		 streamer.  The others should be singletons, too, and we
-		 should not merge them in any way.  */
-	      gcc_assert (code != TRANSLATION_UNIT_DECL
-			  && code != IDENTIFIER_NODE
-			  && !streamer_handle_as_builtin_p (t));
-	    }
-#endif
+	  if (flag_checking)
+	    for (unsigned i = 0; i < len; ++i)
+	      {
+		tree t = map[2*i+1];
+		enum tree_code code = TREE_CODE (t);
+		/* IDENTIFIER_NODEs should be singletons and are merged by the
+		   streamer.  The others should be singletons, too, and we
+		   should not merge them in any way.  */
+		gcc_assert (code != TRANSLATION_UNIT_DECL
+			    && code != IDENTIFIER_NODE
+			    && !streamer_handle_as_builtin_p (t));
+	      }
 
 	  /* Fixup the streamer cache with the prevailing nodes according
 	     to the tree node mapping computed by compare_tree_sccs.  */
@@ -2636,10 +2635,8 @@ lto_fixup_state (struct lto_in_decl_state *state)
       for (i = 0; i < vec_safe_length (trees); i++)
 	{
 	  tree t = (*trees)[i];
-#ifdef ENABLE_CHECKING
-	  if (TYPE_P (t))
+	  if (CHECKING_P && TYPE_P (t))
 	    verify_type (t);
-#endif
 	  if (VAR_OR_FUNCTION_DECL_P (t)
 	      && (TREE_PUBLIC (t) || DECL_EXTERNAL (t)))
 	    (*trees)[i] = lto_symtab_prevailing_decl (t);
@@ -3101,9 +3098,8 @@ do_whole_program_analysis (void)
       fprintf (symtab->dump_file, "Optimized ");
       symtab_node::dump_table (symtab->dump_file);
     }
-#ifdef ENABLE_CHECKING
-  symtab_node::verify_symtab_nodes ();
-#endif
+
+  symtab_node::checking_verify_symtab_nodes ();
   bitmap_obstack_release (NULL);
 
   /* We are about to launch the final LTRANS phase, stop the WPA timer.  */
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index b444864..8b24699 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -3083,14 +3083,14 @@ scan_omp_target (gomp_target *stmt, omp_context *outer_ctx)
     {
       TYPE_FIELDS (ctx->record_type)
 	= nreverse (TYPE_FIELDS (ctx->record_type));
-#ifdef ENABLE_CHECKING
-      tree field;
-      unsigned int align = DECL_ALIGN (TYPE_FIELDS (ctx->record_type));
-      for (field = TYPE_FIELDS (ctx->record_type);
-	   field;
-	   field = DECL_CHAIN (field))
-	gcc_assert (DECL_ALIGN (field) == align);
-#endif
+      if (flag_checking)
+	{
+	  unsigned int align = DECL_ALIGN (TYPE_FIELDS (ctx->record_type));
+	  for (tree field = TYPE_FIELDS (ctx->record_type);
+	       field;
+	       field = DECL_CHAIN (field))
+	    gcc_assert (DECL_ALIGN (field) == align);
+	}
       layout_type (ctx->record_type);
       if (offloaded)
 	fixup_child_record_type (ctx);
@@ -6661,10 +6661,8 @@ expand_omp_taskreg (struct omp_region *region)
 	}
       if (gimple_in_ssa_p (cfun))
 	update_ssa (TODO_update_ssa);
-#ifdef ENABLE_CHECKING
-      if (!loops_state_satisfies_p (LOOPS_NEED_FIXUP))
+      if (flag_checking && !loops_state_satisfies_p (LOOPS_NEED_FIXUP))
 	verify_loop_structure ();
-#endif
       pop_cfun ();
     }
 
@@ -11481,10 +11479,8 @@ expand_omp_target (struct omp_region *region)
 	  if (changed)
 	    cleanup_tree_cfg ();
 	}
-#ifdef ENABLE_CHECKING
-      if (!loops_state_satisfies_p (LOOPS_NEED_FIXUP))
+      if (flag_checking && !loops_state_satisfies_p (LOOPS_NEED_FIXUP))
 	verify_loop_structure ();
-#endif
       pop_cfun ();
     }
 
@@ -12021,10 +12017,8 @@ execute_expand_omp (void)
 
   expand_omp (root_omp_region);
 
-#ifdef ENABLE_CHECKING
-  if (!loops_state_satisfies_p (LOOPS_NEED_FIXUP))
+  if (flag_checking && !loops_state_satisfies_p (LOOPS_NEED_FIXUP))
     verify_loop_structure ();
-#endif
   cleanup_tree_cfg ();
 
   free_omp_regions ();
@@ -14108,7 +14102,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx)
       default:
 	break;
       case OMP_CLAUSE_MAP:
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
 	/* First check what we're prepared to handle in the following.  */
 	switch (OMP_CLAUSE_MAP_KIND (c))
 	  {
diff --git a/gcc/passes.c b/gcc/passes.c
index 5b41102..010af1d 100644
--- a/gcc/passes.c
+++ b/gcc/passes.c
@@ -1955,9 +1955,8 @@ execute_function_todo (function *fn, void *data)
 
   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 (flag_checking && !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);
 
@@ -1991,7 +1990,6 @@ execute_function_todo (function *fn, void *data)
       /* 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;
@@ -2011,11 +2009,10 @@ execute_function_todo (function *fn, void *data)
 static void
 execute_todo (unsigned int flags)
 {
-#if defined ENABLE_CHECKING
-  if (cfun
+  if (flag_checking
+      && cfun
       && need_ssa_update_p (cfun))
     gcc_assert (flags & TODO_update_ssa_any);
-#endif
 
   timevar_push (TV_TODO);
 
@@ -2074,14 +2071,12 @@ clear_last_verified (function *fn, void *data ATTRIBUTE_UNUSED)
 /* Helper function. Verify that the properties has been turn into the
    properties expected by the pass.  */
 
-#ifdef ENABLE_CHECKING
-static void
+static void DEBUG_FUNCTION
 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.  */
@@ -2329,10 +2324,9 @@ execute_one_pass (opt_pass *pass)
   /* 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 (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)
diff --git a/gcc/predict.c b/gcc/predict.c
index 0b3016c..0fe2eb5 100644
--- a/gcc/predict.c
+++ b/gcc/predict.c
@@ -2205,8 +2205,6 @@ tree_bb_level_predictions (void)
     }
 }
 
-#ifdef ENABLE_CHECKING
-
 /* Callback for hash_map::traverse, asserts that the pointer map is
    empty.  */
 
@@ -2217,7 +2215,6 @@ assert_is_empty (const_basic_block const &, edge_prediction *const &value,
   gcc_assert (!value);
   return false;
 }
-#endif
 
 /* Predict branch probabilities and estimate profile for basic block BB.  */
 
@@ -2352,9 +2349,9 @@ tree_estimate_probability (void)
   FOR_EACH_BB_FN (bb, cfun)
     combine_predictions_for_bb (bb);
 
-#ifdef ENABLE_CHECKING
-  bb_predictions->traverse<void *, assert_is_empty> (NULL);
-#endif
+  if (flag_checking)
+    bb_predictions->traverse<void *, assert_is_empty> (NULL);
+
   delete bb_predictions;
   bb_predictions = NULL;
 
@@ -2545,11 +2542,12 @@ propagate_freq (basic_block head, bitmap tovisit)
       /* Compute frequency of basic block.  */
       if (bb != head)
 	{
-#ifdef ENABLE_CHECKING
-	  FOR_EACH_EDGE (e, ei, bb->preds)
-	    gcc_assert (!bitmap_bit_p (tovisit, e->src->index)
-			|| (e->flags & EDGE_DFS_BACK));
-#endif
+	  if (flag_checking)
+	    {
+	      FOR_EACH_EDGE (e, ei, bb->preds)
+		gcc_assert (!bitmap_bit_p (tovisit, e->src->index)
+			    || (e->flags & EDGE_DFS_BACK));
+	    }
 
 	  FOR_EACH_EDGE (e, ei, bb->preds)
 	    if (EDGE_INFO (e)->back_edge)
diff --git a/gcc/pretty-print.c b/gcc/pretty-print.c
index 5889015..8cfcee3 100644
--- a/gcc/pretty-print.c
+++ b/gcc/pretty-print.c
@@ -625,10 +625,11 @@ pp_format (pretty_printer *pp, text_info *text)
       *formatters[argno] = XOBFINISH (&buffer->chunk_obstack, const char *);
     }
 
-#ifdef ENABLE_CHECKING
-  for (; argno < PP_NL_ARGMAX; argno++)
-    gcc_assert (!formatters[argno]);
-#endif
+  if (CHECKING_P)
+    {
+      for (; argno < PP_NL_ARGMAX; argno++)
+	gcc_assert (!formatters[argno]);
+    }
 
   /* Revert to normal obstack and wrapping mode.  */
   buffer->obstack = &buffer->formatted_obstack;
diff --git a/gcc/real.c b/gcc/real.c
index 85ac83d..1b0885f 100644
--- a/gcc/real.c
+++ b/gcc/real.c
@@ -1808,15 +1808,13 @@ real_to_decimal_for_mode (char *str, const REAL_VALUE_TYPE *r_orig,
   /* Append the exponent.  */
   sprintf (last, "e%+d", dec_exp);
 
-#ifdef ENABLE_CHECKING
   /* Verify that we can read the original value back in.  */
-  if (mode != VOIDmode)
+  if (CHECKING_P && mode != VOIDmode)
     {
       real_from_string (&r, str);
       real_convert (&r, mode, &r);
       gcc_assert (real_identical (&r, r_orig));
     }
-#endif
 }
 
 /* Likewise, except always uses round-to-nearest.  */
diff --git a/gcc/recog.c b/gcc/recog.c
index c032424..2cd06f5 100644
--- a/gcc/recog.c
+++ b/gcc/recog.c
@@ -2975,9 +2975,7 @@ split_all_insns (void)
   if (changed)
     find_many_sub_basic_blocks (blocks);
 
-#ifdef ENABLE_CHECKING
-  verify_flow_info ();
-#endif
+  checking_verify_flow_info ();
 
   sbitmap_free (blocks);
 }
diff --git a/gcc/regcprop.c b/gcc/regcprop.c
index 6f7d01e..b0dc61b 100644
--- a/gcc/regcprop.c
+++ b/gcc/regcprop.c
@@ -100,9 +100,8 @@ static bool replace_oldest_value_addr (rtx *, enum reg_class,
 static bool replace_oldest_value_mem (rtx, rtx_insn *, struct value_data *);
 static bool copyprop_hardreg_forward_1 (basic_block, struct value_data *);
 extern void debug_value_data (struct value_data *);
-#ifdef ENABLE_CHECKING
+
 static void validate_value_data (struct value_data *);
-#endif
 
 /* Free all queued updates for DEBUG_INSNs that change some reg to
    register REGNO.  */
@@ -150,9 +149,7 @@ kill_value_one_regno (unsigned int regno, struct value_data *vd)
   if (vd->e[regno].debug_insn_changes)
     free_debug_insn_changes (vd, regno);
 
-#ifdef ENABLE_CHECKING
   validate_value_data (vd);
-#endif
 }
 
 /* Kill the value in register REGNO for NREGS, and any other registers
@@ -365,9 +362,7 @@ copy_value (rtx dest, rtx src, struct value_data *vd)
     continue;
   vd->e[i].next_regno = dr;
 
-#ifdef ENABLE_CHECKING
   validate_value_data (vd);
-#endif
 }
 
 /* Return true if a mode change from ORIG to NEW is allowed for REGNO.  */
@@ -1141,10 +1136,12 @@ copyprop_hardreg_forward_bb_without_debug_insn (basic_block bb)
   skip_debug_insn_p = false;
 }
 
-#ifdef ENABLE_CHECKING
 static void
 validate_value_data (struct value_data *vd)
 {
+  if (!flag_checking)
+    return;
+
   HARD_REG_SET set;
   unsigned int i, j;
 
@@ -1187,7 +1184,7 @@ validate_value_data (struct value_data *vd)
 		      i, GET_MODE_NAME (vd->e[i].mode), vd->e[i].oldest_regno,
 		      vd->e[i].next_regno);
 }
-#endif
+
 \f
 namespace {
 
diff --git a/gcc/reload.c b/gcc/reload.c
index cc61d77..32eec02 100644
--- a/gcc/reload.c
+++ b/gcc/reload.c
@@ -85,7 +85,7 @@ a register with any other reload.  */
 
 #define REG_OK_STRICT
 
-/* We do not enable this with ENABLE_CHECKING, since it is awfully slow.  */
+/* We do not enable this with CHECKING_P, since it is awfully slow.  */
 #undef DEBUG_RELOAD
 
 #include "config.h"
diff --git a/gcc/sched-deps.c b/gcc/sched-deps.c
index 9683055..27dd357 100644
--- a/gcc/sched-deps.c
+++ b/gcc/sched-deps.c
@@ -47,12 +47,6 @@ along with GCC; see the file COPYING3.  If not see
 
 #ifdef INSN_SCHEDULING
 
-#ifdef ENABLE_CHECKING
-#define CHECK (true)
-#else
-#define CHECK (false)
-#endif
-
 /* Holds current parameters for the dependency analyzer.  */
 struct sched_deps_info_def *sched_deps_info;
 
@@ -505,9 +499,7 @@ static enum DEPS_ADJUST_RESULT maybe_add_or_update_dep_1 (dep_t, bool,
 							  rtx, rtx);
 static enum DEPS_ADJUST_RESULT add_or_update_dep_1 (dep_t, bool, rtx, rtx);
 
-#ifdef ENABLE_CHECKING
 static void check_dep (dep_t, bool);
-#endif
 \f
 /* Return nonzero if a load of the memory reference MEM can cause a trap.  */
 
@@ -1228,9 +1220,8 @@ add_or_update_dep_1 (dep_t new_dep, bool resolved_p,
   gcc_assert (INSN_P (DEP_PRO (new_dep)) && INSN_P (DEP_CON (new_dep))
 	      && DEP_PRO (new_dep) != DEP_CON (new_dep));
 
-#ifdef ENABLE_CHECKING
-  check_dep (new_dep, mem1 != NULL);
-#endif
+  if (flag_checking)
+    check_dep (new_dep, mem1 != NULL);
 
   if (true_dependency_cache != NULL)
     {
@@ -1348,9 +1339,8 @@ sd_add_dep (dep_t dep, bool resolved_p)
 
   add_to_deps_list (DEP_NODE_BACK (n), con_back_deps);
 
-#ifdef ENABLE_CHECKING
-  check_dep (dep, false);
-#endif
+  if (flag_checking)
+    check_dep (dep, false);
 
   add_to_deps_list (DEP_NODE_FORW (n), pro_forw_deps);
 
@@ -4515,7 +4505,6 @@ debug_ds (ds_t s)
   fprintf (stderr, "\n");
 }
 
-#ifdef ENABLE_CHECKING
 /* Verify that dependence type and status are consistent.
    If RELAXED_P is true, then skip dep_weakness checks.  */
 static void
@@ -4600,7 +4589,6 @@ check_dep (dep_t dep, bool relaxed_p)
 	gcc_assert (ds & BEGIN_CONTROL);
     }
 }
-#endif /* ENABLE_CHECKING */
 
 /* The following code discovers opportunities to switch a memory reference
    and an increment by modifying the address.  We ensure that this is done
diff --git a/gcc/sel-sched-ir.c b/gcc/sel-sched-ir.c
index 8ea4dce..8000178 100644
--- a/gcc/sel-sched-ir.c
+++ b/gcc/sel-sched-ir.c
@@ -954,7 +954,6 @@ return_regset_to_pool (regset rs)
   regset_pool.v[regset_pool.n++] = rs;
 }
 
-#ifdef ENABLE_CHECKING
 /* This is used as a qsort callback for sorting regset pool stacks.
    X and XX are addresses of two regsets.  They are never equal.  */
 static int
@@ -968,44 +967,42 @@ cmp_v_in_regset_pool (const void *x, const void *xx)
     return -1;
   gcc_unreachable ();
 }
-#endif
 
-/*  Free the regset pool possibly checking for memory leaks.  */
+/* Free the regset pool possibly checking for memory leaks.  */
 void
-free_regset_pool (void)
+free_regset_pool ()
 {
-#ifdef ENABLE_CHECKING
-  {
-    regset *v = regset_pool.v;
-    int i = 0;
-    int n = regset_pool.n;
+  if (flag_checking)
+    {
+      regset *v = regset_pool.v;
+      int i = 0;
+      int n = regset_pool.n;
 
-    regset *vv = regset_pool.vv;
-    int ii = 0;
-    int nn = regset_pool.nn;
+      regset *vv = regset_pool.vv;
+      int ii = 0;
+      int nn = regset_pool.nn;
 
-    int diff = 0;
+      int diff = 0;
 
-    gcc_assert (n <= nn);
+      gcc_assert (n <= nn);
 
-    /* Sort both vectors so it will be possible to compare them.  */
-    qsort (v, n, sizeof (*v), cmp_v_in_regset_pool);
-    qsort (vv, nn, sizeof (*vv), cmp_v_in_regset_pool);
+      /* Sort both vectors so it will be possible to compare them.  */
+      qsort (v, n, sizeof (*v), cmp_v_in_regset_pool);
+      qsort (vv, nn, sizeof (*vv), cmp_v_in_regset_pool);
 
-    while (ii < nn)
-      {
-        if (v[i] == vv[ii])
-          i++;
-        else
-          /* VV[II] was lost.  */
-          diff++;
+      while (ii < nn)
+	{
+	  if (v[i] == vv[ii])
+	    i++;
+	  else
+	    /* VV[II] was lost.  */
+	    diff++;
 
-        ii++;
-      }
+	  ii++;
+	}
 
-    gcc_assert (diff == regset_pool.diff);
-  }
-#endif
+      gcc_assert (diff == regset_pool.diff);
+    }
 
   /* If not true - we have a memory leak.  */
   gcc_assert (regset_pool.diff == 0);
@@ -3623,7 +3620,6 @@ insn_is_the_only_one_in_bb_p (insn_t insn)
   return sel_bb_head_p (insn) && sel_bb_end_p (insn);
 }
 
-#ifdef ENABLE_CHECKING
 /* Check that the region we're scheduling still has at most one
    backedge.  */
 static void
@@ -3644,9 +3640,8 @@ verify_backedges (void)
       gcc_assert (n <= 1);
     }
 }
-#endif
-\f
 
+\f
 /* Functions to work with control flow.  */
 
 /* Recompute BLOCK_TO_BB and BB_FOR_BLOCK for current region so that blocks
@@ -3889,10 +3884,12 @@ tidy_control_flow (basic_block xbb, bool full_tidying)
 	sel_recompute_toporder ();
     }
 
-#ifdef ENABLE_CHECKING
-  verify_backedges ();
-  verify_dominators (CDI_DOMINATORS);
-#endif
+  /* TODO: use separate flag for CFG checking.  */
+  if (flag_checking)
+    {
+      verify_backedges ();
+      verify_dominators (CDI_DOMINATORS);
+    }
 
   return changed;
 }
diff --git a/gcc/sel-sched.c b/gcc/sel-sched.c
index 721013f..fcf9ba8 100644
--- a/gcc/sel-sched.c
+++ b/gcc/sel-sched.c
@@ -378,7 +378,7 @@ struct moveop_static_params
      they are to be removed.  */
   int uid;
 
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
   /* This is initialized to the insn on which the driver stopped its traversal.  */
   insn_t failed_insn;
 #endif
@@ -1655,7 +1655,7 @@ find_best_reg_for_expr (expr_t expr, blist_t bnds, bool *is_orig_reg_p)
   collect_unavailable_regs_from_bnds (expr, bnds, used_regs, &reg_rename_data,
 				      &original_insns);
 
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
   /* If after reload, make sure we're working with hard regs here.  */
   if (reload_completed)
     {
@@ -3593,7 +3593,7 @@ vinsn_vec_has_expr_p (vinsn_vec_t vinsn_vec, expr_t expr)
   return false;
 }
 
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
 /* Return true if either of expressions from ORIG_OPS can be blocked
    by previously created bookkeeping code.  STATIC_PARAMS points to static
    parameters of move_op.  */
@@ -4889,11 +4889,10 @@ move_cond_jump (rtx_insn *insn, bnd_t bnd)
   block_bnd = BLOCK_FOR_INSN (BND_TO (bnd));
   prev = BND_TO (bnd);
 
-#ifdef ENABLE_CHECKING
   /* Moving of jump should not cross any other jumps or beginnings of new
      basic blocks.  The only exception is when we move a jump through
      mutually exclusive insns along fallthru edges.  */
-  if (block_from != block_bnd)
+  if (CHECKING_P && block_from != block_bnd)
     {
       bb = block_from;
       for (link = PREV_INSN (insn); link != PREV_INSN (prev);
@@ -4908,7 +4907,6 @@ move_cond_jump (rtx_insn *insn, bnd_t bnd)
             }
         }
     }
-#endif
 
   /* Jump is moved to the boundary.  */
   next = PREV_INSN (insn);
@@ -6205,7 +6203,7 @@ move_op_orig_expr_not_found (insn_t insn, av_set_t orig_ops ATTRIBUTE_UNUSED,
 {
   moveop_static_params_p sparams = (moveop_static_params_p) static_params;
 
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
   sparams->failed_insn = insn;
 #endif
 
@@ -6380,7 +6378,6 @@ code_motion_process_successors (insn_t insn, av_set_t orig_ops,
         }
     }
 
-#ifdef ENABLE_CHECKING
   /* Here, RES==1 if original expr was found at least for one of the
      successors.  After the loop, RES may happen to have zero value
      only if at some point the expr searched is present in av_set, but is
@@ -6388,6 +6385,7 @@ code_motion_process_successors (insn_t insn, av_set_t orig_ops,
      The exception is when the original operation is blocked by
      bookkeeping generated for another fence or for another path in current
      move_op.  */
+#if CHECKING_P
   gcc_assert (res == 1
 	      || (res == 0
 		  && av_set_could_be_blocked_by_bookkeeping_p (orig_ops,
@@ -6695,7 +6693,7 @@ move_op (insn_t insn, av_set_t orig_ops, expr_t expr_vliw,
   sparams.dest = dest;
   sparams.c_expr = c_expr;
   sparams.uid = INSN_UID (EXPR_INSN_RTX (expr_vliw));
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
   sparams.failed_insn = NULL;
 #endif
   sparams.was_renamed = false;
diff --git a/gcc/sese.h b/gcc/sese.h
index d429d58..8446db8 100644
--- a/gcc/sese.h
+++ b/gcc/sese.h
@@ -119,16 +119,20 @@ sese_nb_params (sese_info_p region)
 static inline bool
 bb_in_region (basic_block bb, basic_block entry, basic_block exit)
 {
-#ifdef ENABLE_CHECKING
-  {
-    edge e;
-    edge_iterator ei;
+/* FIXME: (PR 67842) this check is incorrect.  dominated_by_p has no effect,
+   but changing it to gcc_assert (dominated_by_p (...)) causes regressions,
+   e.g., gcc.dg/graphite/block-1.c.  */
+#if 0
+  if (flag_checking)
+    {
+      edge e;
+      edge_iterator ei;
 
-    /* Check that there are no edges coming in the region: all the
-       predecessors of EXIT are dominated by ENTRY.  */
-    FOR_EACH_EDGE (e, ei, exit->preds)
-      dominated_by_p (CDI_DOMINATORS, e->src, entry);
-  }
+      /* Check that there are no edges coming in the region: all the
+	 predecessors of EXIT are dominated by ENTRY.  */
+      FOR_EACH_EDGE (e, ei, exit->preds)
+	dominated_by_p (CDI_DOMINATORS, e->src, entry);
+    }
 #endif
 
   return dominated_by_p (CDI_DOMINATORS, bb, entry)
diff --git a/gcc/ssa-iterators.h b/gcc/ssa-iterators.h
index e04b630..1bf93bd 100644
--- a/gcc/ssa-iterators.h
+++ b/gcc/ssa-iterators.h
@@ -344,9 +344,8 @@ first_readonly_imm_use (imm_use_iterator *imm, tree var)
 {
   imm->end_p = &(SSA_NAME_IMM_USE_NODE (var));
   imm->imm_use = imm->end_p->next;
-#ifdef ENABLE_CHECKING
-  imm->iter_node.next = imm->imm_use->next;
-#endif
+  if (CHECKING_P)
+    imm->iter_node.next = imm->imm_use->next;
   if (end_readonly_imm_use_p (imm))
     return NULL_USE_OPERAND_P;
   return imm->imm_use;
@@ -358,14 +357,15 @@ next_readonly_imm_use (imm_use_iterator *imm)
 {
   use_operand_p old = imm->imm_use;
 
-#ifdef ENABLE_CHECKING
   /* If this assertion fails, it indicates the 'next' pointer has changed
      since the last bump.  This indicates that the list is being modified
      via stmt changes, or SET_USE, or somesuch thing, and you need to be
      using the SAFE version of the iterator.  */
-  gcc_assert (imm->iter_node.next == old->next);
-  imm->iter_node.next = old->next->next;
-#endif
+  if (CHECKING_P)
+    {
+      gcc_assert (imm->iter_node.next == old->next);
+      imm->iter_node.next = old->next->next;
+    }
 
   imm->imm_use = old->next;
   if (end_readonly_imm_use_p (imm))
diff --git a/gcc/store-motion.c b/gcc/store-motion.c
index ec3faa2..ed1a399 100644
--- a/gcc/store-motion.c
+++ b/gcc/store-motion.c
@@ -644,9 +644,6 @@ compute_store_table (void)
 {
   int ret;
   basic_block bb;
-#ifdef ENABLE_CHECKING
-  unsigned regno;
-#endif
   rtx_insn *insn;
   rtx_insn *tmp;
   df_ref def;
@@ -692,11 +689,12 @@ compute_store_table (void)
 	      last_set_in[DF_REF_REGNO (def)] = 0;
 	}
 
-#ifdef ENABLE_CHECKING
-      /* last_set_in should now be all-zero.  */
-      for (regno = 0; regno < max_gcse_regno; regno++)
-	gcc_assert (!last_set_in[regno]);
-#endif
+      if (flag_checking)
+	{
+	  /* last_set_in should now be all-zero.  */
+	  for (unsigned regno = 0; regno < max_gcse_regno; regno++)
+	    gcc_assert (!last_set_in[regno]);
+	}
 
       /* Clear temporary marks.  */
       for (ptr = first_st_expr (); ptr != NULL; ptr = next_st_expr (ptr))
diff --git a/gcc/symbol-summary.h b/gcc/symbol-summary.h
index eefbfd9..4a1a510 100644
--- a/gcc/symbol-summary.h
+++ b/gcc/symbol-summary.h
@@ -39,14 +39,12 @@ public:
   function_summary (symbol_table *symtab, bool ggc = false): m_ggc (ggc),
     m_map (13, ggc), m_insertion_enabled (true), m_symtab (symtab)
   {
-#ifdef ENABLE_CHECKING
-    cgraph_node *node;
-
-    FOR_EACH_FUNCTION (node)
-    {
-      gcc_checking_assert (node->summary_uid > 0);
-    }
-#endif
+    if (flag_checking)
+      {
+	cgraph_node *node;
+	FOR_EACH_FUNCTION (node)
+	  gcc_assert (node->summary_uid > 0);
+      }
 
     m_symtab_insertion_hook =
       symtab->add_cgraph_insertion_hook
diff --git a/gcc/symtab.c b/gcc/symtab.c
index c33aa01..5a9ff54 100644
--- a/gcc/symtab.c
+++ b/gcc/symtab.c
@@ -1093,8 +1093,8 @@ symtab_node::verify (void)
 
 /* Verify symbol table for internal consistency.  */
 
-DEBUG_FUNCTION void
-symtab_node::verify_symtab_nodes (void)
+void
+symtab_node::verify_symtab_nodes ()
 {
   symtab_node *node;
   hash_map<tree, symtab_node *> comdat_head_map (251);
diff --git a/gcc/target.h b/gcc/target.h
index a79f424..ffc4d6a 100644
--- a/gcc/target.h
+++ b/gcc/target.h
@@ -52,21 +52,21 @@
 #include "tm.h"
 #include "hard-reg-set.h"
 
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
 
 struct cumulative_args_t { void *magic; void *p; };
 
-#else /* !ENABLE_CHECKING */
+#else /* !CHECKING_P */
 
 /* When using a GCC build compiler, we could use
    __attribute__((transparent_union)) to get cumulative_args_t function
    arguments passed like scalars where the ABI would mandate a less
    efficient way of argument passing otherwise.  However, that would come
-   at the cost of less type-safe !ENABLE_CHECKING compilation.  */
+   at the cost of less type-safe !CHECKING_P compilation.  */
 
 union cumulative_args_t { void *p; };
 
-#endif /* !ENABLE_CHECKING */
+#endif /* !CHECKING_P */
 
 /* Types used by the record_gcc_switches() target function.  */
 enum print_switch_type
@@ -200,9 +200,9 @@ extern struct gcc_target targetm;
 static inline CUMULATIVE_ARGS *
 get_cumulative_args (cumulative_args_t arg)
 {
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
   gcc_assert (arg.magic == CUMULATIVE_ARGS_MAGIC);
-#endif /* ENABLE_CHECKING */
+#endif /* CHECKING_P */
   return (CUMULATIVE_ARGS *) arg.p;
 }
 
@@ -211,9 +211,9 @@ pack_cumulative_args (CUMULATIVE_ARGS *arg)
 {
   cumulative_args_t ret;
 
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
   ret.magic = CUMULATIVE_ARGS_MAGIC;
-#endif /* ENABLE_CHECKING */
+#endif /* CHECKING_P */
   ret.p = (void *) arg;
   return ret;
 }
diff --git a/gcc/timevar.c b/gcc/timevar.c
index 8249727..02b8113 100644
--- a/gcc/timevar.c
+++ b/gcc/timevar.c
@@ -727,10 +727,13 @@ timer::print (FILE *fp)
 #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
+  if (CHECKING_P)
+    {
+      fprintf (fp, "Extra diagnostic checks enabled; "
+		   "compiler may run slowly.\n");
+      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");
diff --git a/gcc/trans-mem.c b/gcc/trans-mem.c
index 488c20e..d0b54ef 100644
--- a/gcc/trans-mem.c
+++ b/gcc/trans-mem.c
@@ -5341,9 +5341,7 @@ ipa_tm_execute (void)
   enum availability a;
   unsigned int i;
 
-#ifdef ENABLE_CHECKING
-  cgraph_node::verify_cgraph_nodes ();
-#endif
+  cgraph_node::checking_verify_cgraph_nodes ();
 
   bitmap_obstack_initialize (&tm_obstack);
   initialize_original_copy_tables ();
@@ -5589,9 +5587,7 @@ ipa_tm_execute (void)
   FOR_EACH_FUNCTION (node)
     node->aux = NULL;
 
-#ifdef ENABLE_CHECKING
-  cgraph_node::verify_cgraph_nodes ();
-#endif
+  cgraph_node::checking_verify_cgraph_nodes ();
 
   return 0;
 }
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 735ac46..ac4ccf3 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -6472,14 +6472,12 @@ move_stmt_op (tree *tp, int *walk_subtrees, void *data)
 	  || (p->orig_block == NULL_TREE
 	      && block != NULL_TREE))
 	TREE_SET_BLOCK (t, p->new_block);
-#ifdef ENABLE_CHECKING
-      else if (block != NULL_TREE)
+      else if (flag_checking && block != NULL_TREE)
 	{
 	  while (block && TREE_CODE (block) == BLOCK && block != p->orig_block)
 	    block = BLOCK_SUPERCONTEXT (block);
 	  gcc_assert (block == p->orig_block);
 	}
-#endif
     }
   else if (DECL_P (t) || TREE_CODE (t) == SSA_NAME)
     {
@@ -6947,7 +6945,7 @@ fixup_loop_arrays_after_move (struct function *fn1, struct function *fn2,
 /* Verify that the blocks in BBS_P are a single-entry, single-exit region
    delimited by ENTRY_BB and EXIT_BB, possibly containing noreturn blocks.  */
 
-DEBUG_FUNCTION void
+void
 verify_sese (basic_block entry, basic_block exit, vec<basic_block> *bbs_p)
 {
   basic_block bb;
@@ -7064,9 +7062,9 @@ move_sese_region_to_fn (struct function *dest_cfun, basic_block entry_bb,
   bbs.create (0);
   bbs.safe_push (entry_bb);
   gather_blocks_in_sese_region (entry_bb, exit_bb, &bbs);
-#ifdef ENABLE_CHECKING
-  verify_sese (entry_bb, exit_bb, &bbs);
-#endif
+
+  if (flag_checking)
+    verify_sese (entry_bb, exit_bb, &bbs);
 
   /* The blocks that used to be dominated by something in BBS will now be
      dominated by the new block.  */
@@ -7908,13 +7906,11 @@ gimple_flow_call_edges_add (sbitmap blocks)
 		     no edge to the exit block in CFG already.
 		     Calling make_edge in such case would cause us to
 		     mark that edge as fake and remove it later.  */
-#ifdef ENABLE_CHECKING
-		  if (stmt == last_stmt)
+		  if (flag_checking && stmt == last_stmt)
 		    {
 		      e = find_edge (bb, EXIT_BLOCK_PTR_FOR_FN (cfun));
 		      gcc_assert (e == NULL);
 		    }
-#endif
 
 		  /* Note that the following may create a new basic block
 		     and renumber the existing basic blocks.  */
diff --git a/gcc/tree-cfgcleanup.c b/gcc/tree-cfgcleanup.c
index eeedd8a..aba8848 100644
--- a/gcc/tree-cfgcleanup.c
+++ b/gcc/tree-cfgcleanup.c
@@ -729,9 +729,7 @@ cleanup_tree_cfg_noloop (void)
     }
   else
     {
-#ifdef ENABLE_CHECKING
-      verify_dominators (CDI_DOMINATORS);
-#endif
+      checking_verify_dominators (CDI_DOMINATORS);
       changed = false;
     }
 
@@ -740,9 +738,7 @@ cleanup_tree_cfg_noloop (void)
   gcc_assert (dom_info_available_p (CDI_DOMINATORS));
   compact_blocks ();
 
-#ifdef ENABLE_CHECKING
-  verify_flow_info ();
-#endif
+  checking_verify_flow_info ();
 
   timevar_pop (TV_TREE_CLEANUP_CFG);
 
@@ -777,9 +773,7 @@ repair_loop_structures (void)
 
   BITMAP_FREE (changed_bbs);
 
-#ifdef ENABLE_CHECKING
-  verify_loop_structure ();
-#endif
+  checking_verify_loop_structure ();
   scev_reset ();
 
   timevar_pop (TV_REPAIR_LOOPS);
diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c
index cb1f08a..f6c2d06 100644
--- a/gcc/tree-eh.c
+++ b/gcc/tree-eh.c
@@ -703,7 +703,7 @@ maybe_record_in_goto_queue (struct leh_state *state, gimple *stmt)
 }
 
 
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
 /* We do not process GIMPLE_SWITCHes for now.  As long as the original source
    was in fact structured, and we've not yet done jump threading, then none
    of the labels will leave outer GIMPLE_TRY_FINALLY nodes. Verify this.  */
@@ -3921,9 +3921,8 @@ remove_unreachable_handlers (void)
   sbitmap_free (r_reachable);
   sbitmap_free (lp_reachable);
 
-#ifdef ENABLE_CHECKING
-  verify_eh_tree (cfun);
-#endif
+  if (flag_checking)
+    verify_eh_tree (cfun);
 }
 
 /* Remove unreachable handlers if any landing pads have been removed after
diff --git a/gcc/tree-if-conv.c b/gcc/tree-if-conv.c
index f201ab5..ae79f0e 100644
--- a/gcc/tree-if-conv.c
+++ b/gcc/tree-if-conv.c
@@ -2787,13 +2787,12 @@ pass_if_conversion::execute (function *fun)
 	    && !loop->dont_vectorize))
       todo |= tree_if_conversion (loop);
 
-#ifdef ENABLE_CHECKING
-  {
-    basic_block bb;
-    FOR_EACH_BB_FN (bb, fun)
-      gcc_assert (!bb->aux);
-  }
-#endif
+  if (flag_checking)
+    {
+      basic_block bb;
+      FOR_EACH_BB_FN (bb, fun)
+	gcc_assert (!bb->aux);
+    }
 
   return todo;
 }
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index b8269ef..00c0c84 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -4481,10 +4481,8 @@ expand_call_inline (basic_block bb, gimple *stmt, copy_body_data *id)
   fn = cg_edge->callee->decl;
   cg_edge->callee->get_untransformed_body ();
 
-#ifdef ENABLE_CHECKING
-  if (cg_edge->callee->decl != id->dst_node->decl)
+  if (flag_checking && cg_edge->callee->decl != id->dst_node->decl)
     cg_edge->callee->verify ();
-#endif
 
   /* We will be inlining this callee.  */
   id->eh_lp_nr = lookup_stmt_eh_lp (stmt);
@@ -4973,7 +4971,7 @@ optimize_inline_calls (tree fn)
 
   pop_gimplify_context (NULL);
 
-#ifdef ENABLE_CHECKING
+  if (flag_checking)
     {
       struct cgraph_edge *e;
 
@@ -4983,7 +4981,6 @@ optimize_inline_calls (tree fn)
       for (e = id.dst_node->callees; e; e = e->next_callee)
 	gcc_assert (e->inline_failed);
     }
-#endif
 
   /* Fold queued statements.  */
   fold_marked_statements (last, id.statements_to_fold);
@@ -4999,9 +4996,8 @@ optimize_inline_calls (tree fn)
   number_blocks (fn);
 
   delete_unreachable_blocks_update_callgraph (&id);
-#ifdef ENABLE_CHECKING
-  id.dst_node->verify ();
-#endif
+  if (flag_checking)
+    id.dst_node->verify ();
 
   /* It would be nice to check SSA/CFG/statement consistency here, but it is
      not possible yet - the IPA passes might make various functions to not
diff --git a/gcc/tree-into-ssa.c b/gcc/tree-into-ssa.c
index 9fd698d..732a571 100644
--- a/gcc/tree-into-ssa.c
+++ b/gcc/tree-into-ssa.c
@@ -3169,44 +3169,45 @@ update_ssa (unsigned update_flags)
   if (!need_ssa_update_p (cfun))
     return;
 
-#ifdef ENABLE_CHECKING
-  timevar_push (TV_TREE_STMT_VERIFY);
+  if (flag_checking)
+    {
+      timevar_push (TV_TREE_STMT_VERIFY);
 
-  bool err = false;
+      bool err = false;
 
-  FOR_EACH_BB_FN (bb, cfun)
-    {
-      gimple_stmt_iterator gsi;
-      for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+      FOR_EACH_BB_FN (bb, cfun)
 	{
-	  gimple *stmt = gsi_stmt (gsi);
-
-	  ssa_op_iter i;
-	  use_operand_p use_p;
-	  FOR_EACH_SSA_USE_OPERAND (use_p, stmt, i, SSA_OP_ALL_USES)
+	  gimple_stmt_iterator gsi;
+	  for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
 	    {
-	      tree use = USE_FROM_PTR (use_p);
-	      if (TREE_CODE (use) != SSA_NAME)
-		continue;
+	      gimple *stmt = gsi_stmt (gsi);
 
-	      if (SSA_NAME_IN_FREE_LIST (use))
+	      ssa_op_iter i;
+	      use_operand_p use_p;
+	      FOR_EACH_SSA_USE_OPERAND (use_p, stmt, i, SSA_OP_ALL_USES)
 		{
-		  error ("statement uses released SSA name:");
-		  debug_gimple_stmt (stmt);
-		  fprintf (stderr, "The use of ");
-		  print_generic_expr (stderr, use, 0);
-		  fprintf (stderr," should have been replaced\n");
-		  err = true;
+		  tree use = USE_FROM_PTR (use_p);
+		  if (TREE_CODE (use) != SSA_NAME)
+		    continue;
+
+		  if (SSA_NAME_IN_FREE_LIST (use))
+		    {
+		      error ("statement uses released SSA name:");
+		      debug_gimple_stmt (stmt);
+		      fprintf (stderr, "The use of ");
+		      print_generic_expr (stderr, use, 0);
+		      fprintf (stderr," should have been replaced\n");
+		      err = true;
+		    }
 		}
 	    }
 	}
-    }
 
-  if (err)
-    internal_error ("cannot update SSA form");
+      if (err)
+	internal_error ("cannot update SSA form");
 
-  timevar_pop (TV_TREE_STMT_VERIFY);
-#endif
+      timevar_pop (TV_TREE_STMT_VERIFY);
+    }
 
   timevar_push (TV_TREE_SSA_INCREMENTAL);
 
@@ -3271,29 +3272,28 @@ update_ssa (unsigned update_flags)
 	 placement heuristics.  */
       prepare_block_for_update (start_bb, insert_phi_p);
 
-#ifdef ENABLE_CHECKING
-      for (i = 1; i < num_ssa_names; ++i)
-	{
-	  tree name = ssa_name (i);
-	  if (!name
-	      || virtual_operand_p (name))
-	    continue;
-
-	  /* For all but virtual operands, which do not have SSA names
-	     with overlapping life ranges, ensure that symbols marked
-	     for renaming do not have existing SSA names associated with
-	     them as we do not re-write them out-of-SSA before going
-	     into SSA for the remaining symbol uses.  */
-	  if (marked_for_renaming (SSA_NAME_VAR (name)))
-	    {
-	      fprintf (stderr, "Existing SSA name for symbol marked for "
-		       "renaming: ");
-	      print_generic_expr (stderr, name, TDF_SLIM);
-	      fprintf (stderr, "\n");
-	      internal_error ("SSA corruption");
-	    }
-	}
-#endif
+      if (flag_checking)
+	for (i = 1; i < num_ssa_names; ++i)
+	  {
+	    tree name = ssa_name (i);
+	    if (!name
+		|| virtual_operand_p (name))
+	      continue;
+
+	    /* For all but virtual operands, which do not have SSA names
+	       with overlapping life ranges, ensure that symbols marked
+	       for renaming do not have existing SSA names associated with
+	       them as we do not re-write them out-of-SSA before going
+	       into SSA for the remaining symbol uses.  */
+	    if (marked_for_renaming (SSA_NAME_VAR (name)))
+	      {
+		fprintf (stderr, "Existing SSA name for symbol marked for "
+			 "renaming: ");
+		print_generic_expr (stderr, name, TDF_SLIM);
+		fprintf (stderr, "\n");
+		internal_error ("SSA corruption");
+	      }
+	  }
     }
   else
     {
diff --git a/gcc/tree-loop-distribution.c b/gcc/tree-loop-distribution.c
index 6f86d53..18025c8 100644
--- a/gcc/tree-loop-distribution.c
+++ b/gcc/tree-loop-distribution.c
@@ -1821,9 +1821,7 @@ out:
       rewrite_into_loop_closed_ssa (NULL, TODO_update_ssa);
     }
 
-#ifdef ENABLE_CHECKING
-  verify_loop_structure ();
-#endif
+  checking_verify_loop_structure ();
 
   return 0;
 }
diff --git a/gcc/tree-outof-ssa.c b/gcc/tree-outof-ssa.c
index 8dc4908..1c4c63c 100644
--- a/gcc/tree-outof-ssa.c
+++ b/gcc/tree-outof-ssa.c
@@ -841,24 +841,23 @@ eliminate_useless_phis (void)
 	  result = gimple_phi_result (phi);
 	  if (virtual_operand_p (result))
 	    {
-#ifdef ENABLE_CHECKING
-	      size_t i;
 	      /* There should be no arguments which are not virtual, or the
 	         results will be incorrect.  */
-	      for (i = 0; i < gimple_phi_num_args (phi); i++)
-	        {
-		  tree arg = PHI_ARG_DEF (phi, i);
-		  if (TREE_CODE (arg) == SSA_NAME
-		      && !virtual_operand_p (arg))
-		    {
-		      fprintf (stderr, "Argument of PHI is not virtual (");
-		      print_generic_expr (stderr, arg, TDF_SLIM);
-		      fprintf (stderr, "), but the result is :");
-		      print_gimple_stmt (stderr, phi, 0, TDF_SLIM);
-		      internal_error ("SSA corruption");
-		    }
-		}
-#endif
+	      if (flag_checking)
+		for (size_t i = 0; i < gimple_phi_num_args (phi); i++)
+		  {
+		    tree arg = PHI_ARG_DEF (phi, i);
+		    if (TREE_CODE (arg) == SSA_NAME
+			&& !virtual_operand_p (arg))
+		      {
+			fprintf (stderr, "Argument of PHI is not virtual (");
+			print_generic_expr (stderr, arg, TDF_SLIM);
+			fprintf (stderr, "), but the result is :");
+			print_gimple_stmt (stderr, phi, 0, TDF_SLIM);
+			internal_error ("SSA corruption");
+		      }
+		  }
+
 	      remove_phi_node (&gsi, true);
 	    }
           else
@@ -884,9 +883,11 @@ eliminate_useless_phis (void)
    variable.  */
 
 static void
-rewrite_trees (var_map map ATTRIBUTE_UNUSED)
+rewrite_trees (var_map map)
 {
-#ifdef ENABLE_CHECKING
+  if (!flag_checking)
+    return;
+
   basic_block bb;
   /* Search for PHIs where the destination has no partition, but one
      or more arguments has a partition.  This should not happen and can
@@ -918,7 +919,6 @@ rewrite_trees (var_map map ATTRIBUTE_UNUSED)
 	    }
 	}
     }
-#endif
 }
 
 /* Given the out-of-ssa info object SA (with prepared partitions)
diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c
index c7aa62c..26389a3 100644
--- a/gcc/tree-parloops.c
+++ b/gcc/tree-parloops.c
@@ -2784,9 +2784,7 @@ pass_parallelize_loops::execute (function *fun)
     {
       fun->curr_properties &= ~(PROP_gimple_eomp);
 
-#ifdef ENABLE_CHECKING
-      verify_loop_structure ();
-#endif
+      checking_verify_loop_structure ();
 
       return TODO_update_ssa;
     }
diff --git a/gcc/tree-predcom.c b/gcc/tree-predcom.c
index 4abac13..5f6e1b0 100644
--- a/gcc/tree-predcom.c
+++ b/gcc/tree-predcom.c
@@ -896,13 +896,9 @@ suitable_component_p (struct loop *loop, struct component *comp)
       if (!determine_offset (first->ref, a->ref, &a->offset))
 	return false;
 
-#ifdef ENABLE_CHECKING
-      {
-	enum ref_step_type a_step;
-	ok = suitable_reference_p (a->ref, &a_step);
-	gcc_assert (ok && a_step == comp->comp_step);
-      }
-#endif
+      enum ref_step_type a_step;
+      gcc_checking_assert (suitable_reference_p (a->ref, &a_step)
+			   && a_step == comp->comp_step);
     }
 
   /* If there is a write inside the component, we must know whether the
diff --git a/gcc/tree-profile.c b/gcc/tree-profile.c
index 2b11554..bc99278 100644
--- a/gcc/tree-profile.c
+++ b/gcc/tree-profile.c
@@ -462,9 +462,8 @@ gimple_gen_const_delta_profiler (histogram_value value ATTRIBUTE_UNUSED,
 			       unsigned base ATTRIBUTE_UNUSED)
 {
   /* FIXME implement this.  */
-#ifdef ENABLE_CHECKING
-  internal_error ("unimplemented functionality");
-#endif
+  if (flag_checking)
+    internal_error ("unimplemented functionality");
   gcc_unreachable ();
 }
 
diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c
index 3b8d594..a5bd831 100644
--- a/gcc/tree-ssa-alias.c
+++ b/gcc/tree-ssa-alias.c
@@ -1442,12 +1442,7 @@ refs_may_alias_p_1 (ao_ref *ref1, ao_ref *ref2, bool tbaa_p)
 				      ao_ref_alias_set (ref2), -1,
 				      tbaa_p);
 
-  /* We really do not want to end up here, but returning true is safe.  */
-#ifdef ENABLE_CHECKING
   gcc_unreachable ();
-#else
-  return true;
-#endif
 }
 
 static bool
diff --git a/gcc/tree-ssa-live.c b/gcc/tree-ssa-live.c
index 25b548b..a61026d 100644
--- a/gcc/tree-ssa-live.c
+++ b/gcc/tree-ssa-live.c
@@ -52,9 +52,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "ipa-utils.h"
 #include "cfgloop.h"
 
-#ifdef ENABLE_CHECKING
-static void  verify_live_on_entry (tree_live_info_p);
-#endif
+static void verify_live_on_entry (tree_live_info_p);
 
 
 /* VARMAP maintains a mapping from SSA version number to real variables.
@@ -1153,9 +1151,8 @@ calculate_live_ranges (var_map map, bool want_livein)
 
   live_worklist (live);
 
-#ifdef ENABLE_CHECKING
-  verify_live_on_entry (live);
-#endif
+  if (flag_checking)
+    verify_live_on_entry (live);
 
   calculate_live_on_exit (live);
 
@@ -1292,7 +1289,6 @@ debug (tree_live_info_d *ptr)
 }
 
 
-#ifdef ENABLE_CHECKING
 /* Verify that SSA_VAR is a non-virtual SSA_NAME.  */
 
 void
@@ -1422,4 +1418,3 @@ verify_live_on_entry (tree_live_info_p live)
     }
   gcc_assert (num <= 0);
 }
-#endif
diff --git a/gcc/tree-ssa-live.h b/gcc/tree-ssa-live.h
index 1f88358..0cb3a1a 100644
--- a/gcc/tree-ssa-live.h
+++ b/gcc/tree-ssa-live.h
@@ -80,9 +80,7 @@ extern void remove_unused_locals (void);
 extern void dump_var_map (FILE *, var_map);
 extern void debug (_var_map &ref);
 extern void debug (_var_map *ptr);
-#ifdef ENABLE_CHECKING
 extern void register_ssa_partition_check (tree ssa_var);
-#endif
 
 
 /* Return number of partitions in MAP.  */
@@ -181,12 +179,10 @@ num_basevars (var_map map)
    partitions may be filtered out by a view later.  */
 
 static inline void
-register_ssa_partition (var_map map ATTRIBUTE_UNUSED,
-			tree ssa_var ATTRIBUTE_UNUSED)
+register_ssa_partition (var_map map ATTRIBUTE_UNUSED, tree ssa_var)
 {
-#if defined ENABLE_CHECKING
-  register_ssa_partition_check (ssa_var);
-#endif
+  if (flag_checking)
+    register_ssa_partition_check (ssa_var);
 }
 
 
diff --git a/gcc/tree-ssa-loop-ivcanon.c b/gcc/tree-ssa-loop-ivcanon.c
index 6599ffc..0d5f56e 100644
--- a/gcc/tree-ssa-loop-ivcanon.c
+++ b/gcc/tree-ssa-loop-ivcanon.c
@@ -1376,10 +1376,8 @@ tree_unroll_loops_completely (bool may_increase_size, bool unroll_outer)
 	  /* Clean up the information about numbers of iterations, since
 	     complete unrolling might have invalidated it.  */
 	  scev_reset ();
-#ifdef ENABLE_CHECKING
-	  if (loops_state_satisfies_p (LOOP_CLOSED_SSA))
+	  if (flag_checking && loops_state_satisfies_p (LOOP_CLOSED_SSA))
 	    verify_loop_closed_ssa (true);
-#endif
 	}
       if (loop_closed_ssa_invalidated)
         BITMAP_FREE (loop_closed_ssa_invalidated);
diff --git a/gcc/tree-ssa-loop-manip.c b/gcc/tree-ssa-loop-manip.c
index 27ba275..e6befc6 100644
--- a/gcc/tree-ssa-loop-manip.c
+++ b/gcc/tree-ssa-loop-manip.c
@@ -278,22 +278,22 @@ add_exit_phi (basic_block exit, tree var)
   edge e;
   edge_iterator ei;
 
-#ifdef ENABLE_CHECKING
   /* Check that at least one of the edges entering the EXIT block exits
      the loop, or a superloop of that loop, that VAR is defined in.  */
-  gimple *def_stmt = SSA_NAME_DEF_STMT (var);
-  basic_block def_bb = gimple_bb (def_stmt);
-  FOR_EACH_EDGE (e, ei, exit->preds)
+  if (flag_checking)
     {
-      struct loop *aloop = find_common_loop (def_bb->loop_father,
-					     e->src->loop_father);
-      if (!flow_bb_inside_loop_p (aloop, e->dest))
-	break;
+      gimple *def_stmt = SSA_NAME_DEF_STMT (var);
+      basic_block def_bb = gimple_bb (def_stmt);
+      FOR_EACH_EDGE (e, ei, exit->preds)
+	{
+	  struct loop *aloop = find_common_loop (def_bb->loop_father,
+						 e->src->loop_father);
+	  if (!flow_bb_inside_loop_p (aloop, e->dest))
+	    break;
+	}
+      gcc_assert (e);
     }
 
-  gcc_checking_assert (e);
-#endif
-
   phi = create_phi_node (NULL_TREE, exit);
   create_new_def_for (var, phi, gimple_phi_result_ptr (phi));
   FOR_EACH_EDGE (e, ei, exit->preds)
@@ -729,7 +729,7 @@ check_loop_closed_ssa_stmt (basic_block bb, gimple *stmt)
 /* Checks that invariants of the loop closed ssa form are preserved.
    Call verify_ssa when VERIFY_SSA_P is true.  */
 
-DEBUG_FUNCTION void
+void
 verify_loop_closed_ssa (bool verify_ssa_p)
 {
   basic_block bb;
@@ -1368,11 +1368,9 @@ tree_transform_and_unroll_loop (struct loop *loop, unsigned factor,
   gimple_cond_set_rhs (exit_if, exit_bound);
   update_stmt (exit_if);
 
-#ifdef ENABLE_CHECKING
-  verify_flow_info ();
-  verify_loop_structure ();
-  verify_loop_closed_ssa (true);
-#endif
+  checking_verify_flow_info ();
+  checking_verify_loop_structure ();
+  checking_verify_loop_closed_ssa (true);
 }
 
 /* Wrapper over tree_transform_and_unroll_loop for case we do not
diff --git a/gcc/tree-ssa-loop-manip.h b/gcc/tree-ssa-loop-manip.h
index 9285718..96b02a6 100644
--- a/gcc/tree-ssa-loop-manip.h
+++ b/gcc/tree-ssa-loop-manip.h
@@ -27,6 +27,14 @@ extern void create_iv (tree, tree, tree, struct loop *, gimple_stmt_iterator *,
 extern void rewrite_into_loop_closed_ssa (bitmap, unsigned);
 extern void rewrite_virtuals_into_loop_closed_ssa (struct loop *);
 extern void verify_loop_closed_ssa (bool);
+
+static inline void
+checking_verify_loop_closed_ssa (bool verify_ssa_p)
+{
+  if (flag_checking)
+    verify_loop_closed_ssa (verify_ssa_p);
+}
+
 extern basic_block split_loop_exit_edge (edge);
 extern basic_block ip_end_pos (struct loop *);
 extern basic_block ip_normal_pos (struct loop *);
diff --git a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c
index 21604f5..21fb0a3 100644
--- a/gcc/tree-ssa-math-opts.c
+++ b/gcc/tree-ssa-math-opts.c
@@ -541,10 +541,9 @@ pass_cse_reciprocals::execute (function *fun)
   calculate_dominance_info (CDI_DOMINATORS);
   calculate_dominance_info (CDI_POST_DOMINATORS);
 
-#ifdef ENABLE_CHECKING
-  FOR_EACH_BB_FN (bb, fun)
-    gcc_assert (!bb->aux);
-#endif
+  if (flag_checking)
+    FOR_EACH_BB_FN (bb, fun)
+      gcc_assert (!bb->aux);
 
   for (arg = DECL_ARGUMENTS (fun->decl); arg; arg = DECL_CHAIN (arg))
     if (FLOAT_TYPE_P (TREE_TYPE (arg))
diff --git a/gcc/tree-ssa-operands.c b/gcc/tree-ssa-operands.c
index 544e9df..92d1ab2 100644
--- a/gcc/tree-ssa-operands.c
+++ b/gcc/tree-ssa-operands.c
@@ -881,12 +881,13 @@ get_expr_operands (struct function *fn, gimple *stmt, tree *expr_p, int flags)
     }
 
   /* If we get here, something has gone wrong.  */
-#ifdef ENABLE_CHECKING
-  fprintf (stderr, "unhandled expression in get_expr_operands():\n");
-  debug_tree (expr);
-  fputs ("\n", stderr);
-#endif
-  gcc_unreachable ();
+  if (flag_checking)
+    {
+      fprintf (stderr, "unhandled expression in get_expr_operands():\n");
+      debug_tree (expr);
+      fputs ("\n", stderr);
+      gcc_unreachable ();
+    }
 }
 
 
diff --git a/gcc/tree-ssa-propagate.c b/gcc/tree-ssa-propagate.c
index fbe41f9..363f439 100644
--- a/gcc/tree-ssa-propagate.c
+++ b/gcc/tree-ssa-propagate.c
@@ -1501,14 +1501,14 @@ static void
 replace_exp_1 (use_operand_p op_p, tree val,
     	       bool for_propagation ATTRIBUTE_UNUSED)
 {
-#if defined ENABLE_CHECKING
-  tree op = USE_FROM_PTR (op_p);
-
-  gcc_assert (!(for_propagation
-		&& TREE_CODE (op) == SSA_NAME
-		&& TREE_CODE (val) == SSA_NAME
-		&& !may_propagate_copy (op, val)));
-#endif
+  if (flag_checking)
+    {
+      tree op = USE_FROM_PTR (op_p);
+      gcc_assert (!(for_propagation
+		  && TREE_CODE (op) == SSA_NAME
+		  && TREE_CODE (val) == SSA_NAME
+		  && !may_propagate_copy (op, val)));
+    }
 
   if (TREE_CODE (val) == SSA_NAME)
     SET_USE (op_p, val);
diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c
index 8d86dcb..ab2becc 100644
--- a/gcc/tree-ssa-structalias.c
+++ b/gcc/tree-ssa-structalias.c
@@ -2544,10 +2544,11 @@ rewrite_constraints (constraint_graph_t graph,
   int i;
   constraint_t c;
 
-#ifdef ENABLE_CHECKING
-  for (unsigned int j = 0; j < graph->size; j++)
-    gcc_assert (find (j) == j);
-#endif
+  if (flag_checking)
+    {
+      for (unsigned int j = 0; j < graph->size; j++)
+	gcc_assert (find (j) == j);
+    }
 
   FOR_EACH_VEC_ELT (constraints, i, c)
     {
diff --git a/gcc/tree-ssa-ter.c b/gcc/tree-ssa-ter.c
index 7a7bcc9..b2d19ed 100644
--- a/gcc/tree-ssa-ter.c
+++ b/gcc/tree-ssa-ter.c
@@ -182,9 +182,7 @@ struct temp_expr_table
 /* A place for the many, many bitmaps we create.  */
 static bitmap_obstack ter_bitmap_obstack;
 
-#ifdef ENABLE_CHECKING
 extern void debug_ter (FILE *, temp_expr_table *);
-#endif
 
 
 /* Create a new TER table for MAP.  */
@@ -232,16 +230,16 @@ free_temp_expr_table (temp_expr_table *t)
 {
   bitmap ret = NULL;
 
-#ifdef ENABLE_CHECKING
-  unsigned x;
-  for (x = 0; x <= num_var_partitions (t->map); x++)
-    gcc_assert (!t->kill_list[x]);
-  for (x = 0; x < num_ssa_names; x++)
+  if (flag_checking)
     {
-      gcc_assert (t->expr_decl_uids[x] == NULL);
-      gcc_assert (t->partition_dependencies[x] == NULL);
+      for (unsigned x = 0; x <= num_var_partitions (t->map); x++)
+	gcc_assert (!t->kill_list[x]);
+      for (unsigned x = 0; x < num_ssa_names; x++)
+	{
+	  gcc_assert (t->expr_decl_uids[x] == NULL);
+	  gcc_assert (t->partition_dependencies[x] == NULL);
+	}
     }
-#endif
 
   BITMAP_FREE (t->partition_in_use);
   BITMAP_FREE (t->new_replaceable_dependencies);
@@ -748,7 +746,6 @@ dump_replaceable_exprs (FILE *f, bitmap expr)
 }
 
 
-#ifdef ENABLE_CHECKING
 /* Dump the status of the various tables in the expression table.  This is used
    exclusively to debug TER.  F is the place to send debug info and T is the
    table being debugged.  */
@@ -796,4 +793,3 @@ debug_ter (FILE *f, temp_expr_table *t)
 
   fprintf (f, "\n----------\n");
 }
-#endif
diff --git a/gcc/tree-ssa-threadupdate.c b/gcc/tree-ssa-threadupdate.c
index e426c1d..b650911 100644
--- a/gcc/tree-ssa-threadupdate.c
+++ b/gcc/tree-ssa-threadupdate.c
@@ -2357,7 +2357,7 @@ bb_ends_with_multiway_branch (basic_block bb ATTRIBUTE_UNUSED)
    REGION have exactly one incoming edge.  The only exception is the first block
    that may not have been connected to the rest of the cfg yet.  */
 
-DEBUG_FUNCTION void
+void
 verify_jump_thread (basic_block *region, unsigned n_region)
 {
   for (unsigned i = 0; i < n_region; i++)
@@ -2510,9 +2510,8 @@ duplicate_thread_path (edge entry, edge exit,
       scale_bbs_frequencies_int (region_copy, n_region, entry_freq, total_freq);
     }
 
-#ifdef ENABLE_CHECKING
-  verify_jump_thread (region_copy, n_region);
-#endif
+  if (flag_checking)
+    verify_jump_thread (region_copy, n_region);
 
   /* Remove the last branch in the jump thread path.  */
   remove_ctrl_stmt_and_useless_edges (region_copy[n_region - 1], exit->dest);
diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c
index 4b869be..b425b2c 100644
--- a/gcc/tree-ssa.c
+++ b/gcc/tree-ssa.c
@@ -910,7 +910,7 @@ error:
 /* Verify common invariants in the SSA web.
    TODO: verify the variable annotations.  */
 
-DEBUG_FUNCTION void
+void
 verify_ssa (bool check_modified_stmt, bool check_ssa_operands)
 {
   size_t i;
diff --git a/gcc/tree-ssa.h b/gcc/tree-ssa.h
index a3b9bed..570ac9c 100644
--- a/gcc/tree-ssa.h
+++ b/gcc/tree-ssa.h
@@ -77,5 +77,13 @@ redirect_edge_var_map_location (edge_var_map *v)
   return v->locus;
 }
 
+/* Verify SSA invariants, if internal consistency checks are enabled.  */
+
+static inline void
+checking_verify_ssa (bool check_modified_stmt, bool check_ssa_operands)
+{
+  if (flag_checking)
+    verify_ssa (check_modified_stmt, check_ssa_operands);
+}
 
 #endif /* GCC_TREE_SSA_H */
diff --git a/gcc/tree-ssanames.c b/gcc/tree-ssanames.c
index 82fd4a1..496ec3c 100644
--- a/gcc/tree-ssanames.c
+++ b/gcc/tree-ssanames.c
@@ -338,9 +338,8 @@ release_ssa_name_fn (struct function *fn, tree var)
       if (MAY_HAVE_DEBUG_STMTS)
 	insert_debug_temp_for_var_def (NULL, var);
 
-#ifdef ENABLE_CHECKING
-      verify_imm_links (stderr, var);
-#endif
+      if (flag_checking)
+	verify_imm_links (stderr, var);
       while (imm->next != imm)
 	delink_imm_use (imm->next);
 
diff --git a/gcc/tree-stdarg.c b/gcc/tree-stdarg.c
index 3e6d98c..0ed107c 100644
--- a/gcc/tree-stdarg.c
+++ b/gcc/tree-stdarg.c
@@ -1107,13 +1107,14 @@ expand_ifn_va_arg (function *fun)
   if ((fun->curr_properties & PROP_gimple_lva) == 0)
     expand_ifn_va_arg_1 (fun);
 
-#if ENABLE_CHECKING
+  if (!flag_checking)
+    return;
+
   basic_block bb;
   gimple_stmt_iterator i;
   FOR_EACH_BB_FN (bb, fun)
     for (i = gsi_start_bb (bb); !gsi_end_p (i); gsi_next (&i))
       gcc_assert (!gimple_call_ifn_va_arg_p (gsi_stmt (i)));
-#endif
 }
 
 namespace {
diff --git a/gcc/tree-vect-loop-manip.c b/gcc/tree-vect-loop-manip.c
index 11c3ae2..d9d01ec 100644
--- a/gcc/tree-vect-loop-manip.c
+++ b/gcc/tree-vect-loop-manip.c
@@ -919,9 +919,7 @@ slpeel_tree_duplicate_loop_to_edge_cfg (struct loop *loop,
   free (new_bbs);
   free (bbs);
 
-#ifdef ENABLE_CHECKING
-  verify_dominators (CDI_DOMINATORS);
-#endif
+  checking_verify_dominators (CDI_DOMINATORS);
 
   return new_loop;
 }
@@ -1003,11 +1001,13 @@ slpeel_can_duplicate_loop_p (const struct loop *loop, const_edge e)
   return true;
 }
 
-#ifdef ENABLE_CHECKING
 static void
-slpeel_verify_cfg_after_peeling (struct loop *first_loop,
-                                 struct loop *second_loop)
+slpeel_checking_verify_cfg_after_peeling (struct loop *first_loop,
+					  struct loop *second_loop)
 {
+  if (!flag_checking)
+    return;
+
   basic_block loop1_exit_bb = single_exit (first_loop)->dest;
   basic_block loop2_entry_bb = loop_preheader_edge (second_loop)->src;
   basic_block loop1_entry_bb = loop_preheader_edge (first_loop)->src;
@@ -1035,7 +1035,6 @@ slpeel_verify_cfg_after_peeling (struct loop *first_loop,
      second_loop.  */
   /* TODO */
 }
-#endif
 
 /* If the run time cost model check determines that vectorization is
    not profitable and hence scalar loop should be generated then set
@@ -1773,9 +1772,7 @@ vect_do_peeling_for_loop_bound (loop_vec_info loop_vinfo,
 				     0, LOOP_VINFO_VECT_FACTOR (loop_vinfo));
   gcc_assert (new_loop);
   gcc_assert (loop_num == loop->num);
-#ifdef ENABLE_CHECKING
-  slpeel_verify_cfg_after_peeling (loop, new_loop);
-#endif
+  slpeel_checking_verify_cfg_after_peeling (loop, new_loop);
 
   /* A guard that controls whether the new_loop is to be executed or skipped
      is placed in LOOP->exit.  LOOP->exit therefore has two successors - one
@@ -2032,9 +2029,7 @@ vect_do_peeling_for_alignment (loop_vec_info loop_vinfo, tree ni_name,
 				   bound, 0);
 
   gcc_assert (new_loop);
-#ifdef ENABLE_CHECKING
-  slpeel_verify_cfg_after_peeling (new_loop, loop);
-#endif
+  slpeel_checking_verify_cfg_after_peeling (new_loop, loop);
   /* For vectorization factor N, we need to copy at most N-1 values 
      for alignment and this means N-2 loopback edge executions.  */
   max_iter = LOOP_VINFO_VECT_FACTOR (loop_vinfo) - 2;
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index fe34ffd..d10d66d 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -242,9 +242,7 @@ static inline bool
 supports_overflow_infinity (const_tree type)
 {
   tree min = vrp_val_min (type), max = vrp_val_max (type);
-#ifdef ENABLE_CHECKING
-  gcc_assert (needs_overflow_infinity (type));
-#endif
+  gcc_checking_assert (needs_overflow_infinity (type));
   return (min != NULL_TREE
 	  && CONSTANT_CLASS_P (min)
 	  && max != NULL_TREE
@@ -373,9 +371,9 @@ static void
 set_value_range (value_range *vr, enum value_range_type t, tree min,
 		 tree max, bitmap equiv)
 {
-#if defined ENABLE_CHECKING
   /* Check the validity of the range.  */
-  if (t == VR_RANGE || t == VR_ANTI_RANGE)
+  if (flag_checking
+      && (t == VR_RANGE || t == VR_ANTI_RANGE))
     {
       int cmp;
 
@@ -395,12 +393,12 @@ set_value_range (value_range *vr, enum value_range_type t, tree min,
 		    || !is_overflow_infinity (max));
     }
 
-  if (t == VR_UNDEFINED || t == VR_VARYING)
-    gcc_assert (min == NULL_TREE && max == NULL_TREE);
-
-  if (t == VR_UNDEFINED || t == VR_VARYING)
-    gcc_assert (equiv == NULL || bitmap_empty_p (equiv));
-#endif
+  if (flag_checking
+      && (t == VR_UNDEFINED || t == VR_VARYING))
+    {
+      gcc_assert (min == NULL_TREE && max == NULL_TREE);
+      gcc_assert (equiv == NULL || bitmap_empty_p (equiv));
+    }
 
   vr->type = t;
   vr->min = min;
diff --git a/gcc/tree.c b/gcc/tree.c
index 905c60e..4c81997 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -5935,10 +5935,11 @@ free_lang_data_in_cgraph (void)
   /* Traverse every type found freeing its language data.  */
   FOR_EACH_VEC_ELT (fld.types, i, t)
     free_lang_data_in_type (t);
-#ifdef ENABLE_CHECKING
-  FOR_EACH_VEC_ELT (fld.types, i, t)
-    verify_type (t);
-#endif
+  if (flag_checking)
+    {
+      FOR_EACH_VEC_ELT (fld.types, i, t)
+	verify_type (t);
+    }
 
   delete fld.pset;
   fld.worklist.release ();
diff --git a/gcc/value-prof.c b/gcc/value-prof.c
index ddf1215..24eff07 100644
--- a/gcc/value-prof.c
+++ b/gcc/value-prof.c
@@ -230,9 +230,8 @@ gimple_remove_histogram_value (struct function *fun, gimple *stmt,
       hist2->hvalue.next = hist->hvalue.next;
     }
   free (hist->hvalue.counters);
-#ifdef ENABLE_CHECKING
-  memset (hist, 0xab, sizeof (*hist));
-#endif
+  if (CHECKING_P)
+    memset (hist, 0xab, sizeof (*hist));
   free (hist);
 }
 
@@ -595,9 +594,8 @@ free_hist (void **slot, void *data ATTRIBUTE_UNUSED)
 {
   histogram_value hist = *(histogram_value *) slot;
   free (hist->hvalue.counters);
-#ifdef ENABLE_CHECKING
-  memset (hist, 0xab, sizeof (*hist));
-#endif
+  if (CHECKING_P)
+    memset (hist, 0xab, sizeof (*hist));
   free (hist);
   return 1;
 }
diff --git a/gcc/var-tracking.c b/gcc/var-tracking.c
index 8010ce1..60c0320 100644
--- a/gcc/var-tracking.c
+++ b/gcc/var-tracking.c
@@ -399,7 +399,7 @@ struct variable
 /* Macro to access MEM_OFFSET as an HOST_WIDE_INT.  Evaluates MEM twice.  */
 #define INT_MEM_OFFSET(mem) (MEM_OFFSET_KNOWN_P (mem) ? MEM_OFFSET (mem) : 0)
 
-#if ENABLE_CHECKING && (GCC_VERSION >= 2007)
+#if CHECKING_P && (GCC_VERSION >= 2007)
 
 /* Access VAR's Ith part's offset, checking that it's not a one-part
    variable.  */
@@ -3571,7 +3571,6 @@ loc_cmp (rtx x, rtx y)
   return 0;
 }
 
-#if ENABLE_CHECKING
 /* Check the order of entries in one-part variables.   */
 
 int
@@ -3603,7 +3602,6 @@ canonicalize_loc_order_check (variable **slot,
 
   return 1;
 }
-#endif
 
 /* Mark with VALUE_RECURSED_INTO values that have neighbors that are
    more likely to be chosen as canonical for an equivalence set.
@@ -3832,17 +3830,16 @@ canonicalize_values_star (variable **slot, dataflow_set *set)
 	    else
 	      gcc_unreachable ();
 
-#if ENABLE_CHECKING
-	    while (list)
-	      {
-		if (list->offset == 0
-		    && (dv_as_opaque (list->dv) == dv_as_opaque (dv)
-			|| dv_as_opaque (list->dv) == dv_as_opaque (cdv)))
-		  gcc_unreachable ();
+	    if (flag_checking)
+	      while (list)
+		{
+		  if (list->offset == 0
+		      && (dv_as_opaque (list->dv) == dv_as_opaque (dv)
+			  || dv_as_opaque (list->dv) == dv_as_opaque (cdv)))
+		    gcc_unreachable ();
 
-		list = list->next;
-	      }
-#endif
+		  list = list->next;
+		}
 	  }
       }
 
@@ -6930,10 +6927,9 @@ compute_bb_dataflow (basic_block bb)
 	->traverse <dataflow_set *, canonicalize_values_mark> (out);
       shared_hash_htab (out->vars)
 	->traverse <dataflow_set *, canonicalize_values_star> (out);
-#if ENABLE_CHECKING
-      shared_hash_htab (out->vars)
-	->traverse <dataflow_set *, canonicalize_loc_order_check> (out);
-#endif
+      if (flag_checking)
+	shared_hash_htab (out->vars)
+	  ->traverse <dataflow_set *, canonicalize_loc_order_check> (out);
     }
   changed = dataflow_set_different (&old_out, out);
   dataflow_set_destroy (&old_out);
@@ -7038,13 +7034,14 @@ vt_find_locations (void)
 		  if (adjust)
 		    {
 		      dataflow_post_merge_adjust (in, &VTI (bb)->permp);
-#if ENABLE_CHECKING
-		      /* Merge and merge_adjust should keep entries in
-			 canonical order.  */
-		      shared_hash_htab (in->vars)
-			->traverse <dataflow_set *,
-				    canonicalize_loc_order_check> (in);
-#endif
+
+		      if (flag_checking)
+			/* Merge and merge_adjust should keep entries in
+			   canonical order.  */
+			shared_hash_htab (in->vars)
+			  ->traverse <dataflow_set *,
+				      canonicalize_loc_order_check> (in);
+
 		      if (dst_can_be_shared)
 			{
 			  shared_hash_destroy (in->vars);
@@ -9465,11 +9462,12 @@ vt_emit_notes (void)
 	 again.  */
       dataflow_set_clear (&VTI (bb)->in);
     }
-#ifdef ENABLE_CHECKING
-  shared_hash_htab (cur.vars)
-    ->traverse <variable_table_type *, emit_notes_for_differences_1>
-      (shared_hash_htab (empty_shared_hash));
-#endif
+
+  if (flag_checking)
+    shared_hash_htab (cur.vars)
+      ->traverse <variable_table_type *, emit_notes_for_differences_1>
+	(shared_hash_htab (empty_shared_hash));
+
   dataflow_set_destroy (&cur);
 
   if (MAY_HAVE_DEBUG_INSNS)

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 2/9] ENABLE_CHECKING refactoring: libcpp
  2015-10-12 20:57     ` Jeff Law
@ 2015-10-19  1:18       ` Mikhail Maltsev
  2015-10-21 22:29         ` Jeff Law
  0 siblings, 1 reply; 77+ messages in thread
From: Mikhail Maltsev @ 2015-10-19  1:18 UTC (permalink / raw)
  To: Jeff Law, Bernd Schmidt, gcc-patches mailing list, Richard Biener

[-- Attachment #1: Type: text/plain, Size: 1393 bytes --]

On 10/12/2015 11:57 PM, Jeff Law wrote:
> On 10/06/2015 06:40 AM, Bernd Schmidt wrote:
>> I'm not entirely sure what to make of this series. There seem to be good
>> bits in there but also some things I find questionable. I'll add some
>> comments on things that occur to me.
> Maybe we should start pulling out the bits that we think are ready & good and
> start installing them independently.
> 
(snip)

>> Probably a good thing, but it looks like libcpp has grown its own
>> variant linemap_assert; we should check whether that can be replaced.
>>
>> Also, the previous patch already introduces a use of gcc_assert, or at
>> least a reference to it, and it's only defined here. The two
>> modifications of libcpp/system.h should probably be merged into one.
> Agreed.
> 
> jeff

I moved the 'libcpp/system.h' parts into the first patch of the series. As for
replacing linemap_assert, I hope it can be done separately.

-- 
Regards,
    Mikhail Maltsev

libcpp/ChangeLog:

2015-10-19  Mikhail Maltsev  <maltsevm@gmail.com>

        * include/line-map.h: Use CHECKING_P instead of ENABLE_CHECKING.
        * init.c: Likewise.
        * macro.c (struct macro_arg_token_iter, set_arg_token,
        macro_arg_token_iter_init, macro_arg_token_iter_forward,
        macro_arg_token_iter_get_token, macro_arg_token_iter_get_location,
        alloc_expanded_arg_mem, _cpp_backup_tokens): Likewise.

[-- Attachment #2: 0002-libcpp-v2.patch --]
[-- Type: text/x-patch, Size: 4628 bytes --]

From 5bb52360b2a065015cb081b4528f2f9295c326d6 Mon Sep 17 00:00:00 2001
From: Mikhail Maltsev <maltsevm@gmail.com>
Date: Tue, 22 Sep 2015 02:51:31 +0300
Subject: [PATCH 2/7] libcpp - v2

---
 libcpp/include/line-map.h |  2 +-
 libcpp/init.c             |  2 +-
 libcpp/macro.c            | 38 +++++++++++++++-----------------------
 3 files changed, 17 insertions(+), 25 deletions(-)

diff --git a/libcpp/include/line-map.h b/libcpp/include/line-map.h
index bc747c1..e718fc2 100644
--- a/libcpp/include/line-map.h
+++ b/libcpp/include/line-map.h
@@ -272,7 +272,7 @@ struct GTY((tag ("2"))) line_map_macro : public line_map {
   source_location expansion;
 };
 
-#if defined ENABLE_CHECKING && (GCC_VERSION >= 2007)
+#if CHECKING_P && (GCC_VERSION >= 2007)
 
 /* Assertion macro to be used in line-map code.  */
 #define linemap_assert(EXPR)                  \
diff --git a/libcpp/init.c b/libcpp/init.c
index 2d5626f..0419e95 100644
--- a/libcpp/init.c
+++ b/libcpp/init.c
@@ -535,7 +535,7 @@ cpp_init_builtins (cpp_reader *pfile, int hosted)
 
 /* Sanity-checks are dependent on command-line options, so it is
    called as a subroutine of cpp_read_main_file ().  */
-#if ENABLE_CHECKING
+#if CHECKING_P
 static void sanity_checks (cpp_reader *);
 static void sanity_checks (cpp_reader *pfile)
 {
diff --git a/libcpp/macro.c b/libcpp/macro.c
index 786c21b..60a0753 100644
--- a/libcpp/macro.c
+++ b/libcpp/macro.c
@@ -73,7 +73,7 @@ struct macro_arg_token_iter
      -ftrack-macro-expansion is used this location tracks loci across
      macro expansion.  */
   const source_location *location_ptr;
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
   /* The number of times the iterator went forward. This useful only
      when checking is enabled.  */
   size_t num_forwards;
@@ -1310,14 +1310,11 @@ set_arg_token (macro_arg *arg, const cpp_token *token,
 
   if (loc != NULL)
     {
-#ifdef ENABLE_CHECKING
-      if (kind == MACRO_ARG_TOKEN_STRINGIFIED
-	  || !track_macro_exp_p)
-	/* We can't set the location of a stringified argument
-	   token and we can't set any location if we aren't tracking
-	   macro expansion locations.   */
-	abort ();
-#endif
+      /* We can't set the location of a stringified argument
+	 token and we can't set any location if we aren't tracking
+	 macro expansion locations.   */
+      gcc_checking_assert (kind != MACRO_ARG_TOKEN_STRINGIFIED
+			   && track_macro_exp_p);
       *loc = location;
     }
 }
@@ -1403,7 +1400,7 @@ macro_arg_token_iter_init (macro_arg_token_iter *iter,
   iter->location_ptr = NULL;
   if (track_macro_exp_p)
     iter->location_ptr = get_arg_token_location (arg, kind);
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
   iter->num_forwards = 0;
   if (track_macro_exp_p
       && token_ptr != NULL
@@ -1428,14 +1425,14 @@ macro_arg_token_iter_forward (macro_arg_token_iter *it)
 	it->location_ptr++;
       break;
     case MACRO_ARG_TOKEN_STRINGIFIED:
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
       if (it->num_forwards > 0)
 	abort ();
 #endif
       break;
     }
 
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
   it->num_forwards++;
 #endif
 }
@@ -1444,7 +1441,7 @@ macro_arg_token_iter_forward (macro_arg_token_iter *it)
 static const cpp_token *
 macro_arg_token_iter_get_token (const macro_arg_token_iter *it)
 {
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
   if (it->kind == MACRO_ARG_TOKEN_STRINGIFIED
       && it->num_forwards > 0)
     abort ();
@@ -1458,7 +1455,7 @@ macro_arg_token_iter_get_token (const macro_arg_token_iter *it)
 static source_location
 macro_arg_token_iter_get_location (const macro_arg_token_iter *it)
 {
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
   if (it->kind == MACRO_ARG_TOKEN_STRINGIFIED
       && it->num_forwards > 0)
     abort ();
@@ -2144,11 +2141,9 @@ tokens_buff_add_token (_cpp_buff *buffer,
 static void
 alloc_expanded_arg_mem (cpp_reader *pfile, macro_arg *arg, size_t capacity)
 {
-#ifdef ENABLE_CHECKING
-  if (arg->expanded != NULL
-      || arg->expanded_virt_locs != NULL)
-    abort ();
-#endif
+  gcc_checking_assert (arg->expanded == NULL
+		       && arg->expanded_virt_locs == NULL);
+
   arg->expanded = XNEWVEC (const cpp_token *, capacity);
   if (CPP_OPTION (pfile, track_macro_expansion))
     arg->expanded_virt_locs = XNEWVEC (source_location, capacity);
@@ -2709,10 +2704,7 @@ _cpp_backup_tokens (cpp_reader *pfile, unsigned int count)
 	    {
 	      macro_context *m = pfile->context->c.mc;
 	      m->cur_virt_loc--;
-#ifdef ENABLE_CHECKING
-	      if (m->cur_virt_loc < m->virt_locs)
-		abort ();
-#endif
+	      gcc_checking_assert (m->cur_virt_loc >= m->virt_locs);
 	    }
 	  else
 	    abort ();
-- 
2.1.4


^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 1/9] ENABLE_CHECKING refactoring
  2015-10-18  8:25   ` Mikhail Maltsev
@ 2015-10-19 11:14     ` Bernd Schmidt
  2015-10-19 13:54       ` Mikhail Maltsev
  2015-10-20 16:14     ` Jeff Law
  2015-10-21 21:17     ` Jeff Law
  2 siblings, 1 reply; 77+ messages in thread
From: Bernd Schmidt @ 2015-10-19 11:14 UTC (permalink / raw)
  To: Mikhail Maltsev, Jeff Law, gcc-patches mailing list, Richard Biener

On 10/18/2015 08:17 AM, Mikhail Maltsev wrote:
> On 10/12/2015 11:57 PM, Jeff Law wrote:
>>>> -#ifdef ENABLE_CHECKING
>>>> +#if CHECKING_P
>>>
>>> I fail to see the point of this change.
>> I'm guessing (and Mikhail, please correct me if I'm wrong), but I think he's
>> trying to get away from ENABLE_CHECKING and instead use a macro which is
>> always defined to a value.
> Yes, exactly. Such macro is better because it can be used both for conditional
> compilation (if needed) and normal if-s (unlike ENABLE_CHECKING).

But for normal C conditions the patches end up using flag_checking, so 
the CHECKING_P macro buys us nothing over ENABLE_CHECKING. A change like 
this is just churn: changing things without making forward progress, and 
every change like that will cause someone else grief when they have to 
adjust their own out-of-tree patches. (It's something I think we've been 
doing too much lately, and others have complained to me about this issue 
as well).

I'm ok with pretty much all of the rest of the changes (some minor 
comments to follow), so if you could eliminate CHECKING_P I'd be likely 
to approve them.


Bernd

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 7/9] ENABLE_CHECKING refactoring: middle-end, LTO FE
  2015-10-19  0:56       ` Mikhail Maltsev
@ 2015-10-19 12:19         ` Bernd Schmidt
  2015-10-26 17:04           ` Jeff Law
  0 siblings, 1 reply; 77+ messages in thread
From: Bernd Schmidt @ 2015-10-19 12:19 UTC (permalink / raw)
  To: Mikhail Maltsev, Richard Biener; +Cc: gcc-patches mailing list, Jeff Law

> diff --git a/gcc/cfgcleanup.c b/gcc/cfgcleanup.c
> -
> -#ifdef ENABLE_CHECKING
> -              verify_flow_info ();
> -#endif
> +	      checking_verify_flow_info ();

This looks misindented.

> -#ifdef ENABLE_CHECKING
>         cgraph_edge *e;
>         gcc_checking_assert (
>   	!(e = caller->get_edge (call_stmt)) || e->speculative);
> -#endif

While you're here, that would look nicer as
          gcc_checking_assert (!(e = caller->get_edge (call_stmt))
                               || e->speculative);

> -#ifdef ENABLE_CHECKING
> -  if (check_same_comdat_groups)
> +  if (CHECKING_P && check_same_comdat_groups)

flag_checking

> -#ifdef ENABLE_CHECKING
> -  struct df_rd_bb_info *bb_info = DF_RD_BB_INFO (g->bb);
> -#endif
> +  struct df_rd_bb_info *bb_info = flag_checking ? DF_RD_BB_INFO (g->bb)
> +						: NULL;

I think no need to make that conditional, that's a bit too ugly.

> +      if (CHECKING_P)
> +	sparseset_set_bit (active_defs_check, regno);

> +  if (CHECKING_P)
> +    sparseset_clear (active_defs_check);

 > -#ifdef ENABLE_CHECKING
 > -  active_defs_check = sparseset_alloc (max_reg_num ());
 > -#endif

 > +  if (CHECKING_P)
 > +    active_defs_check = sparseset_alloc (max_reg_num ());

 > +  if (CHECKING_P)
 > +    sparseset_free (active_defs_check);

flag_checking. Lots of other occurrences, I'll mention some but not all 
but please fix them for consistency.

>   void
>   sem_item_optimizer::verify_classes (void)
>   {
> -#if ENABLE_CHECKING
> +  if (!flag_checking)
> +    return;
> +

Not entirely sure whether you want to wrap this into a 
checking_verify_classes instead so that it remains easily callable by 
the debugger?

> +	  if (flag_checking)
> +	    {
> +	      for (symtab_node *n = node->same_comdat_group;
> +		   n != node;
> +		   n = n->same_comdat_group)
> +		/* If at least one of same comdat group functions is external,
> +		   all of them have to be, otherwise it is a front-end bug.  */
> +		gcc_assert (DECL_EXTERNAL (n->decl));
> +	    }

Unnecessary set of braces.

> diff --git a/gcc/lra-assigns.c b/gcc/lra-assigns.c
> index 2986f57..941a829 100644
> --- a/gcc/lra-assigns.c
> +++ b/gcc/lra-assigns.c
> @@ -1591,7 +1591,7 @@ lra_assign (void)
>     bitmap_initialize (&all_spilled_pseudos, &reg_obstack);
>     create_live_range_start_chains ();
>     setup_live_pseudos_and_spill_after_risky_transforms (&all_spilled_pseudos);
> -#ifdef ENABLE_CHECKING
> +#if CHECKING_P
>     if (!flag_ipa_ra)
>       for (i = FIRST_PSEUDO_REGISTER; i < max_regno; i++)
>         if (lra_reg_info[i].nrefs != 0 && reg_renumber[i] >= 0

Seems inconsistent, use flag_checking and no #if? Looks like the problem 
you're trying to solve is that a structure field exists only with 
checking, I think that could just be made available unconditionally - 
the struct is huge anyway.

As mentioned in the other mail, I see no value changing the #ifdefs to 
#ifs here or elsewhere in the patch.

> -  check_rtl (false);
> -#endif
> +  if (flag_checking)
> +    check_rtl (/*final_p=*/false);

Lose the /*final_p=*/.

> -#ifdef ENABLE_CHECKING
> +#if CHECKING_P
>   	      gcc_assert (!bitmap_bit_p (output, DECL_UID (node->decl)));
>   	      bitmap_set_bit (output, DECL_UID (node->decl));
>   #endif

Not entirely clear why this isn't using flag_checking.

>   	  tree t = (*trees)[i];
> -#ifdef ENABLE_CHECKING
> -	  if (TYPE_P (t))
> +	  if (CHECKING_P && TYPE_P (t))
>   	    verify_type (t);
> -#endif

flag_checking

> @@ -14108,7 +14102,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx)
>         default:
>   	break;
>         case OMP_CLAUSE_MAP:
> -#ifdef ENABLE_CHECKING
> +#if CHECKING_P
>   	/* First check what we're prepared to handle in the following.  */
>   	switch (OMP_CLAUSE_MAP_KIND (c))
>   	  {

Here too...

> -#ifdef ENABLE_CHECKING
> -static void
> +static void DEBUG_FUNCTION
>   verify_curr_properties (function *fn, void *data)

Hmm, I noticed a few cases where we lost the DEBUG_FUNCTION annotation 
and was going to comment that this is one is odd - but don't we actually 
want to keep DEBUG_FUNCTION annotations for the others as well so that 
they don't get inlined everywhere and eliminated?

> +	  if (flag_checking)
> +	    {
> +	      FOR_EACH_EDGE (e, ei, bb->preds)
> +		gcc_assert (!bitmap_bit_p (tovisit, e->src->index)
> +			    || (e->flags & EDGE_DFS_BACK));
> +	    }

Unnecessary braces.

> +  if (CHECKING_P)
> +    {
> +      for (; argno < PP_NL_ARGMAX; argno++)
> +	gcc_assert (!formatters[argno]);
> +    }

Here too. Use flag_checking.

> +  if (CHECKING_P && mode != VOIDmode)

flag_checking.

> -#ifdef ENABLE_CHECKING
>   static void
>   validate_value_data (struct value_data *vd)
>   {
> +  if (!flag_checking)
> +    return;

Same thought as before, it might be better to have this check in the 
callers for easier use from the debugger.

> -#endif
> -
>
> +

Don't change the whitespace here. Looks like you probably removed a page 
break.

>
> -#ifdef ENABLE_CHECKING
> +#if CHECKING_P
>     /* This is initialized to the insn on which the driver stopped its traversal.  */
>     insn_t failed_insn;
>   #endif

I think here it would also be reasonable to make the field (and its 
initializations) unconditional and use flag_checking for the code using it.

> -#ifdef ENABLE_CHECKING
> -  {
> -    edge e;
> -    edge_iterator ei;
> +/* FIXME: (PR 67842) this check is incorrect.  dominated_by_p has no effect,
> +   but changing it to gcc_assert (dominated_by_p (...)) causes regressions,
> +   e.g., gcc.dg/graphite/block-1.c.  */
> +#if 0

This change should probably be submitted separately, people are more 
likely to see it than if it's buried in a sea of cosmetic changes.

> +      if (flag_checking)
> +	{
> +	  /* last_set_in should now be all-zero.  */
> +	  for (unsigned regno = 0; regno < max_gcse_regno; regno++)
> +	    gcc_assert (!last_set_in[regno]);
> +	}

Braces.
> @@ -211,9 +211,9 @@ pack_cumulative_args (CUMULATIVE_ARGS *arg)
>   {
>     cumulative_args_t ret;
>
> -#ifdef ENABLE_CHECKING
> +#if CHECKING_P
>     ret.magic = CUMULATIVE_ARGS_MAGIC;
> -#endif /* ENABLE_CHECKING */
> +#endif /* CHECKING_P */

In this case I think it's ok to keep using conditional compilation as 
you're doing, since the extra magic field in cumulative_args_t looks 
like it would be expensive. (Not that we're spending a huge amount of 
time computing arg layout, but still...)

>
>   static void
> -rewrite_trees (var_map map ATTRIBUTE_UNUSED)
> +rewrite_trees (var_map map)
>   {
> -#ifdef ENABLE_CHECKING
> +  if (!flag_checking)
> +    return;

Bit of an odd name for a function that only does verification. It was 
considerably bigger in 4.2 at least, so maybe it ought to be renamed at 
this point.

> -	enum ref_step_type a_step;
> -	ok = suitable_reference_p (a->ref, &a_step);
> -	gcc_assert (ok && a_step == comp->comp_step);
> -      }
> -#endif
> +      enum ref_step_type a_step;
> +      gcc_checking_assert (suitable_reference_p (a->ref, &a_step)
> +			   && a_step == comp->comp_step);

I think we're supposed to stop saying things like "enum" or "struct". If 
you really want, you can go through the places you're changing and 
modifying them so that they're changed only once. But it's not a 
requirement.

> diff --git a/gcc/tree-stdarg.c b/gcc/tree-stdarg.c
> index 3e6d98c..0ed107c 100644
> --- a/gcc/tree-stdarg.c
> +++ b/gcc/tree-stdarg.c
> @@ -1107,13 +1107,14 @@ expand_ifn_va_arg (function *fun)
>     if ((fun->curr_properties & PROP_gimple_lva) == 0)
>       expand_ifn_va_arg_1 (fun);
>
> -#if ENABLE_CHECKING
> +  if (!flag_checking)
> +    return;
> +
>     basic_block bb;
>     gimple_stmt_iterator i;
>     FOR_EACH_BB_FN (bb, fun)
>       for (i = gsi_start_bb (bb); !gsi_end_p (i); gsi_next (&i))
>         gcc_assert (!gimple_call_ifn_va_arg_p (gsi_stmt (i)));
> -#endif


I think this would be better wrapped in an "if (flag_checking)", someone 
might want to append to the function at some point.


Bernd

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 1/9] ENABLE_CHECKING refactoring
  2015-10-19 11:14     ` Bernd Schmidt
@ 2015-10-19 13:54       ` Mikhail Maltsev
  2015-10-21 15:59         ` Jeff Law
  0 siblings, 1 reply; 77+ messages in thread
From: Mikhail Maltsev @ 2015-10-19 13:54 UTC (permalink / raw)
  To: Bernd Schmidt, Jeff Law, gcc-patches mailing list, Richard Biener

On 10/19/2015 02:13 PM, Bernd Schmidt wrote:
> But for normal C conditions the patches end up using flag_checking, so
> the CHECKING_P macro buys us nothing over ENABLE_CHECKING.
Presumably 'if (CHECKING_P)' can be used for performance-critical parts
(in this case the condition will be DCE-d) and also for those parts of
the compiler which we want to decouple from 'options.h'.
IIRC, Jeff's idea was get rid of 'ENABLE_CHECKING' completely and use
either 'flag_checking' or 'CHECKING_P'. But I don't know what is the
consensus on it (I would like to hear Jeff's and Richard's opinion).
Of course it will be easy for me to adjust the patch to whatever the
final decision will be.

-- 
Regards,
    Mikhail Maltsev

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 1/9] ENABLE_CHECKING refactoring
  2015-10-18  8:25   ` Mikhail Maltsev
  2015-10-19 11:14     ` Bernd Schmidt
@ 2015-10-20 16:14     ` Jeff Law
  2015-10-21 21:17     ` Jeff Law
  2 siblings, 0 replies; 77+ messages in thread
From: Jeff Law @ 2015-10-20 16:14 UTC (permalink / raw)
  To: Mikhail Maltsev, gcc-patches mailing list, Richard Biener

On 10/18/2015 12:17 AM, Mikhail Maltsev wrote:
> On 10/12/2015 11:57 PM, Jeff Law wrote:
>>>> -#ifdef ENABLE_CHECKING
>>>> +#if CHECKING_P
>>>
>>> I fail to see the point of this change.
>> I'm guessing (and Mikhail, please correct me if I'm wrong), but I think he's
>> trying to get away from ENABLE_CHECKING and instead use a macro which is
>> always defined to a value.
> Yes, exactly. Such macro is better because it can be used both for conditional
> compilation (if needed) and normal if-s (unlike ENABLE_CHECKING).
>
> On 10/14/2015 12:33 AM, Jeff Law wrote:
>>>    gcc/common.opt  | 5 +++++
>>>    gcc/system.h    | 3 +++
>>>    libcpp/system.h | 8 ++++++++
>>>    3 files changed, 16 insertions(+)
>> I committed this prerequisite patch to the trunk.
>>
>> jeff
>>
>
> There is a typo here:
>
>> #ifdef ENABLE_CHECKING
>> #define gcc_checking_assert(EXPR) gcc_assert (EXPR)
>> +#define CHECKING_P 1
>> #else
>> +/* N.B.: in release build EXPR is not evaluated.  */
>> #define gcc_checking_assert(EXPR) ((void)(0 && (EXPR)))
>> +#define CHECKING_P 1
>> #endif
>
> In my original patch the second definition actually was
> '+#define CHECKING_P 0'
Not sure how that happened.  I'll take care of it.


I'd actually planned to start extracting the non-controversial stuff out 
of the later patches, but just ran out of time before going onto PTO.

>
> Also, gcc_checking_assert in libcpp requires gcc_assert to be defined. That was
> missing in my original patch (and was added in patch 2/9), but I think it would
> be better to fix it here, as Bernd noticed (in the last paragraph of [1]).
Sounds wise.  Agreed.

>
> Besides, I like Richard's proposal [2] about moving CHECKING_P macros into
> configure.ac.
>
> [1] https://gcc.gnu.org/ml/gcc-patches/2015-10/msg00550.html
> [2] https://gcc.gnu.org/ml/gcc-patches/2015-10/msg00555.html
>
> It required minor tweaking in order to silence autotools' warnings. I attached
> the modified patch.
When I tried that, I couldn't get it to work.  My autotools-fu is quite 
limited.

>
> OK for trunk (after bootstrap/regtest)?
I'll take a closer look later today, after my morning meetings.

>
> P.S. I am planning to post at least some of the other updated parts today, and I
> also hope to get in time with the whole series (before stage1 ends).
Excellent.

jeff

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 6/9] ENABLE_CHECKING refactoring: generators
  2015-10-19  0:09     ` Mikhail Maltsev
@ 2015-10-21 10:57       ` Richard Biener
  2015-10-28 16:32         ` Jeff Law
  2015-10-29 16:31       ` Jeff Law
  1 sibling, 1 reply; 77+ messages in thread
From: Richard Biener @ 2015-10-21 10:57 UTC (permalink / raw)
  To: Mikhail Maltsev; +Cc: gcc-patches mailing list, Jeff Law

On Mon, Oct 19, 2015 at 1:55 AM, Mikhail Maltsev <maltsevm@gmail.com> wrote:
> On 10/06/2015 03:56 PM, Richard Biener wrote:
>> The generators should simply unconditionally check (not in generated
>> files, of course).
>> And the generated code parts should use flag_checking.
>>
>> Richard.
>
> genautomata has some macros similar to tree checks, so I avoided changing them.
> genconditions for some reason #undef-s ENABLE_CHECKING in the generated code. I
> did not look at it in details, but decided to simply #define CHECKING_P to 0 for
> consistency.
>
> As for genextract and gengtype, I followed your recommendations, that is, used
> flag_checking instead of CHECKING_P in genextract, and always enable debugging
> functions in gengtype.

diff --git a/gcc/genextract.c b/gcc/genextract.c
index fe97701..a03ac97 100644
--- a/gcc/genextract.c
+++ b/gcc/genextract.c
@@ -373,10 +373,11 @@ insn_extract (rtx_insn *insn)\n{\n\
   rtx pat = PATTERN (insn);\n\
   int i ATTRIBUTE_UNUSED; /* only for peepholes */\n\
 \n\
-#ifdef ENABLE_CHECKING\n\
-  memset (ro, 0xab, sizeof (*ro) * MAX_RECOG_OPERANDS);\n\
-  memset (ro_loc, 0xab, sizeof (*ro_loc) * MAX_RECOG_OPERANDS);\n\
-#endif\n");
+  if (flag_checking)\n\
+    {\n\
+      memset (ro, 0xab, sizeof (*ro) * MAX_RECOG_OPERANDS);\n\
+      memset (ro_loc, 0xab, sizeof (*ro_loc) * MAX_RECOG_OPERANDS);\n\
+    }\n");



flag_checking will be never set, so as suggested make it do the checking bits
unconditionally.

Otherwise the patch is ok.  (needs sorting out the CHECKING_P vs.
ENABLE_CHECKING
elsewhere)

Thanks,
Richard.


> --
> Regards,
>     Mikhail Maltsev
>
> gcc/ChangeLog:
>
> 2015-10-19  Mikhail Maltsev  <maltsevm@gmail.com>
>
>         * genautomata.c: Use CHECKING_P instead of ENABLE_CHECKING.
>         * genconditions.c: Define CHECKING_P in the generated code.
>         * genextract.c: Use flag_checking in insn_extract.
>         * gengtype.c (main): Remove conditional compilation.
>         * gengtype.h: Likewise.

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 5/9] ENABLE_CHECKING refactoring: pool allocators
  2015-10-19  0:47       ` Mikhail Maltsev
@ 2015-10-21 11:02         ` Richard Biener
  2015-10-26  2:07           ` Mikhail Maltsev
  0 siblings, 1 reply; 77+ messages in thread
From: Richard Biener @ 2015-10-21 11:02 UTC (permalink / raw)
  To: Mikhail Maltsev; +Cc: Bernd Schmidt, gcc-patches mailing list, Jeff Law

On Mon, Oct 19, 2015 at 2:09 AM, Mikhail Maltsev <maltsevm@gmail.com> wrote:
> On 10/06/2015 03:45 PM, Richard Biener wrote:
>> On Tue, Oct 6, 2015 at 2:41 PM, Bernd Schmidt <bschmidt@redhat.com> wrote:
>>> On 10/06/2015 01:32 AM, Mikhail Maltsev wrote:
>>>>
>>>> gcc/ChangeLog:
>>>>
>>>> 2015-10-05  Mikhail Maltsev  <maltsevm@gmail.com>
>>>>
>>>>         * alloc-pool.h (base_pool_allocator::initialize, ::allocate,
>>>>         ::remove): Adjust to use CHECKING_P.
>>>
>>>
>>> Why CHECKING_P for these and not flag_checking as elsewhere?
>>
>> Probably because they are in inline functions and thus possibly would
>> affect optimization.  Not sure why they are inline functions in the
>> first place...  I'd agree to using flag_checking here.
>>
>> Richard.
>>
>>>
>>> Bernd
>
> Adjusted. Note: I had to include 'options.h' into 'alloc-pool.h' in order to use
> flag_checking.

Ugh (stupid templates).

@@ -387,10 +389,10 @@ base_pool_allocator <TBlockAllocator>::allocate ()
       block = m_virgin_free_list;
       header = (allocation_pool_list*) allocation_object::get_data (block);
       header->next = NULL;
-#ifdef ENABLE_CHECKING
+
       /* Mark the element to be free.  */
-      ((allocation_object*) block)->id = 0;
-#endif
+      if (flag_checking)
+       ((allocation_object*) block)->id = 0;

just set id to zero unconditionally.  That'll be faster than checking
flag_checking.

-#ifdef ENABLE_CHECKING
   /* Set the ID for element.  */
-  allocation_object::get_instance (header)->id = m_id;
-#endif
+  if (flag_checking)
+    allocation_object::get_instance (header)->id = m_id;

likewise.

Given that, the pool initialization itself can do with unconditonally
computing the id as well, thus

-#ifdef ENABLE_CHECKING
-  /* Increase the last used ID and use it for this pool.
-     ID == 0 is used for free elements of pool so skip it.  */
-  last_id++;
-  if (last_id == 0)
-    last_id++;
+  if (flag_checking)
+    {
+      /* Increase the last used ID and use it for this pool.
+        ID == 0 is used for free elements of pool so skip it.  */
+      last_id++;
+      if (last_id == 0)
+       last_id++;

-  m_id = last_id;
-#endif
+      m_id = last_id;
+    }

make that unconditionally enabled as well.

-#ifdef ENABLE_CHECKING
-  gcc_assert (object
+  gcc_checking_assert (object
              /* Check if we free more than we allocated, which is Bad (TM).  */
              && m_elts_free < m_elts_allocated
              /* Check whether the PTR was allocated from POOL.  */
              && m_id == allocation_object::get_instance (object)->id);

-  memset (object, 0xaf, size);
-
-  /* Mark the element to be free.  */
-  allocation_object::get_instance (object)->id = 0;
-#endif
+  if (flag_checking)
+    {
+      memset (object, 0xaf, size);
+      /* Mark the element to be free.  */
+      allocation_object::get_instance (object)->id = 0;
+    }


guard the assert with flag_checking and do the id set unconditionally
(for consistency).

Ok with those changes.

Thanks,
Richard.


> --
> Regards,
>     Mikhail Maltsev
>
> 2015-10-19  Mikhail Maltsev  <maltsevm@gmail.com>
>
>         * alloc-pool.h (base_pool_allocator ::initialize, ::allocate,
>         ::remove): Adjust to use flag_checking.

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 1/9] ENABLE_CHECKING refactoring
  2015-10-19 13:54       ` Mikhail Maltsev
@ 2015-10-21 15:59         ` Jeff Law
  2015-10-21 16:06           ` Bernd Schmidt
  0 siblings, 1 reply; 77+ messages in thread
From: Jeff Law @ 2015-10-21 15:59 UTC (permalink / raw)
  To: Mikhail Maltsev, Bernd Schmidt, gcc-patches mailing list, Richard Biener

On 10/19/2015 07:23 AM, Mikhail Maltsev wrote:
> On 10/19/2015 02:13 PM, Bernd Schmidt wrote:
>> But for normal C conditions the patches end up using flag_checking, so
>> the CHECKING_P macro buys us nothing over ENABLE_CHECKING.
> Presumably 'if (CHECKING_P)' can be used for performance-critical parts
> (in this case the condition will be DCE-d) and also for those parts of
> the compiler which we want to decouple from 'options.h'.
> IIRC, Jeff's idea was get rid of 'ENABLE_CHECKING' completely and use
> either 'flag_checking' or 'CHECKING_P'. But I don't know what is the
> consensus on it (I would like to hear Jeff's and Richard's opinion).
> Of course it will be easy for me to adjust the patch to whatever the
> final decision will be.
Bernd,

The problem is the existing ENABLE_CHECKING conditions.

Anything which is #ifdef ENABLE_CHECKING will have its behavior changed 
if we change things so that ENABLE_CHECKING is always defined with a value.

So if we wanted to continue to use ENABLE_CHECKING, but with a value, 
then every #ifdef has to be fixed all-at-once.

By using CHECKING_P we can incrementally work our way through uses of 
ENABLE_CHECKING, converting them as we go as we're not changing the 
meaning of ENABLE_CHECKING.

Once everything is converted, we just drop ENABLE_CHECKING completely.

Does using CHECKING_P make more churn?  Perhaps, but it allows us the 
freedom to incrementally fix the existing code rather than having to do 
everything at once.

jeff

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 1/9] ENABLE_CHECKING refactoring
  2015-10-21 15:59         ` Jeff Law
@ 2015-10-21 16:06           ` Bernd Schmidt
  2015-10-21 16:18             ` Richard Biener
  2015-10-21 16:19             ` Jeff Law
  0 siblings, 2 replies; 77+ messages in thread
From: Bernd Schmidt @ 2015-10-21 16:06 UTC (permalink / raw)
  To: Jeff Law, Mikhail Maltsev, gcc-patches mailing list, Richard Biener

On 10/21/2015 05:56 PM, Jeff Law wrote:
> The problem is the existing ENABLE_CHECKING conditions.
>
> Anything which is #ifdef ENABLE_CHECKING will have its behavior changed
> if we change things so that ENABLE_CHECKING is always defined with a value.
>
> So if we wanted to continue to use ENABLE_CHECKING, but with a value,
> then every #ifdef has to be fixed all-at-once.

But why change it to have a value? Just keep it as-is, and use 
flag_checking for runtime tests.


Bernd

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 1/9] ENABLE_CHECKING refactoring
  2015-10-21 16:06           ` Bernd Schmidt
@ 2015-10-21 16:18             ` Richard Biener
  2015-10-21 16:28               ` Jeff Law
  2015-10-21 16:19             ` Jeff Law
  1 sibling, 1 reply; 77+ messages in thread
From: Richard Biener @ 2015-10-21 16:18 UTC (permalink / raw)
  To: Bernd Schmidt, Jeff Law, Mikhail Maltsev, gcc-patches mailing list

On October 21, 2015 6:04:38 PM GMT+02:00, Bernd Schmidt <bschmidt@redhat.com> wrote:
>On 10/21/2015 05:56 PM, Jeff Law wrote:
>> The problem is the existing ENABLE_CHECKING conditions.
>>
>> Anything which is #ifdef ENABLE_CHECKING will have its behavior
>changed
>> if we change things so that ENABLE_CHECKING is always defined with a
>value.
>>
>> So if we wanted to continue to use ENABLE_CHECKING, but with a value,
>> then every #ifdef has to be fixed all-at-once.
>
>But why change it to have a value? Just keep it as-is, and use 
>flag_checking for runtime tests.

The goal is to get rid of conditional compilation.

Richard.

>
>Bernd


^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 1/9] ENABLE_CHECKING refactoring
  2015-10-21 16:06           ` Bernd Schmidt
  2015-10-21 16:18             ` Richard Biener
@ 2015-10-21 16:19             ` Jeff Law
  2015-10-21 16:22               ` Bernd Schmidt
  1 sibling, 1 reply; 77+ messages in thread
From: Jeff Law @ 2015-10-21 16:19 UTC (permalink / raw)
  To: Bernd Schmidt, Mikhail Maltsev, gcc-patches mailing list, Richard Biener

On 10/21/2015 10:04 AM, Bernd Schmidt wrote:
> On 10/21/2015 05:56 PM, Jeff Law wrote:
>> The problem is the existing ENABLE_CHECKING conditions.
>>
>> Anything which is #ifdef ENABLE_CHECKING will have its behavior changed
>> if we change things so that ENABLE_CHECKING is always defined with a
>> value.
>>
>> So if we wanted to continue to use ENABLE_CHECKING, but with a value,
>> then every #ifdef has to be fixed all-at-once.
>
> But why change it to have a value? Just keep it as-is, and use
> flag_checking for runtime tests.
To avoid conditionally compiled code.  I'm of the opinion we should be 
stomping out as much as we reasonably can.

Essentially each blob of code that is conditionally compiled represents 
two paths that can't be tested for basic syntax correctness together. 
As a result we regularly see one of the two paths being broken from a 
syntax point of view.

By stomping out the conditionally compiled code a standard build will 
test both paths for basic syntax correctness.  It'll take time to get 
there, but that's where things, IMHO, need to go to help reduce the long 
term cost of maintenance.


jeff

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 1/9] ENABLE_CHECKING refactoring
  2015-10-21 16:19             ` Jeff Law
@ 2015-10-21 16:22               ` Bernd Schmidt
  2015-10-21 16:44                 ` Jakub Jelinek
  2015-10-21 20:06                 ` Jeff Law
  0 siblings, 2 replies; 77+ messages in thread
From: Bernd Schmidt @ 2015-10-21 16:22 UTC (permalink / raw)
  To: Jeff Law, Mikhail Maltsev, gcc-patches mailing list, Richard Biener

On 10/21/2015 06:18 PM, Jeff Law wrote:
> To avoid conditionally compiled code.  I'm of the opinion we should be
> stomping out as much as we reasonably can.

Yeah, I get that, but the point I'm trying to make is that if you get 
rid of all conditional compilation, you don't need either 
ENABLE_CHECKING or CHECKING_P, because you'll be testing flag_checking. 
And if some conditional compilation remains (let's say in the 
cumulative_args case), then there's no win from changing the spelling 
from ENABLE_CHECKING to CHECKING_P.


Bernd

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 1/9] ENABLE_CHECKING refactoring
  2015-10-21 16:18             ` Richard Biener
@ 2015-10-21 16:28               ` Jeff Law
  2015-11-07 22:42                 ` Gerald Pfeifer
  0 siblings, 1 reply; 77+ messages in thread
From: Jeff Law @ 2015-10-21 16:28 UTC (permalink / raw)
  To: Richard Biener, Bernd Schmidt, Mikhail Maltsev, gcc-patches mailing list

On 10/21/2015 10:18 AM, Richard Biener wrote:
> On October 21, 2015 6:04:38 PM GMT+02:00, Bernd Schmidt <bschmidt@redhat.com> wrote:
>> On 10/21/2015 05:56 PM, Jeff Law wrote:
>>> The problem is the existing ENABLE_CHECKING conditions.
>>>
>>> Anything which is #ifdef ENABLE_CHECKING will have its behavior
>> changed
>>> if we change things so that ENABLE_CHECKING is always defined with a
>> value.
>>>
>>> So if we wanted to continue to use ENABLE_CHECKING, but with a value,
>>> then every #ifdef has to be fixed all-at-once.
>>
>> But why change it to have a value? Just keep it as-is, and use
>> flag_checking for runtime tests.
>
> The goal is to get rid of conditional compilation.
Precisely.  I've been watching some other projects going down this path 
and seeing good results.  I strongly believe it'll help drive down the 
development/maintenance costs for GCC.

I might even claim it's already helping.  While we're still seeing 
syntax errors in the conditionally compiled code, it doesn't feel like 
we're seeing it as often as in the past.  That's purely anecdotal based 
on what I've seen fly by over the last couple years.


Jeff


^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 1/9] ENABLE_CHECKING refactoring
  2015-10-21 16:22               ` Bernd Schmidt
@ 2015-10-21 16:44                 ` Jakub Jelinek
  2015-10-22  7:58                   ` Richard Biener
  2015-10-21 20:06                 ` Jeff Law
  1 sibling, 1 reply; 77+ messages in thread
From: Jakub Jelinek @ 2015-10-21 16:44 UTC (permalink / raw)
  To: Bernd Schmidt
  Cc: Jeff Law, Mikhail Maltsev, gcc-patches mailing list, Richard Biener

On Wed, Oct 21, 2015 at 06:22:37PM +0200, Bernd Schmidt wrote:
> On 10/21/2015 06:18 PM, Jeff Law wrote:
> >To avoid conditionally compiled code.  I'm of the opinion we should be
> >stomping out as much as we reasonably can.
> 
> Yeah, I get that, but the point I'm trying to make is that if you get rid of
> all conditional compilation, you don't need either ENABLE_CHECKING or
> CHECKING_P, because you'll be testing flag_checking. And if some conditional
> compilation remains (let's say in the cumulative_args case), then there's no
> win from changing the spelling from ENABLE_CHECKING to CHECKING_P.

So, what is the plan with flag_checking?  Will --enable-checking=yes vs.
release just affect the default value of that flag, or will it be turned
into 0 for release builds?  If the former, I'd at least like to see
a __builtin_expect making it unlikely for the release builds and likely for
the development builds (to match the default value).

	Jakub

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 1/9] ENABLE_CHECKING refactoring
  2015-10-21 16:22               ` Bernd Schmidt
  2015-10-21 16:44                 ` Jakub Jelinek
@ 2015-10-21 20:06                 ` Jeff Law
  1 sibling, 0 replies; 77+ messages in thread
From: Jeff Law @ 2015-10-21 20:06 UTC (permalink / raw)
  To: Bernd Schmidt, Mikhail Maltsev, gcc-patches mailing list, Richard Biener

On 10/21/2015 10:22 AM, Bernd Schmidt wrote:
> On 10/21/2015 06:18 PM, Jeff Law wrote:
>> To avoid conditionally compiled code.  I'm of the opinion we should be
>> stomping out as much as we reasonably can.
>
> Yeah, I get that, but the point I'm trying to make is that if you get
> rid of all conditional compilation, you don't need either
> ENABLE_CHECKING or CHECKING_P, because you'll be testing flag_checking.
> And if some conditional compilation remains (let's say in the
> cumulative_args case), then there's no win from changing the spelling
> from ENABLE_CHECKING to CHECKING_P.
But if you can't make the change as a single atomic commit, then we run 
the risk of turning on checking bits when ENABLE_CHECKING is defined to 0.

CHECKING_P allows us to pursue removal of the conditionally compiled 
code incrementally.  Each removal of a hunk of conditionally compiled 
code is possible independently of all the other removals.

jeff

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 1/9] ENABLE_CHECKING refactoring
  2015-10-18  8:25   ` Mikhail Maltsev
  2015-10-19 11:14     ` Bernd Schmidt
  2015-10-20 16:14     ` Jeff Law
@ 2015-10-21 21:17     ` Jeff Law
  2 siblings, 0 replies; 77+ messages in thread
From: Jeff Law @ 2015-10-21 21:17 UTC (permalink / raw)
  To: Mikhail Maltsev, gcc-patches mailing list, Richard Biener

On 10/18/2015 12:17 AM, Mikhail Maltsev wrote:
>
> Also, gcc_checking_assert in libcpp requires gcc_assert to be defined. That was
> missing in my original patch (and was added in patch 2/9), but I think it would
> be better to fix it here, as Bernd noticed (in the last paragraph of [1]).
>
> Besides, I like Richard's proposal [2] about moving CHECKING_P macros into
> configure.ac.
>
> [1] https://gcc.gnu.org/ml/gcc-patches/2015-10/msg00550.html
> [2] https://gcc.gnu.org/ml/gcc-patches/2015-10/msg00555.html
>
> It required minor tweaking in order to silence autotools' warnings. I attached
> the modified patch.
>
> OK for trunk (after bootstrap/regtest)?
>
> P.S. I am planning to post at least some of the other updated parts today, and I
> also hope to get in time with the whole series (before stage1 ends).
OK for the trunk.  And I went ahead and installed the patch for you.

jeff

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 2/9] ENABLE_CHECKING refactoring: libcpp
  2015-10-06 12:40   ` Bernd Schmidt
  2015-10-12 20:57     ` Jeff Law
@ 2015-10-21 21:19     ` Jeff Law
  1 sibling, 0 replies; 77+ messages in thread
From: Jeff Law @ 2015-10-21 21:19 UTC (permalink / raw)
  To: Bernd Schmidt, Mikhail Maltsev, gcc-patches mailing list, Richard Biener

On 10/06/2015 06:40 AM, Bernd Schmidt wrote:
> I'm not entirely sure what to make of this series. There seem to be good
> bits in there but also some things I find questionable. I'll add some
> comments on things that occur to me.
>
> On 10/06/2015 01:28 AM, Mikhail Maltsev wrote:
>>
>>     * include/line-map.h: Fix use of ENABLE_CHECKING.
>
> Fix how? What's wrong with it?
I think it was just a poor choice of words for the ChangeLog.


> Probably a good thing, but it looks like libcpp has grown its own
> variant linemap_assert; we should check whether that can be replaced.
Agreed.  Let's push it onto the queue of things to clean up.

jeff

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 2/9] ENABLE_CHECKING refactoring: libcpp
  2015-10-19  1:18       ` Mikhail Maltsev
@ 2015-10-21 22:29         ` Jeff Law
  0 siblings, 0 replies; 77+ messages in thread
From: Jeff Law @ 2015-10-21 22:29 UTC (permalink / raw)
  To: Mikhail Maltsev, Bernd Schmidt, gcc-patches mailing list, Richard Biener

On 10/18/2015 06:56 PM, Mikhail Maltsev wrote:
> On 10/12/2015 11:57 PM, Jeff Law wrote:
>> >On 10/06/2015 06:40 AM, Bernd Schmidt wrote:
>>> >>I'm not entirely sure what to make of this series. There seem to be good
>>> >>bits in there but also some things I find questionable. I'll add some
>>> >>comments on things that occur to me.
>> >Maybe we should start pulling out the bits that we think are ready & good and
>> >start installing them independently.
>> >
> (snip)
>
>>> >>Probably a good thing, but it looks like libcpp has grown its own
>>> >>variant linemap_assert; we should check whether that can be replaced.
>>> >>
>>> >>Also, the previous patch already introduces a use of gcc_assert, or at
>>> >>least a reference to it, and it's only defined here. The two
>>> >>modifications of libcpp/system.h should probably be merged into one.
>> >Agreed.
>> >
>> >jeff
> I moved the 'libcpp/system.h' parts into the first patch of the series. As for
> replacing linemap_assert, I hope it can be done separately.
Thanks.  I went ahead and tested, then installed patch #2.

And yes, I think replacing linemap_assert can be done as a follow-up.


jeff

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 1/9] ENABLE_CHECKING refactoring
  2015-10-21 16:44                 ` Jakub Jelinek
@ 2015-10-22  7:58                   ` Richard Biener
  0 siblings, 0 replies; 77+ messages in thread
From: Richard Biener @ 2015-10-22  7:58 UTC (permalink / raw)
  To: Jakub Jelinek
  Cc: Bernd Schmidt, Jeff Law, Mikhail Maltsev, gcc-patches mailing list

On Wed, Oct 21, 2015 at 6:27 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Wed, Oct 21, 2015 at 06:22:37PM +0200, Bernd Schmidt wrote:
>> On 10/21/2015 06:18 PM, Jeff Law wrote:
>> >To avoid conditionally compiled code.  I'm of the opinion we should be
>> >stomping out as much as we reasonably can.
>>
>> Yeah, I get that, but the point I'm trying to make is that if you get rid of
>> all conditional compilation, you don't need either ENABLE_CHECKING or
>> CHECKING_P, because you'll be testing flag_checking. And if some conditional
>> compilation remains (let's say in the cumulative_args case), then there's no
>> win from changing the spelling from ENABLE_CHECKING to CHECKING_P.
>
> So, what is the plan with flag_checking?  Will --enable-checking=yes vs.
> release just affect the default value of that flag, or will it be turned
> into 0 for release builds?  If the former, I'd at least like to see
> a __builtin_expect making it unlikely for the release builds and likely for
> the development builds (to match the default value).

My plan is to make flag_checking a runtine controllable value (via -fchecking)
so if you run into an issue with a release build you can still do -fchecking
with the same build.  We can't (and shouldn't) guard everything with
flag_checking
because the hit on compile-time with flag_checking == 0 will be too
big (like the
tree checking macros).  But for example all the verify_XXX () calls
can be safely
guarded by flag_checking.

So we _do_ want a always-defined ENABLE_CHECKING (or CHECKING_P) to
be able to remove conditional compilation for cases where we do not want to
do runtime checks for performance reasons.

Richard.

>         Jakub

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 3/9] ENABLE_CHECKING refactoring: Java and Ada
  2015-10-05 23:30 ` [PATCH 3/9] ENABLE_CHECKING refactoring: Java and Ada Mikhail Maltsev
@ 2015-10-22 19:25   ` Jeff Law
  0 siblings, 0 replies; 77+ messages in thread
From: Jeff Law @ 2015-10-22 19:25 UTC (permalink / raw)
  To: Mikhail Maltsev, gcc-patches mailing list, Richard Biener

On 10/05/2015 05:30 PM, Mikhail Maltsev wrote:
> gcc/java/ChangeLog:
>
> 2015-10-05  Mikhail Maltsev<maltsevm@gmail.com>
>
> 	* decl.c (java_mark_decl_local): Use flag_checking instead of
> 	ENABLE_CHECKING.
>
>
> gcc/ada/ChangeLog:
>
> 2015-10-05  Mikhail Maltsev<maltsevm@gmail.com>
>
> 	* gcc-interface/decl.c (gnat_to_gnu_entity): Use gcc_checking_assert.
> 	* gcc-interface/trans.c (assoc_to_constructor): Use flag_checking.
> 	* gcc-interface/utils.c (relate_alias_sets): Likewise.
> 	* gcc-interface/utils2.c (build_binary_op, build_unary_op): Use
> 	gcc_checking_assert
>
>
>
> 0003-Ada-and-Java-FE-s.patch
>
>
>  From e8de7d2dc24cff85b6c1e44157dad23c85e435e1 Mon Sep 17 00:00:00 2001
> From: Mikhail Maltsev<maltsevm@gmail.com>
> Date: Sun, 20 Sep 2015 05:06:01 +0300
> Subject: [PATCH 3/9] Ada and Java FE's
>
> ---
>   gcc/ada/gcc-interface/decl.c   |  4 +---
>   gcc/ada/gcc-interface/trans.c  | 11 ++++++-----
>   gcc/ada/gcc-interface/utils.c  |  4 +---
>   gcc/ada/gcc-interface/utils2.c | 20 ++++++++------------
>   gcc/java/decl.c                |  4 +---
>   5 files changed, 17 insertions(+), 26 deletions(-)
>
> diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c
> index 0f3087d..7906495 100644
> --- a/gcc/ada/gcc-interface/utils.c
> +++ b/gcc/ada/gcc-interface/utils.c
> @@ -1499,9 +1499,7 @@ relate_alias_sets (tree gnu_new_type, tree gnu_old_type, enum alias_set_op op)
>         /* The alias set shouldn't be copied between array types with different
>   	 aliasing settings because this can break the aliasing relationship
>   	 between the array type and its element type.  */
> -#ifndef ENABLE_CHECKING
> -      if (flag_strict_aliasing)
> -#endif
> +      if (flag_checking || flag_strict_aliasing)
>   	gcc_assert (!(TREE_CODE (gnu_new_type) == ARRAY_TYPE
>   		      && TREE_CODE (gnu_old_type) == ARRAY_TYPE
>   		      && TYPE_NONALIASED_COMPONENT (gnu_new_type)
I wonder who wrote that gem initially.  I don't like conditional 
compilation, I don't like the original code here even more.  Having the 
IF, but not the true/false arms conditionally compiled is just gross.

Having said that, I hope it wasn't me that wrote the code :-)


I've installed this on the trunk.

jeff

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 4/9] ENABLE_CHECKING refactoring: Fortran
  2015-10-05 23:31 ` [PATCH 4/9] ENABLE_CHECKING refactoring: Fortran Mikhail Maltsev
@ 2015-10-23 22:38   ` Jeff Law
  0 siblings, 0 replies; 77+ messages in thread
From: Jeff Law @ 2015-10-23 22:38 UTC (permalink / raw)
  To: Mikhail Maltsev, gcc-patches mailing list, Richard Biener

On 10/05/2015 05:31 PM, Mikhail Maltsev wrote:
> 2015-10-05  Mikhail Maltsev<maltsevm@gmail.com>
>
> 	* trans-common.c (create_common): Adjust to use flag_checking.
> 	* trans.c (gfc_add_modify_loc): Use gcc_checking_assert.
I went ahead and did independent testing on this patch, x86_64-linux-gnu 
as well as building everything in config-list.mk

I've installed this patch on the trunk.

I believe Richi has already approved the updated patch #5.  So please go 
ahead and install that patch.

Thanks,
Jeff

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 5/9] ENABLE_CHECKING refactoring: pool allocators
  2015-10-21 11:02         ` Richard Biener
@ 2015-10-26  2:07           ` Mikhail Maltsev
  2015-10-26  9:48             ` Richard Biener
  0 siblings, 1 reply; 77+ messages in thread
From: Mikhail Maltsev @ 2015-10-26  2:07 UTC (permalink / raw)
  To: Richard Biener; +Cc: Bernd Schmidt, gcc-patches mailing list, Jeff Law

[-- Attachment #1: Type: text/plain, Size: 696 bytes --]

On 10/21/2015 01:57 PM, Richard Biener wrote:
> Ugh (stupid templates).
> 
> @@ -387,10 +389,10 @@ base_pool_allocator <TBlockAllocator>::allocate ()
>        block = m_virgin_free_list;
>        header = (allocation_pool_list*) allocation_object::get_data (block);
>        header->next = NULL;
> -#ifdef ENABLE_CHECKING
> +
>        /* Mark the element to be free.  */
> -      ((allocation_object*) block)->id = 0;
> -#endif
> +      if (flag_checking)
> +       ((allocation_object*) block)->id = 0;
> 
> just set id to zero unconditionally.  That'll be faster than checking
> flag_checking.

I fixed this and other issues, and committed the attached patch.

-- 
Regards,
    Mikhail Maltsev

[-- Attachment #2: alloc_checking2.patch --]
[-- Type: text/x-patch, Size: 3347 bytes --]

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 81d0e1c..d8a22c3 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2015-10-26  Mikhail Maltsev  <maltsevm@gmail.com>
+
+	* alloc-pool.h (base_pool_allocator::initialize, ::allocate): Remove
+	conditional compilation.
+	(base_pool_allocator::remove): Use flag_checking.
+
 2015-10-25  John David Anglin  <danglin@gcc.gnu.org>
 
 	* config/pa/som.h (EH_FRAME_THROUGH_COLLECT2): Define.
diff --git a/gcc/alloc-pool.h b/gcc/alloc-pool.h
index 70105ba..404b558 100644
--- a/gcc/alloc-pool.h
+++ b/gcc/alloc-pool.h
@@ -21,6 +21,7 @@ along with GCC; see the file COPYING3.  If not see
 #define ALLOC_POOL_H
 
 #include "memory-block.h"
+#include "options.h"	    // for flag_checking
 
 extern void dump_alloc_pool_statistics (void);
 
@@ -275,7 +276,6 @@ base_pool_allocator <TBlockAllocator>::initialize ()
   m_elts_per_block = (TBlockAllocator::block_size - header_size) / size;
   gcc_checking_assert (m_elts_per_block != 0);
 
-#ifdef ENABLE_CHECKING
   /* Increase the last used ID and use it for this pool.
      ID == 0 is used for free elements of pool so skip it.  */
   last_id++;
@@ -283,7 +283,6 @@ base_pool_allocator <TBlockAllocator>::initialize ()
     last_id++;
 
   m_id = last_id;
-#endif
 }
 
 /* Free all memory allocated for the given memory pool.  */
@@ -387,10 +386,9 @@ base_pool_allocator <TBlockAllocator>::allocate ()
       block = m_virgin_free_list;
       header = (allocation_pool_list*) allocation_object::get_data (block);
       header->next = NULL;
-#ifdef ENABLE_CHECKING
+
       /* Mark the element to be free.  */
       ((allocation_object*) block)->id = 0;
-#endif
       VALGRIND_DISCARD (VALGRIND_MAKE_MEM_NOACCESS (header,size));
       m_returned_free_list = header;
       m_virgin_free_list += m_elt_size;
@@ -404,10 +402,8 @@ base_pool_allocator <TBlockAllocator>::allocate ()
   m_returned_free_list = header->next;
   m_elts_free--;
 
-#ifdef ENABLE_CHECKING
   /* Set the ID for element.  */
   allocation_object::get_instance (header)->id = m_id;
-#endif
   VALGRIND_DISCARD (VALGRIND_MAKE_MEM_UNDEFINED (header, size));
 
   return (void *)(header);
@@ -418,26 +414,23 @@ template <typename TBlockAllocator>
 inline void
 base_pool_allocator <TBlockAllocator>::remove (void *object)
 {
-  gcc_checking_assert (m_initialized);
-
-  allocation_pool_list *header;
-  int size ATTRIBUTE_UNUSED;
-  size = m_elt_size - offsetof (allocation_object, u.data);
-
-#ifdef ENABLE_CHECKING
-  gcc_assert (object
+  if (flag_checking)
+    {
+      gcc_assert (m_initialized);
+      gcc_assert (object
 	      /* Check if we free more than we allocated, which is Bad (TM).  */
 	      && m_elts_free < m_elts_allocated
 	      /* Check whether the PTR was allocated from POOL.  */
 	      && m_id == allocation_object::get_instance (object)->id);
 
-  memset (object, 0xaf, size);
+      int size = m_elt_size - offsetof (allocation_object, u.data);
+      memset (object, 0xaf, size);
+    }
 
   /* Mark the element to be free.  */
   allocation_object::get_instance (object)->id = 0;
-#endif
 
-  header = (allocation_pool_list*) object;
+  allocation_pool_list *header = (allocation_pool_list*) object;
   header->next = m_returned_free_list;
   m_returned_free_list = header;
   VALGRIND_DISCARD (VALGRIND_MAKE_MEM_NOACCESS (object, size));

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 5/9] ENABLE_CHECKING refactoring: pool allocators
  2015-10-26  2:07           ` Mikhail Maltsev
@ 2015-10-26  9:48             ` Richard Biener
  2015-10-26 10:57               ` Mikhail Maltsev
  0 siblings, 1 reply; 77+ messages in thread
From: Richard Biener @ 2015-10-26  9:48 UTC (permalink / raw)
  To: Mikhail Maltsev; +Cc: Bernd Schmidt, gcc-patches mailing list, Jeff Law

[-- Attachment #1: Type: text/plain, Size: 1097 bytes --]

On Mon, Oct 26, 2015 at 2:18 AM, Mikhail Maltsev <maltsevm@gmail.com> wrote:
> On 10/21/2015 01:57 PM, Richard Biener wrote:
>> Ugh (stupid templates).
>>
>> @@ -387,10 +389,10 @@ base_pool_allocator <TBlockAllocator>::allocate ()
>>        block = m_virgin_free_list;
>>        header = (allocation_pool_list*) allocation_object::get_data (block);
>>        header->next = NULL;
>> -#ifdef ENABLE_CHECKING
>> +
>>        /* Mark the element to be free.  */
>> -      ((allocation_object*) block)->id = 0;
>> -#endif
>> +      if (flag_checking)
>> +       ((allocation_object*) block)->id = 0;
>>
>> just set id to zero unconditionally.  That'll be faster than checking
>> flag_checking.
>
> I fixed this and other issues, and committed the attached patch.

I committed the attached to fix build with the valgrind annotations active.

Richard.

2015-10-26  Richard Biener  <rguenther@suse.de>

        * alloc-pool.h (base_pool_allocator): Use placement new.
        (base_pool_allocator::remove): Likewise.  Compute size outside of
        flag_checking.


> --
> Regards,
>     Mikhail Maltsev

[-- Attachment #2: p --]
[-- Type: application/octet-stream, Size: 1659 bytes --]

2015-10-26  Richard Biener  <rguenther@suse.de>

	* alloc-pool.h (base_pool_allocator): Use placement new.
	(base_pool_allocator::remove): Likewise.  Compute size outside of
	flag_checking.

Index: gcc/alloc-pool.h
===================================================================
--- gcc/alloc-pool.h	(revision 229307)
+++ gcc/alloc-pool.h	(working copy)
@@ -363,7 +363,7 @@ base_pool_allocator <TBlockAllocator>::a
 
 	  /* Make the block.  */
 	  block = reinterpret_cast<char *> (TBlockAllocator::allocate ());
-	  block_header = (allocation_pool_list*) block;
+	  block_header = new (block) allocation_pool_list;
 	  block += align_eight (sizeof (allocation_pool_list));
 
 	  /* Throw it on the block list.  */
@@ -414,6 +414,8 @@ template <typename TBlockAllocator>
 inline void
 base_pool_allocator <TBlockAllocator>::remove (void *object)
 {
+  int size = m_elt_size - offsetof (allocation_object, u.data);
+
   if (flag_checking)
     {
       gcc_assert (m_initialized);
@@ -423,14 +425,13 @@ base_pool_allocator <TBlockAllocator>::r
 	      /* Check whether the PTR was allocated from POOL.  */
 	      && m_id == allocation_object::get_instance (object)->id);
 
-      int size = m_elt_size - offsetof (allocation_object, u.data);
       memset (object, 0xaf, size);
     }
 
   /* Mark the element to be free.  */
   allocation_object::get_instance (object)->id = 0;
 
-  allocation_pool_list *header = (allocation_pool_list*) object;
+  allocation_pool_list *header = new (object) allocation_pool_list;
   header->next = m_returned_free_list;
   m_returned_free_list = header;
   VALGRIND_DISCARD (VALGRIND_MAKE_MEM_NOACCESS (object, size));

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 5/9] ENABLE_CHECKING refactoring: pool allocators
  2015-10-26  9:48             ` Richard Biener
@ 2015-10-26 10:57               ` Mikhail Maltsev
  0 siblings, 0 replies; 77+ messages in thread
From: Mikhail Maltsev @ 2015-10-26 10:57 UTC (permalink / raw)
  To: Richard Biener; +Cc: Bernd Schmidt, gcc-patches mailing list, Jeff Law

On 10/26/2015 12:47 PM, Richard Biener wrote:
> I committed the attached to fix build with the valgrind annotations active.
> 
> Richard.
> 
Doh! Sorry for breakage.

-- 
Regards,
    Mikhail Maltsev

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 7/9] ENABLE_CHECKING refactoring: middle-end, LTO FE
  2015-10-19 12:19         ` Bernd Schmidt
@ 2015-10-26 17:04           ` Jeff Law
  2015-10-26 17:15             ` Bernd Schmidt
  0 siblings, 1 reply; 77+ messages in thread
From: Jeff Law @ 2015-10-26 17:04 UTC (permalink / raw)
  To: Bernd Schmidt, Mikhail Maltsev, Richard Biener; +Cc: gcc-patches mailing list

On 10/19/2015 06:13 AM, Bernd Schmidt wrote:
>> diff --git a/gcc/cfgcleanup.c b/gcc/cfgcleanup.c
>> -
>> -#ifdef ENABLE_CHECKING
>> -              verify_flow_info ();
>> -#endif
>> +          checking_verify_flow_info ();
>
> This looks misindented.
Looks that way, but it was a spaces vs tabs issue.  Oh how I long for 
the day when there's a commit hook that just fixes that stuff for us.


>
>> -#ifdef ENABLE_CHECKING
>>         cgraph_edge *e;
>>         gcc_checking_assert (
>>       !(e = caller->get_edge (call_stmt)) || e->speculative);
>> -#endif
>
> While you're here, that would look nicer as
>           gcc_checking_assert (!(e = caller->get_edge (call_stmt))
>                                || e->speculative);
Agreed & fixed.

>
>> -#ifdef ENABLE_CHECKING
>> -  if (check_same_comdat_groups)
>> +  if (CHECKING_P && check_same_comdat_groups)
>
> flag_checking
Agreed & fixed.

>
>> -#ifdef ENABLE_CHECKING
>> -  struct df_rd_bb_info *bb_info = DF_RD_BB_INFO (g->bb);
>> -#endif
>> +  struct df_rd_bb_info *bb_info = flag_checking ? DF_RD_BB_INFO (g->bb)
>> +                        : NULL;
>
> I think no need to make that conditional, that's a bit too ugly.
Given that BB_INFO is only used in a checking path, I think we can just 
sink the variable and its initialization into that path and drop the 
conditional nonsense.  Done.  Fixed minor indention in the assert as well.



>
>> +      if (CHECKING_P)
>> +    sparseset_set_bit (active_defs_check, regno);
>
>> +  if (CHECKING_P)
>> +    sparseset_clear (active_defs_check);
>
>  > -#ifdef ENABLE_CHECKING
>  > -  active_defs_check = sparseset_alloc (max_reg_num ());
>  > -#endif
>
>  > +  if (CHECKING_P)
>  > +    active_defs_check = sparseset_alloc (max_reg_num ());
>
>  > +  if (CHECKING_P)
>  > +    sparseset_free (active_defs_check);
>
> flag_checking. Lots of other occurrences, I'll mention some but not all
> but please fix them for consistency.
Those which were used in conditionals like above I fixed.  I left the 
CPP conditionals alone.  Obviously a second round of conditional 
compilation is going to be needed :-)

>
>>   void
>>   sem_item_optimizer::verify_classes (void)
>>   {
>> -#if ENABLE_CHECKING
>> +  if (!flag_checking)
>> +    return;
>> +
>
> Not entirely sure whether you want to wrap this into a
> checking_verify_classes instead so that it remains easily callable by
> the debugger?
I'd tend to agree.  If I call a verify routine from the debugger, I 
expect it to actually verify state, not to early exit because checking 
was turned off entirely.  I clearly missed that when initially reviewing 
the ICF work.

I think pushing the conditional up to the callers should be sufficient, 
which is what I've done.



>
>> +      if (flag_checking)
>> +        {
>> +          for (symtab_node *n = node->same_comdat_group;
>> +           n != node;
>> +           n = n->same_comdat_group)
>> +        /* If at least one of same comdat group functions is external,
>> +           all of them have to be, otherwise it is a front-end bug.  */
>> +        gcc_assert (DECL_EXTERNAL (n->decl));
>> +        }
>
> Unnecessary set of braces.
Agreed.  But I've looked at both formattings and the one above actually 
seems easier to look at visually to me.  I thought it might be the 
comments making the code look like a longer block, so I tried pushing in 
the extra braces, but that wasn't really an improvement (to me) over 
Mikhai's version.

I left it as-is.  Obviously if you really want the unnecessary braces 
squashed out, we can do that.


>
>> diff --git a/gcc/lra-assigns.c b/gcc/lra-assigns.c
>> index 2986f57..941a829 100644
>> --- a/gcc/lra-assigns.c
>> +++ b/gcc/lra-assigns.c
>> @@ -1591,7 +1591,7 @@ lra_assign (void)
>>     bitmap_initialize (&all_spilled_pseudos, &reg_obstack);
>>     create_live_range_start_chains ();
>>     setup_live_pseudos_and_spill_after_risky_transforms
>> (&all_spilled_pseudos);
>> -#ifdef ENABLE_CHECKING
>> +#if CHECKING_P
>>     if (!flag_ipa_ra)
>>       for (i = FIRST_PSEUDO_REGISTER; i < max_regno; i++)
>>         if (lra_reg_info[i].nrefs != 0 && reg_renumber[i] >= 0
>
> Seems inconsistent, use flag_checking and no #if? Looks like the problem
> you're trying to solve is that a structure field exists only with
> checking, I think that could just be made available unconditionally -
> the struct is huge anyway.
Yea, more importantly, I don't like structs that change size based on 
checking bits.   I've made the field available and removed the 
conditional assignment to the field.  I can't see how this could 
possibly be performance critical.

>
> As mentioned in the other mail, I see no value changing the #ifdefs to
> #ifs here or elsewhere in the patch.
>
>> -  check_rtl (false);
>> -#endif
>> +  if (flag_checking)
>> +    check_rtl (/*final_p=*/false);
>
> Lose the /*final_p=*/.
Fixed both occurrences.

>
>> -#ifdef ENABLE_CHECKING
>> +#if CHECKING_P
>>             gcc_assert (!bitmap_bit_p (output, DECL_UID (node->decl)));
>>             bitmap_set_bit (output, DECL_UID (node->decl));
>>   #endif
>
> Not entirely clear why this isn't using flag_checking.
Me neither.   I think we can drop the conditional code here.  Just to be 
consistent with current behaviour, enclosing initialization of OUTPUT in 
a flag_checking conditional.

There's some chance that we could get a "may be used uninitialized" 
warning if we do that.  I'll try it and see what happens in practice.

>
>>         tree t = (*trees)[i];
>> -#ifdef ENABLE_CHECKING
>> -      if (TYPE_P (t))
>> +      if (CHECKING_P && TYPE_P (t))
>>           verify_type (t);
>> -#endif
>
> flag_checking
Fixed.

>
>> @@ -14108,7 +14102,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p,
>> omp_context *ctx)
>>         default:
>>       break;
>>         case OMP_CLAUSE_MAP:
>> -#ifdef ENABLE_CHECKING
>> +#if CHECKING_P
>>       /* First check what we're prepared to handle in the following.  */
>>       switch (OMP_CLAUSE_MAP_KIND (c))
>>         {
>
> Here too...
Likewise.

>
>> -#ifdef ENABLE_CHECKING
>> -static void
>> +static void DEBUG_FUNCTION
>>   verify_curr_properties (function *fn, void *data)
>
> Hmm, I noticed a few cases where we lost the DEBUG_FUNCTION annotation
> and was going to comment that this is one is odd - but don't we actually
> want to keep DEBUG_FUNCTION annotations for the others as well so that
> they don't get inlined everywhere and eliminated?
I would think so.  I'll do a pass over and put them back where they got 
lost.



>
>> +      if (flag_checking)
>> +        {
>> +          FOR_EACH_EDGE (e, ei, bb->preds)
>> +        gcc_assert (!bitmap_bit_p (tovisit, e->src->index)
>> +                || (e->flags & EDGE_DFS_BACK));
>> +        }
>
> Unnecessary braces.
Fixed.

>
>> +  if (CHECKING_P)
>> +    {
>> +      for (; argno < PP_NL_ARGMAX; argno++)
>> +    gcc_assert (!formatters[argno]);
>> +    }
>
> Here too. Use flag_checking.
Fixed.

>
>> +  if (CHECKING_P && mode != VOIDmode)
>
> flag_checking.
Fixed.

>
>> -#ifdef ENABLE_CHECKING
>>   static void
>>   validate_value_data (struct value_data *vd)
>>   {
>> +  if (!flag_checking)
>> +    return;
>
> Same thought as before, it might be better to have this check in the
> callers for easier use from the debugger.
Agreed & fixed.

>
>> -#endif
>> -
>>
>> +
>
> Don't change the whitespace here. Looks like you probably removed a page
> break.
Not obvious where it got lost as there's no filename in the review 
comments :-)

>
>>
>> -#ifdef ENABLE_CHECKING
>> +#if CHECKING_P
>>     /* This is initialized to the insn on which the driver stopped its
>> traversal.  */
>>     insn_t failed_insn;
>>   #endif
>
> I think here it would also be reasonable to make the field (and its
> initializations) unconditional and use flag_checking for the code using it.
Agreed & done.  There's an awful line break in the usage.  I didn't try 
to fix that.

>
>> -#ifdef ENABLE_CHECKING
>> -  {
>> -    edge e;
>> -    edge_iterator ei;
>> +/* FIXME: (PR 67842) this check is incorrect.  dominated_by_p has no
>> effect,
>> +   but changing it to gcc_assert (dominated_by_p (...)) causes
>> regressions,
>> +   e.g., gcc.dg/graphite/block-1.c.  */
>> +#if 0
>
> This change should probably be submitted separately, people are more
> likely to see it than if it's buried in a sea of cosmetic changes.
Agreed.  Removed from this changeset.

>
>> +      if (flag_checking)
>> +    {
>> +      /* last_set_in should now be all-zero.  */
>> +      for (unsigned regno = 0; regno < max_gcse_regno; regno++)
>> +        gcc_assert (!last_set_in[regno]);
>> +    }
>
> Braces.
I think with the comment before the loop that the extra brances are OK.


>
>>
>>   static void
>> -rewrite_trees (var_map map ATTRIBUTE_UNUSED)
>> +rewrite_trees (var_map map)
>>   {
>> -#ifdef ENABLE_CHECKING
>> +  if (!flag_checking)
>> +    return;
>
> Bit of an odd name for a function that only does verification. It was
> considerably bigger in 4.2 at least, so maybe it ought to be renamed at
> this point.
Yes, it changed significantly as a result of some of Matz's work. 
Essentially we don't have to rewrite all the tress back into normal form 
for expansion anymore.

Seems like that should be an independent patch.

>
>> -    enum ref_step_type a_step;
>> -    ok = suitable_reference_p (a->ref, &a_step);
>> -    gcc_assert (ok && a_step == comp->comp_step);
>> -      }
>> -#endif
>> +      enum ref_step_type a_step;
>> +      gcc_checking_assert (suitable_reference_p (a->ref, &a_step)
>> +               && a_step == comp->comp_step);
>
> I think we're supposed to stop saying things like "enum" or "struct". If
> you really want, you can go through the places you're changing and
> modifying them so that they're changed only once. But it's not a
> requirement.
Seems like this kind of thing is a separate cleanup.  Someone (Trevor?) 
was fixing up this kind of stuff.   No strong opinions whether or not to 
fix this instance.  It'd be a step forward in C++-ification.  But it'd 
be inconsistent with the rest of the file.


>
>> diff --git a/gcc/tree-stdarg.c b/gcc/tree-stdarg.c
>> index 3e6d98c..0ed107c 100644
>> --- a/gcc/tree-stdarg.c
>> +++ b/gcc/tree-stdarg.c
>> @@ -1107,13 +1107,14 @@ expand_ifn_va_arg (function *fun)
>>     if ((fun->curr_properties & PROP_gimple_lva) == 0)
>>       expand_ifn_va_arg_1 (fun);
>>
>> -#if ENABLE_CHECKING
>> +  if (!flag_checking)
>> +    return;
>> +
>>     basic_block bb;
>>     gimple_stmt_iterator i;
>>     FOR_EACH_BB_FN (bb, fun)
>>       for (i = gsi_start_bb (bb); !gsi_end_p (i); gsi_next (&i))
>>         gcc_assert (!gimple_call_ifn_va_arg_p (gsi_stmt (i)));
>> -#endif
>
>
> I think this would be better wrapped in an "if (flag_checking)", someone
> might want to append to the function at some point.
Done.

I'm going to do a build/test cycle with the suggestions from above and 
see what falls out.

Thanks for all the suggestions!

jeff

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 7/9] ENABLE_CHECKING refactoring: middle-end, LTO FE
  2015-10-26 17:04           ` Jeff Law
@ 2015-10-26 17:15             ` Bernd Schmidt
  2015-10-26 19:05               ` Jeff Law
  0 siblings, 1 reply; 77+ messages in thread
From: Bernd Schmidt @ 2015-10-26 17:15 UTC (permalink / raw)
  To: Jeff Law, Mikhail Maltsev, Richard Biener; +Cc: gcc-patches mailing list

On 10/26/2015 05:59 PM, Jeff Law wrote:
> I left it as-is.  Obviously if you really want the unnecessary braces
> squashed out, we can do that.

It's not a rule I particularly care about myself, but I'm flagging stuff 
like this for the sake of consistency.

>> Don't change the whitespace here. Looks like you probably removed a page
>> break.
> Not obvious where it got lost as there's no filename in the review
> comments :-)

Oops. I think it was one of the sel-sched files.


Bernd

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 7/9] ENABLE_CHECKING refactoring: middle-end, LTO FE
  2015-10-26 17:15             ` Bernd Schmidt
@ 2015-10-26 19:05               ` Jeff Law
  2015-10-28  1:17                 ` Jeff Law
  0 siblings, 1 reply; 77+ messages in thread
From: Jeff Law @ 2015-10-26 19:05 UTC (permalink / raw)
  To: Bernd Schmidt, Mikhail Maltsev, Richard Biener; +Cc: gcc-patches mailing list

On 10/26/2015 11:14 AM, Bernd Schmidt wrote:
> On 10/26/2015 05:59 PM, Jeff Law wrote:
>> I left it as-is.  Obviously if you really want the unnecessary braces
>> squashed out, we can do that.
>
> It's not a rule I particularly care about myself, but I'm flagging stuff
> like this for the sake of consistency.
Noted.

>
>>> Don't change the whitespace here. Looks like you probably removed a page
>>> break.
>> Not obvious where it got lost as there's no filename in the review
>> comments :-)
>
> Oops. I think it was one of the sel-sched files.
I'll do a looksie over things for undesirable whitespace changes.

At least some of the CHECKING_P vs flag_checking thingies are for things 
that are used outside the compiler proper.  ie things that don't have 
the options structure.  The pretty-printer and diagnostics stuff was of 
that nature.  So I'm keeping CHECKING_P rather than flag_checking in those.

Jeff

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 7/9] ENABLE_CHECKING refactoring: middle-end, LTO FE
  2015-10-26 19:05               ` Jeff Law
@ 2015-10-28  1:17                 ` Jeff Law
  2015-10-28  2:12                   ` Trevor Saunders
  0 siblings, 1 reply; 77+ messages in thread
From: Jeff Law @ 2015-10-28  1:17 UTC (permalink / raw)
  To: Bernd Schmidt, Mikhail Maltsev, Richard Biener; +Cc: gcc-patches mailing list

[-- Attachment #1: Type: text/plain, Size: 2151 bytes --]

On 10/26/2015 12:45 PM, Jeff Law wrote:
>>>> Don't change the whitespace here. Looks like you probably removed a
>>>> page
>>>> break.
>>> Not obvious where it got lost as there's no filename in the review
>>> comments :-)
>>
>> Oops. I think it was one of the sel-sched files.
> I'll do a looksie over things for undesirable whitespace changes.
>
> At least some of the CHECKING_P vs flag_checking thingies are for things
> that are used outside the compiler proper.  ie things that don't have
> the options structure.  The pretty-printer and diagnostics stuff was of
> that nature.  So I'm keeping CHECKING_P rather than flag_checking in those.
I found the whitespace change and reverted that bit (along with the 
other changes mentioned in my message yesterday).

I introduced checking_verify_classes wrapper around verify_classes in 
ipa-icf.c to match how that situation was handled elsewhere (as opposed 
to just pulling the test up into the callers).  The more I think about 
it, the more I prefer the factoring done by Mikhail -- because it does 
make it significantly easier to make checking more fine grained 
controlled later.  We might want to carry this into verify_insn_chain 
and a few other places too.

I also fixed several prototypes/definitions which had an empty parameter 
list to explicitly have no parameters ie  foo (void).  I'm not sure why 
Mikhail's patch dropped the "void".  Similarly I put back the 
DEBUG_FUNCTION annotations that were dropped.


Obviously we'll want another pass over the remaining ENABLE_CHECKING 
bits once the rest of Mikhail's patches are installed.  Then we'll 
probably want a pass over the CHECKING_P instances to see which really 
need to stay #ifs vs runtime checks of flag_checking.

I've bootstrapped and regression tested this change on x86_64-linux-gnu 
and an earlier version has built all the configurations in config-list.mk

Given this is primarily Mikhail's patch -- my contributions would best 
be summarized as trying to address Bernd's comments and ChangeLog 
cleanup.  I'm going to give final approval to this patch and install it.

Attached is the actual patch committed


Jeff


[-- Attachment #2: cl --]
[-- Type: text/plain, Size: 8648 bytes --]

gcc/lto/ChangeLog:
2015-10-19  Mikhail Maltsev  <maltsevm@gmail.com>

	* lto.c (unify_scc): Use flag_checking and remove ENABLE_CHECKING
	conditionals.
	(lto_fixup_state): Likewise.
	(do_whole_program_analysis): Use
	symtab_node::checking_verify_symtab_nodes and remove ENABLE_CHECKING
	conditionals.

gcc/ChangeLog:

2015-10-19  Mikhail Maltsev  <maltsevm@gmail.com>

	* attribs.c (check_attribute_tables): New function, broken out from...
	(init_attributes): Use it.
	* cfgcleanup.c (try_optimize_cfg): Use flag_checking, CHECKING_P
	gcc_checking_assert and checking_* functions to eliminate
	ENABLE_CHECKING conditionals.
	* cfgexpand.c (expand_goto, expand_debug_expr): Likewise.
	(pass_expand::execute): Likewise.
	* cgraphclones.c (symbol_table::materialize_all_clones): Likewise.
	* cgraphunit.c (mark_functions_to_output): Likewise.
	(cgraph_node::expand_thunk): Likewise.
	(symbol_table::compile): Likewise.
	* ddg.c (add_cross_iteration_register_deps): Likewise.
	(create_ddg_all_sccs): Likewise.
	* df-core.c (df_finish_pass, df_analyze): Likewise.
	* diagnostic-core.h: Likewise.
	* diagnostic.c (diagnostic_report_diagnostic): Likewise.
	* dominance.c (calculate_dominance_info): Likewise.
	* dwarf2out.c (add_AT_die_ref): Likewise.
	(const_ok_for_output_1, mem_loc_descriptor): Likewise.
	(loc_list_from_tree, gen_lexical_block_die): Likewise.
	gen_type_die_with_usage, gen_type_die): Likewise.
	(dwarf2out_decl): Likewise.
	* emit-rtl.c (verify_rtx_sharing, reorder_insns_nobb): Likewise.
	* except.c (duplicate_eh_regions): Likewise.
	* fwprop.c (register_active_defs, update_df_init): Likewise.
	(fwprop_init, fwprop_done): Likewise.
	(update_uses): Likewise.
	* ggc-page.c (ggc_grow): Likewise.
	* gimplify.c (gimplify_body): Likewise.
	(gimplify_hasher::equal): Likewise.
	* graphite-isl-ast-to-gimple.c (graphite_verify): Likewise.
	* graphite-scop-detection.c (canonicalize_loop_closed_ssa_form):
	Likewise.
	* graphite-sese-to-poly.c (rewrite_reductions_out_of_ssa): Likewise.
	(rewrite_cross_bb_scalar_deps_out_of_ssa): Likwise.
	* hash-table.h (::find_empty_slot_for_expand): Likewise.
	* ifcvt.c (if_convert): Likewise.
	* ipa-cp.c (ipcp_propagate_stage): Likewise.
	* ipa-devirt.c (type_in_anonymous_namespace_p): Likewise.
	(odr_type_p, odr_types_equivalent_p): Likewise.
	(add_type_duplicate, get_odr_type): Likewise.
	* ipa-icf.c (sem_item_optimizer::execute): Likewise.
	(sem_item_optimizer::subdivide_classes_by_equality): Likewise.
	(sem_item_optimizer::verify_classes): Likewise.
	(sem_item_optimizer::traverse_congruence_split): Likewise.
	(sem_item_optimizer::checking_verify_classes): New.
	* ipa-icf.h (sem_item_optimizer::checking_verify_classes): Add new
	method.
	* cfgrtl.c (commit_edge_insertions): Likewise.
	(fixup_reorder_chain, cfg_layout_finalize): Likewise.
	(rtl_flow_call_edges_add): Likewise.
	* cgraph.c (symbol_table::create_edge): Likewise.
	(cgraph_edge::redirect_call_stmt_to_callee): Likewise.
	* cgraph.h (symtab_node): Likewise.
	(symtab_node::checking_verify_symtab_nodes): Define.
	(cgraph_node::checking_verify_cgraph_nodes): Define.
	* cfghooks.h (checking_verify_flow_info): Define.
	* cfgloop.h (checking_verify_loop_structure): Define.
	* dominance.h (checking_verify_dominators): Define.
	* et-forest.c: Fix comment.
	* ipa-inline-analysis.c (compute_inline_parameters): Use flag_checking,
	CHECKING_P gcc_checking_assert and checking_* functions to eliminate
	ENABLE_CHECKING conditionals.
	* ipa-inline-transform.c (save_inline_function_body): Likewise.
	* ipa-inline.c (inline_small_functions): Likewise.
	(early_inliner): Likewise.
	* ipa-inline.h (estimate_edge_growth): Likewise.
	* ipa-visibility.c (function_and_variable_visibility): Likewise.
	* ipa.c (symbol_table::remove_unreachable_nodes): Likewise.
	(ipa_single_use): Likewise.
	* ira-int.h: Likewise.
	* ira.c (ira): Likewise.
	* loop-doloop.c (doloop_optimize_loops): Likewise.
	* loop-init.c (loop_optimizer_init, fix_loop_structure): Likewise.
	* loop-invariant.c (move_loop_invariants): Likewise.
	* lra-assigns.c (lra_assign): Likewise.
	* lra-constraints.c (lra_constraints): Likewise.
	* lra-eliminations.c (lra_eliminate): Likewise.
	* lra-int.h (struct lra_reg): Likewise.
	* lra-lives.c (check_pseudos_live_through_calls): Likewise.
	(lra_create_live_ranges_1): Likewise.
	* lra-remat.c (create_remat_bb_data): Likewise.
	* lra.c (lra_update_insn_recog_data, restore_scratches): Likewise.
	(lra): Likewise.
	(check_rtl): Always define. Remove incorrect guard around
	extract_constrain_insn call.
	* lto-cgraph.c (input_cgraph_1: Use flag_checking,
	CHECKING_P gcc_checking_assert and checking_* functions to eliminate
	ENABLE_CHECKING conditionals.
	* lto-streamer-out.c (DFS::DFS): Likewise.
	(lto_output): Likewise.
	* lto-streamer.c (lto_streamer_init): Likewise.
	* omp-low.c (scan_omp_target, expand_omp_taskreg): Likewise.
	expand_omp_target, execute_expand_omp): Likewise.
	(lower_omp_target): Likewise.
	* passes.c (execute_function_todo): Likewise.
	(execute_todo, execute_one_pass): Likewise.
	(verify_curr_properties): Always define.
	* predict.c (tree_estimate_probability: Use flag_checking,
	CHECKING_P gcc_checking_assert and checking_* functions to eliminate
	ENABLE_CHECKING conditionals.
	(propagate_freq): Likewise.
	* pretty-print.c (pp_format): Likewise.
	* real.c (real_to_decimal_for_mode): Likewise.
	* recog.c (split_all_insns): Likewise.
	* regcprop.c (kill_value_one_regno): Likewise.
	(copy_value): Likewise.
	(validate_value_data): Define unconditionally.
	* reload.c: Fix comment.
	* timevar.c: Include options.h
	* tree-ssa.h (checking_verify_ssa): Define.
	* tree-ssa-loop-manip.h (checking_verify_loop_closed_ssa): Define.
	* sched-deps.c (CHECK): Remove unused macro.
	(add_or_update_dep_1, sd_add_dep: Use flag_checking, CHECKING_P
	gcc_checking_assert and checking_* functions to eliminate
	ENABLE_CHECKING conditionals.
	* sel-sched-ir.c (free_regset_pool, tidy_control_flow): Likewise.
	* sel-sched.c (struct moveop_static_params): Likewise.
	(find_best_reg_for_expr, move_cond_jump): Likewise.
	(move_op_orig_expr_not_found): Likewise.
	(code_motion_process_successors, move_op): Likewise.
	* ssa-iterators.h (first_readonly_imm_use): Likewise.
	(next_readonly_imm_use): Likewise.
	* store-motion.c (compute_store_table): Likewise.
	* symbol-summary.h (function_summary::function_summary): Likewise.
	* target.h (cumulative_args_t): Likewise.
	(get_cumulative_args, pack_cumulative_args): Likewise.
	* timevar.c: (timer::print): Likewise.
	* trans-mem.c (ipa_tm_execute): Likewise.
	* tree-cfg.c (move_stmt_op): Likewise.
	(move_sese_region_to_fn): Likewise.
	(gimple_flow_call_edges_add): Likewise.
	* tree-cfgcleanup.c (cleanup_tree_cfg_noloop, repair_loop_structures):
	Likewise.
	* tree-eh.c (remove_unreachable_handlers): Likewise.
	* tree-if-conv.c (pass_if_conversion::execute): Likewise.
	* tree-inline.c (expand_call_inline, optimize_inline_calls): Likewise.
	* tree-into-ssa.c (update_ssa): Likewise.
	* tree-loop-distribution.c (pass_loop_distribution::execute): Likewise.
	* tree-outof-ssa.c (eliminate_useless_phis, rewrite_trees): Likewise.
	* tree-parloops.c (pass_parallelize_loops::execute): Likewise.
	* tree-predcom.c (suitable_component_p): Likewise.
	* tree-profile.c (gimple_gen_const_delta_profiler): Likewise.
	* tree-ssa-alias.c (refs_may_alias_p_1): Likewise.
	* tree-ssa-live.c (verify_live_on_entry): Likewise.
	* tree-ssa-live.h (register_ssa_partition): Likewise.
	* tree-ssa-loop-ivcanon.c (tree_unroll_loops_completely): Likewise.
	* tree-ssa-loop-manip.c (add_exit_phi): Likewise.
	(tree_transform_and_unroll_loop): Likewise.
	* tree-ssa-math-opts.c (pass_cse_reciprocals::execute): Likewise.
	* tree-ssa-operands.c (get_expr_operands): Likewise.
	* tree-ssa-propagate.c (replace_exp_1): Likewise.
	* tree-ssa-structalias.c (rewrite_constraints): Likewise.
	* tree-ssa-ter.c (free_temp_expr_table): Likewise.
	* tree-ssa-threadupdate.c (duplicate_thread_path): Likewise.
	* tree-ssanames.c (release_ssa_name_fn): Likewise.
	* tree-stdarg.c (expand_ifn_va_arg): Likewise.
	* tree-vect-loop-manip.c
	(slpeel_tree_duplicate_loop_to_edge_cfg): Likewise.
	(slpeel_checking_verify_cfg_after_peeling): Likewise.
	(vect_do_peeling_for_loop_bound): Likewise.
	(vect_do_peeling_for_alignment): Likewise.
	* tree-vrp.c (supports_overflow_infinity): Likewise.
	(set_value_range): Likewise.
	* tree.c (free_lang_data_in_cgraph): Likewise.
	* value-prof.c (gimple_remove_histogram_value): Likewise.
	(free_hist): Likewise.
	* var-tracking.c (canonicalize_values_star): Likewise.
	(compute_bb_dataflow, vt_find_locations, vt_emit_notes): Likewise.


[-- Attachment #3: patch --]
[-- Type: text/plain, Size: 123978 bytes --]

diff --git a/gcc/attribs.c b/gcc/attribs.c
index 6cbe011..e7af7b0 100644
--- a/gcc/attribs.c
+++ b/gcc/attribs.c
@@ -174,8 +174,58 @@ find_attribute_namespace (const char* ns)
   return NULL;
 }
 
-/* Initialize attribute tables, and make some sanity checks
-   if --enable-checking.  */
+/* Make some sanity checks on the attribute tables.  */
+
+static void
+check_attribute_tables (void)
+{
+  for (size_t i = 0; i < ARRAY_SIZE (attribute_tables); i++)
+    for (size_t j = 0; attribute_tables[i][j].name != NULL; j++)
+      {
+	/* The name must not begin and end with __.  */
+	const char *name = attribute_tables[i][j].name;
+	int len = strlen (name);
+
+	gcc_assert (!(name[0] == '_' && name[1] == '_'
+		      && name[len - 1] == '_' && name[len - 2] == '_'));
+
+	/* The minimum and maximum lengths must be consistent.  */
+	gcc_assert (attribute_tables[i][j].min_length >= 0);
+
+	gcc_assert (attribute_tables[i][j].max_length == -1
+		    || (attribute_tables[i][j].max_length
+			>= attribute_tables[i][j].min_length));
+
+	/* An attribute cannot require both a DECL and a TYPE.  */
+	gcc_assert (!attribute_tables[i][j].decl_required
+		    || !attribute_tables[i][j].type_required);
+
+	  /* If an attribute requires a function type, in particular
+	     it requires a type.  */
+	gcc_assert (!attribute_tables[i][j].function_type_required
+		    || attribute_tables[i][j].type_required);
+      }
+
+  /* Check that each name occurs just once in each table.  */
+  for (size_t i = 0; i < ARRAY_SIZE (attribute_tables); i++)
+    for (size_t j = 0; attribute_tables[i][j].name != NULL; j++)
+      for (size_t k = j + 1; attribute_tables[i][k].name != NULL; k++)
+	gcc_assert (strcmp (attribute_tables[i][j].name,
+			    attribute_tables[i][k].name));
+
+  /* Check that no name occurs in more than one table.  Names that
+     begin with '*' are exempt, and may be overridden.  */
+  for (size_t i = 0; i < ARRAY_SIZE (attribute_tables); i++)
+    for (size_t j = i + 1; j < ARRAY_SIZE (attribute_tables); j++)
+      for (size_t k = 0; attribute_tables[i][k].name != NULL; k++)
+	for (size_t l = 0; attribute_tables[j][l].name != NULL; l++)
+	  gcc_assert (attribute_tables[i][k].name[0] == '*'
+		      || strcmp (attribute_tables[i][k].name,
+				 attribute_tables[j][l].name));
+}
+
+/* Initialize attribute tables, and make some sanity checks if checking is
+   enabled.  */
 
 void
 init_attributes (void)
@@ -195,62 +245,8 @@ init_attributes (void)
     if (attribute_tables[i] == NULL)
       attribute_tables[i] = empty_attribute_table;
 
-#ifdef ENABLE_CHECKING
-  /* Make some sanity checks on the attribute tables.  */
-  for (i = 0; i < ARRAY_SIZE (attribute_tables); i++)
-    {
-      int j;
-
-      for (j = 0; attribute_tables[i][j].name != NULL; j++)
-	{
-	  /* The name must not begin and end with __.  */
-	  const char *name = attribute_tables[i][j].name;
-	  int len = strlen (name);
-
-	  gcc_assert (!(name[0] == '_' && name[1] == '_'
-			&& name[len - 1] == '_' && name[len - 2] == '_'));
-
-	  /* The minimum and maximum lengths must be consistent.  */
-	  gcc_assert (attribute_tables[i][j].min_length >= 0);
-
-	  gcc_assert (attribute_tables[i][j].max_length == -1
-		      || (attribute_tables[i][j].max_length
-			  >= attribute_tables[i][j].min_length));
-
-	  /* An attribute cannot require both a DECL and a TYPE.  */
-	  gcc_assert (!attribute_tables[i][j].decl_required
-		      || !attribute_tables[i][j].type_required);
-
-	  /* If an attribute requires a function type, in particular
-	     it requires a type.  */
-	  gcc_assert (!attribute_tables[i][j].function_type_required
-		      || attribute_tables[i][j].type_required);
-	}
-    }
-
-  /* Check that each name occurs just once in each table.  */
-  for (i = 0; i < ARRAY_SIZE (attribute_tables); i++)
-    {
-      int j, k;
-      for (j = 0; attribute_tables[i][j].name != NULL; j++)
-	for (k = j + 1; attribute_tables[i][k].name != NULL; k++)
-	  gcc_assert (strcmp (attribute_tables[i][j].name,
-			      attribute_tables[i][k].name));
-    }
-  /* Check that no name occurs in more than one table.  Names that
-     begin with '*' are exempt, and may be overridden.  */
-  for (i = 0; i < ARRAY_SIZE (attribute_tables); i++)
-    {
-      size_t j, k, l;
-
-      for (j = i + 1; j < ARRAY_SIZE (attribute_tables); j++)
-	for (k = 0; attribute_tables[i][k].name != NULL; k++)
-	  for (l = 0; attribute_tables[j][l].name != NULL; l++)
-	    gcc_assert (attribute_tables[i][k].name[0] == '*'
-			|| strcmp (attribute_tables[i][k].name,
-				   attribute_tables[j][l].name));
-    }
-#endif
+  if (flag_checking)
+    check_attribute_tables ();
 
   for (i = 0; i < ARRAY_SIZE (attribute_tables); ++i)
     /* Put all the GNU attributes into the "gnu" namespace.  */
diff --git a/gcc/cfgcleanup.c b/gcc/cfgcleanup.c
index 7e576bc..c9b132d 100644
--- a/gcc/cfgcleanup.c
+++ b/gcc/cfgcleanup.c
@@ -2873,11 +2873,8 @@ try_optimize_cfg (int mode)
                  to detect and fix during edge forwarding, and in some cases
                  is only visible after newly unreachable blocks are deleted,
                  which will be done in fixup_partitions.  */
-              fixup_partitions ();
-
-#ifdef ENABLE_CHECKING
-              verify_flow_info ();
-#endif
+	      fixup_partitions ();
+	      checking_verify_flow_info ();
             }
 
 	  changed_overall |= changed;
diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c
index 8d5fb64..200520a 100644
--- a/gcc/cfgexpand.c
+++ b/gcc/cfgexpand.c
@@ -3269,12 +3269,13 @@ expand_computed_goto (tree exp)
 static void
 expand_goto (tree label)
 {
-#ifdef ENABLE_CHECKING
-  /* Check for a nonlocal goto to a containing function.  Should have
-     gotten translated to __builtin_nonlocal_goto.  */
-  tree context = decl_function_context (label);
-  gcc_assert (!context || context == current_function_decl);
-#endif
+  if (flag_checking)
+    {
+      /* Check for a nonlocal goto to a containing function.  Should have
+	 gotten translated to __builtin_nonlocal_goto.  */
+      tree context = decl_function_context (label);
+      gcc_assert (!context || context == current_function_decl);
+    }
 
   emit_jump (jump_target_rtx (label));
 }
@@ -5056,12 +5057,12 @@ expand_debug_expr (tree exp)
 
     default:
     flag_unsupported:
-#ifdef ENABLE_CHECKING
-      debug_tree (exp);
-      gcc_unreachable ();
-#else
+      if (flag_checking)
+	{
+	  debug_tree (exp);
+	  gcc_unreachable ();
+	}
       return NULL;
-#endif
     }
 }
 
@@ -6422,9 +6423,7 @@ pass_expand::execute (function *fun)
      gcc.c-torture/execute/ipa-sra-2.c execution, -Os -m32 fails otherwise.  */
   cleanup_cfg (CLEANUP_NO_INSN_DEL);
 
-#ifdef ENABLE_CHECKING
-  verify_flow_info ();
-#endif
+  checking_verify_flow_info ();
 
   /* Initialize pseudos allocated for hard registers.  */
   emit_initial_value_sets ();
diff --git a/gcc/cfghooks.h b/gcc/cfghooks.h
index 0d25cf6..a0cb6fd 100644
--- a/gcc/cfghooks.h
+++ b/gcc/cfghooks.h
@@ -186,6 +186,18 @@ struct cfg_hooks
 };
 
 extern void verify_flow_info (void);
+
+/* Check control flow invariants, if internal consistency checks are
+   enabled.  */
+
+static inline void
+checking_verify_flow_info (void)
+{
+  /* TODO: Add a separate option for -fchecking=cfg.  */
+  if (flag_checking)
+    verify_flow_info ();
+}
+
 extern void dump_bb (FILE *, basic_block, int, int);
 extern void dump_bb_for_graph (pretty_printer *, basic_block);
 extern void dump_flow_info (FILE *, int);
diff --git a/gcc/cfgloop.h b/gcc/cfgloop.h
index cd4a4c9..6af6893 100644
--- a/gcc/cfgloop.h
+++ b/gcc/cfgloop.h
@@ -311,6 +311,16 @@ extern void delete_loop (struct loop *);
 
 extern void verify_loop_structure (void);
 
+/* Check loop structure invariants, if internal consistency checks are
+   enabled.  */
+
+static inline void
+checking_verify_loop_structure (void)
+{
+  if (flag_checking)
+    verify_loop_structure ();
+}
+
 /* Loop analysis.  */
 extern bool just_once_each_iteration_p (const struct loop *, const_basic_block);
 gcov_type expected_loop_iterations_unbounded (const struct loop *);
diff --git a/gcc/cfgrtl.c b/gcc/cfgrtl.c
index d2fe1e0..14b9406 100644
--- a/gcc/cfgrtl.c
+++ b/gcc/cfgrtl.c
@@ -2096,9 +2096,7 @@ commit_edge_insertions (void)
      which will be done by fixup_partitions.  */
   fixup_partitions ();
 
-#ifdef ENABLE_CHECKING
-  verify_flow_info ();
-#endif
+  checking_verify_flow_info ();
 
   FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR_FOR_FN (cfun),
 		  EXIT_BLOCK_PTR_FOR_FN (cfun), next_bb)
@@ -3722,9 +3720,8 @@ fixup_reorder_chain (void)
     insn = NEXT_INSN (insn);
 
   set_last_insn (insn);
-#ifdef ENABLE_CHECKING
-  verify_insn_chain ();
-#endif
+  if (flag_checking)
+    verify_insn_chain ();
 
   /* Now add jumps and labels as needed to match the blocks new
      outgoing edges.  */
@@ -4312,9 +4309,7 @@ break_superblocks (void)
 void
 cfg_layout_finalize (void)
 {
-#ifdef ENABLE_CHECKING
-  verify_flow_info ();
-#endif
+  checking_verify_flow_info ();
   force_one_exit_fallthru ();
   rtl_register_cfg_hooks ();
   if (reload_completed && !targetm.have_epilogue ())
@@ -4324,10 +4319,9 @@ cfg_layout_finalize (void)
   rebuild_jump_labels (get_insns ());
   delete_dead_jumptables ();
 
-#ifdef ENABLE_CHECKING
-  verify_insn_chain ();
-  verify_flow_info ();
-#endif
+  if (flag_checking)
+    verify_insn_chain ();
+  checking_verify_flow_info ();
 }
 
 
@@ -4892,13 +4886,11 @@ rtl_flow_call_edges_add (sbitmap blocks)
 		 block in CFG already.  Calling make_edge in such case would
 		 cause us to mark that edge as fake and remove it later.  */
 
-#ifdef ENABLE_CHECKING
-	      if (split_at_insn == BB_END (bb))
+	      if (flag_checking && split_at_insn == BB_END (bb))
 		{
 		  e = find_edge (bb, EXIT_BLOCK_PTR_FOR_FN (cfun));
 		  gcc_assert (e == NULL);
 		}
-#endif
 
 	      /* Note that the following may create a new basic block
 		 and renumber the existing basic blocks.  */
diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index cfcfaf3..69804c3 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -832,11 +832,9 @@ symbol_table::create_edge (cgraph_node *caller, cgraph_node *callee,
     {
       /* This is a rather expensive check possibly triggering
 	 construction of call stmt hashtable.  */
-#ifdef ENABLE_CHECKING
       cgraph_edge *e;
-      gcc_checking_assert (
-	!(e = caller->get_edge (call_stmt)) || e->speculative);
-#endif
+      gcc_checking_assert (!(e = caller->get_edge (call_stmt))
+			   || e->speculative);
 
       gcc_assert (is_gimple_call (call_stmt));
     }
@@ -1282,9 +1280,6 @@ cgraph_edge::redirect_call_stmt_to_callee (void)
   gcall *new_stmt;
   gimple_stmt_iterator gsi;
   bool skip_bounds = false;
-#ifdef ENABLE_CHECKING
-  cgraph_node *node;
-#endif
 
   if (e->speculative)
     {
@@ -1402,13 +1397,11 @@ cgraph_edge::redirect_call_stmt_to_callee (void)
 	  && !skip_bounds))
     return e->call_stmt;
 
-#ifdef ENABLE_CHECKING
-  if (decl)
+  if (flag_checking && decl)
     {
-      node = cgraph_node::get (decl);
+      cgraph_node *node = cgraph_node::get (decl);
       gcc_assert (!node || !node->clone.combined_args_to_skip);
     }
-#endif
 
   if (symtab->dump_file)
     {
diff --git a/gcc/cgraph.h b/gcc/cgraph.h
index 7c54f24..0a0ff70 100644
--- a/gcc/cgraph.h
+++ b/gcc/cgraph.h
@@ -362,7 +362,6 @@ public:
      and NULL otherwise.  */
   static inline symtab_node *get (const_tree decl)
   {
-#ifdef ENABLE_CHECKING
     /* Check that we are called for sane type of object - functions
        and static or external variables.  */
     gcc_checking_assert (TREE_CODE (decl) == FUNCTION_DECL
@@ -374,7 +373,6 @@ public:
        memcpy/memset on the tree nodes.  */
     gcc_checking_assert (!decl->decl_with_vis.symtab_node
 			 || decl->decl_with_vis.symtab_node->decl == decl);
-#endif
     return decl->decl_with_vis.symtab_node;
   }
 
@@ -398,6 +396,9 @@ public:
   /* Verify symbol table for internal consistency.  */
   static DEBUG_FUNCTION void verify_symtab_nodes (void);
 
+  /* Perform internal consistency checks, if they are enabled.  */
+  static inline void checking_verify_symtab_nodes (void);
+
   /* Type of the symbol.  */
   ENUM_BITFIELD (symtab_type) type : 8;
 
@@ -558,6 +559,13 @@ private:
   symtab_node *ultimate_alias_target_1 (enum availability *avail = NULL);
 };
 
+inline void
+symtab_node::checking_verify_symtab_nodes (void)
+{
+  if (flag_checking)
+    symtab_node::verify_symtab_nodes ();
+}
+
 /* Walk all aliases for NODE.  */
 #define FOR_EACH_ALIAS(node, alias) \
   for (unsigned x_i = 0; node->iterate_direct_aliases (x_i, alias); x_i++)
@@ -1205,6 +1213,9 @@ public:
   /* Verify whole cgraph structure.  */
   static void DEBUG_FUNCTION verify_cgraph_nodes (void);
 
+  /* Verify cgraph, if consistency checking is enabled.  */
+  static inline void checking_verify_cgraph_nodes (void);
+
   /* Worker to bring NODE local.  */
   static bool make_local (cgraph_node *node, void *);
 
@@ -2753,6 +2764,15 @@ cgraph_node::can_remove_if_no_direct_calls_and_refs_p (void)
   return true;
 }
 
+/* Verify cgraph, if consistency checking is enabled.  */
+
+inline void
+cgraph_node::checking_verify_cgraph_nodes (void)
+{
+  if (flag_checking)
+    cgraph_node::verify_cgraph_nodes ();
+}
+
 /* Return true when variable can be removed from variable pool
    if all direct calls are eliminated.  */
 
diff --git a/gcc/cgraphclones.c b/gcc/cgraphclones.c
index f243f6f..f36ef34 100644
--- a/gcc/cgraphclones.c
+++ b/gcc/cgraphclones.c
@@ -1074,9 +1074,8 @@ symbol_table::materialize_all_clones (void)
 
   if (symtab->dump_file)
     fprintf (symtab->dump_file, "Materializing clones\n");
-#ifdef ENABLE_CHECKING
-  cgraph_node::verify_cgraph_nodes ();
-#endif
+
+  cgraph_node::checking_verify_cgraph_nodes ();
 
   /* We can also do topological order, but number of iterations should be
      bounded by number of IPA passes since single IPA pass is probably not
@@ -1145,9 +1144,9 @@ symbol_table::materialize_all_clones (void)
       node->clear_stmts_in_references ();
   if (symtab->dump_file)
     fprintf (symtab->dump_file, "Materialization Call site updates done.\n");
-#ifdef ENABLE_CHECKING
-  cgraph_node::verify_cgraph_nodes ();
-#endif
+
+  cgraph_node::checking_verify_cgraph_nodes ();
+
   symtab->remove_unreachable_nodes (symtab->dump_file);
 }
 
diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index 0b0c0f4..eab8c7f 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -1325,13 +1325,12 @@ handle_alias_pairs (void)
 static void
 mark_functions_to_output (void)
 {
-  cgraph_node *node;
-#ifdef ENABLE_CHECKING
   bool check_same_comdat_groups = false;
+  cgraph_node *node;
 
-  FOR_EACH_FUNCTION (node)
-    gcc_assert (!node->process);
-#endif
+  if (flag_checking)
+    FOR_EACH_FUNCTION (node)
+      gcc_assert (!node->process);
 
   FOR_EACH_FUNCTION (node)
     {
@@ -1365,15 +1364,14 @@ mark_functions_to_output (void)
 	}
       else if (node->same_comdat_group)
 	{
-#ifdef ENABLE_CHECKING
-	  check_same_comdat_groups = true;
-#endif
+	  if (flag_checking)
+	    check_same_comdat_groups = true;
 	}
       else
 	{
 	  /* We should've reclaimed all functions that are not needed.  */
-#ifdef ENABLE_CHECKING
-	  if (!node->global.inlined_to
+	  if (flag_checking
+	      && !node->global.inlined_to
 	      && gimple_has_body_p (decl)
 	      /* FIXME: in ltrans unit when offline copy is outside partition but inline copies
 		 are inside partition, we can end up not removing the body since we no longer
@@ -1386,7 +1384,6 @@ mark_functions_to_output (void)
 	      node->debug ();
 	      internal_error ("failed to reclaim unneeded function");
 	    }
-#endif
 	  gcc_assert (node->global.inlined_to
 		      || !gimple_has_body_p (decl)
 		      || node->in_other_partition
@@ -1397,8 +1394,7 @@ mark_functions_to_output (void)
 	}
 
     }
-#ifdef ENABLE_CHECKING
-  if (check_same_comdat_groups)
+  if (flag_checking && check_same_comdat_groups)
     FOR_EACH_FUNCTION (node)
       if (node->same_comdat_group && !node->process)
 	{
@@ -1418,7 +1414,6 @@ mark_functions_to_output (void)
 			      "comdat group");
 	    }
 	}
-#endif
 }
 
 /* DECL is FUNCTION_DECL.  Initialize datastructures so DECL is a function
@@ -1887,9 +1882,7 @@ cgraph_node::expand_thunk (bool output_asm_thunks, bool force_gimple_thunk)
       TREE_ASM_WRITTEN (thunk_fndecl) = false;
       delete_unreachable_blocks ();
       update_ssa (TODO_update_ssa);
-#ifdef ENABLE_CHECKING
-      verify_flow_info ();
-#endif
+      checking_verify_flow_info ();
       free_dominance_info (CDI_DOMINATORS);
 
       /* Since we want to emit the thunk, we explicitly mark its name as
@@ -2373,9 +2366,7 @@ symbol_table::compile (void)
   if (seen_error ())
     return;
 
-#ifdef ENABLE_CHECKING
-  symtab_node::verify_symtab_nodes ();
-#endif
+  symtab_node::checking_verify_symtab_nodes ();
 
   timevar_push (TV_CGRAPHOPT);
   if (pre_ipa_mem_report)
@@ -2424,9 +2415,7 @@ symbol_table::compile (void)
   (*debug_hooks->assembly_start) ();
   if (!quiet_flag)
     fprintf (stderr, "Assembling functions:\n");
-#ifdef ENABLE_CHECKING
-  symtab_node::verify_symtab_nodes ();
-#endif
+  symtab_node::checking_verify_symtab_nodes ();
 
   materialize_all_clones ();
   bitmap_obstack_initialize (NULL);
@@ -2482,7 +2471,8 @@ symbol_table::compile (void)
       fprintf (dump_file, "\nFinal ");
       symtab_node::dump_table (dump_file);
     }
-#ifdef ENABLE_CHECKING
+  if (!flag_checking)
+    return;
   symtab_node::verify_symtab_nodes ();
   /* Double check that all inline clones are gone and that all
      function bodies have been released from memory.  */
@@ -2501,7 +2491,6 @@ symbol_table::compile (void)
       if (error_found)
 	internal_error ("nodes with unreleased memory found");
     }
-#endif
 }
 
 
diff --git a/gcc/ddg.c b/gcc/ddg.c
index ada4657..b03ab93 100644
--- a/gcc/ddg.c
+++ b/gcc/ddg.c
@@ -300,19 +300,16 @@ add_cross_iteration_register_deps (ddg_ptr g, df_ref last_def)
   rtx_insn *def_insn = DF_REF_INSN (last_def);
   ddg_node_ptr last_def_node = get_node_of_insn (g, def_insn);
   ddg_node_ptr use_node;
-#ifdef ENABLE_CHECKING
-  struct df_rd_bb_info *bb_info = DF_RD_BB_INFO (g->bb);
-#endif
   df_ref first_def = df_bb_regno_first_def_find (g->bb, regno);
 
   gcc_assert (last_def_node);
   gcc_assert (first_def);
 
-#ifdef ENABLE_CHECKING
-  if (DF_REF_ID (last_def) != DF_REF_ID (first_def))
-    gcc_assert (!bitmap_bit_p (&bb_info->gen,
-			       DF_REF_ID (first_def)));
-#endif
+  if (flag_checking && DF_REF_ID (last_def) != DF_REF_ID (first_def))
+    {
+      struct df_rd_bb_info *bb_info = DF_RD_BB_INFO (g->bb);
+      gcc_assert (!bitmap_bit_p (&bb_info->gen, DF_REF_ID (first_def)));
+    }
 
   /* Create inter-loop true dependences and anti dependences.  */
   for (r_use = DF_REF_CHAIN (last_def); r_use != NULL; r_use = r_use->next)
@@ -1013,7 +1010,6 @@ order_sccs (ddg_all_sccs_ptr g)
 	 (int (*) (const void *, const void *)) compare_sccs);
 }
 
-#ifdef ENABLE_CHECKING
 /* Check that every node in SCCS belongs to exactly one strongly connected
    component and that no element of SCCS is empty.  */
 static void
@@ -1033,7 +1029,6 @@ check_sccs (ddg_all_sccs_ptr sccs, int num_nodes)
     }
   sbitmap_free (tmp);
 }
-#endif
 
 /* Perform the Strongly Connected Components decomposing algorithm on the
    DDG and return DDG_ALL_SCCS structure that contains them.  */
@@ -1079,9 +1074,10 @@ create_ddg_all_sccs (ddg_ptr g)
   sbitmap_free (from);
   sbitmap_free (to);
   sbitmap_free (scc_nodes);
-#ifdef ENABLE_CHECKING
-  check_sccs (sccs, num_nodes);
-#endif
+
+  if (flag_checking)
+    check_sccs (sccs, num_nodes);
+
   return sccs;
 }
 
diff --git a/gcc/df-core.c b/gcc/df-core.c
index 8d2d7a1..72a5eb5 100644
--- a/gcc/df-core.c
+++ b/gcc/df-core.c
@@ -682,10 +682,8 @@ df_finish_pass (bool verify ATTRIBUTE_UNUSED)
 #endif
 #endif
 
-#ifdef ENABLE_CHECKING
-  if (verify)
+  if (flag_checking && verify)
     df->changeable_flags |= DF_VERIFY_SCHEDULED;
-#endif
 }
 
 
@@ -1273,12 +1271,14 @@ df_analyze (void)
   for (i = 0; i < df->n_blocks; i++)
     bitmap_set_bit (current_all_blocks, df->postorder[i]);
 
-#ifdef ENABLE_CHECKING
-  /* Verify that POSTORDER_INVERTED only contains blocks reachable from
-     the ENTRY block.  */
-  for (i = 0; i < df->n_blocks_inverted; i++)
-    gcc_assert (bitmap_bit_p (current_all_blocks, df->postorder_inverted[i]));
-#endif
+  if (flag_checking)
+    {
+      /* Verify that POSTORDER_INVERTED only contains blocks reachable from
+	 the ENTRY block.  */
+      for (i = 0; i < df->n_blocks_inverted; i++)
+	gcc_assert (bitmap_bit_p (current_all_blocks,
+				  df->postorder_inverted[i]));
+    }
 
   /* Make sure that we have pruned any unreachable blocks from these
      sets.  */
diff --git a/gcc/diagnostic-core.h b/gcc/diagnostic-core.h
index 66d2e42..6cc1e6b 100644
--- a/gcc/diagnostic-core.h
+++ b/gcc/diagnostic-core.h
@@ -48,7 +48,7 @@ extern const char *trim_filename (const char *);
 /* None of these functions are suitable for ATTRIBUTE_PRINTF, because
    each language front end can extend them with its own set of format
    specifiers.  We must use custom format checks.  */
-#if (ENABLE_CHECKING && GCC_VERSION >= 4001) || GCC_VERSION == BUILDING_GCC_VERSION
+#if (CHECKING_P && GCC_VERSION >= 4001) || GCC_VERSION == BUILDING_GCC_VERSION
 #define ATTRIBUTE_GCC_DIAG(m, n) __attribute__ ((__format__ (GCC_DIAG_STYLE, m, n))) ATTRIBUTE_NONNULL(m)
 #else
 #define ATTRIBUTE_GCC_DIAG(m, n) ATTRIBUTE_NONNULL(m)
diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c
index 831859a..11c369d 100644
--- a/gcc/diagnostic.c
+++ b/gcc/diagnostic.c
@@ -736,12 +736,12 @@ diagnostic_report_diagnostic (diagnostic_context *context,
 
   if (diagnostic->kind == DK_ICE || diagnostic->kind == DK_ICE_NOBT)
     {
-#ifndef ENABLE_CHECKING
       /* When not checking, ICEs are converted to fatal errors when an
 	 error has already occurred.  This is counteracted by
 	 abort_on_error.  */
-      if ((diagnostic_kind_count (context, DK_ERROR) > 0
-	   || diagnostic_kind_count (context, DK_SORRY) > 0)
+      if (!CHECKING_P
+	  && (diagnostic_kind_count (context, DK_ERROR) > 0
+	      || diagnostic_kind_count (context, DK_SORRY) > 0)
 	  && !context->abort_on_error)
 	{
 	  expanded_location s 
@@ -750,7 +750,6 @@ diagnostic_report_diagnostic (diagnostic_context *context,
 		   s.file, s.line);
 	  exit (ICE_EXIT_CODE);
 	}
-#endif
       if (context->internal_error)
 	(*context->internal_error) (context,
 				    diagnostic->message.format_spec,
diff --git a/gcc/dominance.c b/gcc/dominance.c
index 09645be..a72b0c1 100644
--- a/gcc/dominance.c
+++ b/gcc/dominance.c
@@ -634,9 +634,7 @@ calculate_dominance_info (cdi_direction dir)
 
   if (dom_computed[dir_index] == DOM_OK)
     {
-#if ENABLE_CHECKING
-      verify_dominators (dir);
-#endif
+      checking_verify_dominators (dir);
       return;
     }
 
@@ -665,11 +663,7 @@ calculate_dominance_info (cdi_direction dir)
       dom_computed[dir_index] = DOM_NO_FAST_QUERY;
     }
   else
-    {
-#if ENABLE_CHECKING
-      verify_dominators (dir);
-#endif
-    }
+    checking_verify_dominators (dir);
 
   compute_dom_fast_query (dir);
 
diff --git a/gcc/dominance.h b/gcc/dominance.h
index 37e138b..7254f2f 100644
--- a/gcc/dominance.h
+++ b/gcc/dominance.h
@@ -60,6 +60,17 @@ extern bool dominated_by_p (enum cdi_direction, const_basic_block,
 unsigned bb_dom_dfs_in (enum cdi_direction, basic_block);
 unsigned bb_dom_dfs_out (enum cdi_direction, basic_block);
 extern void verify_dominators (enum cdi_direction);
+
+/* Verify invariants of computed dominance information, if internal consistency
+   checks are enabled.  */
+
+static inline void
+checking_verify_dominators (cdi_direction dir)
+{
+  if (flag_checking)
+    verify_dominators (dir);
+}
+
 basic_block recompute_dominator (enum cdi_direction, basic_block);
 extern void iterate_fix_dominators (enum cdi_direction,
 				    vec<basic_block> , bool);
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index c1b7c7b..6e0db41 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -4149,15 +4149,12 @@ static inline void
 add_AT_die_ref (dw_die_ref die, enum dwarf_attribute attr_kind, dw_die_ref targ_die)
 {
   dw_attr_node attr;
+  gcc_checking_assert (targ_die != NULL);
 
-#ifdef ENABLE_CHECKING
-  gcc_assert (targ_die != NULL);
-#else
   /* With LTO we can end up trying to reference something we didn't create
      a DIE for.  Avoid crashing later on a NULL referenced DIE.  */
   if (targ_die == NULL)
     return;
-#endif
 
   attr.dw_attr = attr_kind;
   attr.dw_attr_val.val_class = dw_val_class_die_ref;
@@ -5723,7 +5720,6 @@ debug_dwarf (void)
   print_die (comp_unit_die (), stderr);
 }
 
-#ifdef ENABLE_CHECKING
 /* Sanity checks on DIEs.  */
 
 static void
@@ -5786,7 +5782,6 @@ check_die (dw_die_ref die)
 		    && a->dw_attr != DW_AT_GNU_all_call_sites);
     }
 }
-#endif
 \f
 /* Start a new compilation unit DIE for an include file.  OLD_UNIT is the CU
    for the enclosing include file, if any.  BINCL_DIE is the DW_TAG_GNU_BINCL
@@ -11763,14 +11758,14 @@ const_ok_for_output_1 (rtx rtl)
     {
       /* If delegitimize_address couldn't do anything with the UNSPEC, assume
 	 we can't express it in the debug info.  */
-#ifdef ENABLE_CHECKING
       /* Don't complain about TLS UNSPECs, those are just too hard to
 	 delegitimize.  Note this could be a non-decl SYMBOL_REF such as
 	 one in a constant pool entry, so testing SYMBOL_REF_TLS_MODEL
 	 rather than DECL_THREAD_LOCAL_P is not just an optimization.  */
-      if (XVECLEN (rtl, 0) == 0
-	  || GET_CODE (XVECEXP (rtl, 0, 0)) != SYMBOL_REF
-	  || SYMBOL_REF_TLS_MODEL (XVECEXP (rtl, 0, 0)) == TLS_MODEL_NONE)
+      if (flag_checking
+	  && (XVECLEN (rtl, 0) == 0
+	      || GET_CODE (XVECEXP (rtl, 0, 0)) != SYMBOL_REF
+	      || SYMBOL_REF_TLS_MODEL (XVECEXP (rtl, 0, 0)) == TLS_MODEL_NONE))
 	inform (current_function_decl
 		? DECL_SOURCE_LOCATION (current_function_decl)
 		: UNKNOWN_LOCATION,
@@ -11783,7 +11778,6 @@ const_ok_for_output_1 (rtx rtl)
 		"non-delegitimized UNSPEC %d found in variable location",
 		XINT (rtl, 1));
 #endif
-#endif
       expansion_failed (NULL_TREE, rtl,
 			"UNSPEC hasn't been delegitimized.\n");
       return false;
@@ -13570,12 +13564,12 @@ mem_loc_descriptor (rtx rtl, machine_mode mode,
       goto symref;
 
     default:
-#ifdef ENABLE_CHECKING
-      print_rtl (stderr, rtl);
-      gcc_unreachable ();
-#else
+      if (flag_checking)
+	{
+	  print_rtl (stderr, rtl);
+	  gcc_unreachable ();
+	}
       break;
-#endif
     }
 
   if (mem_loc_result && initialized == VAR_INIT_STATUS_UNINITIALIZED)
@@ -15098,15 +15092,14 @@ loc_list_from_tree (tree loc, int want_address,
 	  return 0;
 	}
 
-#ifdef ENABLE_CHECKING
       /* Otherwise this is a generic code; we should just lists all of
 	 these explicitly.  We forgot one.  */
-      gcc_unreachable ();
-#else
+      if (flag_checking)
+	gcc_unreachable ();
+
       /* In a release build, we want to degrade gracefully: better to
 	 generate incomplete debugging information than to crash.  */
       return NULL;
-#endif
     }
 
   if (!ret && !list_ret)
@@ -19908,18 +19901,17 @@ gen_lexical_block_die (tree stmt, dw_die_ref context_die)
     {
       if (old_die)
 	{
-#ifdef ENABLE_CHECKING
 	  /* This must have been generated early and it won't even
 	     need location information since it's a DW_AT_inline
 	     function.  */
-	  for (dw_die_ref c = context_die; c; c = c->die_parent)
-	    if (c->die_tag == DW_TAG_inlined_subroutine
-		|| c->die_tag == DW_TAG_subprogram)
-	      {
-		gcc_assert (get_AT (c, DW_AT_inline));
-		break;
-	      }
-#endif
+	  if (flag_checking)
+	    for (dw_die_ref c = context_die; c; c = c->die_parent)
+	      if (c->die_tag == DW_TAG_inlined_subroutine
+		  || c->die_tag == DW_TAG_subprogram)
+		{
+		  gcc_assert (get_AT (c, DW_AT_inline));
+		  break;
+		}
 	  return;
 	}
     }
@@ -20736,10 +20728,8 @@ gen_type_die_with_usage (tree type, dw_die_ref context_die,
   if (type == NULL_TREE || type == error_mark_node)
     return;
 
-#ifdef ENABLE_CHECKING
-  if (type)
+  if (flag_checking && type)
      verify_type (type);
-#endif
 
   if (TYPE_NAME (type) != NULL_TREE
       && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
@@ -20933,11 +20923,12 @@ gen_type_die (tree type, dw_die_ref context_die)
   if (type != error_mark_node)
     {
       gen_type_die_with_usage (type, context_die, DINFO_USAGE_DIR_USE);
-#ifdef ENABLE_CHECKING
-      dw_die_ref die = lookup_type_die (type);
-      if (die)
-	check_die (die);
-#endif
+      if (flag_checking)
+	{
+	  dw_die_ref die = lookup_type_die (type);
+	  if (die)
+	    check_die (die);
+	}
     }
 }
 
@@ -21975,11 +21966,12 @@ dwarf2out_decl (tree decl)
 
   gen_decl_die (decl, NULL, context_die);
 
-#ifdef ENABLE_CHECKING
-  dw_die_ref die = lookup_decl_die (decl);
-  if (die)
-    check_die (die);
-#endif
+  if (flag_checking)
+    {
+      dw_die_ref die = lookup_decl_die (decl);
+      if (die)
+	check_die (die);
+    }
 }
 
 /* Write the debugging output for DECL.  */
diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c
index c418c24..8d2e81c 100644
--- a/gcc/emit-rtl.c
+++ b/gcc/emit-rtl.c
@@ -2733,8 +2733,7 @@ verify_rtx_sharing (rtx orig, rtx insn)
 
   /* This rtx may not be shared.  If it has already been seen,
      replace it with a copy of itself.  */
-#ifdef ENABLE_CHECKING
-  if (RTX_FLAG (x, used))
+  if (flag_checking && RTX_FLAG (x, used))
     {
       error ("invalid rtl sharing found in the insn");
       debug_rtx (insn);
@@ -2742,7 +2741,6 @@ verify_rtx_sharing (rtx orig, rtx insn)
       debug_rtx (x);
       internal_error ("internal consistency failure");
     }
-#endif
   gcc_assert (!RTX_FLAG (x, used));
 
   RTX_FLAG (x, used) = 1;
@@ -4259,12 +4257,12 @@ delete_insns_since (rtx_insn *from)
 void
 reorder_insns_nobb (rtx_insn *from, rtx_insn *to, rtx_insn *after)
 {
-#ifdef ENABLE_CHECKING
-  rtx_insn *x;
-  for (x = from; x != to; x = NEXT_INSN (x))
-    gcc_assert (after != x);
-  gcc_assert (after != to);
-#endif
+  if (flag_checking)
+    {
+      for (rtx_insn *x = from; x != to; x = NEXT_INSN (x))
+	gcc_assert (after != x);
+      gcc_assert (after != to);
+    }
 
   /* Splice this bunch out of where it is now.  */
   if (PREV_INSN (from))
diff --git a/gcc/et-forest.c b/gcc/et-forest.c
index 4f919d4..bf2f765 100644
--- a/gcc/et-forest.c
+++ b/gcc/et-forest.c
@@ -28,7 +28,7 @@ License along with libiberty; see the file COPYING3.  If not see
 #include "alloc-pool.h"
 #include "et-forest.h"
 
-/* We do not enable this with ENABLE_CHECKING, since it is awfully slow.  */
+/* We do not enable this with CHECKING_P, since it is awfully slow.  */
 #undef DEBUG_ET
 
 #ifdef DEBUG_ET
diff --git a/gcc/except.c b/gcc/except.c
index 8f77653..5765d58 100644
--- a/gcc/except.c
+++ b/gcc/except.c
@@ -612,9 +612,8 @@ duplicate_eh_regions (struct function *ifun,
   struct duplicate_eh_regions_data data;
   eh_region outer_region;
 
-#ifdef ENABLE_CHECKING
-  verify_eh_tree (ifun);
-#endif
+  if (flag_checking)
+    verify_eh_tree (ifun);
 
   data.label_map = map;
   data.label_map_data = map_data;
@@ -632,9 +631,8 @@ duplicate_eh_regions (struct function *ifun,
 	duplicate_eh_regions_1 (&data, r, outer_region);
     }
 
-#ifdef ENABLE_CHECKING
-  verify_eh_tree (cfun);
-#endif
+  if (flag_checking)
+    verify_eh_tree (cfun);
 
   return data.eh_map;
 }
diff --git a/gcc/fwprop.c b/gcc/fwprop.c
index 16c7981..c9b29e6 100644
--- a/gcc/fwprop.c
+++ b/gcc/fwprop.c
@@ -843,9 +843,7 @@ all_uses_available_at (rtx_insn *def_insn, rtx_insn *target_insn)
 
 \f
 static df_ref *active_defs;
-#ifdef ENABLE_CHECKING
 static sparseset active_defs_check;
-#endif
 
 /* Fill the ACTIVE_DEFS array with the use->def link for the registers
    mentioned in USE_REC.  Register the valid entries in ACTIVE_DEFS_CHECK
@@ -859,9 +857,8 @@ register_active_defs (df_ref use)
       df_ref def = get_def_for_use (use);
       int regno = DF_REF_REGNO (use);
 
-#ifdef ENABLE_CHECKING
-      sparseset_set_bit (active_defs_check, regno);
-#endif
+      if (flag_checking)
+	sparseset_set_bit (active_defs_check, regno);
       active_defs[regno] = def;
     }
 }
@@ -876,9 +873,8 @@ register_active_defs (df_ref use)
 static void
 update_df_init (rtx_insn *def_insn, rtx_insn *insn)
 {
-#ifdef ENABLE_CHECKING
-  sparseset_clear (active_defs_check);
-#endif
+  if (flag_checking)
+    sparseset_clear (active_defs_check);
   register_active_defs (DF_INSN_USES (def_insn));
   register_active_defs (DF_INSN_USES (insn));
   register_active_defs (DF_INSN_EQ_USES (insn));
@@ -899,9 +895,7 @@ update_uses (df_ref use)
       if (DF_REF_ID (use) >= (int) use_def_ref.length ())
         use_def_ref.safe_grow_cleared (DF_REF_ID (use) + 1);
 
-#ifdef ENABLE_CHECKING
-      gcc_assert (sparseset_bit_p (active_defs_check, regno));
-#endif
+      gcc_checking_assert (sparseset_bit_p (active_defs_check, regno));
       use_def_ref[DF_REF_ID (use)] = active_defs[regno];
     }
 }
@@ -1407,9 +1401,8 @@ fwprop_init (void)
   df_set_flags (DF_DEFER_INSN_RESCAN);
 
   active_defs = XNEWVEC (df_ref, max_reg_num ());
-#ifdef ENABLE_CHECKING
-  active_defs_check = sparseset_alloc (max_reg_num ());
-#endif
+  if (flag_checking)
+    active_defs_check = sparseset_alloc (max_reg_num ());
 }
 
 static void
@@ -1419,9 +1412,8 @@ fwprop_done (void)
 
   use_def_ref.release ();
   free (active_defs);
-#ifdef ENABLE_CHECKING
-  sparseset_free (active_defs_check);
-#endif
+  if (flag_checking)
+    sparseset_free (active_defs_check);
 
   free_dominance_info (CDI_DOMINATORS);
   cleanup_cfg (0);
diff --git a/gcc/ggc-page.c b/gcc/ggc-page.c
index 34e9e24..deb21bb 100644
--- a/gcc/ggc-page.c
+++ b/gcc/ggc-page.c
@@ -2201,12 +2201,11 @@ ggc_collect (void)
 void
 ggc_grow (void)
 {
-#ifndef ENABLE_CHECKING
-  G.allocated_last_gc = MAX (G.allocated_last_gc,
-			     G.allocated);
-#else
-  ggc_collect ();
-#endif
+  if (!flag_checking)
+    G.allocated_last_gc = MAX (G.allocated_last_gc,
+			       G.allocated);
+  else
+    ggc_collect ();
   if (!quiet_flag)
     fprintf (stderr, " {GC start %luk} ", (unsigned long) G.allocated / 1024);
 }
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index a2d71d2..4390f7d 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -10319,10 +10319,8 @@ gimplify_body (tree fndecl, bool do_parms)
   pop_gimplify_context (outer_bind);
   gcc_assert (gimplify_ctxp == NULL);
 
-#ifdef ENABLE_CHECKING
-  if (!seen_error ())
+  if (flag_checking && !seen_error ())
     verify_gimple_in_seq (gimple_bind_body (outer_bind));
-#endif
 
   timevar_pop (TV_TREE_GIMPLIFY);
   input_location = saved_location;
@@ -10614,11 +10612,9 @@ gimplify_hasher::equal (const elt_t *p1, const elt_t *p2)
   if (!operand_equal_p (t1, t2, 0))
     return false;
 
-#ifdef ENABLE_CHECKING
   /* Only allow them to compare equal if they also hash equal; otherwise
      results are nondeterminate, and we fail bootstrap comparison.  */
-  gcc_assert (hash (p1) == hash (p2));
-#endif
+  gcc_checking_assert (hash (p1) == hash (p2));
 
   return true;
 }
diff --git a/gcc/graphite-isl-ast-to-gimple.c b/gcc/graphite-isl-ast-to-gimple.c
index de28477..fc4af5a 100644
--- a/gcc/graphite-isl-ast-to-gimple.c
+++ b/gcc/graphite-isl-ast-to-gimple.c
@@ -106,10 +106,8 @@ gmp_cst_to_tree (tree type, mpz_t val)
 static inline void
 graphite_verify (void)
 {
-#ifdef ENABLE_CHECKING
-  verify_loop_structure ();
-  verify_loop_closed_ssa (true);
-#endif
+  checking_verify_loop_structure ();
+  checking_verify_loop_closed_ssa (true);
 }
 
 /* IVS_PARAMS maps ISL's scattering and parameter identifiers
diff --git a/gcc/graphite-scop-detection.c b/gcc/graphite-scop-detection.c
index a95ec57..81158e5 100644
--- a/gcc/graphite-scop-detection.c
+++ b/gcc/graphite-scop-detection.c
@@ -259,21 +259,16 @@ canonicalize_loop_closed_ssa (loop_p loop)
 static void
 canonicalize_loop_closed_ssa_form (void)
 {
-  loop_p loop;
-
-#ifdef ENABLE_CHECKING
-  verify_loop_closed_ssa (true);
-#endif
+  checking_verify_loop_closed_ssa (true);
 
+  loop_p loop;
   FOR_EACH_LOOP (loop, 0)
     canonicalize_loop_closed_ssa (loop);
 
   rewrite_into_loop_closed_ssa (NULL, TODO_update_ssa);
   update_ssa (TODO_update_ssa);
 
-#ifdef ENABLE_CHECKING
-  verify_loop_closed_ssa (true);
-#endif
+  checking_verify_loop_closed_ssa (true);
 }
 
 /* Can all ivs be represented by a signed integer?
diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c
index c06d9de..91abcca 100644
--- a/gcc/graphite-sese-to-poly.c
+++ b/gcc/graphite-sese-to-poly.c
@@ -1522,9 +1522,7 @@ rewrite_reductions_out_of_ssa (scop_p scop)
       }
 
   update_ssa (TODO_update_ssa);
-#ifdef ENABLE_CHECKING
-  verify_loop_closed_ssa (true);
-#endif
+  checking_verify_loop_closed_ssa (true);
 }
 
 /* Rewrite the scalar dependence of DEF used in USE_STMT with a memory
@@ -1699,9 +1697,7 @@ rewrite_cross_bb_scalar_deps_out_of_ssa (scop_p scop)
     {
       scev_reset_htab ();
       update_ssa (TODO_update_ssa);
-#ifdef ENABLE_CHECKING
-      verify_loop_closed_ssa (true);
-#endif
+      checking_verify_loop_closed_ssa (true);
     }
 }
 
diff --git a/gcc/hash-table.h b/gcc/hash-table.h
index 8e3c2ca..192be30 100644
--- a/gcc/hash-table.h
+++ b/gcc/hash-table.h
@@ -638,9 +638,7 @@ hash_table<Descriptor, Allocator>::find_empty_slot_for_expand (hashval_t hash)
 
   if (is_empty (*slot))
     return slot;
-#ifdef ENABLE_CHECKING
   gcc_checking_assert (!is_deleted (*slot));
-#endif
 
   hash2 = hash_table_mod2 (hash, m_size_prime_index);
   for (;;)
@@ -652,9 +650,7 @@ hash_table<Descriptor, Allocator>::find_empty_slot_for_expand (hashval_t hash)
       slot = m_entries + index;
       if (is_empty (*slot))
         return slot;
-#ifdef ENABLE_CHECKING
       gcc_checking_assert (!is_deleted (*slot));
-#endif
     }
 }
 
diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c
index d0ae494..ca53755 100644
--- a/gcc/ifcvt.c
+++ b/gcc/ifcvt.c
@@ -5093,9 +5093,7 @@ if_convert (bool after_combine)
   if (optimize == 1)
     df_remove_problem (df_live);
 
-#ifdef ENABLE_CHECKING
-  verify_flow_info ();
-#endif
+  checking_verify_flow_info ();
 }
 \f
 /* If-conversion and CFG cleanup.  */
diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c
index ef93b20..d1c6236 100644
--- a/gcc/ipa-cp.c
+++ b/gcc/ipa-cp.c
@@ -2920,9 +2920,8 @@ ipcp_propagate_stage (struct ipa_topo_info *topo)
 	     overall_size, max_new_size);
 
   propagate_constants_topo (topo);
-#ifdef ENABLE_CHECKING
-  ipcp_verify_propagated_values ();
-#endif
+  if (flag_checking)
+    ipcp_verify_propagated_values ();
   topo->constants.propagate_effects ();
   topo->contexts.propagate_effects ();
 
diff --git a/gcc/ipa-devirt.c b/gcc/ipa-devirt.c
index a7a8e8e..69dec05 100644
--- a/gcc/ipa-devirt.c
+++ b/gcc/ipa-devirt.c
@@ -272,11 +272,10 @@ type_in_anonymous_namespace_p (const_tree t)
     {
       /* C++ FE uses magic <anon> as assembler names of anonymous types.
  	 verify that this match with type_in_anonymous_namespace_p.  */
-#ifdef ENABLE_CHECKING
       if (in_lto_p)
-	gcc_assert (!strcmp ("<anon>",
-		    IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (TYPE_NAME (t)))));
-#endif
+	gcc_checking_assert (!strcmp ("<anon>",
+				      IDENTIFIER_POINTER
+					(DECL_ASSEMBLER_NAME (TYPE_NAME (t)))));
       return true;
     }
   return false;
@@ -300,15 +299,13 @@ odr_type_p (const_tree t)
   if (TYPE_NAME (t) && TREE_CODE (TYPE_NAME (t)) == TYPE_DECL
       && (DECL_ASSEMBLER_NAME_SET_P (TYPE_NAME (t))))
     {
-#ifdef ENABLE_CHECKING
       /* C++ FE uses magic <anon> as assembler names of anonymous types.
  	 verify that this match with type_in_anonymous_namespace_p.  */
-      gcc_assert (!type_with_linkage_p (t)
-		  || strcmp ("<anon>",
-			     IDENTIFIER_POINTER
-			        (DECL_ASSEMBLER_NAME (TYPE_NAME (t))))
-		  || type_in_anonymous_namespace_p (t));
-#endif
+      gcc_checking_assert (!type_with_linkage_p (t)
+			   || strcmp ("<anon>",
+				      IDENTIFIER_POINTER
+					(DECL_ASSEMBLER_NAME (TYPE_NAME (t))))
+			   || type_in_anonymous_namespace_p (t));
       return true;
     }
   return false;
@@ -1777,11 +1774,10 @@ odr_types_equivalent_p (tree t1, tree t2, bool warn, bool *warned,
 bool
 odr_types_equivalent_p (tree type1, tree type2)
 {
-  hash_set<type_pair> visited;
+  gcc_checking_assert (odr_or_derived_type_p (type1)
+		       && odr_or_derived_type_p (type2));
 
-#ifdef ENABLE_CHECKING
-  gcc_assert (odr_or_derived_type_p (type1) && odr_or_derived_type_p (type2));
-#endif
+  hash_set<type_pair> visited;
   return odr_types_equivalent_p (type1, type2, false, NULL,
 			         &visited, UNKNOWN_LOCATION, UNKNOWN_LOCATION);
 }
@@ -2000,8 +1996,8 @@ add_type_duplicate (odr_type val, tree type)
     }
   gcc_assert (val->odr_violated || !odr_must_violate);
   /* Sanity check that all bases will be build same way again.  */
-#ifdef ENABLE_CHECKING
-  if (COMPLETE_TYPE_P (type) && COMPLETE_TYPE_P (val->type)
+  if (flag_checking
+      && COMPLETE_TYPE_P (type) && COMPLETE_TYPE_P (val->type)
       && TREE_CODE (val->type) == RECORD_TYPE
       && TREE_CODE (type) == RECORD_TYPE
       && TYPE_BINFO (val->type) && TYPE_BINFO (type)
@@ -2030,7 +2026,6 @@ add_type_duplicate (odr_type val, tree type)
 	    j++;
 	  }
     }
-#endif
 
 
   /* Regularize things a little.  During LTO same types may come with
@@ -2136,8 +2131,8 @@ get_odr_type (tree type, bool insert)
       if (slot && *slot)
 	{
 	  val = *slot;
-#ifdef ENABLE_CHECKING
-	  if (in_lto_p && can_be_vtable_hashed_p (type))
+	  if (flag_checking
+	      && in_lto_p && can_be_vtable_hashed_p (type))
 	    {
 	      hash = hash_odr_vtable (type);
 	      vtable_slot = odr_vtable_hash->find_slot_with_hash (type, hash,
@@ -2145,7 +2140,6 @@ get_odr_type (tree type, bool insert)
 	      gcc_assert (!vtable_slot || *vtable_slot == *slot);
 	      vtable_slot = NULL;
 	    }
-#endif
 	}
       else if (*vtable_slot)
 	val = *vtable_slot;
diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c
index b0ef9f1..175f70f 100644
--- a/gcc/ipa-icf.c
+++ b/gcc/ipa-icf.c
@@ -2599,7 +2599,7 @@ sem_item_optimizer::execute (void)
   dump_cong_classes ();
 
   process_cong_reduction ();
-  verify_classes ();
+  checking_verify_classes ();
 
   if (dump_file)
     fprintf (dump_file, "Dump after callgraph-based congruence reduction\n");
@@ -2618,7 +2618,7 @@ sem_item_optimizer::execute (void)
 
   process_cong_reduction ();
   dump_cong_classes ();
-  verify_classes ();
+  checking_verify_classes ();
   bool merged_p = merge_classes (prev_class_count);
 
   if (dump_file && (dump_flags & TDF_DETAILS))
@@ -2883,7 +2883,7 @@ sem_item_optimizer::subdivide_classes_by_equality (bool in_wpa)
 	}
     }
 
-  verify_classes ();
+  checking_verify_classes ();
 }
 
 /* Subdivide classes by address references that members of the class
@@ -2977,12 +2977,20 @@ sem_item_optimizer::subdivide_classes_by_sensitive_refs ()
   return newly_created_classes;
 }
 
-/* Verify congruence classes if checking is enabled.  */
+/* Verify congruence classes, if checking is enabled.  */
+
+void
+sem_item_optimizer::checking_verify_classes (void)
+{
+  if (flag_checking)
+    verify_classes ();
+}
+
+/* Verify congruence classes.  */
 
 void
 sem_item_optimizer::verify_classes (void)
 {
-#if ENABLE_CHECKING
   for (hash_table <congruence_class_group_hash>::iterator it = m_classes.begin ();
        it != m_classes.end (); ++it)
     {
@@ -2990,26 +2998,25 @@ sem_item_optimizer::verify_classes (void)
 	{
 	  congruence_class *cls = (*it)->classes[i];
 
-	  gcc_checking_assert (cls);
-	  gcc_checking_assert (cls->members.length () > 0);
+	  gcc_assert (cls);
+	  gcc_assert (cls->members.length () > 0);
 
 	  for (unsigned int j = 0; j < cls->members.length (); j++)
 	    {
 	      sem_item *item = cls->members[j];
 
-	      gcc_checking_assert (item);
-	      gcc_checking_assert (item->cls == cls);
+	      gcc_assert (item);
+	      gcc_assert (item->cls == cls);
 
 	      for (unsigned k = 0; k < item->usages.length (); k++)
 		{
 		  sem_usage_pair *usage = item->usages[k];
-		  gcc_checking_assert (usage->item->index_in_class <
-				       usage->item->cls->members.length ());
+		  gcc_assert (usage->item->index_in_class <
+			      usage->item->cls->members.length ());
 		}
 	    }
 	}
     }
-#endif
 }
 
 /* Disposes split map traverse function. CLS_PTR is pointer to congruence
@@ -3054,10 +3061,11 @@ sem_item_optimizer::traverse_congruence_split (congruence_class * const &cls,
 	  add_item_to_class (tc, cls->members[i]);
 	}
 
-#ifdef ENABLE_CHECKING
-      for (unsigned int i = 0; i < 2; i++)
-	gcc_checking_assert (newclasses[i]->members.length ());
-#endif
+      if (flag_checking)
+	{
+	  for (unsigned int i = 0; i < 2; i++)
+	    gcc_assert (newclasses[i]->members.length ());
+	}
 
       if (splitter_cls == cls)
 	optimizer->splitter_class_removed = true;
@@ -3152,11 +3160,9 @@ sem_item_optimizer::do_congruence_step_for_index (congruence_class *cls,
 	  else
 	    b = *slot;
 
-#if ENABLE_CHECKING
 	  gcc_checking_assert (usage->item->cls);
 	  gcc_checking_assert (usage->item->index_in_class <
 			       usage->item->cls->members.length ());
-#endif
 
 	  bitmap_set_bit (b, usage->item->index_in_class);
 	}
diff --git a/gcc/ipa-icf.h b/gcc/ipa-icf.h
index ba37426..365e86f 100644
--- a/gcc/ipa-icf.h
+++ b/gcc/ipa-icf.h
@@ -479,6 +479,9 @@ public:
   void dump (void);
 
   /* Verify congruence classes if checking is enabled.  */
+  void checking_verify_classes (void);
+
+  /* Verify congruence classes.  */
   void verify_classes (void);
 
   /* Write IPA ICF summary for symbols.  */
diff --git a/gcc/ipa-inline-analysis.c b/gcc/ipa-inline-analysis.c
index 35322cc..e93d445 100644
--- a/gcc/ipa-inline-analysis.c
+++ b/gcc/ipa-inline-analysis.c
@@ -2964,10 +2964,12 @@ compute_inline_parameters (struct cgraph_node *node, bool early)
   info->size = info->self_size;
   info->stack_frame_offset = 0;
   info->estimated_stack_size = info->estimated_self_stack_size;
-#ifdef ENABLE_CHECKING
-  inline_update_overall_summary (node);
-  gcc_assert (info->time == info->self_time && info->size == info->self_size);
-#endif
+  if (flag_checking)
+    {
+      inline_update_overall_summary (node);
+      gcc_assert (info->time == info->self_time
+		  && info->size == info->self_size);
+    }
 
   pop_cfun ();
 }
diff --git a/gcc/ipa-inline-transform.c b/gcc/ipa-inline-transform.c
index 12f701a..1d7bcaa 100644
--- a/gcc/ipa-inline-transform.c
+++ b/gcc/ipa-inline-transform.c
@@ -491,10 +491,9 @@ save_inline_function_body (struct cgraph_node *node)
       first_clone->remove_symbol_and_inline_clones ();
       first_clone = NULL;
     }
-#ifdef ENABLE_CHECKING
-  else
+  else if (flag_checking)
     first_clone->verify ();
-#endif
+
   return first_clone;
 }
 
diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c
index 8f3919c..db98755 100644
--- a/gcc/ipa-inline.c
+++ b/gcc/ipa-inline.c
@@ -1878,7 +1878,7 @@ inline_small_functions (void)
       if (!edge->inline_failed || !edge->callee->analyzed)
 	continue;
 
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
       /* Be sure that caches are maintained consistent.  */
       sreal cached_badness = edge_badness (edge, false);
  
@@ -2632,9 +2632,8 @@ early_inliner (function *fun)
   if (ipa_node_params_sum)
     return 0;
 
-#ifdef ENABLE_CHECKING
-  node->verify ();
-#endif
+  if (flag_checking)
+    node->verify ();
   node->remove_all_references ();
 
   /* Rebuild this reference because it dosn't depend on
diff --git a/gcc/ipa-inline.h b/gcc/ipa-inline.h
index 85041f6..323d117 100644
--- a/gcc/ipa-inline.h
+++ b/gcc/ipa-inline.h
@@ -299,10 +299,8 @@ estimate_edge_size (struct cgraph_edge *edge)
 static inline int
 estimate_edge_growth (struct cgraph_edge *edge)
 {
-#ifdef ENABLE_CHECKING
   gcc_checking_assert (inline_edge_summary (edge)->call_stmt_size
 		       || !edge->callee->analyzed);
-#endif
   return (estimate_edge_size (edge)
 	  - inline_edge_summary (edge)->call_stmt_size);
 }
diff --git a/gcc/ipa-visibility.c b/gcc/ipa-visibility.c
index 93073d8..0ae4388 100644
--- a/gcc/ipa-visibility.c
+++ b/gcc/ipa-visibility.c
@@ -464,16 +464,15 @@ function_and_variable_visibility (bool whole_program)
 	 what comdat group they are in when they won't be emitted in this TU.  */
       if (node->same_comdat_group && DECL_EXTERNAL (node->decl))
 	{
-#ifdef ENABLE_CHECKING
-	  symtab_node *n;
-
-	  for (n = node->same_comdat_group;
-	       n != node;
-	       n = n->same_comdat_group)
-	      /* If at least one of same comdat group functions is external,
-		 all of them have to be, otherwise it is a front-end bug.  */
-	      gcc_assert (DECL_EXTERNAL (n->decl));
-#endif
+	  if (flag_checking)
+	    {
+	      for (symtab_node *n = node->same_comdat_group;
+		   n != node;
+		   n = n->same_comdat_group)
+		/* If at least one of same comdat group functions is external,
+		   all of them have to be, otherwise it is a front-end bug.  */
+		gcc_assert (DECL_EXTERNAL (n->decl));
+	    }
 	  node->dissolve_same_comdat_group_list ();
 	}
       gcc_assert ((!DECL_WEAK (node->decl)
diff --git a/gcc/ipa.c b/gcc/ipa.c
index 6847305..6dc23ae 100644
--- a/gcc/ipa.c
+++ b/gcc/ipa.c
@@ -319,12 +319,13 @@ symbol_table::remove_unreachable_nodes (FILE *file)
   build_type_inheritance_graph ();
   if (file)
     fprintf (file, "\nReclaiming functions:");
-#ifdef ENABLE_CHECKING
-  FOR_EACH_FUNCTION (node)
-    gcc_assert (!node->aux);
-  FOR_EACH_VARIABLE (vnode)
-    gcc_assert (!vnode->aux);
-#endif
+  if (flag_checking)
+    {
+      FOR_EACH_FUNCTION (node)
+	gcc_assert (!node->aux);
+      FOR_EACH_VARIABLE (vnode)
+	gcc_assert (!vnode->aux);
+    }
   /* Mark functions whose bodies are obviously needed.
      This is mostly when they can be referenced externally.  Inline clones
      are special since their declarations are shared with master clone and thus
@@ -678,9 +679,7 @@ symbol_table::remove_unreachable_nodes (FILE *file)
   if (file)
     fprintf (file, "\n");
 
-#ifdef ENABLE_CHECKING
-  symtab_node::verify_symtab_nodes ();
-#endif
+  symtab_node::checking_verify_symtab_nodes ();
 
   /* If we removed something, perhaps profile could be improved.  */
   if (changed && optimize && inline_edge_summary_vec.exists ())
@@ -1370,13 +1369,12 @@ ipa_single_use (void)
     {
       if (var->aux != BOTTOM)
 	{
-#ifdef ENABLE_CHECKING
 	  /* Not having the single user known means that the VAR is
 	     unreachable.  Either someone forgot to remove unreachable
 	     variables or the reachability here is wrong.  */
 
-          gcc_assert (single_user_map.get (var));
-#endif
+	  gcc_checking_assert (single_user_map.get (var));
+
 	  if (dump_file)
 	    {
 	      fprintf (dump_file, "Variable %s/%i is used by single function\n",
diff --git a/gcc/ira-int.h b/gcc/ira-int.h
index af6c92f..d4160d3 100644
--- a/gcc/ira-int.h
+++ b/gcc/ira-int.h
@@ -26,7 +26,7 @@ along with GCC; see the file COPYING3.  If not see
 /* To provide consistency in naming, all IRA external variables,
    functions, common typedefs start with prefix ira_.  */
 
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
 #define ENABLE_IRA_CHECKING
 #endif
 
diff --git a/gcc/ira.c b/gcc/ira.c
index 4e94632..8e71d50 100644
--- a/gcc/ira.c
+++ b/gcc/ira.c
@@ -5153,9 +5153,9 @@ ira (FILE *f)
     df_remove_problem (df_live);
   gcc_checking_assert (df_live == NULL);
 
-#ifdef ENABLE_CHECKING
-  df->changeable_flags |= DF_VERIFY_SCHEDULED;
-#endif
+  if (flag_checking)
+    df->changeable_flags |= DF_VERIFY_SCHEDULED;
+
   df_analyze ();
 
   init_reg_equiv ();
diff --git a/gcc/loop-doloop.c b/gcc/loop-doloop.c
index 6554597..592ae1f 100644
--- a/gcc/loop-doloop.c
+++ b/gcc/loop-doloop.c
@@ -734,7 +734,5 @@ doloop_optimize_loops (void)
 
   iv_analysis_done ();
 
-#ifdef ENABLE_CHECKING
-  verify_loop_structure ();
-#endif
+  checking_verify_loop_structure ();
 }
diff --git a/gcc/loop-init.c b/gcc/loop-init.c
index 2a38a0f..cd96e70 100644
--- a/gcc/loop-init.c
+++ b/gcc/loop-init.c
@@ -104,10 +104,8 @@ loop_optimizer_init (unsigned flags)
       /* Ensure that the dominators are computed, like flow_loops_find does.  */
       calculate_dominance_info (CDI_DOMINATORS);
 
-#ifdef ENABLE_CHECKING
       if (!needs_fixup)
-	verify_loop_structure ();
-#endif
+	checking_verify_loop_structure ();
 
       /* Clear all flags.  */
       if (recorded_exits)
@@ -129,9 +127,7 @@ loop_optimizer_init (unsigned flags)
   /* Dump loops.  */
   flow_loops_dump (dump_file, NULL, 1);
 
-#ifdef ENABLE_CHECKING
-  verify_loop_structure ();
-#endif
+  checking_verify_loop_structure ();
 
   timevar_pop (TV_LOOP_INIT);
 }
@@ -323,9 +319,7 @@ fix_loop_structure (bitmap changed_bbs)
   /* Apply flags to loops.  */
   apply_loop_flags (current_loops->state | record_exits);
 
-#ifdef ENABLE_CHECKING
-  verify_loop_structure ();
-#endif
+  checking_verify_loop_structure ();
 
   timevar_pop (TV_LOOP_INIT);
 
diff --git a/gcc/loop-invariant.c b/gcc/loop-invariant.c
index 7ac38c6..696f0ee 100644
--- a/gcc/loop-invariant.c
+++ b/gcc/loop-invariant.c
@@ -2137,7 +2137,5 @@ move_loop_invariants (void)
   invariant_table = NULL;
   invariant_table_size = 0;
 
-#ifdef ENABLE_CHECKING
-  verify_flow_info ();
-#endif
+  checking_verify_flow_info ();
 }
diff --git a/gcc/lra-assigns.c b/gcc/lra-assigns.c
index 2986f57..a17e22c 100644
--- a/gcc/lra-assigns.c
+++ b/gcc/lra-assigns.c
@@ -1591,15 +1591,13 @@ lra_assign (void)
   bitmap_initialize (&all_spilled_pseudos, &reg_obstack);
   create_live_range_start_chains ();
   setup_live_pseudos_and_spill_after_risky_transforms (&all_spilled_pseudos);
-#ifdef ENABLE_CHECKING
-  if (!flag_ipa_ra)
+  if (flag_checking && !flag_ipa_ra)
     for (i = FIRST_PSEUDO_REGISTER; i < max_regno; i++)
       if (lra_reg_info[i].nrefs != 0 && reg_renumber[i] >= 0
 	  && lra_reg_info[i].call_p
 	  && overlaps_hard_reg_set_p (call_used_reg_set,
 				      PSEUDO_REGNO_MODE (i), reg_renumber[i]))
 	gcc_unreachable ();
-#endif
   /* Setup insns to process on the next constraint pass.  */
   bitmap_initialize (&changed_pseudo_bitmap, &reg_obstack);
   init_live_reload_and_inheritance_pseudos ();
diff --git a/gcc/lra-constraints.c b/gcc/lra-constraints.c
index afe885a..bc7a292 100644
--- a/gcc/lra-constraints.c
+++ b/gcc/lra-constraints.c
@@ -4455,8 +4455,7 @@ lra_constraints (bool first_p)
   bitmap_clear (&equiv_insn_bitmap);
   /* If we used a new hard regno, changed_p should be true because the
      hard reg is assigned to a new pseudo.  */
-#ifdef ENABLE_CHECKING
-  if (! changed_p)
+  if (flag_checking && !changed_p)
     {
       for (i = FIRST_PSEUDO_REGISTER; i < new_regno_start; i++)
 	if (lra_reg_info[i].nrefs != 0
@@ -4468,7 +4467,6 @@ lra_constraints (bool first_p)
 	      lra_assert (df_regs_ever_live_p (hard_regno + j));
 	  }
     }
-#endif
   return changed_p;
 }
 
diff --git a/gcc/lra-eliminations.c b/gcc/lra-eliminations.c
index fdf4179..448e645 100644
--- a/gcc/lra-eliminations.c
+++ b/gcc/lra-eliminations.c
@@ -1436,11 +1436,11 @@ lra_eliminate (bool final_p, bool first_p)
   bitmap_initialize (&insns_with_changed_offsets, &reg_obstack);
   if (final_p)
     {
-#ifdef ENABLE_CHECKING
-      update_reg_eliminate (&insns_with_changed_offsets);
-      if (! bitmap_empty_p (&insns_with_changed_offsets))
-	gcc_unreachable ();
-#endif
+      if (flag_checking)
+	{
+	  update_reg_eliminate (&insns_with_changed_offsets);
+	  gcc_assert (bitmap_empty_p (&insns_with_changed_offsets));
+	}
       /* We change eliminable hard registers in insns so we should do
 	 this for all insns containing any eliminable hard
 	 register.  */
diff --git a/gcc/lra-int.h b/gcc/lra-int.h
index 5e78604..02b0ae4 100644
--- a/gcc/lra-int.h
+++ b/gcc/lra-int.h
@@ -91,12 +91,10 @@ struct lra_reg
   /* True if the pseudo should not be assigned to a stack register.  */
   bool no_stack_p;
 #endif
-#ifdef ENABLE_CHECKING
   /* True if the pseudo crosses a call.	 It is setup in lra-lives.c
      and used to check that the pseudo crossing a call did not get a
      call used hard register.  */
   bool call_p;
-#endif
   /* Number of references and execution frequencies of the register in
      *non-debug* insns.	 */
   int nrefs, freq;
diff --git a/gcc/lra-lives.c b/gcc/lra-lives.c
index 253bc18..a2c5542 100644
--- a/gcc/lra-lives.c
+++ b/gcc/lra-lives.c
@@ -590,9 +590,7 @@ check_pseudos_live_through_calls (int regno)
   for (hr = 0; hr < FIRST_PSEUDO_REGISTER; hr++)
     if (HARD_REGNO_CALL_PART_CLOBBERED (hr, PSEUDO_REGNO_MODE (regno)))
       SET_HARD_REG_BIT (lra_reg_info[regno].conflict_hard_regs, hr);
-#ifdef ENABLE_CHECKING
   lra_reg_info[regno].call_p = true;
-#endif
   if (! sparseset_bit_p (pseudos_live_through_setjumps, regno))
     return;
   sparseset_clear_bit (pseudos_live_through_setjumps, regno);
@@ -1229,9 +1227,7 @@ lra_create_live_ranges_1 (bool all_p, bool dead_insn_p)
 	lra_reg_info[i].biggest_mode = GET_MODE (regno_reg_rtx[i]);
       else
 	lra_reg_info[i].biggest_mode = VOIDmode;
-#ifdef ENABLE_CHECKING
       lra_reg_info[i].call_p = false;
-#endif
       if (i >= FIRST_PSEUDO_REGISTER
 	  && lra_reg_info[i].nrefs != 0)
 	{
diff --git a/gcc/lra-remat.c b/gcc/lra-remat.c
index 66532b8..68ce502 100644
--- a/gcc/lra-remat.c
+++ b/gcc/lra-remat.c
@@ -578,10 +578,8 @@ create_remat_bb_data (void)
 			   last_basic_block_for_fn (cfun));
   FOR_ALL_BB_FN (bb, cfun)
     {
-#ifdef ENABLE_CHECKING
-      if (bb->index < 0 || bb->index >= last_basic_block_for_fn (cfun))
-	abort ();
-#endif
+      gcc_checking_assert (bb->index >= 0
+			   && bb->index < last_basic_block_for_fn (cfun));
       bb_info = get_remat_bb_data (bb);
       bb_info->bb = bb;
       bitmap_initialize (&bb_info->changed_regs, &reg_obstack);
diff --git a/gcc/lra.c b/gcc/lra.c
index 55b856f..cc5a850 100644
--- a/gcc/lra.c
+++ b/gcc/lra.c
@@ -1199,30 +1199,22 @@ lra_update_insn_recog_data (rtx_insn *insn)
 	  decode_asm_operands (PATTERN (insn), NULL,
 			       data->operand_loc,
 			       constraints, operand_mode, NULL);
-#ifdef ENABLE_CHECKING
-	  {
-	    int i;
 
-	    for (i = 0; i < nop; i++)
+	  if (flag_checking)
+	    for (int i = 0; i < nop; i++)
 	      lra_assert
 		(insn_static_data->operand[i].mode == operand_mode[i]
 		 && insn_static_data->operand[i].constraint == constraints[i]
 		 && ! insn_static_data->operand[i].is_operator);
-	  }
-#endif
 	}
-#ifdef ENABLE_CHECKING
-      {
-	int i;
 
-	for (i = 0; i < insn_static_data->n_operands; i++)
+      if (flag_checking)
+	for (int i = 0; i < insn_static_data->n_operands; i++)
 	  lra_assert
 	    (insn_static_data->operand[i].type
 	     == (insn_static_data->operand[i].constraint[0] == '=' ? OP_OUT
 		 : insn_static_data->operand[i].constraint[0] == '+' ? OP_INOUT
 		 : OP_IN));
-      }
-#endif
     }
   else
     {
@@ -2004,8 +1996,6 @@ restore_scratches (void)
 
 \f
 
-#ifdef ENABLE_CHECKING
-
 /* Function checks RTL for correctness.	 If FINAL_P is true, it is
    done at the end of LRA and the check is more rigorous.  */
 static void
@@ -2024,9 +2014,7 @@ check_rtl (bool final_p)
       {
 	if (final_p)
 	  {
-#ifdef ENABLED_CHECKING
 	    extract_constrain_insn (insn);
-#endif
 	    continue;
 	  }
 	/* LRA code is based on assumption that all addresses can be
@@ -2039,7 +2027,6 @@ check_rtl (bool final_p)
 	  fatal_insn_not_found (insn);
       }
 }
-#endif /* #ifdef ENABLE_CHECKING */
 
 /* Determine if the current function has an exception receiver block
    that reaches the exit block via non-exceptional edges  */
@@ -2233,10 +2220,9 @@ lra (FILE *f)
 
   init_insn_recog_data ();
 
-#ifdef ENABLE_CHECKING
   /* Some quick check on RTL generated by previous passes.  */
-  check_rtl (false);
-#endif
+  if (flag_checking)
+    check_rtl (false);
 
   lra_in_progress = 1;
 
@@ -2437,9 +2423,8 @@ lra (FILE *f)
      by this, so unshare everything here.  */
   unshare_all_rtl_again (get_insns ());
 
-#ifdef ENABLE_CHECKING
-  check_rtl (true);
-#endif
+  if (flag_checking)
+    check_rtl (true);
 
   timevar_pop (TV_LRA);
 }
diff --git a/gcc/lto-cgraph.c b/gcc/lto-cgraph.c
index 51f31c8..eb6f7b6 100644
--- a/gcc/lto-cgraph.c
+++ b/gcc/lto-cgraph.c
@@ -1560,10 +1560,11 @@ input_cgraph_1 (struct lto_file_decl_data *file_data,
   lto_input_toplevel_asms (file_data, order_base);
 
   /* AUX pointers should be all non-zero for function nodes read from the stream.  */
-#ifdef ENABLE_CHECKING
-  FOR_EACH_VEC_ELT (nodes, i, node)
-    gcc_assert (node->aux || !is_a <cgraph_node *> (node));
-#endif
+  if (flag_checking)
+    {
+      FOR_EACH_VEC_ELT (nodes, i, node)
+	gcc_assert (node->aux || !is_a <cgraph_node *> (node));
+    }
   FOR_EACH_VEC_ELT (nodes, i, node)
     {
       int ref;
diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c
index 11daf7a..d54beca 100644
--- a/gcc/lto-streamer-out.c
+++ b/gcc/lto-streamer-out.c
@@ -607,17 +607,12 @@ DFS::DFS (struct output_block *ob, tree expr, bool ref_p, bool this_ref_p,
 		std::swap (sccstack[first + i],
 			   sccstack[first + entry_start + i]);
 
-	      if (scc_entry_len == 1)
-		; /* We already sorted SCC deterministically in hash_scc.  */
-	      else
-		/* Check that we have only one SCC.
-		   Naturally we may have conflicts if hash function is not
- 		   strong enough.  Lets see how far this gets.  */
-		{
-#ifdef ENABLE_CHECKING
-		  gcc_unreachable ();
-#endif
-		}
+	      /* We already sorted SCC deterministically in hash_scc.  */
+
+	      /* Check that we have only one SCC.
+		 Naturally we may have conflicts if hash function is not
+		 strong enough.  Lets see how far this gets.  */
+	      gcc_checking_assert (scc_entry_len == 1);
 	    }
 
 	  /* Write LTO_tree_scc.  */
@@ -2277,12 +2272,13 @@ void
 lto_output (void)
 {
   struct lto_out_decl_state *decl_state;
-#ifdef ENABLE_CHECKING
-  bitmap output = lto_bitmap_alloc ();
-#endif
+  bitmap output = NULL;
   int i, n_nodes;
   lto_symtab_encoder_t encoder = lto_get_out_decl_state ()->symtab_node_encoder;
 
+  if (flag_checking)
+    output = lto_bitmap_alloc ();
+
   /* Initialize the streamer.  */
   lto_streamer_init ();
 
@@ -2296,10 +2292,11 @@ lto_output (void)
 	  if (lto_symtab_encoder_encode_body_p (encoder, node)
 	      && !node->alias)
 	    {
-#ifdef ENABLE_CHECKING
-	      gcc_assert (!bitmap_bit_p (output, DECL_UID (node->decl)));
-	      bitmap_set_bit (output, DECL_UID (node->decl));
-#endif
+	      if (flag_checking)
+		{
+		  gcc_assert (!bitmap_bit_p (output, DECL_UID (node->decl)));
+		  bitmap_set_bit (output, DECL_UID (node->decl));
+		}
 	      decl_state = lto_new_out_decl_state ();
 	      lto_push_out_decl_state (decl_state);
 	      if (gimple_has_body_p (node->decl) || !flag_wpa
@@ -2326,10 +2323,11 @@ lto_output (void)
 	      && !node->alias)
 	    {
 	      timevar_push (TV_IPA_LTO_CTORS_OUT);
-#ifdef ENABLE_CHECKING
-	      gcc_assert (!bitmap_bit_p (output, DECL_UID (node->decl)));
-	      bitmap_set_bit (output, DECL_UID (node->decl));
-#endif
+	      if (flag_checking)
+		{
+		  gcc_assert (!bitmap_bit_p (output, DECL_UID (node->decl)));
+		  bitmap_set_bit (output, DECL_UID (node->decl));
+		}
 	      decl_state = lto_new_out_decl_state ();
 	      lto_push_out_decl_state (decl_state);
 	      if (DECL_INITIAL (node->decl) != error_mark_node
@@ -2353,7 +2351,7 @@ lto_output (void)
 
   output_offload_tables ();
 
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
   lto_bitmap_free (output);
 #endif
 }
diff --git a/gcc/lto-streamer.c b/gcc/lto-streamer.c
index b34ab8b..92b313a 100644
--- a/gcc/lto-streamer.c
+++ b/gcc/lto-streamer.c
@@ -297,13 +297,12 @@ static hash_table<tree_hash_entry> *tree_htab;
 void
 lto_streamer_init (void)
 {
-#ifdef ENABLE_CHECKING
   /* Check that all the TS_* handled by the reader and writer routines
      match exactly the structures defined in treestruct.def.  When a
      new TS_* astructure is added, the streamer should be updated to
      handle it.  */
-  streamer_check_handled_ts_structures ();
-#endif
+  if (flag_checking)
+    streamer_check_handled_ts_structures ();
 
 #ifdef LTO_STREAMER_DEBUG
   tree_htab = new hash_table<tree_hash_entry> (31);
diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c
index 76f8e07..def681d 100644
--- a/gcc/lto/lto.c
+++ b/gcc/lto/lto.c
@@ -1586,19 +1586,18 @@ unify_scc (struct data_in *data_in, unsigned from,
 	  num_sccs_merged++;
 	  total_scc_size_merged += len;
 
-#ifdef ENABLE_CHECKING
-	  for (unsigned i = 0; i < len; ++i)
-	    {
-	      tree t = map[2*i+1];
-	      enum tree_code code = TREE_CODE (t);
-	      /* IDENTIFIER_NODEs should be singletons and are merged by the
-		 streamer.  The others should be singletons, too, and we
-		 should not merge them in any way.  */
-	      gcc_assert (code != TRANSLATION_UNIT_DECL
-			  && code != IDENTIFIER_NODE
-			  && !streamer_handle_as_builtin_p (t));
-	    }
-#endif
+	  if (flag_checking)
+	    for (unsigned i = 0; i < len; ++i)
+	      {
+		tree t = map[2*i+1];
+		enum tree_code code = TREE_CODE (t);
+		/* IDENTIFIER_NODEs should be singletons and are merged by the
+		   streamer.  The others should be singletons, too, and we
+		   should not merge them in any way.  */
+		gcc_assert (code != TRANSLATION_UNIT_DECL
+			    && code != IDENTIFIER_NODE
+			    && !streamer_handle_as_builtin_p (t));
+	      }
 
 	  /* Fixup the streamer cache with the prevailing nodes according
 	     to the tree node mapping computed by compare_tree_sccs.  */
@@ -2636,10 +2635,8 @@ lto_fixup_state (struct lto_in_decl_state *state)
       for (i = 0; i < vec_safe_length (trees); i++)
 	{
 	  tree t = (*trees)[i];
-#ifdef ENABLE_CHECKING
-	  if (TYPE_P (t))
+	  if (flag_checking && TYPE_P (t))
 	    verify_type (t);
-#endif
 	  if (VAR_OR_FUNCTION_DECL_P (t)
 	      && (TREE_PUBLIC (t) || DECL_EXTERNAL (t)))
 	    (*trees)[i] = lto_symtab_prevailing_decl (t);
@@ -3101,9 +3098,8 @@ do_whole_program_analysis (void)
       fprintf (symtab->dump_file, "Optimized ");
       symtab_node::dump_table (symtab->dump_file);
     }
-#ifdef ENABLE_CHECKING
-  symtab_node::verify_symtab_nodes ();
-#endif
+
+  symtab_node::checking_verify_symtab_nodes ();
   bitmap_obstack_release (NULL);
 
   /* We are about to launch the final LTRANS phase, stop the WPA timer.  */
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index ad7c017..e80fedf 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -3083,14 +3083,14 @@ scan_omp_target (gomp_target *stmt, omp_context *outer_ctx)
     {
       TYPE_FIELDS (ctx->record_type)
 	= nreverse (TYPE_FIELDS (ctx->record_type));
-#ifdef ENABLE_CHECKING
-      tree field;
-      unsigned int align = DECL_ALIGN (TYPE_FIELDS (ctx->record_type));
-      for (field = TYPE_FIELDS (ctx->record_type);
-	   field;
-	   field = DECL_CHAIN (field))
-	gcc_assert (DECL_ALIGN (field) == align);
-#endif
+      if (flag_checking)
+	{
+	  unsigned int align = DECL_ALIGN (TYPE_FIELDS (ctx->record_type));
+	  for (tree field = TYPE_FIELDS (ctx->record_type);
+	       field;
+	       field = DECL_CHAIN (field))
+	    gcc_assert (DECL_ALIGN (field) == align);
+	}
       layout_type (ctx->record_type);
       if (offloaded)
 	fixup_child_record_type (ctx);
@@ -6698,10 +6698,8 @@ expand_omp_taskreg (struct omp_region *region)
 	}
       if (gimple_in_ssa_p (cfun))
 	update_ssa (TODO_update_ssa);
-#ifdef ENABLE_CHECKING
-      if (!loops_state_satisfies_p (LOOPS_NEED_FIXUP))
+      if (flag_checking && !loops_state_satisfies_p (LOOPS_NEED_FIXUP))
 	verify_loop_structure ();
-#endif
       pop_cfun ();
     }
 
@@ -11518,10 +11516,8 @@ expand_omp_target (struct omp_region *region)
 	  if (changed)
 	    cleanup_tree_cfg ();
 	}
-#ifdef ENABLE_CHECKING
-      if (!loops_state_satisfies_p (LOOPS_NEED_FIXUP))
+      if (flag_checking && !loops_state_satisfies_p (LOOPS_NEED_FIXUP))
 	verify_loop_structure ();
-#endif
       pop_cfun ();
     }
 
@@ -12058,10 +12054,8 @@ execute_expand_omp (void)
 
   expand_omp (root_omp_region);
 
-#ifdef ENABLE_CHECKING
-  if (!loops_state_satisfies_p (LOOPS_NEED_FIXUP))
+  if (flag_checking && !loops_state_satisfies_p (LOOPS_NEED_FIXUP))
     verify_loop_structure ();
-#endif
   cleanup_tree_cfg ();
 
   free_omp_regions ();
@@ -14145,7 +14139,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx)
       default:
 	break;
       case OMP_CLAUSE_MAP:
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
 	/* First check what we're prepared to handle in the following.  */
 	switch (OMP_CLAUSE_MAP_KIND (c))
 	  {
diff --git a/gcc/passes.c b/gcc/passes.c
index 0d147fd..43dd4e0 100644
--- a/gcc/passes.c
+++ b/gcc/passes.c
@@ -1952,9 +1952,8 @@ execute_function_todo (function *fn, void *data)
 
   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 (flag_checking && !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);
 
@@ -1988,7 +1987,6 @@ execute_function_todo (function *fn, void *data)
       /* 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;
@@ -2008,11 +2006,10 @@ execute_function_todo (function *fn, void *data)
 static void
 execute_todo (unsigned int flags)
 {
-#if defined ENABLE_CHECKING
-  if (cfun
+  if (flag_checking
+      && cfun
       && need_ssa_update_p (cfun))
     gcc_assert (flags & TODO_update_ssa_any);
-#endif
 
   timevar_push (TV_TODO);
 
@@ -2076,14 +2073,12 @@ clear_last_verified (function *fn, void *data ATTRIBUTE_UNUSED)
 /* Helper function. Verify that the properties has been turn into the
    properties expected by the pass.  */
 
-#ifdef ENABLE_CHECKING
-static void
+static void DEBUG_FUNCTION
 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.  */
@@ -2331,10 +2326,9 @@ execute_one_pass (opt_pass *pass)
   /* 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 (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)
diff --git a/gcc/predict.c b/gcc/predict.c
index 0b3016c..4482d47 100644
--- a/gcc/predict.c
+++ b/gcc/predict.c
@@ -2205,8 +2205,6 @@ tree_bb_level_predictions (void)
     }
 }
 
-#ifdef ENABLE_CHECKING
-
 /* Callback for hash_map::traverse, asserts that the pointer map is
    empty.  */
 
@@ -2217,7 +2215,6 @@ assert_is_empty (const_basic_block const &, edge_prediction *const &value,
   gcc_assert (!value);
   return false;
 }
-#endif
 
 /* Predict branch probabilities and estimate profile for basic block BB.  */
 
@@ -2352,9 +2349,9 @@ tree_estimate_probability (void)
   FOR_EACH_BB_FN (bb, cfun)
     combine_predictions_for_bb (bb);
 
-#ifdef ENABLE_CHECKING
-  bb_predictions->traverse<void *, assert_is_empty> (NULL);
-#endif
+  if (flag_checking)
+    bb_predictions->traverse<void *, assert_is_empty> (NULL);
+
   delete bb_predictions;
   bb_predictions = NULL;
 
@@ -2545,11 +2542,10 @@ propagate_freq (basic_block head, bitmap tovisit)
       /* Compute frequency of basic block.  */
       if (bb != head)
 	{
-#ifdef ENABLE_CHECKING
-	  FOR_EACH_EDGE (e, ei, bb->preds)
-	    gcc_assert (!bitmap_bit_p (tovisit, e->src->index)
-			|| (e->flags & EDGE_DFS_BACK));
-#endif
+	  if (flag_checking)
+	    FOR_EACH_EDGE (e, ei, bb->preds)
+	      gcc_assert (!bitmap_bit_p (tovisit, e->src->index)
+			  || (e->flags & EDGE_DFS_BACK));
 
 	  FOR_EACH_EDGE (e, ei, bb->preds)
 	    if (EDGE_INFO (e)->back_edge)
diff --git a/gcc/pretty-print.c b/gcc/pretty-print.c
index 5889015..b24402d 100644
--- a/gcc/pretty-print.c
+++ b/gcc/pretty-print.c
@@ -625,10 +625,9 @@ pp_format (pretty_printer *pp, text_info *text)
       *formatters[argno] = XOBFINISH (&buffer->chunk_obstack, const char *);
     }
 
-#ifdef ENABLE_CHECKING
-  for (; argno < PP_NL_ARGMAX; argno++)
-    gcc_assert (!formatters[argno]);
-#endif
+  if (CHECKING_P)
+    for (; argno < PP_NL_ARGMAX; argno++)
+      gcc_assert (!formatters[argno]);
 
   /* Revert to normal obstack and wrapping mode.  */
   buffer->obstack = &buffer->formatted_obstack;
diff --git a/gcc/real.c b/gcc/real.c
index 85ac83d..a292126 100644
--- a/gcc/real.c
+++ b/gcc/real.c
@@ -1808,15 +1808,13 @@ real_to_decimal_for_mode (char *str, const REAL_VALUE_TYPE *r_orig,
   /* Append the exponent.  */
   sprintf (last, "e%+d", dec_exp);
 
-#ifdef ENABLE_CHECKING
   /* Verify that we can read the original value back in.  */
-  if (mode != VOIDmode)
+  if (flag_checking && mode != VOIDmode)
     {
       real_from_string (&r, str);
       real_convert (&r, mode, &r);
       gcc_assert (real_identical (&r, r_orig));
     }
-#endif
 }
 
 /* Likewise, except always uses round-to-nearest.  */
diff --git a/gcc/recog.c b/gcc/recog.c
index c032424..2cd06f5 100644
--- a/gcc/recog.c
+++ b/gcc/recog.c
@@ -2975,9 +2975,7 @@ split_all_insns (void)
   if (changed)
     find_many_sub_basic_blocks (blocks);
 
-#ifdef ENABLE_CHECKING
-  verify_flow_info ();
-#endif
+  checking_verify_flow_info ();
 
   sbitmap_free (blocks);
 }
diff --git a/gcc/regcprop.c b/gcc/regcprop.c
index 6f7d01e..bc8111c 100644
--- a/gcc/regcprop.c
+++ b/gcc/regcprop.c
@@ -100,9 +100,7 @@ static bool replace_oldest_value_addr (rtx *, enum reg_class,
 static bool replace_oldest_value_mem (rtx, rtx_insn *, struct value_data *);
 static bool copyprop_hardreg_forward_1 (basic_block, struct value_data *);
 extern void debug_value_data (struct value_data *);
-#ifdef ENABLE_CHECKING
 static void validate_value_data (struct value_data *);
-#endif
 
 /* Free all queued updates for DEBUG_INSNs that change some reg to
    register REGNO.  */
@@ -150,9 +148,8 @@ kill_value_one_regno (unsigned int regno, struct value_data *vd)
   if (vd->e[regno].debug_insn_changes)
     free_debug_insn_changes (vd, regno);
 
-#ifdef ENABLE_CHECKING
-  validate_value_data (vd);
-#endif
+  if (flag_checking)
+    validate_value_data (vd);
 }
 
 /* Kill the value in register REGNO for NREGS, and any other registers
@@ -365,9 +362,8 @@ copy_value (rtx dest, rtx src, struct value_data *vd)
     continue;
   vd->e[i].next_regno = dr;
 
-#ifdef ENABLE_CHECKING
-  validate_value_data (vd);
-#endif
+  if (flag_checking)
+    validate_value_data (vd);
 }
 
 /* Return true if a mode change from ORIG to NEW is allowed for REGNO.  */
@@ -1141,7 +1137,6 @@ copyprop_hardreg_forward_bb_without_debug_insn (basic_block bb)
   skip_debug_insn_p = false;
 }
 
-#ifdef ENABLE_CHECKING
 static void
 validate_value_data (struct value_data *vd)
 {
@@ -1187,7 +1182,7 @@ validate_value_data (struct value_data *vd)
 		      i, GET_MODE_NAME (vd->e[i].mode), vd->e[i].oldest_regno,
 		      vd->e[i].next_regno);
 }
-#endif
+
 \f
 namespace {
 
diff --git a/gcc/reload.c b/gcc/reload.c
index cc61d77..32eec02 100644
--- a/gcc/reload.c
+++ b/gcc/reload.c
@@ -85,7 +85,7 @@ a register with any other reload.  */
 
 #define REG_OK_STRICT
 
-/* We do not enable this with ENABLE_CHECKING, since it is awfully slow.  */
+/* We do not enable this with CHECKING_P, since it is awfully slow.  */
 #undef DEBUG_RELOAD
 
 #include "config.h"
diff --git a/gcc/sched-deps.c b/gcc/sched-deps.c
index 9683055..c53a51f 100644
--- a/gcc/sched-deps.c
+++ b/gcc/sched-deps.c
@@ -47,12 +47,6 @@ along with GCC; see the file COPYING3.  If not see
 
 #ifdef INSN_SCHEDULING
 
-#ifdef ENABLE_CHECKING
-#define CHECK (true)
-#else
-#define CHECK (false)
-#endif
-
 /* Holds current parameters for the dependency analyzer.  */
 struct sched_deps_info_def *sched_deps_info;
 
@@ -505,9 +499,8 @@ static enum DEPS_ADJUST_RESULT maybe_add_or_update_dep_1 (dep_t, bool,
 							  rtx, rtx);
 static enum DEPS_ADJUST_RESULT add_or_update_dep_1 (dep_t, bool, rtx, rtx);
 
-#ifdef ENABLE_CHECKING
 static void check_dep (dep_t, bool);
-#endif
+
 \f
 /* Return nonzero if a load of the memory reference MEM can cause a trap.  */
 
@@ -1228,9 +1221,8 @@ add_or_update_dep_1 (dep_t new_dep, bool resolved_p,
   gcc_assert (INSN_P (DEP_PRO (new_dep)) && INSN_P (DEP_CON (new_dep))
 	      && DEP_PRO (new_dep) != DEP_CON (new_dep));
 
-#ifdef ENABLE_CHECKING
-  check_dep (new_dep, mem1 != NULL);
-#endif
+  if (flag_checking)
+    check_dep (new_dep, mem1 != NULL);
 
   if (true_dependency_cache != NULL)
     {
@@ -1348,9 +1340,8 @@ sd_add_dep (dep_t dep, bool resolved_p)
 
   add_to_deps_list (DEP_NODE_BACK (n), con_back_deps);
 
-#ifdef ENABLE_CHECKING
-  check_dep (dep, false);
-#endif
+  if (flag_checking)
+    check_dep (dep, false);
 
   add_to_deps_list (DEP_NODE_FORW (n), pro_forw_deps);
 
@@ -4515,7 +4506,6 @@ debug_ds (ds_t s)
   fprintf (stderr, "\n");
 }
 
-#ifdef ENABLE_CHECKING
 /* Verify that dependence type and status are consistent.
    If RELAXED_P is true, then skip dep_weakness checks.  */
 static void
@@ -4600,7 +4590,6 @@ check_dep (dep_t dep, bool relaxed_p)
 	gcc_assert (ds & BEGIN_CONTROL);
     }
 }
-#endif /* ENABLE_CHECKING */
 
 /* The following code discovers opportunities to switch a memory reference
    and an increment by modifying the address.  We ensure that this is done
diff --git a/gcc/sel-sched-ir.c b/gcc/sel-sched-ir.c
index 8ea4dce..b109a5b 100644
--- a/gcc/sel-sched-ir.c
+++ b/gcc/sel-sched-ir.c
@@ -954,7 +954,6 @@ return_regset_to_pool (regset rs)
   regset_pool.v[regset_pool.n++] = rs;
 }
 
-#ifdef ENABLE_CHECKING
 /* This is used as a qsort callback for sorting regset pool stacks.
    X and XX are addresses of two regsets.  They are never equal.  */
 static int
@@ -968,44 +967,42 @@ cmp_v_in_regset_pool (const void *x, const void *xx)
     return -1;
   gcc_unreachable ();
 }
-#endif
 
-/*  Free the regset pool possibly checking for memory leaks.  */
+/* Free the regset pool possibly checking for memory leaks.  */
 void
 free_regset_pool (void)
 {
-#ifdef ENABLE_CHECKING
-  {
-    regset *v = regset_pool.v;
-    int i = 0;
-    int n = regset_pool.n;
+  if (flag_checking)
+    {
+      regset *v = regset_pool.v;
+      int i = 0;
+      int n = regset_pool.n;
 
-    regset *vv = regset_pool.vv;
-    int ii = 0;
-    int nn = regset_pool.nn;
+      regset *vv = regset_pool.vv;
+      int ii = 0;
+      int nn = regset_pool.nn;
 
-    int diff = 0;
+      int diff = 0;
 
-    gcc_assert (n <= nn);
+      gcc_assert (n <= nn);
 
-    /* Sort both vectors so it will be possible to compare them.  */
-    qsort (v, n, sizeof (*v), cmp_v_in_regset_pool);
-    qsort (vv, nn, sizeof (*vv), cmp_v_in_regset_pool);
+      /* Sort both vectors so it will be possible to compare them.  */
+      qsort (v, n, sizeof (*v), cmp_v_in_regset_pool);
+      qsort (vv, nn, sizeof (*vv), cmp_v_in_regset_pool);
 
-    while (ii < nn)
-      {
-        if (v[i] == vv[ii])
-          i++;
-        else
-          /* VV[II] was lost.  */
-          diff++;
+      while (ii < nn)
+	{
+	  if (v[i] == vv[ii])
+	    i++;
+	  else
+	    /* VV[II] was lost.  */
+	    diff++;
 
-        ii++;
-      }
+	  ii++;
+	}
 
-    gcc_assert (diff == regset_pool.diff);
-  }
-#endif
+      gcc_assert (diff == regset_pool.diff);
+    }
 
   /* If not true - we have a memory leak.  */
   gcc_assert (regset_pool.diff == 0);
@@ -3623,7 +3620,6 @@ insn_is_the_only_one_in_bb_p (insn_t insn)
   return sel_bb_head_p (insn) && sel_bb_end_p (insn);
 }
 
-#ifdef ENABLE_CHECKING
 /* Check that the region we're scheduling still has at most one
    backedge.  */
 static void
@@ -3644,7 +3640,6 @@ verify_backedges (void)
       gcc_assert (n <= 1);
     }
 }
-#endif
 \f
 
 /* Functions to work with control flow.  */
@@ -3889,10 +3884,12 @@ tidy_control_flow (basic_block xbb, bool full_tidying)
 	sel_recompute_toporder ();
     }
 
-#ifdef ENABLE_CHECKING
-  verify_backedges ();
-  verify_dominators (CDI_DOMINATORS);
-#endif
+  /* TODO: use separate flag for CFG checking.  */
+  if (flag_checking)
+    {
+      verify_backedges ();
+      verify_dominators (CDI_DOMINATORS);
+    }
 
   return changed;
 }
diff --git a/gcc/sel-sched.c b/gcc/sel-sched.c
index 721013f..30fcfdb 100644
--- a/gcc/sel-sched.c
+++ b/gcc/sel-sched.c
@@ -378,10 +378,8 @@ struct moveop_static_params
      they are to be removed.  */
   int uid;
 
-#ifdef ENABLE_CHECKING
   /* This is initialized to the insn on which the driver stopped its traversal.  */
   insn_t failed_insn;
-#endif
 
   /* True if we scheduled an insn with different register.  */
   bool was_renamed;
@@ -1655,9 +1653,8 @@ find_best_reg_for_expr (expr_t expr, blist_t bnds, bool *is_orig_reg_p)
   collect_unavailable_regs_from_bnds (expr, bnds, used_regs, &reg_rename_data,
 				      &original_insns);
 
-#ifdef ENABLE_CHECKING
   /* If after reload, make sure we're working with hard regs here.  */
-  if (reload_completed)
+  if (flag_checking && reload_completed)
     {
       reg_set_iterator rsi;
       unsigned i;
@@ -1665,7 +1662,6 @@ find_best_reg_for_expr (expr_t expr, blist_t bnds, bool *is_orig_reg_p)
       EXECUTE_IF_SET_IN_REG_SET (used_regs, FIRST_PSEUDO_REGISTER, i, rsi)
         gcc_unreachable ();
     }
-#endif
 
   if (EXPR_SEPARABLE_P (expr))
     {
@@ -3593,7 +3589,6 @@ vinsn_vec_has_expr_p (vinsn_vec_t vinsn_vec, expr_t expr)
   return false;
 }
 
-#ifdef ENABLE_CHECKING
 /* Return true if either of expressions from ORIG_OPS can be blocked
    by previously created bookkeeping code.  STATIC_PARAMS points to static
    parameters of move_op.  */
@@ -3635,7 +3630,6 @@ av_set_could_be_blocked_by_bookkeeping_p (av_set_t orig_ops, void *static_params
 
   return false;
 }
-#endif
 
 /* Clear VINSN_VEC and detach vinsns.  */
 static void
@@ -4889,11 +4883,10 @@ move_cond_jump (rtx_insn *insn, bnd_t bnd)
   block_bnd = BLOCK_FOR_INSN (BND_TO (bnd));
   prev = BND_TO (bnd);
 
-#ifdef ENABLE_CHECKING
   /* Moving of jump should not cross any other jumps or beginnings of new
      basic blocks.  The only exception is when we move a jump through
      mutually exclusive insns along fallthru edges.  */
-  if (block_from != block_bnd)
+  if (flag_checking && block_from != block_bnd)
     {
       bb = block_from;
       for (link = PREV_INSN (insn); link != PREV_INSN (prev);
@@ -4908,7 +4901,6 @@ move_cond_jump (rtx_insn *insn, bnd_t bnd)
             }
         }
     }
-#endif
 
   /* Jump is moved to the boundary.  */
   next = PREV_INSN (insn);
@@ -6205,9 +6197,7 @@ move_op_orig_expr_not_found (insn_t insn, av_set_t orig_ops ATTRIBUTE_UNUSED,
 {
   moveop_static_params_p sparams = (moveop_static_params_p) static_params;
 
-#ifdef ENABLE_CHECKING
   sparams->failed_insn = insn;
-#endif
 
   /* If we're scheduling separate expr, in order to generate correct code
      we need to stop the search at bookkeeping code generated with the
@@ -6380,7 +6370,6 @@ code_motion_process_successors (insn_t insn, av_set_t orig_ops,
         }
     }
 
-#ifdef ENABLE_CHECKING
   /* Here, RES==1 if original expr was found at least for one of the
      successors.  After the loop, RES may happen to have zero value
      only if at some point the expr searched is present in av_set, but is
@@ -6388,12 +6377,10 @@ code_motion_process_successors (insn_t insn, av_set_t orig_ops,
      The exception is when the original operation is blocked by
      bookkeeping generated for another fence or for another path in current
      move_op.  */
-  gcc_assert (res == 1
-	      || (res == 0
-		  && av_set_could_be_blocked_by_bookkeeping_p (orig_ops,
-							       static_params))
-	      || res == -1);
-#endif
+  gcc_checking_assert (res == 1
+		       || (res == 0
+			    && av_set_could_be_blocked_by_bookkeeping_p (orig_ops, static_params))
+		       || res == -1);
 
   /* Merge data, clean up, etc.  */
   if (res != -1 && code_motion_path_driver_info->after_merge_succs)
@@ -6695,9 +6682,7 @@ move_op (insn_t insn, av_set_t orig_ops, expr_t expr_vliw,
   sparams.dest = dest;
   sparams.c_expr = c_expr;
   sparams.uid = INSN_UID (EXPR_INSN_RTX (expr_vliw));
-#ifdef ENABLE_CHECKING
   sparams.failed_insn = NULL;
-#endif
   sparams.was_renamed = false;
   lparams.e1 = NULL;
 
diff --git a/gcc/ssa-iterators.h b/gcc/ssa-iterators.h
index e04b630..fa7ad3b 100644
--- a/gcc/ssa-iterators.h
+++ b/gcc/ssa-iterators.h
@@ -344,9 +344,7 @@ first_readonly_imm_use (imm_use_iterator *imm, tree var)
 {
   imm->end_p = &(SSA_NAME_IMM_USE_NODE (var));
   imm->imm_use = imm->end_p->next;
-#ifdef ENABLE_CHECKING
   imm->iter_node.next = imm->imm_use->next;
-#endif
   if (end_readonly_imm_use_p (imm))
     return NULL_USE_OPERAND_P;
   return imm->imm_use;
@@ -358,14 +356,15 @@ next_readonly_imm_use (imm_use_iterator *imm)
 {
   use_operand_p old = imm->imm_use;
 
-#ifdef ENABLE_CHECKING
   /* If this assertion fails, it indicates the 'next' pointer has changed
      since the last bump.  This indicates that the list is being modified
      via stmt changes, or SET_USE, or somesuch thing, and you need to be
      using the SAFE version of the iterator.  */
-  gcc_assert (imm->iter_node.next == old->next);
-  imm->iter_node.next = old->next->next;
-#endif
+  if (flag_checking)
+    {
+      gcc_assert (imm->iter_node.next == old->next);
+      imm->iter_node.next = old->next->next;
+    }
 
   imm->imm_use = old->next;
   if (end_readonly_imm_use_p (imm))
diff --git a/gcc/store-motion.c b/gcc/store-motion.c
index ec3faa2..ed1a399 100644
--- a/gcc/store-motion.c
+++ b/gcc/store-motion.c
@@ -644,9 +644,6 @@ compute_store_table (void)
 {
   int ret;
   basic_block bb;
-#ifdef ENABLE_CHECKING
-  unsigned regno;
-#endif
   rtx_insn *insn;
   rtx_insn *tmp;
   df_ref def;
@@ -692,11 +689,12 @@ compute_store_table (void)
 	      last_set_in[DF_REF_REGNO (def)] = 0;
 	}
 
-#ifdef ENABLE_CHECKING
-      /* last_set_in should now be all-zero.  */
-      for (regno = 0; regno < max_gcse_regno; regno++)
-	gcc_assert (!last_set_in[regno]);
-#endif
+      if (flag_checking)
+	{
+	  /* last_set_in should now be all-zero.  */
+	  for (unsigned regno = 0; regno < max_gcse_regno; regno++)
+	    gcc_assert (!last_set_in[regno]);
+	}
 
       /* Clear temporary marks.  */
       for (ptr = first_st_expr (); ptr != NULL; ptr = next_st_expr (ptr))
diff --git a/gcc/symbol-summary.h b/gcc/symbol-summary.h
index eefbfd9..4a1a510 100644
--- a/gcc/symbol-summary.h
+++ b/gcc/symbol-summary.h
@@ -39,14 +39,12 @@ public:
   function_summary (symbol_table *symtab, bool ggc = false): m_ggc (ggc),
     m_map (13, ggc), m_insertion_enabled (true), m_symtab (symtab)
   {
-#ifdef ENABLE_CHECKING
-    cgraph_node *node;
-
-    FOR_EACH_FUNCTION (node)
-    {
-      gcc_checking_assert (node->summary_uid > 0);
-    }
-#endif
+    if (flag_checking)
+      {
+	cgraph_node *node;
+	FOR_EACH_FUNCTION (node)
+	  gcc_assert (node->summary_uid > 0);
+      }
 
     m_symtab_insertion_hook =
       symtab->add_cgraph_insertion_hook
diff --git a/gcc/target.h b/gcc/target.h
index a79f424..ffc4d6a 100644
--- a/gcc/target.h
+++ b/gcc/target.h
@@ -52,21 +52,21 @@
 #include "tm.h"
 #include "hard-reg-set.h"
 
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
 
 struct cumulative_args_t { void *magic; void *p; };
 
-#else /* !ENABLE_CHECKING */
+#else /* !CHECKING_P */
 
 /* When using a GCC build compiler, we could use
    __attribute__((transparent_union)) to get cumulative_args_t function
    arguments passed like scalars where the ABI would mandate a less
    efficient way of argument passing otherwise.  However, that would come
-   at the cost of less type-safe !ENABLE_CHECKING compilation.  */
+   at the cost of less type-safe !CHECKING_P compilation.  */
 
 union cumulative_args_t { void *p; };
 
-#endif /* !ENABLE_CHECKING */
+#endif /* !CHECKING_P */
 
 /* Types used by the record_gcc_switches() target function.  */
 enum print_switch_type
@@ -200,9 +200,9 @@ extern struct gcc_target targetm;
 static inline CUMULATIVE_ARGS *
 get_cumulative_args (cumulative_args_t arg)
 {
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
   gcc_assert (arg.magic == CUMULATIVE_ARGS_MAGIC);
-#endif /* ENABLE_CHECKING */
+#endif /* CHECKING_P */
   return (CUMULATIVE_ARGS *) arg.p;
 }
 
@@ -211,9 +211,9 @@ pack_cumulative_args (CUMULATIVE_ARGS *arg)
 {
   cumulative_args_t ret;
 
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
   ret.magic = CUMULATIVE_ARGS_MAGIC;
-#endif /* ENABLE_CHECKING */
+#endif /* CHECKING_P */
   ret.p = (void *) arg;
   return ret;
 }
diff --git a/gcc/timevar.c b/gcc/timevar.c
index 8249727..3543850 100644
--- a/gcc/timevar.c
+++ b/gcc/timevar.c
@@ -22,6 +22,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "system.h"
 #include "coretypes.h"
 #include "timevar.h"
+#include "options.h"
 
 #ifndef HAVE_CLOCK_T
 typedef int clock_t;
@@ -727,10 +728,13 @@ timer::print (FILE *fp)
 #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
+  if (flag_checking)
+    {
+      fprintf (fp, "Extra diagnostic checks enabled; "
+		   "compiler may run slowly.\n");
+      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");
diff --git a/gcc/trans-mem.c b/gcc/trans-mem.c
index 488c20e..d0b54ef 100644
--- a/gcc/trans-mem.c
+++ b/gcc/trans-mem.c
@@ -5341,9 +5341,7 @@ ipa_tm_execute (void)
   enum availability a;
   unsigned int i;
 
-#ifdef ENABLE_CHECKING
-  cgraph_node::verify_cgraph_nodes ();
-#endif
+  cgraph_node::checking_verify_cgraph_nodes ();
 
   bitmap_obstack_initialize (&tm_obstack);
   initialize_original_copy_tables ();
@@ -5589,9 +5587,7 @@ ipa_tm_execute (void)
   FOR_EACH_FUNCTION (node)
     node->aux = NULL;
 
-#ifdef ENABLE_CHECKING
-  cgraph_node::verify_cgraph_nodes ();
-#endif
+  cgraph_node::checking_verify_cgraph_nodes ();
 
   return 0;
 }
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 40d5eb8..df8700d 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -6465,14 +6465,12 @@ move_stmt_op (tree *tp, int *walk_subtrees, void *data)
 	  || (p->orig_block == NULL_TREE
 	      && block != NULL_TREE))
 	TREE_SET_BLOCK (t, p->new_block);
-#ifdef ENABLE_CHECKING
-      else if (block != NULL_TREE)
+      else if (flag_checking && block != NULL_TREE)
 	{
 	  while (block && TREE_CODE (block) == BLOCK && block != p->orig_block)
 	    block = BLOCK_SUPERCONTEXT (block);
 	  gcc_assert (block == p->orig_block);
 	}
-#endif
     }
   else if (DECL_P (t) || TREE_CODE (t) == SSA_NAME)
     {
@@ -7057,9 +7055,9 @@ move_sese_region_to_fn (struct function *dest_cfun, basic_block entry_bb,
   bbs.create (0);
   bbs.safe_push (entry_bb);
   gather_blocks_in_sese_region (entry_bb, exit_bb, &bbs);
-#ifdef ENABLE_CHECKING
-  verify_sese (entry_bb, exit_bb, &bbs);
-#endif
+
+  if (flag_checking)
+    verify_sese (entry_bb, exit_bb, &bbs);
 
   /* The blocks that used to be dominated by something in BBS will now be
      dominated by the new block.  */
@@ -7901,13 +7899,11 @@ gimple_flow_call_edges_add (sbitmap blocks)
 		     no edge to the exit block in CFG already.
 		     Calling make_edge in such case would cause us to
 		     mark that edge as fake and remove it later.  */
-#ifdef ENABLE_CHECKING
-		  if (stmt == last_stmt)
+		  if (flag_checking && stmt == last_stmt)
 		    {
 		      e = find_edge (bb, EXIT_BLOCK_PTR_FOR_FN (cfun));
 		      gcc_assert (e == NULL);
 		    }
-#endif
 
 		  /* Note that the following may create a new basic block
 		     and renumber the existing basic blocks.  */
diff --git a/gcc/tree-cfgcleanup.c b/gcc/tree-cfgcleanup.c
index eeedd8a..aba8848 100644
--- a/gcc/tree-cfgcleanup.c
+++ b/gcc/tree-cfgcleanup.c
@@ -729,9 +729,7 @@ cleanup_tree_cfg_noloop (void)
     }
   else
     {
-#ifdef ENABLE_CHECKING
-      verify_dominators (CDI_DOMINATORS);
-#endif
+      checking_verify_dominators (CDI_DOMINATORS);
       changed = false;
     }
 
@@ -740,9 +738,7 @@ cleanup_tree_cfg_noloop (void)
   gcc_assert (dom_info_available_p (CDI_DOMINATORS));
   compact_blocks ();
 
-#ifdef ENABLE_CHECKING
-  verify_flow_info ();
-#endif
+  checking_verify_flow_info ();
 
   timevar_pop (TV_TREE_CLEANUP_CFG);
 
@@ -777,9 +773,7 @@ repair_loop_structures (void)
 
   BITMAP_FREE (changed_bbs);
 
-#ifdef ENABLE_CHECKING
-  verify_loop_structure ();
-#endif
+  checking_verify_loop_structure ();
   scev_reset ();
 
   timevar_pop (TV_REPAIR_LOOPS);
diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c
index cb1f08a..f6c2d06 100644
--- a/gcc/tree-eh.c
+++ b/gcc/tree-eh.c
@@ -703,7 +703,7 @@ maybe_record_in_goto_queue (struct leh_state *state, gimple *stmt)
 }
 
 
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
 /* We do not process GIMPLE_SWITCHes for now.  As long as the original source
    was in fact structured, and we've not yet done jump threading, then none
    of the labels will leave outer GIMPLE_TRY_FINALLY nodes. Verify this.  */
@@ -3921,9 +3921,8 @@ remove_unreachable_handlers (void)
   sbitmap_free (r_reachable);
   sbitmap_free (lp_reachable);
 
-#ifdef ENABLE_CHECKING
-  verify_eh_tree (cfun);
-#endif
+  if (flag_checking)
+    verify_eh_tree (cfun);
 }
 
 /* Remove unreachable handlers if any landing pads have been removed after
diff --git a/gcc/tree-if-conv.c b/gcc/tree-if-conv.c
index f201ab5..ae79f0e 100644
--- a/gcc/tree-if-conv.c
+++ b/gcc/tree-if-conv.c
@@ -2787,13 +2787,12 @@ pass_if_conversion::execute (function *fun)
 	    && !loop->dont_vectorize))
       todo |= tree_if_conversion (loop);
 
-#ifdef ENABLE_CHECKING
-  {
-    basic_block bb;
-    FOR_EACH_BB_FN (bb, fun)
-      gcc_assert (!bb->aux);
-  }
-#endif
+  if (flag_checking)
+    {
+      basic_block bb;
+      FOR_EACH_BB_FN (bb, fun)
+	gcc_assert (!bb->aux);
+    }
 
   return todo;
 }
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index b8269ef..00c0c84 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -4481,10 +4481,8 @@ expand_call_inline (basic_block bb, gimple *stmt, copy_body_data *id)
   fn = cg_edge->callee->decl;
   cg_edge->callee->get_untransformed_body ();
 
-#ifdef ENABLE_CHECKING
-  if (cg_edge->callee->decl != id->dst_node->decl)
+  if (flag_checking && cg_edge->callee->decl != id->dst_node->decl)
     cg_edge->callee->verify ();
-#endif
 
   /* We will be inlining this callee.  */
   id->eh_lp_nr = lookup_stmt_eh_lp (stmt);
@@ -4973,7 +4971,7 @@ optimize_inline_calls (tree fn)
 
   pop_gimplify_context (NULL);
 
-#ifdef ENABLE_CHECKING
+  if (flag_checking)
     {
       struct cgraph_edge *e;
 
@@ -4983,7 +4981,6 @@ optimize_inline_calls (tree fn)
       for (e = id.dst_node->callees; e; e = e->next_callee)
 	gcc_assert (e->inline_failed);
     }
-#endif
 
   /* Fold queued statements.  */
   fold_marked_statements (last, id.statements_to_fold);
@@ -4999,9 +4996,8 @@ optimize_inline_calls (tree fn)
   number_blocks (fn);
 
   delete_unreachable_blocks_update_callgraph (&id);
-#ifdef ENABLE_CHECKING
-  id.dst_node->verify ();
-#endif
+  if (flag_checking)
+    id.dst_node->verify ();
 
   /* It would be nice to check SSA/CFG/statement consistency here, but it is
      not possible yet - the IPA passes might make various functions to not
diff --git a/gcc/tree-into-ssa.c b/gcc/tree-into-ssa.c
index 9fd698d..732a571 100644
--- a/gcc/tree-into-ssa.c
+++ b/gcc/tree-into-ssa.c
@@ -3169,44 +3169,45 @@ update_ssa (unsigned update_flags)
   if (!need_ssa_update_p (cfun))
     return;
 
-#ifdef ENABLE_CHECKING
-  timevar_push (TV_TREE_STMT_VERIFY);
+  if (flag_checking)
+    {
+      timevar_push (TV_TREE_STMT_VERIFY);
 
-  bool err = false;
+      bool err = false;
 
-  FOR_EACH_BB_FN (bb, cfun)
-    {
-      gimple_stmt_iterator gsi;
-      for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+      FOR_EACH_BB_FN (bb, cfun)
 	{
-	  gimple *stmt = gsi_stmt (gsi);
-
-	  ssa_op_iter i;
-	  use_operand_p use_p;
-	  FOR_EACH_SSA_USE_OPERAND (use_p, stmt, i, SSA_OP_ALL_USES)
+	  gimple_stmt_iterator gsi;
+	  for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
 	    {
-	      tree use = USE_FROM_PTR (use_p);
-	      if (TREE_CODE (use) != SSA_NAME)
-		continue;
+	      gimple *stmt = gsi_stmt (gsi);
 
-	      if (SSA_NAME_IN_FREE_LIST (use))
+	      ssa_op_iter i;
+	      use_operand_p use_p;
+	      FOR_EACH_SSA_USE_OPERAND (use_p, stmt, i, SSA_OP_ALL_USES)
 		{
-		  error ("statement uses released SSA name:");
-		  debug_gimple_stmt (stmt);
-		  fprintf (stderr, "The use of ");
-		  print_generic_expr (stderr, use, 0);
-		  fprintf (stderr," should have been replaced\n");
-		  err = true;
+		  tree use = USE_FROM_PTR (use_p);
+		  if (TREE_CODE (use) != SSA_NAME)
+		    continue;
+
+		  if (SSA_NAME_IN_FREE_LIST (use))
+		    {
+		      error ("statement uses released SSA name:");
+		      debug_gimple_stmt (stmt);
+		      fprintf (stderr, "The use of ");
+		      print_generic_expr (stderr, use, 0);
+		      fprintf (stderr," should have been replaced\n");
+		      err = true;
+		    }
 		}
 	    }
 	}
-    }
 
-  if (err)
-    internal_error ("cannot update SSA form");
+      if (err)
+	internal_error ("cannot update SSA form");
 
-  timevar_pop (TV_TREE_STMT_VERIFY);
-#endif
+      timevar_pop (TV_TREE_STMT_VERIFY);
+    }
 
   timevar_push (TV_TREE_SSA_INCREMENTAL);
 
@@ -3271,29 +3272,28 @@ update_ssa (unsigned update_flags)
 	 placement heuristics.  */
       prepare_block_for_update (start_bb, insert_phi_p);
 
-#ifdef ENABLE_CHECKING
-      for (i = 1; i < num_ssa_names; ++i)
-	{
-	  tree name = ssa_name (i);
-	  if (!name
-	      || virtual_operand_p (name))
-	    continue;
-
-	  /* For all but virtual operands, which do not have SSA names
-	     with overlapping life ranges, ensure that symbols marked
-	     for renaming do not have existing SSA names associated with
-	     them as we do not re-write them out-of-SSA before going
-	     into SSA for the remaining symbol uses.  */
-	  if (marked_for_renaming (SSA_NAME_VAR (name)))
-	    {
-	      fprintf (stderr, "Existing SSA name for symbol marked for "
-		       "renaming: ");
-	      print_generic_expr (stderr, name, TDF_SLIM);
-	      fprintf (stderr, "\n");
-	      internal_error ("SSA corruption");
-	    }
-	}
-#endif
+      if (flag_checking)
+	for (i = 1; i < num_ssa_names; ++i)
+	  {
+	    tree name = ssa_name (i);
+	    if (!name
+		|| virtual_operand_p (name))
+	      continue;
+
+	    /* For all but virtual operands, which do not have SSA names
+	       with overlapping life ranges, ensure that symbols marked
+	       for renaming do not have existing SSA names associated with
+	       them as we do not re-write them out-of-SSA before going
+	       into SSA for the remaining symbol uses.  */
+	    if (marked_for_renaming (SSA_NAME_VAR (name)))
+	      {
+		fprintf (stderr, "Existing SSA name for symbol marked for "
+			 "renaming: ");
+		print_generic_expr (stderr, name, TDF_SLIM);
+		fprintf (stderr, "\n");
+		internal_error ("SSA corruption");
+	      }
+	  }
     }
   else
     {
diff --git a/gcc/tree-loop-distribution.c b/gcc/tree-loop-distribution.c
index 6f86d53..18025c8 100644
--- a/gcc/tree-loop-distribution.c
+++ b/gcc/tree-loop-distribution.c
@@ -1821,9 +1821,7 @@ out:
       rewrite_into_loop_closed_ssa (NULL, TODO_update_ssa);
     }
 
-#ifdef ENABLE_CHECKING
-  verify_loop_structure ();
-#endif
+  checking_verify_loop_structure ();
 
   return 0;
 }
diff --git a/gcc/tree-outof-ssa.c b/gcc/tree-outof-ssa.c
index 8dc4908..1c4c63c 100644
--- a/gcc/tree-outof-ssa.c
+++ b/gcc/tree-outof-ssa.c
@@ -841,24 +841,23 @@ eliminate_useless_phis (void)
 	  result = gimple_phi_result (phi);
 	  if (virtual_operand_p (result))
 	    {
-#ifdef ENABLE_CHECKING
-	      size_t i;
 	      /* There should be no arguments which are not virtual, or the
 	         results will be incorrect.  */
-	      for (i = 0; i < gimple_phi_num_args (phi); i++)
-	        {
-		  tree arg = PHI_ARG_DEF (phi, i);
-		  if (TREE_CODE (arg) == SSA_NAME
-		      && !virtual_operand_p (arg))
-		    {
-		      fprintf (stderr, "Argument of PHI is not virtual (");
-		      print_generic_expr (stderr, arg, TDF_SLIM);
-		      fprintf (stderr, "), but the result is :");
-		      print_gimple_stmt (stderr, phi, 0, TDF_SLIM);
-		      internal_error ("SSA corruption");
-		    }
-		}
-#endif
+	      if (flag_checking)
+		for (size_t i = 0; i < gimple_phi_num_args (phi); i++)
+		  {
+		    tree arg = PHI_ARG_DEF (phi, i);
+		    if (TREE_CODE (arg) == SSA_NAME
+			&& !virtual_operand_p (arg))
+		      {
+			fprintf (stderr, "Argument of PHI is not virtual (");
+			print_generic_expr (stderr, arg, TDF_SLIM);
+			fprintf (stderr, "), but the result is :");
+			print_gimple_stmt (stderr, phi, 0, TDF_SLIM);
+			internal_error ("SSA corruption");
+		      }
+		  }
+
 	      remove_phi_node (&gsi, true);
 	    }
           else
@@ -884,9 +883,11 @@ eliminate_useless_phis (void)
    variable.  */
 
 static void
-rewrite_trees (var_map map ATTRIBUTE_UNUSED)
+rewrite_trees (var_map map)
 {
-#ifdef ENABLE_CHECKING
+  if (!flag_checking)
+    return;
+
   basic_block bb;
   /* Search for PHIs where the destination has no partition, but one
      or more arguments has a partition.  This should not happen and can
@@ -918,7 +919,6 @@ rewrite_trees (var_map map ATTRIBUTE_UNUSED)
 	    }
 	}
     }
-#endif
 }
 
 /* Given the out-of-ssa info object SA (with prepared partitions)
diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c
index 6781af4..300ec6b 100644
--- a/gcc/tree-parloops.c
+++ b/gcc/tree-parloops.c
@@ -2784,9 +2784,7 @@ pass_parallelize_loops::execute (function *fun)
     {
       fun->curr_properties &= ~(PROP_gimple_eomp);
 
-#ifdef ENABLE_CHECKING
-      verify_loop_structure ();
-#endif
+      checking_verify_loop_structure ();
 
       return TODO_update_ssa;
     }
diff --git a/gcc/tree-predcom.c b/gcc/tree-predcom.c
index 4abac13..5f6e1b0 100644
--- a/gcc/tree-predcom.c
+++ b/gcc/tree-predcom.c
@@ -896,13 +896,9 @@ suitable_component_p (struct loop *loop, struct component *comp)
       if (!determine_offset (first->ref, a->ref, &a->offset))
 	return false;
 
-#ifdef ENABLE_CHECKING
-      {
-	enum ref_step_type a_step;
-	ok = suitable_reference_p (a->ref, &a_step);
-	gcc_assert (ok && a_step == comp->comp_step);
-      }
-#endif
+      enum ref_step_type a_step;
+      gcc_checking_assert (suitable_reference_p (a->ref, &a_step)
+			   && a_step == comp->comp_step);
     }
 
   /* If there is a write inside the component, we must know whether the
diff --git a/gcc/tree-profile.c b/gcc/tree-profile.c
index 0d33c87..54bc644 100644
--- a/gcc/tree-profile.c
+++ b/gcc/tree-profile.c
@@ -461,9 +461,8 @@ gimple_gen_const_delta_profiler (histogram_value value ATTRIBUTE_UNUSED,
 			       unsigned base ATTRIBUTE_UNUSED)
 {
   /* FIXME implement this.  */
-#ifdef ENABLE_CHECKING
-  internal_error ("unimplemented functionality");
-#endif
+  if (flag_checking)
+    internal_error ("unimplemented functionality");
   gcc_unreachable ();
 }
 
diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c
index 3b8d594..a5bd831 100644
--- a/gcc/tree-ssa-alias.c
+++ b/gcc/tree-ssa-alias.c
@@ -1442,12 +1442,7 @@ refs_may_alias_p_1 (ao_ref *ref1, ao_ref *ref2, bool tbaa_p)
 				      ao_ref_alias_set (ref2), -1,
 				      tbaa_p);
 
-  /* We really do not want to end up here, but returning true is safe.  */
-#ifdef ENABLE_CHECKING
   gcc_unreachable ();
-#else
-  return true;
-#endif
 }
 
 static bool
diff --git a/gcc/tree-ssa-live.c b/gcc/tree-ssa-live.c
index 25b548b..a61026d 100644
--- a/gcc/tree-ssa-live.c
+++ b/gcc/tree-ssa-live.c
@@ -52,9 +52,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "ipa-utils.h"
 #include "cfgloop.h"
 
-#ifdef ENABLE_CHECKING
-static void  verify_live_on_entry (tree_live_info_p);
-#endif
+static void verify_live_on_entry (tree_live_info_p);
 
 
 /* VARMAP maintains a mapping from SSA version number to real variables.
@@ -1153,9 +1151,8 @@ calculate_live_ranges (var_map map, bool want_livein)
 
   live_worklist (live);
 
-#ifdef ENABLE_CHECKING
-  verify_live_on_entry (live);
-#endif
+  if (flag_checking)
+    verify_live_on_entry (live);
 
   calculate_live_on_exit (live);
 
@@ -1292,7 +1289,6 @@ debug (tree_live_info_d *ptr)
 }
 
 
-#ifdef ENABLE_CHECKING
 /* Verify that SSA_VAR is a non-virtual SSA_NAME.  */
 
 void
@@ -1422,4 +1418,3 @@ verify_live_on_entry (tree_live_info_p live)
     }
   gcc_assert (num <= 0);
 }
-#endif
diff --git a/gcc/tree-ssa-live.h b/gcc/tree-ssa-live.h
index 1f88358..0cb3a1a 100644
--- a/gcc/tree-ssa-live.h
+++ b/gcc/tree-ssa-live.h
@@ -80,9 +80,7 @@ extern void remove_unused_locals (void);
 extern void dump_var_map (FILE *, var_map);
 extern void debug (_var_map &ref);
 extern void debug (_var_map *ptr);
-#ifdef ENABLE_CHECKING
 extern void register_ssa_partition_check (tree ssa_var);
-#endif
 
 
 /* Return number of partitions in MAP.  */
@@ -181,12 +179,10 @@ num_basevars (var_map map)
    partitions may be filtered out by a view later.  */
 
 static inline void
-register_ssa_partition (var_map map ATTRIBUTE_UNUSED,
-			tree ssa_var ATTRIBUTE_UNUSED)
+register_ssa_partition (var_map map ATTRIBUTE_UNUSED, tree ssa_var)
 {
-#if defined ENABLE_CHECKING
-  register_ssa_partition_check (ssa_var);
-#endif
+  if (flag_checking)
+    register_ssa_partition_check (ssa_var);
 }
 
 
diff --git a/gcc/tree-ssa-loop-ivcanon.c b/gcc/tree-ssa-loop-ivcanon.c
index 38f7c3f..25f297c 100644
--- a/gcc/tree-ssa-loop-ivcanon.c
+++ b/gcc/tree-ssa-loop-ivcanon.c
@@ -1376,10 +1376,8 @@ tree_unroll_loops_completely (bool may_increase_size, bool unroll_outer)
 	  /* Clean up the information about numbers of iterations, since
 	     complete unrolling might have invalidated it.  */
 	  scev_reset ();
-#ifdef ENABLE_CHECKING
-	  if (loops_state_satisfies_p (LOOP_CLOSED_SSA))
+	  if (flag_checking && loops_state_satisfies_p (LOOP_CLOSED_SSA))
 	    verify_loop_closed_ssa (true);
-#endif
 	}
       if (loop_closed_ssa_invalidated)
         BITMAP_FREE (loop_closed_ssa_invalidated);
diff --git a/gcc/tree-ssa-loop-manip.c b/gcc/tree-ssa-loop-manip.c
index 27ba275..ba2340f 100644
--- a/gcc/tree-ssa-loop-manip.c
+++ b/gcc/tree-ssa-loop-manip.c
@@ -278,22 +278,22 @@ add_exit_phi (basic_block exit, tree var)
   edge e;
   edge_iterator ei;
 
-#ifdef ENABLE_CHECKING
   /* Check that at least one of the edges entering the EXIT block exits
      the loop, or a superloop of that loop, that VAR is defined in.  */
-  gimple *def_stmt = SSA_NAME_DEF_STMT (var);
-  basic_block def_bb = gimple_bb (def_stmt);
-  FOR_EACH_EDGE (e, ei, exit->preds)
+  if (flag_checking)
     {
-      struct loop *aloop = find_common_loop (def_bb->loop_father,
-					     e->src->loop_father);
-      if (!flow_bb_inside_loop_p (aloop, e->dest))
-	break;
+      gimple *def_stmt = SSA_NAME_DEF_STMT (var);
+      basic_block def_bb = gimple_bb (def_stmt);
+      FOR_EACH_EDGE (e, ei, exit->preds)
+	{
+	  struct loop *aloop = find_common_loop (def_bb->loop_father,
+						 e->src->loop_father);
+	  if (!flow_bb_inside_loop_p (aloop, e->dest))
+	    break;
+	}
+      gcc_assert (e);
     }
 
-  gcc_checking_assert (e);
-#endif
-
   phi = create_phi_node (NULL_TREE, exit);
   create_new_def_for (var, phi, gimple_phi_result_ptr (phi));
   FOR_EACH_EDGE (e, ei, exit->preds)
@@ -1368,11 +1368,9 @@ tree_transform_and_unroll_loop (struct loop *loop, unsigned factor,
   gimple_cond_set_rhs (exit_if, exit_bound);
   update_stmt (exit_if);
 
-#ifdef ENABLE_CHECKING
-  verify_flow_info ();
-  verify_loop_structure ();
-  verify_loop_closed_ssa (true);
-#endif
+  checking_verify_flow_info ();
+  checking_verify_loop_structure ();
+  checking_verify_loop_closed_ssa (true);
 }
 
 /* Wrapper over tree_transform_and_unroll_loop for case we do not
diff --git a/gcc/tree-ssa-loop-manip.h b/gcc/tree-ssa-loop-manip.h
index 9285718..96b02a6 100644
--- a/gcc/tree-ssa-loop-manip.h
+++ b/gcc/tree-ssa-loop-manip.h
@@ -27,6 +27,14 @@ extern void create_iv (tree, tree, tree, struct loop *, gimple_stmt_iterator *,
 extern void rewrite_into_loop_closed_ssa (bitmap, unsigned);
 extern void rewrite_virtuals_into_loop_closed_ssa (struct loop *);
 extern void verify_loop_closed_ssa (bool);
+
+static inline void
+checking_verify_loop_closed_ssa (bool verify_ssa_p)
+{
+  if (flag_checking)
+    verify_loop_closed_ssa (verify_ssa_p);
+}
+
 extern basic_block split_loop_exit_edge (edge);
 extern basic_block ip_end_pos (struct loop *);
 extern basic_block ip_normal_pos (struct loop *);
diff --git a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c
index 9223642..cb6c749 100644
--- a/gcc/tree-ssa-math-opts.c
+++ b/gcc/tree-ssa-math-opts.c
@@ -541,10 +541,9 @@ pass_cse_reciprocals::execute (function *fun)
   calculate_dominance_info (CDI_DOMINATORS);
   calculate_dominance_info (CDI_POST_DOMINATORS);
 
-#ifdef ENABLE_CHECKING
-  FOR_EACH_BB_FN (bb, fun)
-    gcc_assert (!bb->aux);
-#endif
+  if (flag_checking)
+    FOR_EACH_BB_FN (bb, fun)
+      gcc_assert (!bb->aux);
 
   for (arg = DECL_ARGUMENTS (fun->decl); arg; arg = DECL_CHAIN (arg))
     if (FLOAT_TYPE_P (TREE_TYPE (arg))
diff --git a/gcc/tree-ssa-operands.c b/gcc/tree-ssa-operands.c
index 544e9df..92d1ab2 100644
--- a/gcc/tree-ssa-operands.c
+++ b/gcc/tree-ssa-operands.c
@@ -881,12 +881,13 @@ get_expr_operands (struct function *fn, gimple *stmt, tree *expr_p, int flags)
     }
 
   /* If we get here, something has gone wrong.  */
-#ifdef ENABLE_CHECKING
-  fprintf (stderr, "unhandled expression in get_expr_operands():\n");
-  debug_tree (expr);
-  fputs ("\n", stderr);
-#endif
-  gcc_unreachable ();
+  if (flag_checking)
+    {
+      fprintf (stderr, "unhandled expression in get_expr_operands():\n");
+      debug_tree (expr);
+      fputs ("\n", stderr);
+      gcc_unreachable ();
+    }
 }
 
 
diff --git a/gcc/tree-ssa-propagate.c b/gcc/tree-ssa-propagate.c
index fbe41f9..363f439 100644
--- a/gcc/tree-ssa-propagate.c
+++ b/gcc/tree-ssa-propagate.c
@@ -1501,14 +1501,14 @@ static void
 replace_exp_1 (use_operand_p op_p, tree val,
     	       bool for_propagation ATTRIBUTE_UNUSED)
 {
-#if defined ENABLE_CHECKING
-  tree op = USE_FROM_PTR (op_p);
-
-  gcc_assert (!(for_propagation
-		&& TREE_CODE (op) == SSA_NAME
-		&& TREE_CODE (val) == SSA_NAME
-		&& !may_propagate_copy (op, val)));
-#endif
+  if (flag_checking)
+    {
+      tree op = USE_FROM_PTR (op_p);
+      gcc_assert (!(for_propagation
+		  && TREE_CODE (op) == SSA_NAME
+		  && TREE_CODE (val) == SSA_NAME
+		  && !may_propagate_copy (op, val)));
+    }
 
   if (TREE_CODE (val) == SSA_NAME)
     SET_USE (op_p, val);
diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c
index 5e070bc..52b0813 100644
--- a/gcc/tree-ssa-structalias.c
+++ b/gcc/tree-ssa-structalias.c
@@ -2544,10 +2544,11 @@ rewrite_constraints (constraint_graph_t graph,
   int i;
   constraint_t c;
 
-#ifdef ENABLE_CHECKING
-  for (unsigned int j = 0; j < graph->size; j++)
-    gcc_assert (find (j) == j);
-#endif
+  if (flag_checking)
+    {
+      for (unsigned int j = 0; j < graph->size; j++)
+	gcc_assert (find (j) == j);
+    }
 
   FOR_EACH_VEC_ELT (constraints, i, c)
     {
diff --git a/gcc/tree-ssa-ter.c b/gcc/tree-ssa-ter.c
index 7a7bcc9..b2d19ed 100644
--- a/gcc/tree-ssa-ter.c
+++ b/gcc/tree-ssa-ter.c
@@ -182,9 +182,7 @@ struct temp_expr_table
 /* A place for the many, many bitmaps we create.  */
 static bitmap_obstack ter_bitmap_obstack;
 
-#ifdef ENABLE_CHECKING
 extern void debug_ter (FILE *, temp_expr_table *);
-#endif
 
 
 /* Create a new TER table for MAP.  */
@@ -232,16 +230,16 @@ free_temp_expr_table (temp_expr_table *t)
 {
   bitmap ret = NULL;
 
-#ifdef ENABLE_CHECKING
-  unsigned x;
-  for (x = 0; x <= num_var_partitions (t->map); x++)
-    gcc_assert (!t->kill_list[x]);
-  for (x = 0; x < num_ssa_names; x++)
+  if (flag_checking)
     {
-      gcc_assert (t->expr_decl_uids[x] == NULL);
-      gcc_assert (t->partition_dependencies[x] == NULL);
+      for (unsigned x = 0; x <= num_var_partitions (t->map); x++)
+	gcc_assert (!t->kill_list[x]);
+      for (unsigned x = 0; x < num_ssa_names; x++)
+	{
+	  gcc_assert (t->expr_decl_uids[x] == NULL);
+	  gcc_assert (t->partition_dependencies[x] == NULL);
+	}
     }
-#endif
 
   BITMAP_FREE (t->partition_in_use);
   BITMAP_FREE (t->new_replaceable_dependencies);
@@ -748,7 +746,6 @@ dump_replaceable_exprs (FILE *f, bitmap expr)
 }
 
 
-#ifdef ENABLE_CHECKING
 /* Dump the status of the various tables in the expression table.  This is used
    exclusively to debug TER.  F is the place to send debug info and T is the
    table being debugged.  */
@@ -796,4 +793,3 @@ debug_ter (FILE *f, temp_expr_table *t)
 
   fprintf (f, "\n----------\n");
 }
-#endif
diff --git a/gcc/tree-ssa-threadupdate.c b/gcc/tree-ssa-threadupdate.c
index 8e3437a..90a9172 100644
--- a/gcc/tree-ssa-threadupdate.c
+++ b/gcc/tree-ssa-threadupdate.c
@@ -2510,9 +2510,8 @@ duplicate_thread_path (edge entry, edge exit,
       scale_bbs_frequencies_int (region_copy, n_region, entry_freq, total_freq);
     }
 
-#ifdef ENABLE_CHECKING
-  verify_jump_thread (region_copy, n_region);
-#endif
+  if (flag_checking)
+    verify_jump_thread (region_copy, n_region);
 
   /* Remove the last branch in the jump thread path.  */
   remove_ctrl_stmt_and_useless_edges (region_copy[n_region - 1], exit->dest);
diff --git a/gcc/tree-ssa.h b/gcc/tree-ssa.h
index a2c90a0..5a409e5 100644
--- a/gcc/tree-ssa.h
+++ b/gcc/tree-ssa.h
@@ -77,5 +77,13 @@ redirect_edge_var_map_location (edge_var_map *v)
   return v->locus;
 }
 
+/* Verify SSA invariants, if internal consistency checks are enabled.  */
+
+static inline void
+checking_verify_ssa (bool check_modified_stmt, bool check_ssa_operands)
+{
+  if (flag_checking)
+    verify_ssa (check_modified_stmt, check_ssa_operands);
+}
 
 #endif /* GCC_TREE_SSA_H */
diff --git a/gcc/tree-ssanames.c b/gcc/tree-ssanames.c
index 804ec62..90d75b6 100644
--- a/gcc/tree-ssanames.c
+++ b/gcc/tree-ssanames.c
@@ -336,9 +336,8 @@ release_ssa_name_fn (struct function *fn, tree var)
       if (MAY_HAVE_DEBUG_STMTS)
 	insert_debug_temp_for_var_def (NULL, var);
 
-#ifdef ENABLE_CHECKING
-      verify_imm_links (stderr, var);
-#endif
+      if (flag_checking)
+	verify_imm_links (stderr, var);
       while (imm->next != imm)
 	delink_imm_use (imm->next);
 
diff --git a/gcc/tree-stdarg.c b/gcc/tree-stdarg.c
index 3e6d98c..a38443d 100644
--- a/gcc/tree-stdarg.c
+++ b/gcc/tree-stdarg.c
@@ -1107,13 +1107,14 @@ expand_ifn_va_arg (function *fun)
   if ((fun->curr_properties & PROP_gimple_lva) == 0)
     expand_ifn_va_arg_1 (fun);
 
-#if ENABLE_CHECKING
-  basic_block bb;
-  gimple_stmt_iterator i;
-  FOR_EACH_BB_FN (bb, fun)
-    for (i = gsi_start_bb (bb); !gsi_end_p (i); gsi_next (&i))
-      gcc_assert (!gimple_call_ifn_va_arg_p (gsi_stmt (i)));
-#endif
+  if (flag_checking)
+    {
+      basic_block bb;
+      gimple_stmt_iterator i;
+      FOR_EACH_BB_FN (bb, fun)
+	for (i = gsi_start_bb (bb); !gsi_end_p (i); gsi_next (&i))
+	  gcc_assert (!gimple_call_ifn_va_arg_p (gsi_stmt (i)));
+    }
 }
 
 namespace {
diff --git a/gcc/tree-vect-loop-manip.c b/gcc/tree-vect-loop-manip.c
index 11c3ae2..d9d01ec 100644
--- a/gcc/tree-vect-loop-manip.c
+++ b/gcc/tree-vect-loop-manip.c
@@ -919,9 +919,7 @@ slpeel_tree_duplicate_loop_to_edge_cfg (struct loop *loop,
   free (new_bbs);
   free (bbs);
 
-#ifdef ENABLE_CHECKING
-  verify_dominators (CDI_DOMINATORS);
-#endif
+  checking_verify_dominators (CDI_DOMINATORS);
 
   return new_loop;
 }
@@ -1003,11 +1001,13 @@ slpeel_can_duplicate_loop_p (const struct loop *loop, const_edge e)
   return true;
 }
 
-#ifdef ENABLE_CHECKING
 static void
-slpeel_verify_cfg_after_peeling (struct loop *first_loop,
-                                 struct loop *second_loop)
+slpeel_checking_verify_cfg_after_peeling (struct loop *first_loop,
+					  struct loop *second_loop)
 {
+  if (!flag_checking)
+    return;
+
   basic_block loop1_exit_bb = single_exit (first_loop)->dest;
   basic_block loop2_entry_bb = loop_preheader_edge (second_loop)->src;
   basic_block loop1_entry_bb = loop_preheader_edge (first_loop)->src;
@@ -1035,7 +1035,6 @@ slpeel_verify_cfg_after_peeling (struct loop *first_loop,
      second_loop.  */
   /* TODO */
 }
-#endif
 
 /* If the run time cost model check determines that vectorization is
    not profitable and hence scalar loop should be generated then set
@@ -1773,9 +1772,7 @@ vect_do_peeling_for_loop_bound (loop_vec_info loop_vinfo,
 				     0, LOOP_VINFO_VECT_FACTOR (loop_vinfo));
   gcc_assert (new_loop);
   gcc_assert (loop_num == loop->num);
-#ifdef ENABLE_CHECKING
-  slpeel_verify_cfg_after_peeling (loop, new_loop);
-#endif
+  slpeel_checking_verify_cfg_after_peeling (loop, new_loop);
 
   /* A guard that controls whether the new_loop is to be executed or skipped
      is placed in LOOP->exit.  LOOP->exit therefore has two successors - one
@@ -2032,9 +2029,7 @@ vect_do_peeling_for_alignment (loop_vec_info loop_vinfo, tree ni_name,
 				   bound, 0);
 
   gcc_assert (new_loop);
-#ifdef ENABLE_CHECKING
-  slpeel_verify_cfg_after_peeling (new_loop, loop);
-#endif
+  slpeel_checking_verify_cfg_after_peeling (new_loop, loop);
   /* For vectorization factor N, we need to copy at most N-1 values 
      for alignment and this means N-2 loopback edge executions.  */
   max_iter = LOOP_VINFO_VECT_FACTOR (loop_vinfo) - 2;
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index 0a47d35..3138ae7 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -242,9 +242,7 @@ static inline bool
 supports_overflow_infinity (const_tree type)
 {
   tree min = vrp_val_min (type), max = vrp_val_max (type);
-#ifdef ENABLE_CHECKING
-  gcc_assert (needs_overflow_infinity (type));
-#endif
+  gcc_checking_assert (needs_overflow_infinity (type));
   return (min != NULL_TREE
 	  && CONSTANT_CLASS_P (min)
 	  && max != NULL_TREE
@@ -373,9 +371,9 @@ static void
 set_value_range (value_range *vr, enum value_range_type t, tree min,
 		 tree max, bitmap equiv)
 {
-#if defined ENABLE_CHECKING
   /* Check the validity of the range.  */
-  if (t == VR_RANGE || t == VR_ANTI_RANGE)
+  if (flag_checking
+      && (t == VR_RANGE || t == VR_ANTI_RANGE))
     {
       int cmp;
 
@@ -395,12 +393,12 @@ set_value_range (value_range *vr, enum value_range_type t, tree min,
 		    || !is_overflow_infinity (max));
     }
 
-  if (t == VR_UNDEFINED || t == VR_VARYING)
-    gcc_assert (min == NULL_TREE && max == NULL_TREE);
-
-  if (t == VR_UNDEFINED || t == VR_VARYING)
-    gcc_assert (equiv == NULL || bitmap_empty_p (equiv));
-#endif
+  if (flag_checking
+      && (t == VR_UNDEFINED || t == VR_VARYING))
+    {
+      gcc_assert (min == NULL_TREE && max == NULL_TREE);
+      gcc_assert (equiv == NULL || bitmap_empty_p (equiv));
+    }
 
   vr->type = t;
   vr->min = min;
diff --git a/gcc/tree.c b/gcc/tree.c
index e77d4b8..530e7a9 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -5952,10 +5952,11 @@ free_lang_data_in_cgraph (void)
   /* Traverse every type found freeing its language data.  */
   FOR_EACH_VEC_ELT (fld.types, i, t)
     free_lang_data_in_type (t);
-#ifdef ENABLE_CHECKING
-  FOR_EACH_VEC_ELT (fld.types, i, t)
-    verify_type (t);
-#endif
+  if (flag_checking)
+    {
+      FOR_EACH_VEC_ELT (fld.types, i, t)
+	verify_type (t);
+    }
 
   delete fld.pset;
   fld.worklist.release ();
diff --git a/gcc/value-prof.c b/gcc/value-prof.c
index efdb434..e371c24 100644
--- a/gcc/value-prof.c
+++ b/gcc/value-prof.c
@@ -230,9 +230,8 @@ gimple_remove_histogram_value (struct function *fun, gimple *stmt,
       hist2->hvalue.next = hist->hvalue.next;
     }
   free (hist->hvalue.counters);
-#ifdef ENABLE_CHECKING
-  memset (hist, 0xab, sizeof (*hist));
-#endif
+  if (flag_checking)
+    memset (hist, 0xab, sizeof (*hist));
   free (hist);
 }
 
@@ -595,9 +594,8 @@ free_hist (void **slot, void *data ATTRIBUTE_UNUSED)
 {
   histogram_value hist = *(histogram_value *) slot;
   free (hist->hvalue.counters);
-#ifdef ENABLE_CHECKING
-  memset (hist, 0xab, sizeof (*hist));
-#endif
+  if (flag_checking)
+    memset (hist, 0xab, sizeof (*hist));
   free (hist);
   return 1;
 }
diff --git a/gcc/var-tracking.c b/gcc/var-tracking.c
index 8010ce1..60c0320 100644
--- a/gcc/var-tracking.c
+++ b/gcc/var-tracking.c
@@ -399,7 +399,7 @@ struct variable
 /* Macro to access MEM_OFFSET as an HOST_WIDE_INT.  Evaluates MEM twice.  */
 #define INT_MEM_OFFSET(mem) (MEM_OFFSET_KNOWN_P (mem) ? MEM_OFFSET (mem) : 0)
 
-#if ENABLE_CHECKING && (GCC_VERSION >= 2007)
+#if CHECKING_P && (GCC_VERSION >= 2007)
 
 /* Access VAR's Ith part's offset, checking that it's not a one-part
    variable.  */
@@ -3571,7 +3571,6 @@ loc_cmp (rtx x, rtx y)
   return 0;
 }
 
-#if ENABLE_CHECKING
 /* Check the order of entries in one-part variables.   */
 
 int
@@ -3603,7 +3602,6 @@ canonicalize_loc_order_check (variable **slot,
 
   return 1;
 }
-#endif
 
 /* Mark with VALUE_RECURSED_INTO values that have neighbors that are
    more likely to be chosen as canonical for an equivalence set.
@@ -3832,17 +3830,16 @@ canonicalize_values_star (variable **slot, dataflow_set *set)
 	    else
 	      gcc_unreachable ();
 
-#if ENABLE_CHECKING
-	    while (list)
-	      {
-		if (list->offset == 0
-		    && (dv_as_opaque (list->dv) == dv_as_opaque (dv)
-			|| dv_as_opaque (list->dv) == dv_as_opaque (cdv)))
-		  gcc_unreachable ();
+	    if (flag_checking)
+	      while (list)
+		{
+		  if (list->offset == 0
+		      && (dv_as_opaque (list->dv) == dv_as_opaque (dv)
+			  || dv_as_opaque (list->dv) == dv_as_opaque (cdv)))
+		    gcc_unreachable ();
 
-		list = list->next;
-	      }
-#endif
+		  list = list->next;
+		}
 	  }
       }
 
@@ -6930,10 +6927,9 @@ compute_bb_dataflow (basic_block bb)
 	->traverse <dataflow_set *, canonicalize_values_mark> (out);
       shared_hash_htab (out->vars)
 	->traverse <dataflow_set *, canonicalize_values_star> (out);
-#if ENABLE_CHECKING
-      shared_hash_htab (out->vars)
-	->traverse <dataflow_set *, canonicalize_loc_order_check> (out);
-#endif
+      if (flag_checking)
+	shared_hash_htab (out->vars)
+	  ->traverse <dataflow_set *, canonicalize_loc_order_check> (out);
     }
   changed = dataflow_set_different (&old_out, out);
   dataflow_set_destroy (&old_out);
@@ -7038,13 +7034,14 @@ vt_find_locations (void)
 		  if (adjust)
 		    {
 		      dataflow_post_merge_adjust (in, &VTI (bb)->permp);
-#if ENABLE_CHECKING
-		      /* Merge and merge_adjust should keep entries in
-			 canonical order.  */
-		      shared_hash_htab (in->vars)
-			->traverse <dataflow_set *,
-				    canonicalize_loc_order_check> (in);
-#endif
+
+		      if (flag_checking)
+			/* Merge and merge_adjust should keep entries in
+			   canonical order.  */
+			shared_hash_htab (in->vars)
+			  ->traverse <dataflow_set *,
+				      canonicalize_loc_order_check> (in);
+
 		      if (dst_can_be_shared)
 			{
 			  shared_hash_destroy (in->vars);
@@ -9465,11 +9462,12 @@ vt_emit_notes (void)
 	 again.  */
       dataflow_set_clear (&VTI (bb)->in);
     }
-#ifdef ENABLE_CHECKING
-  shared_hash_htab (cur.vars)
-    ->traverse <variable_table_type *, emit_notes_for_differences_1>
-      (shared_hash_htab (empty_shared_hash));
-#endif
+
+  if (flag_checking)
+    shared_hash_htab (cur.vars)
+      ->traverse <variable_table_type *, emit_notes_for_differences_1>
+	(shared_hash_htab (empty_shared_hash));
+
   dataflow_set_destroy (&cur);
 
   if (MAY_HAVE_DEBUG_INSNS)

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 7/9] ENABLE_CHECKING refactoring: middle-end, LTO FE
  2015-10-28  1:17                 ` Jeff Law
@ 2015-10-28  2:12                   ` Trevor Saunders
  0 siblings, 0 replies; 77+ messages in thread
From: Trevor Saunders @ 2015-10-28  2:12 UTC (permalink / raw)
  To: Jeff Law
  Cc: Bernd Schmidt, Mikhail Maltsev, Richard Biener, gcc-patches mailing list

On Tue, Oct 27, 2015 at 07:06:42PM -0600, Jeff Law wrote:
> On 10/26/2015 12:45 PM, Jeff Law wrote:
> >>>>Don't change the whitespace here. Looks like you probably removed a
> >>>>page
> >>>>break.
> >>>Not obvious where it got lost as there's no filename in the review
> >>>comments :-)
> >>
> >>Oops. I think it was one of the sel-sched files.
> >I'll do a looksie over things for undesirable whitespace changes.
> >
> >At least some of the CHECKING_P vs flag_checking thingies are for things
> >that are used outside the compiler proper.  ie things that don't have
> >the options structure.  The pretty-printer and diagnostics stuff was of
> >that nature.  So I'm keeping CHECKING_P rather than flag_checking in those.
> I found the whitespace change and reverted that bit (along with the other
> changes mentioned in my message yesterday).
> 
> I introduced checking_verify_classes wrapper around verify_classes in
> ipa-icf.c to match how that situation was handled elsewhere (as opposed to
> just pulling the test up into the callers).  The more I think about it, the
> more I prefer the factoring done by Mikhail -- because it does make it
> significantly easier to make checking more fine grained controlled later.
> We might want to carry this into verify_insn_chain and a few other places
> too.
> 
> I also fixed several prototypes/definitions which had an empty parameter
> list to explicitly have no parameters ie  foo (void).  I'm not sure why
> Mikhail's patch dropped the "void".  Similarly I put back the DEBUG_FUNCTION
> annotations that were dropped.

 Well, C++ doesn't have the thing where an empty parameter list means
 implicit var args or whatever exactly it is in C.  So I can see why
 you'd add new functions with just (), but changing lines you don't
 already need to seems like a separate patch to me.

 Trev

> 
> 
> Obviously we'll want another pass over the remaining ENABLE_CHECKING bits
> once the rest of Mikhail's patches are installed.  Then we'll probably want
> a pass over the CHECKING_P instances to see which really need to stay #ifs
> vs runtime checks of flag_checking.
> 
> I've bootstrapped and regression tested this change on x86_64-linux-gnu and
> an earlier version has built all the configurations in config-list.mk
> 
> Given this is primarily Mikhail's patch -- my contributions would best be
> summarized as trying to address Bernd's comments and ChangeLog cleanup.  I'm
> going to give final approval to this patch and install it.
> 
> Attached is the actual patch committed
> 
> 
> Jeff
> 

> gcc/lto/ChangeLog:
> 2015-10-19  Mikhail Maltsev  <maltsevm@gmail.com>
> 
> 	* lto.c (unify_scc): Use flag_checking and remove ENABLE_CHECKING
> 	conditionals.
> 	(lto_fixup_state): Likewise.
> 	(do_whole_program_analysis): Use
> 	symtab_node::checking_verify_symtab_nodes and remove ENABLE_CHECKING
> 	conditionals.
> 
> gcc/ChangeLog:
> 
> 2015-10-19  Mikhail Maltsev  <maltsevm@gmail.com>
> 
> 	* attribs.c (check_attribute_tables): New function, broken out from...
> 	(init_attributes): Use it.
> 	* cfgcleanup.c (try_optimize_cfg): Use flag_checking, CHECKING_P
> 	gcc_checking_assert and checking_* functions to eliminate
> 	ENABLE_CHECKING conditionals.
> 	* cfgexpand.c (expand_goto, expand_debug_expr): Likewise.
> 	(pass_expand::execute): Likewise.
> 	* cgraphclones.c (symbol_table::materialize_all_clones): Likewise.
> 	* cgraphunit.c (mark_functions_to_output): Likewise.
> 	(cgraph_node::expand_thunk): Likewise.
> 	(symbol_table::compile): Likewise.
> 	* ddg.c (add_cross_iteration_register_deps): Likewise.
> 	(create_ddg_all_sccs): Likewise.
> 	* df-core.c (df_finish_pass, df_analyze): Likewise.
> 	* diagnostic-core.h: Likewise.
> 	* diagnostic.c (diagnostic_report_diagnostic): Likewise.
> 	* dominance.c (calculate_dominance_info): Likewise.
> 	* dwarf2out.c (add_AT_die_ref): Likewise.
> 	(const_ok_for_output_1, mem_loc_descriptor): Likewise.
> 	(loc_list_from_tree, gen_lexical_block_die): Likewise.
> 	gen_type_die_with_usage, gen_type_die): Likewise.
> 	(dwarf2out_decl): Likewise.
> 	* emit-rtl.c (verify_rtx_sharing, reorder_insns_nobb): Likewise.
> 	* except.c (duplicate_eh_regions): Likewise.
> 	* fwprop.c (register_active_defs, update_df_init): Likewise.
> 	(fwprop_init, fwprop_done): Likewise.
> 	(update_uses): Likewise.
> 	* ggc-page.c (ggc_grow): Likewise.
> 	* gimplify.c (gimplify_body): Likewise.
> 	(gimplify_hasher::equal): Likewise.
> 	* graphite-isl-ast-to-gimple.c (graphite_verify): Likewise.
> 	* graphite-scop-detection.c (canonicalize_loop_closed_ssa_form):
> 	Likewise.
> 	* graphite-sese-to-poly.c (rewrite_reductions_out_of_ssa): Likewise.
> 	(rewrite_cross_bb_scalar_deps_out_of_ssa): Likwise.
> 	* hash-table.h (::find_empty_slot_for_expand): Likewise.
> 	* ifcvt.c (if_convert): Likewise.
> 	* ipa-cp.c (ipcp_propagate_stage): Likewise.
> 	* ipa-devirt.c (type_in_anonymous_namespace_p): Likewise.
> 	(odr_type_p, odr_types_equivalent_p): Likewise.
> 	(add_type_duplicate, get_odr_type): Likewise.
> 	* ipa-icf.c (sem_item_optimizer::execute): Likewise.
> 	(sem_item_optimizer::subdivide_classes_by_equality): Likewise.
> 	(sem_item_optimizer::verify_classes): Likewise.
> 	(sem_item_optimizer::traverse_congruence_split): Likewise.
> 	(sem_item_optimizer::checking_verify_classes): New.
> 	* ipa-icf.h (sem_item_optimizer::checking_verify_classes): Add new
> 	method.
> 	* cfgrtl.c (commit_edge_insertions): Likewise.
> 	(fixup_reorder_chain, cfg_layout_finalize): Likewise.
> 	(rtl_flow_call_edges_add): Likewise.
> 	* cgraph.c (symbol_table::create_edge): Likewise.
> 	(cgraph_edge::redirect_call_stmt_to_callee): Likewise.
> 	* cgraph.h (symtab_node): Likewise.
> 	(symtab_node::checking_verify_symtab_nodes): Define.
> 	(cgraph_node::checking_verify_cgraph_nodes): Define.
> 	* cfghooks.h (checking_verify_flow_info): Define.
> 	* cfgloop.h (checking_verify_loop_structure): Define.
> 	* dominance.h (checking_verify_dominators): Define.
> 	* et-forest.c: Fix comment.
> 	* ipa-inline-analysis.c (compute_inline_parameters): Use flag_checking,
> 	CHECKING_P gcc_checking_assert and checking_* functions to eliminate
> 	ENABLE_CHECKING conditionals.
> 	* ipa-inline-transform.c (save_inline_function_body): Likewise.
> 	* ipa-inline.c (inline_small_functions): Likewise.
> 	(early_inliner): Likewise.
> 	* ipa-inline.h (estimate_edge_growth): Likewise.
> 	* ipa-visibility.c (function_and_variable_visibility): Likewise.
> 	* ipa.c (symbol_table::remove_unreachable_nodes): Likewise.
> 	(ipa_single_use): Likewise.
> 	* ira-int.h: Likewise.
> 	* ira.c (ira): Likewise.
> 	* loop-doloop.c (doloop_optimize_loops): Likewise.
> 	* loop-init.c (loop_optimizer_init, fix_loop_structure): Likewise.
> 	* loop-invariant.c (move_loop_invariants): Likewise.
> 	* lra-assigns.c (lra_assign): Likewise.
> 	* lra-constraints.c (lra_constraints): Likewise.
> 	* lra-eliminations.c (lra_eliminate): Likewise.
> 	* lra-int.h (struct lra_reg): Likewise.
> 	* lra-lives.c (check_pseudos_live_through_calls): Likewise.
> 	(lra_create_live_ranges_1): Likewise.
> 	* lra-remat.c (create_remat_bb_data): Likewise.
> 	* lra.c (lra_update_insn_recog_data, restore_scratches): Likewise.
> 	(lra): Likewise.
> 	(check_rtl): Always define. Remove incorrect guard around
> 	extract_constrain_insn call.
> 	* lto-cgraph.c (input_cgraph_1: Use flag_checking,
> 	CHECKING_P gcc_checking_assert and checking_* functions to eliminate
> 	ENABLE_CHECKING conditionals.
> 	* lto-streamer-out.c (DFS::DFS): Likewise.
> 	(lto_output): Likewise.
> 	* lto-streamer.c (lto_streamer_init): Likewise.
> 	* omp-low.c (scan_omp_target, expand_omp_taskreg): Likewise.
> 	expand_omp_target, execute_expand_omp): Likewise.
> 	(lower_omp_target): Likewise.
> 	* passes.c (execute_function_todo): Likewise.
> 	(execute_todo, execute_one_pass): Likewise.
> 	(verify_curr_properties): Always define.
> 	* predict.c (tree_estimate_probability: Use flag_checking,
> 	CHECKING_P gcc_checking_assert and checking_* functions to eliminate
> 	ENABLE_CHECKING conditionals.
> 	(propagate_freq): Likewise.
> 	* pretty-print.c (pp_format): Likewise.
> 	* real.c (real_to_decimal_for_mode): Likewise.
> 	* recog.c (split_all_insns): Likewise.
> 	* regcprop.c (kill_value_one_regno): Likewise.
> 	(copy_value): Likewise.
> 	(validate_value_data): Define unconditionally.
> 	* reload.c: Fix comment.
> 	* timevar.c: Include options.h
> 	* tree-ssa.h (checking_verify_ssa): Define.
> 	* tree-ssa-loop-manip.h (checking_verify_loop_closed_ssa): Define.
> 	* sched-deps.c (CHECK): Remove unused macro.
> 	(add_or_update_dep_1, sd_add_dep: Use flag_checking, CHECKING_P
> 	gcc_checking_assert and checking_* functions to eliminate
> 	ENABLE_CHECKING conditionals.
> 	* sel-sched-ir.c (free_regset_pool, tidy_control_flow): Likewise.
> 	* sel-sched.c (struct moveop_static_params): Likewise.
> 	(find_best_reg_for_expr, move_cond_jump): Likewise.
> 	(move_op_orig_expr_not_found): Likewise.
> 	(code_motion_process_successors, move_op): Likewise.
> 	* ssa-iterators.h (first_readonly_imm_use): Likewise.
> 	(next_readonly_imm_use): Likewise.
> 	* store-motion.c (compute_store_table): Likewise.
> 	* symbol-summary.h (function_summary::function_summary): Likewise.
> 	* target.h (cumulative_args_t): Likewise.
> 	(get_cumulative_args, pack_cumulative_args): Likewise.
> 	* timevar.c: (timer::print): Likewise.
> 	* trans-mem.c (ipa_tm_execute): Likewise.
> 	* tree-cfg.c (move_stmt_op): Likewise.
> 	(move_sese_region_to_fn): Likewise.
> 	(gimple_flow_call_edges_add): Likewise.
> 	* tree-cfgcleanup.c (cleanup_tree_cfg_noloop, repair_loop_structures):
> 	Likewise.
> 	* tree-eh.c (remove_unreachable_handlers): Likewise.
> 	* tree-if-conv.c (pass_if_conversion::execute): Likewise.
> 	* tree-inline.c (expand_call_inline, optimize_inline_calls): Likewise.
> 	* tree-into-ssa.c (update_ssa): Likewise.
> 	* tree-loop-distribution.c (pass_loop_distribution::execute): Likewise.
> 	* tree-outof-ssa.c (eliminate_useless_phis, rewrite_trees): Likewise.
> 	* tree-parloops.c (pass_parallelize_loops::execute): Likewise.
> 	* tree-predcom.c (suitable_component_p): Likewise.
> 	* tree-profile.c (gimple_gen_const_delta_profiler): Likewise.
> 	* tree-ssa-alias.c (refs_may_alias_p_1): Likewise.
> 	* tree-ssa-live.c (verify_live_on_entry): Likewise.
> 	* tree-ssa-live.h (register_ssa_partition): Likewise.
> 	* tree-ssa-loop-ivcanon.c (tree_unroll_loops_completely): Likewise.
> 	* tree-ssa-loop-manip.c (add_exit_phi): Likewise.
> 	(tree_transform_and_unroll_loop): Likewise.
> 	* tree-ssa-math-opts.c (pass_cse_reciprocals::execute): Likewise.
> 	* tree-ssa-operands.c (get_expr_operands): Likewise.
> 	* tree-ssa-propagate.c (replace_exp_1): Likewise.
> 	* tree-ssa-structalias.c (rewrite_constraints): Likewise.
> 	* tree-ssa-ter.c (free_temp_expr_table): Likewise.
> 	* tree-ssa-threadupdate.c (duplicate_thread_path): Likewise.
> 	* tree-ssanames.c (release_ssa_name_fn): Likewise.
> 	* tree-stdarg.c (expand_ifn_va_arg): Likewise.
> 	* tree-vect-loop-manip.c
> 	(slpeel_tree_duplicate_loop_to_edge_cfg): Likewise.
> 	(slpeel_checking_verify_cfg_after_peeling): Likewise.
> 	(vect_do_peeling_for_loop_bound): Likewise.
> 	(vect_do_peeling_for_alignment): Likewise.
> 	* tree-vrp.c (supports_overflow_infinity): Likewise.
> 	(set_value_range): Likewise.
> 	* tree.c (free_lang_data_in_cgraph): Likewise.
> 	* value-prof.c (gimple_remove_histogram_value): Likewise.
> 	(free_hist): Likewise.
> 	* var-tracking.c (canonicalize_values_star): Likewise.
> 	(compute_bb_dataflow, vt_find_locations, vt_emit_notes): Likewise.
> 

> diff --git a/gcc/attribs.c b/gcc/attribs.c
> index 6cbe011..e7af7b0 100644
> --- a/gcc/attribs.c
> +++ b/gcc/attribs.c
> @@ -174,8 +174,58 @@ find_attribute_namespace (const char* ns)
>    return NULL;
>  }
>  
> -/* Initialize attribute tables, and make some sanity checks
> -   if --enable-checking.  */
> +/* Make some sanity checks on the attribute tables.  */
> +
> +static void
> +check_attribute_tables (void)
> +{
> +  for (size_t i = 0; i < ARRAY_SIZE (attribute_tables); i++)
> +    for (size_t j = 0; attribute_tables[i][j].name != NULL; j++)
> +      {
> +	/* The name must not begin and end with __.  */
> +	const char *name = attribute_tables[i][j].name;
> +	int len = strlen (name);
> +
> +	gcc_assert (!(name[0] == '_' && name[1] == '_'
> +		      && name[len - 1] == '_' && name[len - 2] == '_'));
> +
> +	/* The minimum and maximum lengths must be consistent.  */
> +	gcc_assert (attribute_tables[i][j].min_length >= 0);
> +
> +	gcc_assert (attribute_tables[i][j].max_length == -1
> +		    || (attribute_tables[i][j].max_length
> +			>= attribute_tables[i][j].min_length));
> +
> +	/* An attribute cannot require both a DECL and a TYPE.  */
> +	gcc_assert (!attribute_tables[i][j].decl_required
> +		    || !attribute_tables[i][j].type_required);
> +
> +	  /* If an attribute requires a function type, in particular
> +	     it requires a type.  */
> +	gcc_assert (!attribute_tables[i][j].function_type_required
> +		    || attribute_tables[i][j].type_required);
> +      }
> +
> +  /* Check that each name occurs just once in each table.  */
> +  for (size_t i = 0; i < ARRAY_SIZE (attribute_tables); i++)
> +    for (size_t j = 0; attribute_tables[i][j].name != NULL; j++)
> +      for (size_t k = j + 1; attribute_tables[i][k].name != NULL; k++)
> +	gcc_assert (strcmp (attribute_tables[i][j].name,
> +			    attribute_tables[i][k].name));
> +
> +  /* Check that no name occurs in more than one table.  Names that
> +     begin with '*' are exempt, and may be overridden.  */
> +  for (size_t i = 0; i < ARRAY_SIZE (attribute_tables); i++)
> +    for (size_t j = i + 1; j < ARRAY_SIZE (attribute_tables); j++)
> +      for (size_t k = 0; attribute_tables[i][k].name != NULL; k++)
> +	for (size_t l = 0; attribute_tables[j][l].name != NULL; l++)
> +	  gcc_assert (attribute_tables[i][k].name[0] == '*'
> +		      || strcmp (attribute_tables[i][k].name,
> +				 attribute_tables[j][l].name));
> +}
> +
> +/* Initialize attribute tables, and make some sanity checks if checking is
> +   enabled.  */
>  
>  void
>  init_attributes (void)
> @@ -195,62 +245,8 @@ init_attributes (void)
>      if (attribute_tables[i] == NULL)
>        attribute_tables[i] = empty_attribute_table;
>  
> -#ifdef ENABLE_CHECKING
> -  /* Make some sanity checks on the attribute tables.  */
> -  for (i = 0; i < ARRAY_SIZE (attribute_tables); i++)
> -    {
> -      int j;
> -
> -      for (j = 0; attribute_tables[i][j].name != NULL; j++)
> -	{
> -	  /* The name must not begin and end with __.  */
> -	  const char *name = attribute_tables[i][j].name;
> -	  int len = strlen (name);
> -
> -	  gcc_assert (!(name[0] == '_' && name[1] == '_'
> -			&& name[len - 1] == '_' && name[len - 2] == '_'));
> -
> -	  /* The minimum and maximum lengths must be consistent.  */
> -	  gcc_assert (attribute_tables[i][j].min_length >= 0);
> -
> -	  gcc_assert (attribute_tables[i][j].max_length == -1
> -		      || (attribute_tables[i][j].max_length
> -			  >= attribute_tables[i][j].min_length));
> -
> -	  /* An attribute cannot require both a DECL and a TYPE.  */
> -	  gcc_assert (!attribute_tables[i][j].decl_required
> -		      || !attribute_tables[i][j].type_required);
> -
> -	  /* If an attribute requires a function type, in particular
> -	     it requires a type.  */
> -	  gcc_assert (!attribute_tables[i][j].function_type_required
> -		      || attribute_tables[i][j].type_required);
> -	}
> -    }
> -
> -  /* Check that each name occurs just once in each table.  */
> -  for (i = 0; i < ARRAY_SIZE (attribute_tables); i++)
> -    {
> -      int j, k;
> -      for (j = 0; attribute_tables[i][j].name != NULL; j++)
> -	for (k = j + 1; attribute_tables[i][k].name != NULL; k++)
> -	  gcc_assert (strcmp (attribute_tables[i][j].name,
> -			      attribute_tables[i][k].name));
> -    }
> -  /* Check that no name occurs in more than one table.  Names that
> -     begin with '*' are exempt, and may be overridden.  */
> -  for (i = 0; i < ARRAY_SIZE (attribute_tables); i++)
> -    {
> -      size_t j, k, l;
> -
> -      for (j = i + 1; j < ARRAY_SIZE (attribute_tables); j++)
> -	for (k = 0; attribute_tables[i][k].name != NULL; k++)
> -	  for (l = 0; attribute_tables[j][l].name != NULL; l++)
> -	    gcc_assert (attribute_tables[i][k].name[0] == '*'
> -			|| strcmp (attribute_tables[i][k].name,
> -				   attribute_tables[j][l].name));
> -    }
> -#endif
> +  if (flag_checking)
> +    check_attribute_tables ();
>  
>    for (i = 0; i < ARRAY_SIZE (attribute_tables); ++i)
>      /* Put all the GNU attributes into the "gnu" namespace.  */
> diff --git a/gcc/cfgcleanup.c b/gcc/cfgcleanup.c
> index 7e576bc..c9b132d 100644
> --- a/gcc/cfgcleanup.c
> +++ b/gcc/cfgcleanup.c
> @@ -2873,11 +2873,8 @@ try_optimize_cfg (int mode)
>                   to detect and fix during edge forwarding, and in some cases
>                   is only visible after newly unreachable blocks are deleted,
>                   which will be done in fixup_partitions.  */
> -              fixup_partitions ();
> -
> -#ifdef ENABLE_CHECKING
> -              verify_flow_info ();
> -#endif
> +	      fixup_partitions ();
> +	      checking_verify_flow_info ();
>              }
>  
>  	  changed_overall |= changed;
> diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c
> index 8d5fb64..200520a 100644
> --- a/gcc/cfgexpand.c
> +++ b/gcc/cfgexpand.c
> @@ -3269,12 +3269,13 @@ expand_computed_goto (tree exp)
>  static void
>  expand_goto (tree label)
>  {
> -#ifdef ENABLE_CHECKING
> -  /* Check for a nonlocal goto to a containing function.  Should have
> -     gotten translated to __builtin_nonlocal_goto.  */
> -  tree context = decl_function_context (label);
> -  gcc_assert (!context || context == current_function_decl);
> -#endif
> +  if (flag_checking)
> +    {
> +      /* Check for a nonlocal goto to a containing function.  Should have
> +	 gotten translated to __builtin_nonlocal_goto.  */
> +      tree context = decl_function_context (label);
> +      gcc_assert (!context || context == current_function_decl);
> +    }
>  
>    emit_jump (jump_target_rtx (label));
>  }
> @@ -5056,12 +5057,12 @@ expand_debug_expr (tree exp)
>  
>      default:
>      flag_unsupported:
> -#ifdef ENABLE_CHECKING
> -      debug_tree (exp);
> -      gcc_unreachable ();
> -#else
> +      if (flag_checking)
> +	{
> +	  debug_tree (exp);
> +	  gcc_unreachable ();
> +	}
>        return NULL;
> -#endif
>      }
>  }
>  
> @@ -6422,9 +6423,7 @@ pass_expand::execute (function *fun)
>       gcc.c-torture/execute/ipa-sra-2.c execution, -Os -m32 fails otherwise.  */
>    cleanup_cfg (CLEANUP_NO_INSN_DEL);
>  
> -#ifdef ENABLE_CHECKING
> -  verify_flow_info ();
> -#endif
> +  checking_verify_flow_info ();
>  
>    /* Initialize pseudos allocated for hard registers.  */
>    emit_initial_value_sets ();
> diff --git a/gcc/cfghooks.h b/gcc/cfghooks.h
> index 0d25cf6..a0cb6fd 100644
> --- a/gcc/cfghooks.h
> +++ b/gcc/cfghooks.h
> @@ -186,6 +186,18 @@ struct cfg_hooks
>  };
>  
>  extern void verify_flow_info (void);
> +
> +/* Check control flow invariants, if internal consistency checks are
> +   enabled.  */
> +
> +static inline void
> +checking_verify_flow_info (void)
> +{
> +  /* TODO: Add a separate option for -fchecking=cfg.  */
> +  if (flag_checking)
> +    verify_flow_info ();
> +}
> +
>  extern void dump_bb (FILE *, basic_block, int, int);
>  extern void dump_bb_for_graph (pretty_printer *, basic_block);
>  extern void dump_flow_info (FILE *, int);
> diff --git a/gcc/cfgloop.h b/gcc/cfgloop.h
> index cd4a4c9..6af6893 100644
> --- a/gcc/cfgloop.h
> +++ b/gcc/cfgloop.h
> @@ -311,6 +311,16 @@ extern void delete_loop (struct loop *);
>  
>  extern void verify_loop_structure (void);
>  
> +/* Check loop structure invariants, if internal consistency checks are
> +   enabled.  */
> +
> +static inline void
> +checking_verify_loop_structure (void)
> +{
> +  if (flag_checking)
> +    verify_loop_structure ();
> +}
> +
>  /* Loop analysis.  */
>  extern bool just_once_each_iteration_p (const struct loop *, const_basic_block);
>  gcov_type expected_loop_iterations_unbounded (const struct loop *);
> diff --git a/gcc/cfgrtl.c b/gcc/cfgrtl.c
> index d2fe1e0..14b9406 100644
> --- a/gcc/cfgrtl.c
> +++ b/gcc/cfgrtl.c
> @@ -2096,9 +2096,7 @@ commit_edge_insertions (void)
>       which will be done by fixup_partitions.  */
>    fixup_partitions ();
>  
> -#ifdef ENABLE_CHECKING
> -  verify_flow_info ();
> -#endif
> +  checking_verify_flow_info ();
>  
>    FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR_FOR_FN (cfun),
>  		  EXIT_BLOCK_PTR_FOR_FN (cfun), next_bb)
> @@ -3722,9 +3720,8 @@ fixup_reorder_chain (void)
>      insn = NEXT_INSN (insn);
>  
>    set_last_insn (insn);
> -#ifdef ENABLE_CHECKING
> -  verify_insn_chain ();
> -#endif
> +  if (flag_checking)
> +    verify_insn_chain ();
>  
>    /* Now add jumps and labels as needed to match the blocks new
>       outgoing edges.  */
> @@ -4312,9 +4309,7 @@ break_superblocks (void)
>  void
>  cfg_layout_finalize (void)
>  {
> -#ifdef ENABLE_CHECKING
> -  verify_flow_info ();
> -#endif
> +  checking_verify_flow_info ();
>    force_one_exit_fallthru ();
>    rtl_register_cfg_hooks ();
>    if (reload_completed && !targetm.have_epilogue ())
> @@ -4324,10 +4319,9 @@ cfg_layout_finalize (void)
>    rebuild_jump_labels (get_insns ());
>    delete_dead_jumptables ();
>  
> -#ifdef ENABLE_CHECKING
> -  verify_insn_chain ();
> -  verify_flow_info ();
> -#endif
> +  if (flag_checking)
> +    verify_insn_chain ();
> +  checking_verify_flow_info ();
>  }
>  
>  
> @@ -4892,13 +4886,11 @@ rtl_flow_call_edges_add (sbitmap blocks)
>  		 block in CFG already.  Calling make_edge in such case would
>  		 cause us to mark that edge as fake and remove it later.  */
>  
> -#ifdef ENABLE_CHECKING
> -	      if (split_at_insn == BB_END (bb))
> +	      if (flag_checking && split_at_insn == BB_END (bb))
>  		{
>  		  e = find_edge (bb, EXIT_BLOCK_PTR_FOR_FN (cfun));
>  		  gcc_assert (e == NULL);
>  		}
> -#endif
>  
>  	      /* Note that the following may create a new basic block
>  		 and renumber the existing basic blocks.  */
> diff --git a/gcc/cgraph.c b/gcc/cgraph.c
> index cfcfaf3..69804c3 100644
> --- a/gcc/cgraph.c
> +++ b/gcc/cgraph.c
> @@ -832,11 +832,9 @@ symbol_table::create_edge (cgraph_node *caller, cgraph_node *callee,
>      {
>        /* This is a rather expensive check possibly triggering
>  	 construction of call stmt hashtable.  */
> -#ifdef ENABLE_CHECKING
>        cgraph_edge *e;
> -      gcc_checking_assert (
> -	!(e = caller->get_edge (call_stmt)) || e->speculative);
> -#endif
> +      gcc_checking_assert (!(e = caller->get_edge (call_stmt))
> +			   || e->speculative);
>  
>        gcc_assert (is_gimple_call (call_stmt));
>      }
> @@ -1282,9 +1280,6 @@ cgraph_edge::redirect_call_stmt_to_callee (void)
>    gcall *new_stmt;
>    gimple_stmt_iterator gsi;
>    bool skip_bounds = false;
> -#ifdef ENABLE_CHECKING
> -  cgraph_node *node;
> -#endif
>  
>    if (e->speculative)
>      {
> @@ -1402,13 +1397,11 @@ cgraph_edge::redirect_call_stmt_to_callee (void)
>  	  && !skip_bounds))
>      return e->call_stmt;
>  
> -#ifdef ENABLE_CHECKING
> -  if (decl)
> +  if (flag_checking && decl)
>      {
> -      node = cgraph_node::get (decl);
> +      cgraph_node *node = cgraph_node::get (decl);
>        gcc_assert (!node || !node->clone.combined_args_to_skip);
>      }
> -#endif
>  
>    if (symtab->dump_file)
>      {
> diff --git a/gcc/cgraph.h b/gcc/cgraph.h
> index 7c54f24..0a0ff70 100644
> --- a/gcc/cgraph.h
> +++ b/gcc/cgraph.h
> @@ -362,7 +362,6 @@ public:
>       and NULL otherwise.  */
>    static inline symtab_node *get (const_tree decl)
>    {
> -#ifdef ENABLE_CHECKING
>      /* Check that we are called for sane type of object - functions
>         and static or external variables.  */
>      gcc_checking_assert (TREE_CODE (decl) == FUNCTION_DECL
> @@ -374,7 +373,6 @@ public:
>         memcpy/memset on the tree nodes.  */
>      gcc_checking_assert (!decl->decl_with_vis.symtab_node
>  			 || decl->decl_with_vis.symtab_node->decl == decl);
> -#endif
>      return decl->decl_with_vis.symtab_node;
>    }
>  
> @@ -398,6 +396,9 @@ public:
>    /* Verify symbol table for internal consistency.  */
>    static DEBUG_FUNCTION void verify_symtab_nodes (void);
>  
> +  /* Perform internal consistency checks, if they are enabled.  */
> +  static inline void checking_verify_symtab_nodes (void);
> +
>    /* Type of the symbol.  */
>    ENUM_BITFIELD (symtab_type) type : 8;
>  
> @@ -558,6 +559,13 @@ private:
>    symtab_node *ultimate_alias_target_1 (enum availability *avail = NULL);
>  };
>  
> +inline void
> +symtab_node::checking_verify_symtab_nodes (void)
> +{
> +  if (flag_checking)
> +    symtab_node::verify_symtab_nodes ();
> +}
> +
>  /* Walk all aliases for NODE.  */
>  #define FOR_EACH_ALIAS(node, alias) \
>    for (unsigned x_i = 0; node->iterate_direct_aliases (x_i, alias); x_i++)
> @@ -1205,6 +1213,9 @@ public:
>    /* Verify whole cgraph structure.  */
>    static void DEBUG_FUNCTION verify_cgraph_nodes (void);
>  
> +  /* Verify cgraph, if consistency checking is enabled.  */
> +  static inline void checking_verify_cgraph_nodes (void);
> +
>    /* Worker to bring NODE local.  */
>    static bool make_local (cgraph_node *node, void *);
>  
> @@ -2753,6 +2764,15 @@ cgraph_node::can_remove_if_no_direct_calls_and_refs_p (void)
>    return true;
>  }
>  
> +/* Verify cgraph, if consistency checking is enabled.  */
> +
> +inline void
> +cgraph_node::checking_verify_cgraph_nodes (void)
> +{
> +  if (flag_checking)
> +    cgraph_node::verify_cgraph_nodes ();
> +}
> +
>  /* Return true when variable can be removed from variable pool
>     if all direct calls are eliminated.  */
>  
> diff --git a/gcc/cgraphclones.c b/gcc/cgraphclones.c
> index f243f6f..f36ef34 100644
> --- a/gcc/cgraphclones.c
> +++ b/gcc/cgraphclones.c
> @@ -1074,9 +1074,8 @@ symbol_table::materialize_all_clones (void)
>  
>    if (symtab->dump_file)
>      fprintf (symtab->dump_file, "Materializing clones\n");
> -#ifdef ENABLE_CHECKING
> -  cgraph_node::verify_cgraph_nodes ();
> -#endif
> +
> +  cgraph_node::checking_verify_cgraph_nodes ();
>  
>    /* We can also do topological order, but number of iterations should be
>       bounded by number of IPA passes since single IPA pass is probably not
> @@ -1145,9 +1144,9 @@ symbol_table::materialize_all_clones (void)
>        node->clear_stmts_in_references ();
>    if (symtab->dump_file)
>      fprintf (symtab->dump_file, "Materialization Call site updates done.\n");
> -#ifdef ENABLE_CHECKING
> -  cgraph_node::verify_cgraph_nodes ();
> -#endif
> +
> +  cgraph_node::checking_verify_cgraph_nodes ();
> +
>    symtab->remove_unreachable_nodes (symtab->dump_file);
>  }
>  
> diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
> index 0b0c0f4..eab8c7f 100644
> --- a/gcc/cgraphunit.c
> +++ b/gcc/cgraphunit.c
> @@ -1325,13 +1325,12 @@ handle_alias_pairs (void)
>  static void
>  mark_functions_to_output (void)
>  {
> -  cgraph_node *node;
> -#ifdef ENABLE_CHECKING
>    bool check_same_comdat_groups = false;
> +  cgraph_node *node;
>  
> -  FOR_EACH_FUNCTION (node)
> -    gcc_assert (!node->process);
> -#endif
> +  if (flag_checking)
> +    FOR_EACH_FUNCTION (node)
> +      gcc_assert (!node->process);
>  
>    FOR_EACH_FUNCTION (node)
>      {
> @@ -1365,15 +1364,14 @@ mark_functions_to_output (void)
>  	}
>        else if (node->same_comdat_group)
>  	{
> -#ifdef ENABLE_CHECKING
> -	  check_same_comdat_groups = true;
> -#endif
> +	  if (flag_checking)
> +	    check_same_comdat_groups = true;
>  	}
>        else
>  	{
>  	  /* We should've reclaimed all functions that are not needed.  */
> -#ifdef ENABLE_CHECKING
> -	  if (!node->global.inlined_to
> +	  if (flag_checking
> +	      && !node->global.inlined_to
>  	      && gimple_has_body_p (decl)
>  	      /* FIXME: in ltrans unit when offline copy is outside partition but inline copies
>  		 are inside partition, we can end up not removing the body since we no longer
> @@ -1386,7 +1384,6 @@ mark_functions_to_output (void)
>  	      node->debug ();
>  	      internal_error ("failed to reclaim unneeded function");
>  	    }
> -#endif
>  	  gcc_assert (node->global.inlined_to
>  		      || !gimple_has_body_p (decl)
>  		      || node->in_other_partition
> @@ -1397,8 +1394,7 @@ mark_functions_to_output (void)
>  	}
>  
>      }
> -#ifdef ENABLE_CHECKING
> -  if (check_same_comdat_groups)
> +  if (flag_checking && check_same_comdat_groups)
>      FOR_EACH_FUNCTION (node)
>        if (node->same_comdat_group && !node->process)
>  	{
> @@ -1418,7 +1414,6 @@ mark_functions_to_output (void)
>  			      "comdat group");
>  	    }
>  	}
> -#endif
>  }
>  
>  /* DECL is FUNCTION_DECL.  Initialize datastructures so DECL is a function
> @@ -1887,9 +1882,7 @@ cgraph_node::expand_thunk (bool output_asm_thunks, bool force_gimple_thunk)
>        TREE_ASM_WRITTEN (thunk_fndecl) = false;
>        delete_unreachable_blocks ();
>        update_ssa (TODO_update_ssa);
> -#ifdef ENABLE_CHECKING
> -      verify_flow_info ();
> -#endif
> +      checking_verify_flow_info ();
>        free_dominance_info (CDI_DOMINATORS);
>  
>        /* Since we want to emit the thunk, we explicitly mark its name as
> @@ -2373,9 +2366,7 @@ symbol_table::compile (void)
>    if (seen_error ())
>      return;
>  
> -#ifdef ENABLE_CHECKING
> -  symtab_node::verify_symtab_nodes ();
> -#endif
> +  symtab_node::checking_verify_symtab_nodes ();
>  
>    timevar_push (TV_CGRAPHOPT);
>    if (pre_ipa_mem_report)
> @@ -2424,9 +2415,7 @@ symbol_table::compile (void)
>    (*debug_hooks->assembly_start) ();
>    if (!quiet_flag)
>      fprintf (stderr, "Assembling functions:\n");
> -#ifdef ENABLE_CHECKING
> -  symtab_node::verify_symtab_nodes ();
> -#endif
> +  symtab_node::checking_verify_symtab_nodes ();
>  
>    materialize_all_clones ();
>    bitmap_obstack_initialize (NULL);
> @@ -2482,7 +2471,8 @@ symbol_table::compile (void)
>        fprintf (dump_file, "\nFinal ");
>        symtab_node::dump_table (dump_file);
>      }
> -#ifdef ENABLE_CHECKING
> +  if (!flag_checking)
> +    return;
>    symtab_node::verify_symtab_nodes ();
>    /* Double check that all inline clones are gone and that all
>       function bodies have been released from memory.  */
> @@ -2501,7 +2491,6 @@ symbol_table::compile (void)
>        if (error_found)
>  	internal_error ("nodes with unreleased memory found");
>      }
> -#endif
>  }
>  
>  
> diff --git a/gcc/ddg.c b/gcc/ddg.c
> index ada4657..b03ab93 100644
> --- a/gcc/ddg.c
> +++ b/gcc/ddg.c
> @@ -300,19 +300,16 @@ add_cross_iteration_register_deps (ddg_ptr g, df_ref last_def)
>    rtx_insn *def_insn = DF_REF_INSN (last_def);
>    ddg_node_ptr last_def_node = get_node_of_insn (g, def_insn);
>    ddg_node_ptr use_node;
> -#ifdef ENABLE_CHECKING
> -  struct df_rd_bb_info *bb_info = DF_RD_BB_INFO (g->bb);
> -#endif
>    df_ref first_def = df_bb_regno_first_def_find (g->bb, regno);
>  
>    gcc_assert (last_def_node);
>    gcc_assert (first_def);
>  
> -#ifdef ENABLE_CHECKING
> -  if (DF_REF_ID (last_def) != DF_REF_ID (first_def))
> -    gcc_assert (!bitmap_bit_p (&bb_info->gen,
> -			       DF_REF_ID (first_def)));
> -#endif
> +  if (flag_checking && DF_REF_ID (last_def) != DF_REF_ID (first_def))
> +    {
> +      struct df_rd_bb_info *bb_info = DF_RD_BB_INFO (g->bb);
> +      gcc_assert (!bitmap_bit_p (&bb_info->gen, DF_REF_ID (first_def)));
> +    }
>  
>    /* Create inter-loop true dependences and anti dependences.  */
>    for (r_use = DF_REF_CHAIN (last_def); r_use != NULL; r_use = r_use->next)
> @@ -1013,7 +1010,6 @@ order_sccs (ddg_all_sccs_ptr g)
>  	 (int (*) (const void *, const void *)) compare_sccs);
>  }
>  
> -#ifdef ENABLE_CHECKING
>  /* Check that every node in SCCS belongs to exactly one strongly connected
>     component and that no element of SCCS is empty.  */
>  static void
> @@ -1033,7 +1029,6 @@ check_sccs (ddg_all_sccs_ptr sccs, int num_nodes)
>      }
>    sbitmap_free (tmp);
>  }
> -#endif
>  
>  /* Perform the Strongly Connected Components decomposing algorithm on the
>     DDG and return DDG_ALL_SCCS structure that contains them.  */
> @@ -1079,9 +1074,10 @@ create_ddg_all_sccs (ddg_ptr g)
>    sbitmap_free (from);
>    sbitmap_free (to);
>    sbitmap_free (scc_nodes);
> -#ifdef ENABLE_CHECKING
> -  check_sccs (sccs, num_nodes);
> -#endif
> +
> +  if (flag_checking)
> +    check_sccs (sccs, num_nodes);
> +
>    return sccs;
>  }
>  
> diff --git a/gcc/df-core.c b/gcc/df-core.c
> index 8d2d7a1..72a5eb5 100644
> --- a/gcc/df-core.c
> +++ b/gcc/df-core.c
> @@ -682,10 +682,8 @@ df_finish_pass (bool verify ATTRIBUTE_UNUSED)
>  #endif
>  #endif
>  
> -#ifdef ENABLE_CHECKING
> -  if (verify)
> +  if (flag_checking && verify)
>      df->changeable_flags |= DF_VERIFY_SCHEDULED;
> -#endif
>  }
>  
>  
> @@ -1273,12 +1271,14 @@ df_analyze (void)
>    for (i = 0; i < df->n_blocks; i++)
>      bitmap_set_bit (current_all_blocks, df->postorder[i]);
>  
> -#ifdef ENABLE_CHECKING
> -  /* Verify that POSTORDER_INVERTED only contains blocks reachable from
> -     the ENTRY block.  */
> -  for (i = 0; i < df->n_blocks_inverted; i++)
> -    gcc_assert (bitmap_bit_p (current_all_blocks, df->postorder_inverted[i]));
> -#endif
> +  if (flag_checking)
> +    {
> +      /* Verify that POSTORDER_INVERTED only contains blocks reachable from
> +	 the ENTRY block.  */
> +      for (i = 0; i < df->n_blocks_inverted; i++)
> +	gcc_assert (bitmap_bit_p (current_all_blocks,
> +				  df->postorder_inverted[i]));
> +    }
>  
>    /* Make sure that we have pruned any unreachable blocks from these
>       sets.  */
> diff --git a/gcc/diagnostic-core.h b/gcc/diagnostic-core.h
> index 66d2e42..6cc1e6b 100644
> --- a/gcc/diagnostic-core.h
> +++ b/gcc/diagnostic-core.h
> @@ -48,7 +48,7 @@ extern const char *trim_filename (const char *);
>  /* None of these functions are suitable for ATTRIBUTE_PRINTF, because
>     each language front end can extend them with its own set of format
>     specifiers.  We must use custom format checks.  */
> -#if (ENABLE_CHECKING && GCC_VERSION >= 4001) || GCC_VERSION == BUILDING_GCC_VERSION
> +#if (CHECKING_P && GCC_VERSION >= 4001) || GCC_VERSION == BUILDING_GCC_VERSION
>  #define ATTRIBUTE_GCC_DIAG(m, n) __attribute__ ((__format__ (GCC_DIAG_STYLE, m, n))) ATTRIBUTE_NONNULL(m)
>  #else
>  #define ATTRIBUTE_GCC_DIAG(m, n) ATTRIBUTE_NONNULL(m)
> diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c
> index 831859a..11c369d 100644
> --- a/gcc/diagnostic.c
> +++ b/gcc/diagnostic.c
> @@ -736,12 +736,12 @@ diagnostic_report_diagnostic (diagnostic_context *context,
>  
>    if (diagnostic->kind == DK_ICE || diagnostic->kind == DK_ICE_NOBT)
>      {
> -#ifndef ENABLE_CHECKING
>        /* When not checking, ICEs are converted to fatal errors when an
>  	 error has already occurred.  This is counteracted by
>  	 abort_on_error.  */
> -      if ((diagnostic_kind_count (context, DK_ERROR) > 0
> -	   || diagnostic_kind_count (context, DK_SORRY) > 0)
> +      if (!CHECKING_P
> +	  && (diagnostic_kind_count (context, DK_ERROR) > 0
> +	      || diagnostic_kind_count (context, DK_SORRY) > 0)
>  	  && !context->abort_on_error)
>  	{
>  	  expanded_location s 
> @@ -750,7 +750,6 @@ diagnostic_report_diagnostic (diagnostic_context *context,
>  		   s.file, s.line);
>  	  exit (ICE_EXIT_CODE);
>  	}
> -#endif
>        if (context->internal_error)
>  	(*context->internal_error) (context,
>  				    diagnostic->message.format_spec,
> diff --git a/gcc/dominance.c b/gcc/dominance.c
> index 09645be..a72b0c1 100644
> --- a/gcc/dominance.c
> +++ b/gcc/dominance.c
> @@ -634,9 +634,7 @@ calculate_dominance_info (cdi_direction dir)
>  
>    if (dom_computed[dir_index] == DOM_OK)
>      {
> -#if ENABLE_CHECKING
> -      verify_dominators (dir);
> -#endif
> +      checking_verify_dominators (dir);
>        return;
>      }
>  
> @@ -665,11 +663,7 @@ calculate_dominance_info (cdi_direction dir)
>        dom_computed[dir_index] = DOM_NO_FAST_QUERY;
>      }
>    else
> -    {
> -#if ENABLE_CHECKING
> -      verify_dominators (dir);
> -#endif
> -    }
> +    checking_verify_dominators (dir);
>  
>    compute_dom_fast_query (dir);
>  
> diff --git a/gcc/dominance.h b/gcc/dominance.h
> index 37e138b..7254f2f 100644
> --- a/gcc/dominance.h
> +++ b/gcc/dominance.h
> @@ -60,6 +60,17 @@ extern bool dominated_by_p (enum cdi_direction, const_basic_block,
>  unsigned bb_dom_dfs_in (enum cdi_direction, basic_block);
>  unsigned bb_dom_dfs_out (enum cdi_direction, basic_block);
>  extern void verify_dominators (enum cdi_direction);
> +
> +/* Verify invariants of computed dominance information, if internal consistency
> +   checks are enabled.  */
> +
> +static inline void
> +checking_verify_dominators (cdi_direction dir)
> +{
> +  if (flag_checking)
> +    verify_dominators (dir);
> +}
> +
>  basic_block recompute_dominator (enum cdi_direction, basic_block);
>  extern void iterate_fix_dominators (enum cdi_direction,
>  				    vec<basic_block> , bool);
> diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
> index c1b7c7b..6e0db41 100644
> --- a/gcc/dwarf2out.c
> +++ b/gcc/dwarf2out.c
> @@ -4149,15 +4149,12 @@ static inline void
>  add_AT_die_ref (dw_die_ref die, enum dwarf_attribute attr_kind, dw_die_ref targ_die)
>  {
>    dw_attr_node attr;
> +  gcc_checking_assert (targ_die != NULL);
>  
> -#ifdef ENABLE_CHECKING
> -  gcc_assert (targ_die != NULL);
> -#else
>    /* With LTO we can end up trying to reference something we didn't create
>       a DIE for.  Avoid crashing later on a NULL referenced DIE.  */
>    if (targ_die == NULL)
>      return;
> -#endif
>  
>    attr.dw_attr = attr_kind;
>    attr.dw_attr_val.val_class = dw_val_class_die_ref;
> @@ -5723,7 +5720,6 @@ debug_dwarf (void)
>    print_die (comp_unit_die (), stderr);
>  }
>  
> -#ifdef ENABLE_CHECKING
>  /* Sanity checks on DIEs.  */
>  
>  static void
> @@ -5786,7 +5782,6 @@ check_die (dw_die_ref die)
>  		    && a->dw_attr != DW_AT_GNU_all_call_sites);
>      }
>  }
> -#endif
>  \f
>  /* Start a new compilation unit DIE for an include file.  OLD_UNIT is the CU
>     for the enclosing include file, if any.  BINCL_DIE is the DW_TAG_GNU_BINCL
> @@ -11763,14 +11758,14 @@ const_ok_for_output_1 (rtx rtl)
>      {
>        /* If delegitimize_address couldn't do anything with the UNSPEC, assume
>  	 we can't express it in the debug info.  */
> -#ifdef ENABLE_CHECKING
>        /* Don't complain about TLS UNSPECs, those are just too hard to
>  	 delegitimize.  Note this could be a non-decl SYMBOL_REF such as
>  	 one in a constant pool entry, so testing SYMBOL_REF_TLS_MODEL
>  	 rather than DECL_THREAD_LOCAL_P is not just an optimization.  */
> -      if (XVECLEN (rtl, 0) == 0
> -	  || GET_CODE (XVECEXP (rtl, 0, 0)) != SYMBOL_REF
> -	  || SYMBOL_REF_TLS_MODEL (XVECEXP (rtl, 0, 0)) == TLS_MODEL_NONE)
> +      if (flag_checking
> +	  && (XVECLEN (rtl, 0) == 0
> +	      || GET_CODE (XVECEXP (rtl, 0, 0)) != SYMBOL_REF
> +	      || SYMBOL_REF_TLS_MODEL (XVECEXP (rtl, 0, 0)) == TLS_MODEL_NONE))
>  	inform (current_function_decl
>  		? DECL_SOURCE_LOCATION (current_function_decl)
>  		: UNKNOWN_LOCATION,
> @@ -11783,7 +11778,6 @@ const_ok_for_output_1 (rtx rtl)
>  		"non-delegitimized UNSPEC %d found in variable location",
>  		XINT (rtl, 1));
>  #endif
> -#endif
>        expansion_failed (NULL_TREE, rtl,
>  			"UNSPEC hasn't been delegitimized.\n");
>        return false;
> @@ -13570,12 +13564,12 @@ mem_loc_descriptor (rtx rtl, machine_mode mode,
>        goto symref;
>  
>      default:
> -#ifdef ENABLE_CHECKING
> -      print_rtl (stderr, rtl);
> -      gcc_unreachable ();
> -#else
> +      if (flag_checking)
> +	{
> +	  print_rtl (stderr, rtl);
> +	  gcc_unreachable ();
> +	}
>        break;
> -#endif
>      }
>  
>    if (mem_loc_result && initialized == VAR_INIT_STATUS_UNINITIALIZED)
> @@ -15098,15 +15092,14 @@ loc_list_from_tree (tree loc, int want_address,
>  	  return 0;
>  	}
>  
> -#ifdef ENABLE_CHECKING
>        /* Otherwise this is a generic code; we should just lists all of
>  	 these explicitly.  We forgot one.  */
> -      gcc_unreachable ();
> -#else
> +      if (flag_checking)
> +	gcc_unreachable ();
> +
>        /* In a release build, we want to degrade gracefully: better to
>  	 generate incomplete debugging information than to crash.  */
>        return NULL;
> -#endif
>      }
>  
>    if (!ret && !list_ret)
> @@ -19908,18 +19901,17 @@ gen_lexical_block_die (tree stmt, dw_die_ref context_die)
>      {
>        if (old_die)
>  	{
> -#ifdef ENABLE_CHECKING
>  	  /* This must have been generated early and it won't even
>  	     need location information since it's a DW_AT_inline
>  	     function.  */
> -	  for (dw_die_ref c = context_die; c; c = c->die_parent)
> -	    if (c->die_tag == DW_TAG_inlined_subroutine
> -		|| c->die_tag == DW_TAG_subprogram)
> -	      {
> -		gcc_assert (get_AT (c, DW_AT_inline));
> -		break;
> -	      }
> -#endif
> +	  if (flag_checking)
> +	    for (dw_die_ref c = context_die; c; c = c->die_parent)
> +	      if (c->die_tag == DW_TAG_inlined_subroutine
> +		  || c->die_tag == DW_TAG_subprogram)
> +		{
> +		  gcc_assert (get_AT (c, DW_AT_inline));
> +		  break;
> +		}
>  	  return;
>  	}
>      }
> @@ -20736,10 +20728,8 @@ gen_type_die_with_usage (tree type, dw_die_ref context_die,
>    if (type == NULL_TREE || type == error_mark_node)
>      return;
>  
> -#ifdef ENABLE_CHECKING
> -  if (type)
> +  if (flag_checking && type)
>       verify_type (type);
> -#endif
>  
>    if (TYPE_NAME (type) != NULL_TREE
>        && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
> @@ -20933,11 +20923,12 @@ gen_type_die (tree type, dw_die_ref context_die)
>    if (type != error_mark_node)
>      {
>        gen_type_die_with_usage (type, context_die, DINFO_USAGE_DIR_USE);
> -#ifdef ENABLE_CHECKING
> -      dw_die_ref die = lookup_type_die (type);
> -      if (die)
> -	check_die (die);
> -#endif
> +      if (flag_checking)
> +	{
> +	  dw_die_ref die = lookup_type_die (type);
> +	  if (die)
> +	    check_die (die);
> +	}
>      }
>  }
>  
> @@ -21975,11 +21966,12 @@ dwarf2out_decl (tree decl)
>  
>    gen_decl_die (decl, NULL, context_die);
>  
> -#ifdef ENABLE_CHECKING
> -  dw_die_ref die = lookup_decl_die (decl);
> -  if (die)
> -    check_die (die);
> -#endif
> +  if (flag_checking)
> +    {
> +      dw_die_ref die = lookup_decl_die (decl);
> +      if (die)
> +	check_die (die);
> +    }
>  }
>  
>  /* Write the debugging output for DECL.  */
> diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c
> index c418c24..8d2e81c 100644
> --- a/gcc/emit-rtl.c
> +++ b/gcc/emit-rtl.c
> @@ -2733,8 +2733,7 @@ verify_rtx_sharing (rtx orig, rtx insn)
>  
>    /* This rtx may not be shared.  If it has already been seen,
>       replace it with a copy of itself.  */
> -#ifdef ENABLE_CHECKING
> -  if (RTX_FLAG (x, used))
> +  if (flag_checking && RTX_FLAG (x, used))
>      {
>        error ("invalid rtl sharing found in the insn");
>        debug_rtx (insn);
> @@ -2742,7 +2741,6 @@ verify_rtx_sharing (rtx orig, rtx insn)
>        debug_rtx (x);
>        internal_error ("internal consistency failure");
>      }
> -#endif
>    gcc_assert (!RTX_FLAG (x, used));
>  
>    RTX_FLAG (x, used) = 1;
> @@ -4259,12 +4257,12 @@ delete_insns_since (rtx_insn *from)
>  void
>  reorder_insns_nobb (rtx_insn *from, rtx_insn *to, rtx_insn *after)
>  {
> -#ifdef ENABLE_CHECKING
> -  rtx_insn *x;
> -  for (x = from; x != to; x = NEXT_INSN (x))
> -    gcc_assert (after != x);
> -  gcc_assert (after != to);
> -#endif
> +  if (flag_checking)
> +    {
> +      for (rtx_insn *x = from; x != to; x = NEXT_INSN (x))
> +	gcc_assert (after != x);
> +      gcc_assert (after != to);
> +    }
>  
>    /* Splice this bunch out of where it is now.  */
>    if (PREV_INSN (from))
> diff --git a/gcc/et-forest.c b/gcc/et-forest.c
> index 4f919d4..bf2f765 100644
> --- a/gcc/et-forest.c
> +++ b/gcc/et-forest.c
> @@ -28,7 +28,7 @@ License along with libiberty; see the file COPYING3.  If not see
>  #include "alloc-pool.h"
>  #include "et-forest.h"
>  
> -/* We do not enable this with ENABLE_CHECKING, since it is awfully slow.  */
> +/* We do not enable this with CHECKING_P, since it is awfully slow.  */
>  #undef DEBUG_ET
>  
>  #ifdef DEBUG_ET
> diff --git a/gcc/except.c b/gcc/except.c
> index 8f77653..5765d58 100644
> --- a/gcc/except.c
> +++ b/gcc/except.c
> @@ -612,9 +612,8 @@ duplicate_eh_regions (struct function *ifun,
>    struct duplicate_eh_regions_data data;
>    eh_region outer_region;
>  
> -#ifdef ENABLE_CHECKING
> -  verify_eh_tree (ifun);
> -#endif
> +  if (flag_checking)
> +    verify_eh_tree (ifun);
>  
>    data.label_map = map;
>    data.label_map_data = map_data;
> @@ -632,9 +631,8 @@ duplicate_eh_regions (struct function *ifun,
>  	duplicate_eh_regions_1 (&data, r, outer_region);
>      }
>  
> -#ifdef ENABLE_CHECKING
> -  verify_eh_tree (cfun);
> -#endif
> +  if (flag_checking)
> +    verify_eh_tree (cfun);
>  
>    return data.eh_map;
>  }
> diff --git a/gcc/fwprop.c b/gcc/fwprop.c
> index 16c7981..c9b29e6 100644
> --- a/gcc/fwprop.c
> +++ b/gcc/fwprop.c
> @@ -843,9 +843,7 @@ all_uses_available_at (rtx_insn *def_insn, rtx_insn *target_insn)
>  
>  \f
>  static df_ref *active_defs;
> -#ifdef ENABLE_CHECKING
>  static sparseset active_defs_check;
> -#endif
>  
>  /* Fill the ACTIVE_DEFS array with the use->def link for the registers
>     mentioned in USE_REC.  Register the valid entries in ACTIVE_DEFS_CHECK
> @@ -859,9 +857,8 @@ register_active_defs (df_ref use)
>        df_ref def = get_def_for_use (use);
>        int regno = DF_REF_REGNO (use);
>  
> -#ifdef ENABLE_CHECKING
> -      sparseset_set_bit (active_defs_check, regno);
> -#endif
> +      if (flag_checking)
> +	sparseset_set_bit (active_defs_check, regno);
>        active_defs[regno] = def;
>      }
>  }
> @@ -876,9 +873,8 @@ register_active_defs (df_ref use)
>  static void
>  update_df_init (rtx_insn *def_insn, rtx_insn *insn)
>  {
> -#ifdef ENABLE_CHECKING
> -  sparseset_clear (active_defs_check);
> -#endif
> +  if (flag_checking)
> +    sparseset_clear (active_defs_check);
>    register_active_defs (DF_INSN_USES (def_insn));
>    register_active_defs (DF_INSN_USES (insn));
>    register_active_defs (DF_INSN_EQ_USES (insn));
> @@ -899,9 +895,7 @@ update_uses (df_ref use)
>        if (DF_REF_ID (use) >= (int) use_def_ref.length ())
>          use_def_ref.safe_grow_cleared (DF_REF_ID (use) + 1);
>  
> -#ifdef ENABLE_CHECKING
> -      gcc_assert (sparseset_bit_p (active_defs_check, regno));
> -#endif
> +      gcc_checking_assert (sparseset_bit_p (active_defs_check, regno));
>        use_def_ref[DF_REF_ID (use)] = active_defs[regno];
>      }
>  }
> @@ -1407,9 +1401,8 @@ fwprop_init (void)
>    df_set_flags (DF_DEFER_INSN_RESCAN);
>  
>    active_defs = XNEWVEC (df_ref, max_reg_num ());
> -#ifdef ENABLE_CHECKING
> -  active_defs_check = sparseset_alloc (max_reg_num ());
> -#endif
> +  if (flag_checking)
> +    active_defs_check = sparseset_alloc (max_reg_num ());
>  }
>  
>  static void
> @@ -1419,9 +1412,8 @@ fwprop_done (void)
>  
>    use_def_ref.release ();
>    free (active_defs);
> -#ifdef ENABLE_CHECKING
> -  sparseset_free (active_defs_check);
> -#endif
> +  if (flag_checking)
> +    sparseset_free (active_defs_check);
>  
>    free_dominance_info (CDI_DOMINATORS);
>    cleanup_cfg (0);
> diff --git a/gcc/ggc-page.c b/gcc/ggc-page.c
> index 34e9e24..deb21bb 100644
> --- a/gcc/ggc-page.c
> +++ b/gcc/ggc-page.c
> @@ -2201,12 +2201,11 @@ ggc_collect (void)
>  void
>  ggc_grow (void)
>  {
> -#ifndef ENABLE_CHECKING
> -  G.allocated_last_gc = MAX (G.allocated_last_gc,
> -			     G.allocated);
> -#else
> -  ggc_collect ();
> -#endif
> +  if (!flag_checking)
> +    G.allocated_last_gc = MAX (G.allocated_last_gc,
> +			       G.allocated);
> +  else
> +    ggc_collect ();
>    if (!quiet_flag)
>      fprintf (stderr, " {GC start %luk} ", (unsigned long) G.allocated / 1024);
>  }
> diff --git a/gcc/gimplify.c b/gcc/gimplify.c
> index a2d71d2..4390f7d 100644
> --- a/gcc/gimplify.c
> +++ b/gcc/gimplify.c
> @@ -10319,10 +10319,8 @@ gimplify_body (tree fndecl, bool do_parms)
>    pop_gimplify_context (outer_bind);
>    gcc_assert (gimplify_ctxp == NULL);
>  
> -#ifdef ENABLE_CHECKING
> -  if (!seen_error ())
> +  if (flag_checking && !seen_error ())
>      verify_gimple_in_seq (gimple_bind_body (outer_bind));
> -#endif
>  
>    timevar_pop (TV_TREE_GIMPLIFY);
>    input_location = saved_location;
> @@ -10614,11 +10612,9 @@ gimplify_hasher::equal (const elt_t *p1, const elt_t *p2)
>    if (!operand_equal_p (t1, t2, 0))
>      return false;
>  
> -#ifdef ENABLE_CHECKING
>    /* Only allow them to compare equal if they also hash equal; otherwise
>       results are nondeterminate, and we fail bootstrap comparison.  */
> -  gcc_assert (hash (p1) == hash (p2));
> -#endif
> +  gcc_checking_assert (hash (p1) == hash (p2));
>  
>    return true;
>  }
> diff --git a/gcc/graphite-isl-ast-to-gimple.c b/gcc/graphite-isl-ast-to-gimple.c
> index de28477..fc4af5a 100644
> --- a/gcc/graphite-isl-ast-to-gimple.c
> +++ b/gcc/graphite-isl-ast-to-gimple.c
> @@ -106,10 +106,8 @@ gmp_cst_to_tree (tree type, mpz_t val)
>  static inline void
>  graphite_verify (void)
>  {
> -#ifdef ENABLE_CHECKING
> -  verify_loop_structure ();
> -  verify_loop_closed_ssa (true);
> -#endif
> +  checking_verify_loop_structure ();
> +  checking_verify_loop_closed_ssa (true);
>  }
>  
>  /* IVS_PARAMS maps ISL's scattering and parameter identifiers
> diff --git a/gcc/graphite-scop-detection.c b/gcc/graphite-scop-detection.c
> index a95ec57..81158e5 100644
> --- a/gcc/graphite-scop-detection.c
> +++ b/gcc/graphite-scop-detection.c
> @@ -259,21 +259,16 @@ canonicalize_loop_closed_ssa (loop_p loop)
>  static void
>  canonicalize_loop_closed_ssa_form (void)
>  {
> -  loop_p loop;
> -
> -#ifdef ENABLE_CHECKING
> -  verify_loop_closed_ssa (true);
> -#endif
> +  checking_verify_loop_closed_ssa (true);
>  
> +  loop_p loop;
>    FOR_EACH_LOOP (loop, 0)
>      canonicalize_loop_closed_ssa (loop);
>  
>    rewrite_into_loop_closed_ssa (NULL, TODO_update_ssa);
>    update_ssa (TODO_update_ssa);
>  
> -#ifdef ENABLE_CHECKING
> -  verify_loop_closed_ssa (true);
> -#endif
> +  checking_verify_loop_closed_ssa (true);
>  }
>  
>  /* Can all ivs be represented by a signed integer?
> diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c
> index c06d9de..91abcca 100644
> --- a/gcc/graphite-sese-to-poly.c
> +++ b/gcc/graphite-sese-to-poly.c
> @@ -1522,9 +1522,7 @@ rewrite_reductions_out_of_ssa (scop_p scop)
>        }
>  
>    update_ssa (TODO_update_ssa);
> -#ifdef ENABLE_CHECKING
> -  verify_loop_closed_ssa (true);
> -#endif
> +  checking_verify_loop_closed_ssa (true);
>  }
>  
>  /* Rewrite the scalar dependence of DEF used in USE_STMT with a memory
> @@ -1699,9 +1697,7 @@ rewrite_cross_bb_scalar_deps_out_of_ssa (scop_p scop)
>      {
>        scev_reset_htab ();
>        update_ssa (TODO_update_ssa);
> -#ifdef ENABLE_CHECKING
> -      verify_loop_closed_ssa (true);
> -#endif
> +      checking_verify_loop_closed_ssa (true);
>      }
>  }
>  
> diff --git a/gcc/hash-table.h b/gcc/hash-table.h
> index 8e3c2ca..192be30 100644
> --- a/gcc/hash-table.h
> +++ b/gcc/hash-table.h
> @@ -638,9 +638,7 @@ hash_table<Descriptor, Allocator>::find_empty_slot_for_expand (hashval_t hash)
>  
>    if (is_empty (*slot))
>      return slot;
> -#ifdef ENABLE_CHECKING
>    gcc_checking_assert (!is_deleted (*slot));
> -#endif
>  
>    hash2 = hash_table_mod2 (hash, m_size_prime_index);
>    for (;;)
> @@ -652,9 +650,7 @@ hash_table<Descriptor, Allocator>::find_empty_slot_for_expand (hashval_t hash)
>        slot = m_entries + index;
>        if (is_empty (*slot))
>          return slot;
> -#ifdef ENABLE_CHECKING
>        gcc_checking_assert (!is_deleted (*slot));
> -#endif
>      }
>  }
>  
> diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c
> index d0ae494..ca53755 100644
> --- a/gcc/ifcvt.c
> +++ b/gcc/ifcvt.c
> @@ -5093,9 +5093,7 @@ if_convert (bool after_combine)
>    if (optimize == 1)
>      df_remove_problem (df_live);
>  
> -#ifdef ENABLE_CHECKING
> -  verify_flow_info ();
> -#endif
> +  checking_verify_flow_info ();
>  }
>  \f
>  /* If-conversion and CFG cleanup.  */
> diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c
> index ef93b20..d1c6236 100644
> --- a/gcc/ipa-cp.c
> +++ b/gcc/ipa-cp.c
> @@ -2920,9 +2920,8 @@ ipcp_propagate_stage (struct ipa_topo_info *topo)
>  	     overall_size, max_new_size);
>  
>    propagate_constants_topo (topo);
> -#ifdef ENABLE_CHECKING
> -  ipcp_verify_propagated_values ();
> -#endif
> +  if (flag_checking)
> +    ipcp_verify_propagated_values ();
>    topo->constants.propagate_effects ();
>    topo->contexts.propagate_effects ();
>  
> diff --git a/gcc/ipa-devirt.c b/gcc/ipa-devirt.c
> index a7a8e8e..69dec05 100644
> --- a/gcc/ipa-devirt.c
> +++ b/gcc/ipa-devirt.c
> @@ -272,11 +272,10 @@ type_in_anonymous_namespace_p (const_tree t)
>      {
>        /* C++ FE uses magic <anon> as assembler names of anonymous types.
>   	 verify that this match with type_in_anonymous_namespace_p.  */
> -#ifdef ENABLE_CHECKING
>        if (in_lto_p)
> -	gcc_assert (!strcmp ("<anon>",
> -		    IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (TYPE_NAME (t)))));
> -#endif
> +	gcc_checking_assert (!strcmp ("<anon>",
> +				      IDENTIFIER_POINTER
> +					(DECL_ASSEMBLER_NAME (TYPE_NAME (t)))));
>        return true;
>      }
>    return false;
> @@ -300,15 +299,13 @@ odr_type_p (const_tree t)
>    if (TYPE_NAME (t) && TREE_CODE (TYPE_NAME (t)) == TYPE_DECL
>        && (DECL_ASSEMBLER_NAME_SET_P (TYPE_NAME (t))))
>      {
> -#ifdef ENABLE_CHECKING
>        /* C++ FE uses magic <anon> as assembler names of anonymous types.
>   	 verify that this match with type_in_anonymous_namespace_p.  */
> -      gcc_assert (!type_with_linkage_p (t)
> -		  || strcmp ("<anon>",
> -			     IDENTIFIER_POINTER
> -			        (DECL_ASSEMBLER_NAME (TYPE_NAME (t))))
> -		  || type_in_anonymous_namespace_p (t));
> -#endif
> +      gcc_checking_assert (!type_with_linkage_p (t)
> +			   || strcmp ("<anon>",
> +				      IDENTIFIER_POINTER
> +					(DECL_ASSEMBLER_NAME (TYPE_NAME (t))))
> +			   || type_in_anonymous_namespace_p (t));
>        return true;
>      }
>    return false;
> @@ -1777,11 +1774,10 @@ odr_types_equivalent_p (tree t1, tree t2, bool warn, bool *warned,
>  bool
>  odr_types_equivalent_p (tree type1, tree type2)
>  {
> -  hash_set<type_pair> visited;
> +  gcc_checking_assert (odr_or_derived_type_p (type1)
> +		       && odr_or_derived_type_p (type2));
>  
> -#ifdef ENABLE_CHECKING
> -  gcc_assert (odr_or_derived_type_p (type1) && odr_or_derived_type_p (type2));
> -#endif
> +  hash_set<type_pair> visited;
>    return odr_types_equivalent_p (type1, type2, false, NULL,
>  			         &visited, UNKNOWN_LOCATION, UNKNOWN_LOCATION);
>  }
> @@ -2000,8 +1996,8 @@ add_type_duplicate (odr_type val, tree type)
>      }
>    gcc_assert (val->odr_violated || !odr_must_violate);
>    /* Sanity check that all bases will be build same way again.  */
> -#ifdef ENABLE_CHECKING
> -  if (COMPLETE_TYPE_P (type) && COMPLETE_TYPE_P (val->type)
> +  if (flag_checking
> +      && COMPLETE_TYPE_P (type) && COMPLETE_TYPE_P (val->type)
>        && TREE_CODE (val->type) == RECORD_TYPE
>        && TREE_CODE (type) == RECORD_TYPE
>        && TYPE_BINFO (val->type) && TYPE_BINFO (type)
> @@ -2030,7 +2026,6 @@ add_type_duplicate (odr_type val, tree type)
>  	    j++;
>  	  }
>      }
> -#endif
>  
>  
>    /* Regularize things a little.  During LTO same types may come with
> @@ -2136,8 +2131,8 @@ get_odr_type (tree type, bool insert)
>        if (slot && *slot)
>  	{
>  	  val = *slot;
> -#ifdef ENABLE_CHECKING
> -	  if (in_lto_p && can_be_vtable_hashed_p (type))
> +	  if (flag_checking
> +	      && in_lto_p && can_be_vtable_hashed_p (type))
>  	    {
>  	      hash = hash_odr_vtable (type);
>  	      vtable_slot = odr_vtable_hash->find_slot_with_hash (type, hash,
> @@ -2145,7 +2140,6 @@ get_odr_type (tree type, bool insert)
>  	      gcc_assert (!vtable_slot || *vtable_slot == *slot);
>  	      vtable_slot = NULL;
>  	    }
> -#endif
>  	}
>        else if (*vtable_slot)
>  	val = *vtable_slot;
> diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c
> index b0ef9f1..175f70f 100644
> --- a/gcc/ipa-icf.c
> +++ b/gcc/ipa-icf.c
> @@ -2599,7 +2599,7 @@ sem_item_optimizer::execute (void)
>    dump_cong_classes ();
>  
>    process_cong_reduction ();
> -  verify_classes ();
> +  checking_verify_classes ();
>  
>    if (dump_file)
>      fprintf (dump_file, "Dump after callgraph-based congruence reduction\n");
> @@ -2618,7 +2618,7 @@ sem_item_optimizer::execute (void)
>  
>    process_cong_reduction ();
>    dump_cong_classes ();
> -  verify_classes ();
> +  checking_verify_classes ();
>    bool merged_p = merge_classes (prev_class_count);
>  
>    if (dump_file && (dump_flags & TDF_DETAILS))
> @@ -2883,7 +2883,7 @@ sem_item_optimizer::subdivide_classes_by_equality (bool in_wpa)
>  	}
>      }
>  
> -  verify_classes ();
> +  checking_verify_classes ();
>  }
>  
>  /* Subdivide classes by address references that members of the class
> @@ -2977,12 +2977,20 @@ sem_item_optimizer::subdivide_classes_by_sensitive_refs ()
>    return newly_created_classes;
>  }
>  
> -/* Verify congruence classes if checking is enabled.  */
> +/* Verify congruence classes, if checking is enabled.  */
> +
> +void
> +sem_item_optimizer::checking_verify_classes (void)
> +{
> +  if (flag_checking)
> +    verify_classes ();
> +}
> +
> +/* Verify congruence classes.  */
>  
>  void
>  sem_item_optimizer::verify_classes (void)
>  {
> -#if ENABLE_CHECKING
>    for (hash_table <congruence_class_group_hash>::iterator it = m_classes.begin ();
>         it != m_classes.end (); ++it)
>      {
> @@ -2990,26 +2998,25 @@ sem_item_optimizer::verify_classes (void)
>  	{
>  	  congruence_class *cls = (*it)->classes[i];
>  
> -	  gcc_checking_assert (cls);
> -	  gcc_checking_assert (cls->members.length () > 0);
> +	  gcc_assert (cls);
> +	  gcc_assert (cls->members.length () > 0);
>  
>  	  for (unsigned int j = 0; j < cls->members.length (); j++)
>  	    {
>  	      sem_item *item = cls->members[j];
>  
> -	      gcc_checking_assert (item);
> -	      gcc_checking_assert (item->cls == cls);
> +	      gcc_assert (item);
> +	      gcc_assert (item->cls == cls);
>  
>  	      for (unsigned k = 0; k < item->usages.length (); k++)
>  		{
>  		  sem_usage_pair *usage = item->usages[k];
> -		  gcc_checking_assert (usage->item->index_in_class <
> -				       usage->item->cls->members.length ());
> +		  gcc_assert (usage->item->index_in_class <
> +			      usage->item->cls->members.length ());
>  		}
>  	    }
>  	}
>      }
> -#endif
>  }
>  
>  /* Disposes split map traverse function. CLS_PTR is pointer to congruence
> @@ -3054,10 +3061,11 @@ sem_item_optimizer::traverse_congruence_split (congruence_class * const &cls,
>  	  add_item_to_class (tc, cls->members[i]);
>  	}
>  
> -#ifdef ENABLE_CHECKING
> -      for (unsigned int i = 0; i < 2; i++)
> -	gcc_checking_assert (newclasses[i]->members.length ());
> -#endif
> +      if (flag_checking)
> +	{
> +	  for (unsigned int i = 0; i < 2; i++)
> +	    gcc_assert (newclasses[i]->members.length ());
> +	}
>  
>        if (splitter_cls == cls)
>  	optimizer->splitter_class_removed = true;
> @@ -3152,11 +3160,9 @@ sem_item_optimizer::do_congruence_step_for_index (congruence_class *cls,
>  	  else
>  	    b = *slot;
>  
> -#if ENABLE_CHECKING
>  	  gcc_checking_assert (usage->item->cls);
>  	  gcc_checking_assert (usage->item->index_in_class <
>  			       usage->item->cls->members.length ());
> -#endif
>  
>  	  bitmap_set_bit (b, usage->item->index_in_class);
>  	}
> diff --git a/gcc/ipa-icf.h b/gcc/ipa-icf.h
> index ba37426..365e86f 100644
> --- a/gcc/ipa-icf.h
> +++ b/gcc/ipa-icf.h
> @@ -479,6 +479,9 @@ public:
>    void dump (void);
>  
>    /* Verify congruence classes if checking is enabled.  */
> +  void checking_verify_classes (void);
> +
> +  /* Verify congruence classes.  */
>    void verify_classes (void);
>  
>    /* Write IPA ICF summary for symbols.  */
> diff --git a/gcc/ipa-inline-analysis.c b/gcc/ipa-inline-analysis.c
> index 35322cc..e93d445 100644
> --- a/gcc/ipa-inline-analysis.c
> +++ b/gcc/ipa-inline-analysis.c
> @@ -2964,10 +2964,12 @@ compute_inline_parameters (struct cgraph_node *node, bool early)
>    info->size = info->self_size;
>    info->stack_frame_offset = 0;
>    info->estimated_stack_size = info->estimated_self_stack_size;
> -#ifdef ENABLE_CHECKING
> -  inline_update_overall_summary (node);
> -  gcc_assert (info->time == info->self_time && info->size == info->self_size);
> -#endif
> +  if (flag_checking)
> +    {
> +      inline_update_overall_summary (node);
> +      gcc_assert (info->time == info->self_time
> +		  && info->size == info->self_size);
> +    }
>  
>    pop_cfun ();
>  }
> diff --git a/gcc/ipa-inline-transform.c b/gcc/ipa-inline-transform.c
> index 12f701a..1d7bcaa 100644
> --- a/gcc/ipa-inline-transform.c
> +++ b/gcc/ipa-inline-transform.c
> @@ -491,10 +491,9 @@ save_inline_function_body (struct cgraph_node *node)
>        first_clone->remove_symbol_and_inline_clones ();
>        first_clone = NULL;
>      }
> -#ifdef ENABLE_CHECKING
> -  else
> +  else if (flag_checking)
>      first_clone->verify ();
> -#endif
> +
>    return first_clone;
>  }
>  
> diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c
> index 8f3919c..db98755 100644
> --- a/gcc/ipa-inline.c
> +++ b/gcc/ipa-inline.c
> @@ -1878,7 +1878,7 @@ inline_small_functions (void)
>        if (!edge->inline_failed || !edge->callee->analyzed)
>  	continue;
>  
> -#ifdef ENABLE_CHECKING
> +#if CHECKING_P
>        /* Be sure that caches are maintained consistent.  */
>        sreal cached_badness = edge_badness (edge, false);
>   
> @@ -2632,9 +2632,8 @@ early_inliner (function *fun)
>    if (ipa_node_params_sum)
>      return 0;
>  
> -#ifdef ENABLE_CHECKING
> -  node->verify ();
> -#endif
> +  if (flag_checking)
> +    node->verify ();
>    node->remove_all_references ();
>  
>    /* Rebuild this reference because it dosn't depend on
> diff --git a/gcc/ipa-inline.h b/gcc/ipa-inline.h
> index 85041f6..323d117 100644
> --- a/gcc/ipa-inline.h
> +++ b/gcc/ipa-inline.h
> @@ -299,10 +299,8 @@ estimate_edge_size (struct cgraph_edge *edge)
>  static inline int
>  estimate_edge_growth (struct cgraph_edge *edge)
>  {
> -#ifdef ENABLE_CHECKING
>    gcc_checking_assert (inline_edge_summary (edge)->call_stmt_size
>  		       || !edge->callee->analyzed);
> -#endif
>    return (estimate_edge_size (edge)
>  	  - inline_edge_summary (edge)->call_stmt_size);
>  }
> diff --git a/gcc/ipa-visibility.c b/gcc/ipa-visibility.c
> index 93073d8..0ae4388 100644
> --- a/gcc/ipa-visibility.c
> +++ b/gcc/ipa-visibility.c
> @@ -464,16 +464,15 @@ function_and_variable_visibility (bool whole_program)
>  	 what comdat group they are in when they won't be emitted in this TU.  */
>        if (node->same_comdat_group && DECL_EXTERNAL (node->decl))
>  	{
> -#ifdef ENABLE_CHECKING
> -	  symtab_node *n;
> -
> -	  for (n = node->same_comdat_group;
> -	       n != node;
> -	       n = n->same_comdat_group)
> -	      /* If at least one of same comdat group functions is external,
> -		 all of them have to be, otherwise it is a front-end bug.  */
> -	      gcc_assert (DECL_EXTERNAL (n->decl));
> -#endif
> +	  if (flag_checking)
> +	    {
> +	      for (symtab_node *n = node->same_comdat_group;
> +		   n != node;
> +		   n = n->same_comdat_group)
> +		/* If at least one of same comdat group functions is external,
> +		   all of them have to be, otherwise it is a front-end bug.  */
> +		gcc_assert (DECL_EXTERNAL (n->decl));
> +	    }
>  	  node->dissolve_same_comdat_group_list ();
>  	}
>        gcc_assert ((!DECL_WEAK (node->decl)
> diff --git a/gcc/ipa.c b/gcc/ipa.c
> index 6847305..6dc23ae 100644
> --- a/gcc/ipa.c
> +++ b/gcc/ipa.c
> @@ -319,12 +319,13 @@ symbol_table::remove_unreachable_nodes (FILE *file)
>    build_type_inheritance_graph ();
>    if (file)
>      fprintf (file, "\nReclaiming functions:");
> -#ifdef ENABLE_CHECKING
> -  FOR_EACH_FUNCTION (node)
> -    gcc_assert (!node->aux);
> -  FOR_EACH_VARIABLE (vnode)
> -    gcc_assert (!vnode->aux);
> -#endif
> +  if (flag_checking)
> +    {
> +      FOR_EACH_FUNCTION (node)
> +	gcc_assert (!node->aux);
> +      FOR_EACH_VARIABLE (vnode)
> +	gcc_assert (!vnode->aux);
> +    }
>    /* Mark functions whose bodies are obviously needed.
>       This is mostly when they can be referenced externally.  Inline clones
>       are special since their declarations are shared with master clone and thus
> @@ -678,9 +679,7 @@ symbol_table::remove_unreachable_nodes (FILE *file)
>    if (file)
>      fprintf (file, "\n");
>  
> -#ifdef ENABLE_CHECKING
> -  symtab_node::verify_symtab_nodes ();
> -#endif
> +  symtab_node::checking_verify_symtab_nodes ();
>  
>    /* If we removed something, perhaps profile could be improved.  */
>    if (changed && optimize && inline_edge_summary_vec.exists ())
> @@ -1370,13 +1369,12 @@ ipa_single_use (void)
>      {
>        if (var->aux != BOTTOM)
>  	{
> -#ifdef ENABLE_CHECKING
>  	  /* Not having the single user known means that the VAR is
>  	     unreachable.  Either someone forgot to remove unreachable
>  	     variables or the reachability here is wrong.  */
>  
> -          gcc_assert (single_user_map.get (var));
> -#endif
> +	  gcc_checking_assert (single_user_map.get (var));
> +
>  	  if (dump_file)
>  	    {
>  	      fprintf (dump_file, "Variable %s/%i is used by single function\n",
> diff --git a/gcc/ira-int.h b/gcc/ira-int.h
> index af6c92f..d4160d3 100644
> --- a/gcc/ira-int.h
> +++ b/gcc/ira-int.h
> @@ -26,7 +26,7 @@ along with GCC; see the file COPYING3.  If not see
>  /* To provide consistency in naming, all IRA external variables,
>     functions, common typedefs start with prefix ira_.  */
>  
> -#ifdef ENABLE_CHECKING
> +#if CHECKING_P
>  #define ENABLE_IRA_CHECKING
>  #endif
>  
> diff --git a/gcc/ira.c b/gcc/ira.c
> index 4e94632..8e71d50 100644
> --- a/gcc/ira.c
> +++ b/gcc/ira.c
> @@ -5153,9 +5153,9 @@ ira (FILE *f)
>      df_remove_problem (df_live);
>    gcc_checking_assert (df_live == NULL);
>  
> -#ifdef ENABLE_CHECKING
> -  df->changeable_flags |= DF_VERIFY_SCHEDULED;
> -#endif
> +  if (flag_checking)
> +    df->changeable_flags |= DF_VERIFY_SCHEDULED;
> +
>    df_analyze ();
>  
>    init_reg_equiv ();
> diff --git a/gcc/loop-doloop.c b/gcc/loop-doloop.c
> index 6554597..592ae1f 100644
> --- a/gcc/loop-doloop.c
> +++ b/gcc/loop-doloop.c
> @@ -734,7 +734,5 @@ doloop_optimize_loops (void)
>  
>    iv_analysis_done ();
>  
> -#ifdef ENABLE_CHECKING
> -  verify_loop_structure ();
> -#endif
> +  checking_verify_loop_structure ();
>  }
> diff --git a/gcc/loop-init.c b/gcc/loop-init.c
> index 2a38a0f..cd96e70 100644
> --- a/gcc/loop-init.c
> +++ b/gcc/loop-init.c
> @@ -104,10 +104,8 @@ loop_optimizer_init (unsigned flags)
>        /* Ensure that the dominators are computed, like flow_loops_find does.  */
>        calculate_dominance_info (CDI_DOMINATORS);
>  
> -#ifdef ENABLE_CHECKING
>        if (!needs_fixup)
> -	verify_loop_structure ();
> -#endif
> +	checking_verify_loop_structure ();
>  
>        /* Clear all flags.  */
>        if (recorded_exits)
> @@ -129,9 +127,7 @@ loop_optimizer_init (unsigned flags)
>    /* Dump loops.  */
>    flow_loops_dump (dump_file, NULL, 1);
>  
> -#ifdef ENABLE_CHECKING
> -  verify_loop_structure ();
> -#endif
> +  checking_verify_loop_structure ();
>  
>    timevar_pop (TV_LOOP_INIT);
>  }
> @@ -323,9 +319,7 @@ fix_loop_structure (bitmap changed_bbs)
>    /* Apply flags to loops.  */
>    apply_loop_flags (current_loops->state | record_exits);
>  
> -#ifdef ENABLE_CHECKING
> -  verify_loop_structure ();
> -#endif
> +  checking_verify_loop_structure ();
>  
>    timevar_pop (TV_LOOP_INIT);
>  
> diff --git a/gcc/loop-invariant.c b/gcc/loop-invariant.c
> index 7ac38c6..696f0ee 100644
> --- a/gcc/loop-invariant.c
> +++ b/gcc/loop-invariant.c
> @@ -2137,7 +2137,5 @@ move_loop_invariants (void)
>    invariant_table = NULL;
>    invariant_table_size = 0;
>  
> -#ifdef ENABLE_CHECKING
> -  verify_flow_info ();
> -#endif
> +  checking_verify_flow_info ();
>  }
> diff --git a/gcc/lra-assigns.c b/gcc/lra-assigns.c
> index 2986f57..a17e22c 100644
> --- a/gcc/lra-assigns.c
> +++ b/gcc/lra-assigns.c
> @@ -1591,15 +1591,13 @@ lra_assign (void)
>    bitmap_initialize (&all_spilled_pseudos, &reg_obstack);
>    create_live_range_start_chains ();
>    setup_live_pseudos_and_spill_after_risky_transforms (&all_spilled_pseudos);
> -#ifdef ENABLE_CHECKING
> -  if (!flag_ipa_ra)
> +  if (flag_checking && !flag_ipa_ra)
>      for (i = FIRST_PSEUDO_REGISTER; i < max_regno; i++)
>        if (lra_reg_info[i].nrefs != 0 && reg_renumber[i] >= 0
>  	  && lra_reg_info[i].call_p
>  	  && overlaps_hard_reg_set_p (call_used_reg_set,
>  				      PSEUDO_REGNO_MODE (i), reg_renumber[i]))
>  	gcc_unreachable ();
> -#endif
>    /* Setup insns to process on the next constraint pass.  */
>    bitmap_initialize (&changed_pseudo_bitmap, &reg_obstack);
>    init_live_reload_and_inheritance_pseudos ();
> diff --git a/gcc/lra-constraints.c b/gcc/lra-constraints.c
> index afe885a..bc7a292 100644
> --- a/gcc/lra-constraints.c
> +++ b/gcc/lra-constraints.c
> @@ -4455,8 +4455,7 @@ lra_constraints (bool first_p)
>    bitmap_clear (&equiv_insn_bitmap);
>    /* If we used a new hard regno, changed_p should be true because the
>       hard reg is assigned to a new pseudo.  */
> -#ifdef ENABLE_CHECKING
> -  if (! changed_p)
> +  if (flag_checking && !changed_p)
>      {
>        for (i = FIRST_PSEUDO_REGISTER; i < new_regno_start; i++)
>  	if (lra_reg_info[i].nrefs != 0
> @@ -4468,7 +4467,6 @@ lra_constraints (bool first_p)
>  	      lra_assert (df_regs_ever_live_p (hard_regno + j));
>  	  }
>      }
> -#endif
>    return changed_p;
>  }
>  
> diff --git a/gcc/lra-eliminations.c b/gcc/lra-eliminations.c
> index fdf4179..448e645 100644
> --- a/gcc/lra-eliminations.c
> +++ b/gcc/lra-eliminations.c
> @@ -1436,11 +1436,11 @@ lra_eliminate (bool final_p, bool first_p)
>    bitmap_initialize (&insns_with_changed_offsets, &reg_obstack);
>    if (final_p)
>      {
> -#ifdef ENABLE_CHECKING
> -      update_reg_eliminate (&insns_with_changed_offsets);
> -      if (! bitmap_empty_p (&insns_with_changed_offsets))
> -	gcc_unreachable ();
> -#endif
> +      if (flag_checking)
> +	{
> +	  update_reg_eliminate (&insns_with_changed_offsets);
> +	  gcc_assert (bitmap_empty_p (&insns_with_changed_offsets));
> +	}
>        /* We change eliminable hard registers in insns so we should do
>  	 this for all insns containing any eliminable hard
>  	 register.  */
> diff --git a/gcc/lra-int.h b/gcc/lra-int.h
> index 5e78604..02b0ae4 100644
> --- a/gcc/lra-int.h
> +++ b/gcc/lra-int.h
> @@ -91,12 +91,10 @@ struct lra_reg
>    /* True if the pseudo should not be assigned to a stack register.  */
>    bool no_stack_p;
>  #endif
> -#ifdef ENABLE_CHECKING
>    /* True if the pseudo crosses a call.	 It is setup in lra-lives.c
>       and used to check that the pseudo crossing a call did not get a
>       call used hard register.  */
>    bool call_p;
> -#endif
>    /* Number of references and execution frequencies of the register in
>       *non-debug* insns.	 */
>    int nrefs, freq;
> diff --git a/gcc/lra-lives.c b/gcc/lra-lives.c
> index 253bc18..a2c5542 100644
> --- a/gcc/lra-lives.c
> +++ b/gcc/lra-lives.c
> @@ -590,9 +590,7 @@ check_pseudos_live_through_calls (int regno)
>    for (hr = 0; hr < FIRST_PSEUDO_REGISTER; hr++)
>      if (HARD_REGNO_CALL_PART_CLOBBERED (hr, PSEUDO_REGNO_MODE (regno)))
>        SET_HARD_REG_BIT (lra_reg_info[regno].conflict_hard_regs, hr);
> -#ifdef ENABLE_CHECKING
>    lra_reg_info[regno].call_p = true;
> -#endif
>    if (! sparseset_bit_p (pseudos_live_through_setjumps, regno))
>      return;
>    sparseset_clear_bit (pseudos_live_through_setjumps, regno);
> @@ -1229,9 +1227,7 @@ lra_create_live_ranges_1 (bool all_p, bool dead_insn_p)
>  	lra_reg_info[i].biggest_mode = GET_MODE (regno_reg_rtx[i]);
>        else
>  	lra_reg_info[i].biggest_mode = VOIDmode;
> -#ifdef ENABLE_CHECKING
>        lra_reg_info[i].call_p = false;
> -#endif
>        if (i >= FIRST_PSEUDO_REGISTER
>  	  && lra_reg_info[i].nrefs != 0)
>  	{
> diff --git a/gcc/lra-remat.c b/gcc/lra-remat.c
> index 66532b8..68ce502 100644
> --- a/gcc/lra-remat.c
> +++ b/gcc/lra-remat.c
> @@ -578,10 +578,8 @@ create_remat_bb_data (void)
>  			   last_basic_block_for_fn (cfun));
>    FOR_ALL_BB_FN (bb, cfun)
>      {
> -#ifdef ENABLE_CHECKING
> -      if (bb->index < 0 || bb->index >= last_basic_block_for_fn (cfun))
> -	abort ();
> -#endif
> +      gcc_checking_assert (bb->index >= 0
> +			   && bb->index < last_basic_block_for_fn (cfun));
>        bb_info = get_remat_bb_data (bb);
>        bb_info->bb = bb;
>        bitmap_initialize (&bb_info->changed_regs, &reg_obstack);
> diff --git a/gcc/lra.c b/gcc/lra.c
> index 55b856f..cc5a850 100644
> --- a/gcc/lra.c
> +++ b/gcc/lra.c
> @@ -1199,30 +1199,22 @@ lra_update_insn_recog_data (rtx_insn *insn)
>  	  decode_asm_operands (PATTERN (insn), NULL,
>  			       data->operand_loc,
>  			       constraints, operand_mode, NULL);
> -#ifdef ENABLE_CHECKING
> -	  {
> -	    int i;
>  
> -	    for (i = 0; i < nop; i++)
> +	  if (flag_checking)
> +	    for (int i = 0; i < nop; i++)
>  	      lra_assert
>  		(insn_static_data->operand[i].mode == operand_mode[i]
>  		 && insn_static_data->operand[i].constraint == constraints[i]
>  		 && ! insn_static_data->operand[i].is_operator);
> -	  }
> -#endif
>  	}
> -#ifdef ENABLE_CHECKING
> -      {
> -	int i;
>  
> -	for (i = 0; i < insn_static_data->n_operands; i++)
> +      if (flag_checking)
> +	for (int i = 0; i < insn_static_data->n_operands; i++)
>  	  lra_assert
>  	    (insn_static_data->operand[i].type
>  	     == (insn_static_data->operand[i].constraint[0] == '=' ? OP_OUT
>  		 : insn_static_data->operand[i].constraint[0] == '+' ? OP_INOUT
>  		 : OP_IN));
> -      }
> -#endif
>      }
>    else
>      {
> @@ -2004,8 +1996,6 @@ restore_scratches (void)
>  
>  \f
>  
> -#ifdef ENABLE_CHECKING
> -
>  /* Function checks RTL for correctness.	 If FINAL_P is true, it is
>     done at the end of LRA and the check is more rigorous.  */
>  static void
> @@ -2024,9 +2014,7 @@ check_rtl (bool final_p)
>        {
>  	if (final_p)
>  	  {
> -#ifdef ENABLED_CHECKING
>  	    extract_constrain_insn (insn);
> -#endif
>  	    continue;
>  	  }
>  	/* LRA code is based on assumption that all addresses can be
> @@ -2039,7 +2027,6 @@ check_rtl (bool final_p)
>  	  fatal_insn_not_found (insn);
>        }
>  }
> -#endif /* #ifdef ENABLE_CHECKING */
>  
>  /* Determine if the current function has an exception receiver block
>     that reaches the exit block via non-exceptional edges  */
> @@ -2233,10 +2220,9 @@ lra (FILE *f)
>  
>    init_insn_recog_data ();
>  
> -#ifdef ENABLE_CHECKING
>    /* Some quick check on RTL generated by previous passes.  */
> -  check_rtl (false);
> -#endif
> +  if (flag_checking)
> +    check_rtl (false);
>  
>    lra_in_progress = 1;
>  
> @@ -2437,9 +2423,8 @@ lra (FILE *f)
>       by this, so unshare everything here.  */
>    unshare_all_rtl_again (get_insns ());
>  
> -#ifdef ENABLE_CHECKING
> -  check_rtl (true);
> -#endif
> +  if (flag_checking)
> +    check_rtl (true);
>  
>    timevar_pop (TV_LRA);
>  }
> diff --git a/gcc/lto-cgraph.c b/gcc/lto-cgraph.c
> index 51f31c8..eb6f7b6 100644
> --- a/gcc/lto-cgraph.c
> +++ b/gcc/lto-cgraph.c
> @@ -1560,10 +1560,11 @@ input_cgraph_1 (struct lto_file_decl_data *file_data,
>    lto_input_toplevel_asms (file_data, order_base);
>  
>    /* AUX pointers should be all non-zero for function nodes read from the stream.  */
> -#ifdef ENABLE_CHECKING
> -  FOR_EACH_VEC_ELT (nodes, i, node)
> -    gcc_assert (node->aux || !is_a <cgraph_node *> (node));
> -#endif
> +  if (flag_checking)
> +    {
> +      FOR_EACH_VEC_ELT (nodes, i, node)
> +	gcc_assert (node->aux || !is_a <cgraph_node *> (node));
> +    }
>    FOR_EACH_VEC_ELT (nodes, i, node)
>      {
>        int ref;
> diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c
> index 11daf7a..d54beca 100644
> --- a/gcc/lto-streamer-out.c
> +++ b/gcc/lto-streamer-out.c
> @@ -607,17 +607,12 @@ DFS::DFS (struct output_block *ob, tree expr, bool ref_p, bool this_ref_p,
>  		std::swap (sccstack[first + i],
>  			   sccstack[first + entry_start + i]);
>  
> -	      if (scc_entry_len == 1)
> -		; /* We already sorted SCC deterministically in hash_scc.  */
> -	      else
> -		/* Check that we have only one SCC.
> -		   Naturally we may have conflicts if hash function is not
> - 		   strong enough.  Lets see how far this gets.  */
> -		{
> -#ifdef ENABLE_CHECKING
> -		  gcc_unreachable ();
> -#endif
> -		}
> +	      /* We already sorted SCC deterministically in hash_scc.  */
> +
> +	      /* Check that we have only one SCC.
> +		 Naturally we may have conflicts if hash function is not
> +		 strong enough.  Lets see how far this gets.  */
> +	      gcc_checking_assert (scc_entry_len == 1);
>  	    }
>  
>  	  /* Write LTO_tree_scc.  */
> @@ -2277,12 +2272,13 @@ void
>  lto_output (void)
>  {
>    struct lto_out_decl_state *decl_state;
> -#ifdef ENABLE_CHECKING
> -  bitmap output = lto_bitmap_alloc ();
> -#endif
> +  bitmap output = NULL;
>    int i, n_nodes;
>    lto_symtab_encoder_t encoder = lto_get_out_decl_state ()->symtab_node_encoder;
>  
> +  if (flag_checking)
> +    output = lto_bitmap_alloc ();
> +
>    /* Initialize the streamer.  */
>    lto_streamer_init ();
>  
> @@ -2296,10 +2292,11 @@ lto_output (void)
>  	  if (lto_symtab_encoder_encode_body_p (encoder, node)
>  	      && !node->alias)
>  	    {
> -#ifdef ENABLE_CHECKING
> -	      gcc_assert (!bitmap_bit_p (output, DECL_UID (node->decl)));
> -	      bitmap_set_bit (output, DECL_UID (node->decl));
> -#endif
> +	      if (flag_checking)
> +		{
> +		  gcc_assert (!bitmap_bit_p (output, DECL_UID (node->decl)));
> +		  bitmap_set_bit (output, DECL_UID (node->decl));
> +		}
>  	      decl_state = lto_new_out_decl_state ();
>  	      lto_push_out_decl_state (decl_state);
>  	      if (gimple_has_body_p (node->decl) || !flag_wpa
> @@ -2326,10 +2323,11 @@ lto_output (void)
>  	      && !node->alias)
>  	    {
>  	      timevar_push (TV_IPA_LTO_CTORS_OUT);
> -#ifdef ENABLE_CHECKING
> -	      gcc_assert (!bitmap_bit_p (output, DECL_UID (node->decl)));
> -	      bitmap_set_bit (output, DECL_UID (node->decl));
> -#endif
> +	      if (flag_checking)
> +		{
> +		  gcc_assert (!bitmap_bit_p (output, DECL_UID (node->decl)));
> +		  bitmap_set_bit (output, DECL_UID (node->decl));
> +		}
>  	      decl_state = lto_new_out_decl_state ();
>  	      lto_push_out_decl_state (decl_state);
>  	      if (DECL_INITIAL (node->decl) != error_mark_node
> @@ -2353,7 +2351,7 @@ lto_output (void)
>  
>    output_offload_tables ();
>  
> -#ifdef ENABLE_CHECKING
> +#if CHECKING_P
>    lto_bitmap_free (output);
>  #endif
>  }
> diff --git a/gcc/lto-streamer.c b/gcc/lto-streamer.c
> index b34ab8b..92b313a 100644
> --- a/gcc/lto-streamer.c
> +++ b/gcc/lto-streamer.c
> @@ -297,13 +297,12 @@ static hash_table<tree_hash_entry> *tree_htab;
>  void
>  lto_streamer_init (void)
>  {
> -#ifdef ENABLE_CHECKING
>    /* Check that all the TS_* handled by the reader and writer routines
>       match exactly the structures defined in treestruct.def.  When a
>       new TS_* astructure is added, the streamer should be updated to
>       handle it.  */
> -  streamer_check_handled_ts_structures ();
> -#endif
> +  if (flag_checking)
> +    streamer_check_handled_ts_structures ();
>  
>  #ifdef LTO_STREAMER_DEBUG
>    tree_htab = new hash_table<tree_hash_entry> (31);
> diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c
> index 76f8e07..def681d 100644
> --- a/gcc/lto/lto.c
> +++ b/gcc/lto/lto.c
> @@ -1586,19 +1586,18 @@ unify_scc (struct data_in *data_in, unsigned from,
>  	  num_sccs_merged++;
>  	  total_scc_size_merged += len;
>  
> -#ifdef ENABLE_CHECKING
> -	  for (unsigned i = 0; i < len; ++i)
> -	    {
> -	      tree t = map[2*i+1];
> -	      enum tree_code code = TREE_CODE (t);
> -	      /* IDENTIFIER_NODEs should be singletons and are merged by the
> -		 streamer.  The others should be singletons, too, and we
> -		 should not merge them in any way.  */
> -	      gcc_assert (code != TRANSLATION_UNIT_DECL
> -			  && code != IDENTIFIER_NODE
> -			  && !streamer_handle_as_builtin_p (t));
> -	    }
> -#endif
> +	  if (flag_checking)
> +	    for (unsigned i = 0; i < len; ++i)
> +	      {
> +		tree t = map[2*i+1];
> +		enum tree_code code = TREE_CODE (t);
> +		/* IDENTIFIER_NODEs should be singletons and are merged by the
> +		   streamer.  The others should be singletons, too, and we
> +		   should not merge them in any way.  */
> +		gcc_assert (code != TRANSLATION_UNIT_DECL
> +			    && code != IDENTIFIER_NODE
> +			    && !streamer_handle_as_builtin_p (t));
> +	      }
>  
>  	  /* Fixup the streamer cache with the prevailing nodes according
>  	     to the tree node mapping computed by compare_tree_sccs.  */
> @@ -2636,10 +2635,8 @@ lto_fixup_state (struct lto_in_decl_state *state)
>        for (i = 0; i < vec_safe_length (trees); i++)
>  	{
>  	  tree t = (*trees)[i];
> -#ifdef ENABLE_CHECKING
> -	  if (TYPE_P (t))
> +	  if (flag_checking && TYPE_P (t))
>  	    verify_type (t);
> -#endif
>  	  if (VAR_OR_FUNCTION_DECL_P (t)
>  	      && (TREE_PUBLIC (t) || DECL_EXTERNAL (t)))
>  	    (*trees)[i] = lto_symtab_prevailing_decl (t);
> @@ -3101,9 +3098,8 @@ do_whole_program_analysis (void)
>        fprintf (symtab->dump_file, "Optimized ");
>        symtab_node::dump_table (symtab->dump_file);
>      }
> -#ifdef ENABLE_CHECKING
> -  symtab_node::verify_symtab_nodes ();
> -#endif
> +
> +  symtab_node::checking_verify_symtab_nodes ();
>    bitmap_obstack_release (NULL);
>  
>    /* We are about to launch the final LTRANS phase, stop the WPA timer.  */
> diff --git a/gcc/omp-low.c b/gcc/omp-low.c
> index ad7c017..e80fedf 100644
> --- a/gcc/omp-low.c
> +++ b/gcc/omp-low.c
> @@ -3083,14 +3083,14 @@ scan_omp_target (gomp_target *stmt, omp_context *outer_ctx)
>      {
>        TYPE_FIELDS (ctx->record_type)
>  	= nreverse (TYPE_FIELDS (ctx->record_type));
> -#ifdef ENABLE_CHECKING
> -      tree field;
> -      unsigned int align = DECL_ALIGN (TYPE_FIELDS (ctx->record_type));
> -      for (field = TYPE_FIELDS (ctx->record_type);
> -	   field;
> -	   field = DECL_CHAIN (field))
> -	gcc_assert (DECL_ALIGN (field) == align);
> -#endif
> +      if (flag_checking)
> +	{
> +	  unsigned int align = DECL_ALIGN (TYPE_FIELDS (ctx->record_type));
> +	  for (tree field = TYPE_FIELDS (ctx->record_type);
> +	       field;
> +	       field = DECL_CHAIN (field))
> +	    gcc_assert (DECL_ALIGN (field) == align);
> +	}
>        layout_type (ctx->record_type);
>        if (offloaded)
>  	fixup_child_record_type (ctx);
> @@ -6698,10 +6698,8 @@ expand_omp_taskreg (struct omp_region *region)
>  	}
>        if (gimple_in_ssa_p (cfun))
>  	update_ssa (TODO_update_ssa);
> -#ifdef ENABLE_CHECKING
> -      if (!loops_state_satisfies_p (LOOPS_NEED_FIXUP))
> +      if (flag_checking && !loops_state_satisfies_p (LOOPS_NEED_FIXUP))
>  	verify_loop_structure ();
> -#endif
>        pop_cfun ();
>      }
>  
> @@ -11518,10 +11516,8 @@ expand_omp_target (struct omp_region *region)
>  	  if (changed)
>  	    cleanup_tree_cfg ();
>  	}
> -#ifdef ENABLE_CHECKING
> -      if (!loops_state_satisfies_p (LOOPS_NEED_FIXUP))
> +      if (flag_checking && !loops_state_satisfies_p (LOOPS_NEED_FIXUP))
>  	verify_loop_structure ();
> -#endif
>        pop_cfun ();
>      }
>  
> @@ -12058,10 +12054,8 @@ execute_expand_omp (void)
>  
>    expand_omp (root_omp_region);
>  
> -#ifdef ENABLE_CHECKING
> -  if (!loops_state_satisfies_p (LOOPS_NEED_FIXUP))
> +  if (flag_checking && !loops_state_satisfies_p (LOOPS_NEED_FIXUP))
>      verify_loop_structure ();
> -#endif
>    cleanup_tree_cfg ();
>  
>    free_omp_regions ();
> @@ -14145,7 +14139,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx)
>        default:
>  	break;
>        case OMP_CLAUSE_MAP:
> -#ifdef ENABLE_CHECKING
> +#if CHECKING_P
>  	/* First check what we're prepared to handle in the following.  */
>  	switch (OMP_CLAUSE_MAP_KIND (c))
>  	  {
> diff --git a/gcc/passes.c b/gcc/passes.c
> index 0d147fd..43dd4e0 100644
> --- a/gcc/passes.c
> +++ b/gcc/passes.c
> @@ -1952,9 +1952,8 @@ execute_function_todo (function *fn, void *data)
>  
>    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 (flag_checking && !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);
>  
> @@ -1988,7 +1987,6 @@ execute_function_todo (function *fn, void *data)
>        /* 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;
> @@ -2008,11 +2006,10 @@ execute_function_todo (function *fn, void *data)
>  static void
>  execute_todo (unsigned int flags)
>  {
> -#if defined ENABLE_CHECKING
> -  if (cfun
> +  if (flag_checking
> +      && cfun
>        && need_ssa_update_p (cfun))
>      gcc_assert (flags & TODO_update_ssa_any);
> -#endif
>  
>    timevar_push (TV_TODO);
>  
> @@ -2076,14 +2073,12 @@ clear_last_verified (function *fn, void *data ATTRIBUTE_UNUSED)
>  /* Helper function. Verify that the properties has been turn into the
>     properties expected by the pass.  */
>  
> -#ifdef ENABLE_CHECKING
> -static void
> +static void DEBUG_FUNCTION
>  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.  */
> @@ -2331,10 +2326,9 @@ execute_one_pass (opt_pass *pass)
>    /* 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 (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)
> diff --git a/gcc/predict.c b/gcc/predict.c
> index 0b3016c..4482d47 100644
> --- a/gcc/predict.c
> +++ b/gcc/predict.c
> @@ -2205,8 +2205,6 @@ tree_bb_level_predictions (void)
>      }
>  }
>  
> -#ifdef ENABLE_CHECKING
> -
>  /* Callback for hash_map::traverse, asserts that the pointer map is
>     empty.  */
>  
> @@ -2217,7 +2215,6 @@ assert_is_empty (const_basic_block const &, edge_prediction *const &value,
>    gcc_assert (!value);
>    return false;
>  }
> -#endif
>  
>  /* Predict branch probabilities and estimate profile for basic block BB.  */
>  
> @@ -2352,9 +2349,9 @@ tree_estimate_probability (void)
>    FOR_EACH_BB_FN (bb, cfun)
>      combine_predictions_for_bb (bb);
>  
> -#ifdef ENABLE_CHECKING
> -  bb_predictions->traverse<void *, assert_is_empty> (NULL);
> -#endif
> +  if (flag_checking)
> +    bb_predictions->traverse<void *, assert_is_empty> (NULL);
> +
>    delete bb_predictions;
>    bb_predictions = NULL;
>  
> @@ -2545,11 +2542,10 @@ propagate_freq (basic_block head, bitmap tovisit)
>        /* Compute frequency of basic block.  */
>        if (bb != head)
>  	{
> -#ifdef ENABLE_CHECKING
> -	  FOR_EACH_EDGE (e, ei, bb->preds)
> -	    gcc_assert (!bitmap_bit_p (tovisit, e->src->index)
> -			|| (e->flags & EDGE_DFS_BACK));
> -#endif
> +	  if (flag_checking)
> +	    FOR_EACH_EDGE (e, ei, bb->preds)
> +	      gcc_assert (!bitmap_bit_p (tovisit, e->src->index)
> +			  || (e->flags & EDGE_DFS_BACK));
>  
>  	  FOR_EACH_EDGE (e, ei, bb->preds)
>  	    if (EDGE_INFO (e)->back_edge)
> diff --git a/gcc/pretty-print.c b/gcc/pretty-print.c
> index 5889015..b24402d 100644
> --- a/gcc/pretty-print.c
> +++ b/gcc/pretty-print.c
> @@ -625,10 +625,9 @@ pp_format (pretty_printer *pp, text_info *text)
>        *formatters[argno] = XOBFINISH (&buffer->chunk_obstack, const char *);
>      }
>  
> -#ifdef ENABLE_CHECKING
> -  for (; argno < PP_NL_ARGMAX; argno++)
> -    gcc_assert (!formatters[argno]);
> -#endif
> +  if (CHECKING_P)
> +    for (; argno < PP_NL_ARGMAX; argno++)
> +      gcc_assert (!formatters[argno]);
>  
>    /* Revert to normal obstack and wrapping mode.  */
>    buffer->obstack = &buffer->formatted_obstack;
> diff --git a/gcc/real.c b/gcc/real.c
> index 85ac83d..a292126 100644
> --- a/gcc/real.c
> +++ b/gcc/real.c
> @@ -1808,15 +1808,13 @@ real_to_decimal_for_mode (char *str, const REAL_VALUE_TYPE *r_orig,
>    /* Append the exponent.  */
>    sprintf (last, "e%+d", dec_exp);
>  
> -#ifdef ENABLE_CHECKING
>    /* Verify that we can read the original value back in.  */
> -  if (mode != VOIDmode)
> +  if (flag_checking && mode != VOIDmode)
>      {
>        real_from_string (&r, str);
>        real_convert (&r, mode, &r);
>        gcc_assert (real_identical (&r, r_orig));
>      }
> -#endif
>  }
>  
>  /* Likewise, except always uses round-to-nearest.  */
> diff --git a/gcc/recog.c b/gcc/recog.c
> index c032424..2cd06f5 100644
> --- a/gcc/recog.c
> +++ b/gcc/recog.c
> @@ -2975,9 +2975,7 @@ split_all_insns (void)
>    if (changed)
>      find_many_sub_basic_blocks (blocks);
>  
> -#ifdef ENABLE_CHECKING
> -  verify_flow_info ();
> -#endif
> +  checking_verify_flow_info ();
>  
>    sbitmap_free (blocks);
>  }
> diff --git a/gcc/regcprop.c b/gcc/regcprop.c
> index 6f7d01e..bc8111c 100644
> --- a/gcc/regcprop.c
> +++ b/gcc/regcprop.c
> @@ -100,9 +100,7 @@ static bool replace_oldest_value_addr (rtx *, enum reg_class,
>  static bool replace_oldest_value_mem (rtx, rtx_insn *, struct value_data *);
>  static bool copyprop_hardreg_forward_1 (basic_block, struct value_data *);
>  extern void debug_value_data (struct value_data *);
> -#ifdef ENABLE_CHECKING
>  static void validate_value_data (struct value_data *);
> -#endif
>  
>  /* Free all queued updates for DEBUG_INSNs that change some reg to
>     register REGNO.  */
> @@ -150,9 +148,8 @@ kill_value_one_regno (unsigned int regno, struct value_data *vd)
>    if (vd->e[regno].debug_insn_changes)
>      free_debug_insn_changes (vd, regno);
>  
> -#ifdef ENABLE_CHECKING
> -  validate_value_data (vd);
> -#endif
> +  if (flag_checking)
> +    validate_value_data (vd);
>  }
>  
>  /* Kill the value in register REGNO for NREGS, and any other registers
> @@ -365,9 +362,8 @@ copy_value (rtx dest, rtx src, struct value_data *vd)
>      continue;
>    vd->e[i].next_regno = dr;
>  
> -#ifdef ENABLE_CHECKING
> -  validate_value_data (vd);
> -#endif
> +  if (flag_checking)
> +    validate_value_data (vd);
>  }
>  
>  /* Return true if a mode change from ORIG to NEW is allowed for REGNO.  */
> @@ -1141,7 +1137,6 @@ copyprop_hardreg_forward_bb_without_debug_insn (basic_block bb)
>    skip_debug_insn_p = false;
>  }
>  
> -#ifdef ENABLE_CHECKING
>  static void
>  validate_value_data (struct value_data *vd)
>  {
> @@ -1187,7 +1182,7 @@ validate_value_data (struct value_data *vd)
>  		      i, GET_MODE_NAME (vd->e[i].mode), vd->e[i].oldest_regno,
>  		      vd->e[i].next_regno);
>  }
> -#endif
> +
>  \f
>  namespace {
>  
> diff --git a/gcc/reload.c b/gcc/reload.c
> index cc61d77..32eec02 100644
> --- a/gcc/reload.c
> +++ b/gcc/reload.c
> @@ -85,7 +85,7 @@ a register with any other reload.  */
>  
>  #define REG_OK_STRICT
>  
> -/* We do not enable this with ENABLE_CHECKING, since it is awfully slow.  */
> +/* We do not enable this with CHECKING_P, since it is awfully slow.  */
>  #undef DEBUG_RELOAD
>  
>  #include "config.h"
> diff --git a/gcc/sched-deps.c b/gcc/sched-deps.c
> index 9683055..c53a51f 100644
> --- a/gcc/sched-deps.c
> +++ b/gcc/sched-deps.c
> @@ -47,12 +47,6 @@ along with GCC; see the file COPYING3.  If not see
>  
>  #ifdef INSN_SCHEDULING
>  
> -#ifdef ENABLE_CHECKING
> -#define CHECK (true)
> -#else
> -#define CHECK (false)
> -#endif
> -
>  /* Holds current parameters for the dependency analyzer.  */
>  struct sched_deps_info_def *sched_deps_info;
>  
> @@ -505,9 +499,8 @@ static enum DEPS_ADJUST_RESULT maybe_add_or_update_dep_1 (dep_t, bool,
>  							  rtx, rtx);
>  static enum DEPS_ADJUST_RESULT add_or_update_dep_1 (dep_t, bool, rtx, rtx);
>  
> -#ifdef ENABLE_CHECKING
>  static void check_dep (dep_t, bool);
> -#endif
> +
>  \f
>  /* Return nonzero if a load of the memory reference MEM can cause a trap.  */
>  
> @@ -1228,9 +1221,8 @@ add_or_update_dep_1 (dep_t new_dep, bool resolved_p,
>    gcc_assert (INSN_P (DEP_PRO (new_dep)) && INSN_P (DEP_CON (new_dep))
>  	      && DEP_PRO (new_dep) != DEP_CON (new_dep));
>  
> -#ifdef ENABLE_CHECKING
> -  check_dep (new_dep, mem1 != NULL);
> -#endif
> +  if (flag_checking)
> +    check_dep (new_dep, mem1 != NULL);
>  
>    if (true_dependency_cache != NULL)
>      {
> @@ -1348,9 +1340,8 @@ sd_add_dep (dep_t dep, bool resolved_p)
>  
>    add_to_deps_list (DEP_NODE_BACK (n), con_back_deps);
>  
> -#ifdef ENABLE_CHECKING
> -  check_dep (dep, false);
> -#endif
> +  if (flag_checking)
> +    check_dep (dep, false);
>  
>    add_to_deps_list (DEP_NODE_FORW (n), pro_forw_deps);
>  
> @@ -4515,7 +4506,6 @@ debug_ds (ds_t s)
>    fprintf (stderr, "\n");
>  }
>  
> -#ifdef ENABLE_CHECKING
>  /* Verify that dependence type and status are consistent.
>     If RELAXED_P is true, then skip dep_weakness checks.  */
>  static void
> @@ -4600,7 +4590,6 @@ check_dep (dep_t dep, bool relaxed_p)
>  	gcc_assert (ds & BEGIN_CONTROL);
>      }
>  }
> -#endif /* ENABLE_CHECKING */
>  
>  /* The following code discovers opportunities to switch a memory reference
>     and an increment by modifying the address.  We ensure that this is done
> diff --git a/gcc/sel-sched-ir.c b/gcc/sel-sched-ir.c
> index 8ea4dce..b109a5b 100644
> --- a/gcc/sel-sched-ir.c
> +++ b/gcc/sel-sched-ir.c
> @@ -954,7 +954,6 @@ return_regset_to_pool (regset rs)
>    regset_pool.v[regset_pool.n++] = rs;
>  }
>  
> -#ifdef ENABLE_CHECKING
>  /* This is used as a qsort callback for sorting regset pool stacks.
>     X and XX are addresses of two regsets.  They are never equal.  */
>  static int
> @@ -968,44 +967,42 @@ cmp_v_in_regset_pool (const void *x, const void *xx)
>      return -1;
>    gcc_unreachable ();
>  }
> -#endif
>  
> -/*  Free the regset pool possibly checking for memory leaks.  */
> +/* Free the regset pool possibly checking for memory leaks.  */
>  void
>  free_regset_pool (void)
>  {
> -#ifdef ENABLE_CHECKING
> -  {
> -    regset *v = regset_pool.v;
> -    int i = 0;
> -    int n = regset_pool.n;
> +  if (flag_checking)
> +    {
> +      regset *v = regset_pool.v;
> +      int i = 0;
> +      int n = regset_pool.n;
>  
> -    regset *vv = regset_pool.vv;
> -    int ii = 0;
> -    int nn = regset_pool.nn;
> +      regset *vv = regset_pool.vv;
> +      int ii = 0;
> +      int nn = regset_pool.nn;
>  
> -    int diff = 0;
> +      int diff = 0;
>  
> -    gcc_assert (n <= nn);
> +      gcc_assert (n <= nn);
>  
> -    /* Sort both vectors so it will be possible to compare them.  */
> -    qsort (v, n, sizeof (*v), cmp_v_in_regset_pool);
> -    qsort (vv, nn, sizeof (*vv), cmp_v_in_regset_pool);
> +      /* Sort both vectors so it will be possible to compare them.  */
> +      qsort (v, n, sizeof (*v), cmp_v_in_regset_pool);
> +      qsort (vv, nn, sizeof (*vv), cmp_v_in_regset_pool);
>  
> -    while (ii < nn)
> -      {
> -        if (v[i] == vv[ii])
> -          i++;
> -        else
> -          /* VV[II] was lost.  */
> -          diff++;
> +      while (ii < nn)
> +	{
> +	  if (v[i] == vv[ii])
> +	    i++;
> +	  else
> +	    /* VV[II] was lost.  */
> +	    diff++;
>  
> -        ii++;
> -      }
> +	  ii++;
> +	}
>  
> -    gcc_assert (diff == regset_pool.diff);
> -  }
> -#endif
> +      gcc_assert (diff == regset_pool.diff);
> +    }
>  
>    /* If not true - we have a memory leak.  */
>    gcc_assert (regset_pool.diff == 0);
> @@ -3623,7 +3620,6 @@ insn_is_the_only_one_in_bb_p (insn_t insn)
>    return sel_bb_head_p (insn) && sel_bb_end_p (insn);
>  }
>  
> -#ifdef ENABLE_CHECKING
>  /* Check that the region we're scheduling still has at most one
>     backedge.  */
>  static void
> @@ -3644,7 +3640,6 @@ verify_backedges (void)
>        gcc_assert (n <= 1);
>      }
>  }
> -#endif
>  \f
>  
>  /* Functions to work with control flow.  */
> @@ -3889,10 +3884,12 @@ tidy_control_flow (basic_block xbb, bool full_tidying)
>  	sel_recompute_toporder ();
>      }
>  
> -#ifdef ENABLE_CHECKING
> -  verify_backedges ();
> -  verify_dominators (CDI_DOMINATORS);
> -#endif
> +  /* TODO: use separate flag for CFG checking.  */
> +  if (flag_checking)
> +    {
> +      verify_backedges ();
> +      verify_dominators (CDI_DOMINATORS);
> +    }
>  
>    return changed;
>  }
> diff --git a/gcc/sel-sched.c b/gcc/sel-sched.c
> index 721013f..30fcfdb 100644
> --- a/gcc/sel-sched.c
> +++ b/gcc/sel-sched.c
> @@ -378,10 +378,8 @@ struct moveop_static_params
>       they are to be removed.  */
>    int uid;
>  
> -#ifdef ENABLE_CHECKING
>    /* This is initialized to the insn on which the driver stopped its traversal.  */
>    insn_t failed_insn;
> -#endif
>  
>    /* True if we scheduled an insn with different register.  */
>    bool was_renamed;
> @@ -1655,9 +1653,8 @@ find_best_reg_for_expr (expr_t expr, blist_t bnds, bool *is_orig_reg_p)
>    collect_unavailable_regs_from_bnds (expr, bnds, used_regs, &reg_rename_data,
>  				      &original_insns);
>  
> -#ifdef ENABLE_CHECKING
>    /* If after reload, make sure we're working with hard regs here.  */
> -  if (reload_completed)
> +  if (flag_checking && reload_completed)
>      {
>        reg_set_iterator rsi;
>        unsigned i;
> @@ -1665,7 +1662,6 @@ find_best_reg_for_expr (expr_t expr, blist_t bnds, bool *is_orig_reg_p)
>        EXECUTE_IF_SET_IN_REG_SET (used_regs, FIRST_PSEUDO_REGISTER, i, rsi)
>          gcc_unreachable ();
>      }
> -#endif
>  
>    if (EXPR_SEPARABLE_P (expr))
>      {
> @@ -3593,7 +3589,6 @@ vinsn_vec_has_expr_p (vinsn_vec_t vinsn_vec, expr_t expr)
>    return false;
>  }
>  
> -#ifdef ENABLE_CHECKING
>  /* Return true if either of expressions from ORIG_OPS can be blocked
>     by previously created bookkeeping code.  STATIC_PARAMS points to static
>     parameters of move_op.  */
> @@ -3635,7 +3630,6 @@ av_set_could_be_blocked_by_bookkeeping_p (av_set_t orig_ops, void *static_params
>  
>    return false;
>  }
> -#endif
>  
>  /* Clear VINSN_VEC and detach vinsns.  */
>  static void
> @@ -4889,11 +4883,10 @@ move_cond_jump (rtx_insn *insn, bnd_t bnd)
>    block_bnd = BLOCK_FOR_INSN (BND_TO (bnd));
>    prev = BND_TO (bnd);
>  
> -#ifdef ENABLE_CHECKING
>    /* Moving of jump should not cross any other jumps or beginnings of new
>       basic blocks.  The only exception is when we move a jump through
>       mutually exclusive insns along fallthru edges.  */
> -  if (block_from != block_bnd)
> +  if (flag_checking && block_from != block_bnd)
>      {
>        bb = block_from;
>        for (link = PREV_INSN (insn); link != PREV_INSN (prev);
> @@ -4908,7 +4901,6 @@ move_cond_jump (rtx_insn *insn, bnd_t bnd)
>              }
>          }
>      }
> -#endif
>  
>    /* Jump is moved to the boundary.  */
>    next = PREV_INSN (insn);
> @@ -6205,9 +6197,7 @@ move_op_orig_expr_not_found (insn_t insn, av_set_t orig_ops ATTRIBUTE_UNUSED,
>  {
>    moveop_static_params_p sparams = (moveop_static_params_p) static_params;
>  
> -#ifdef ENABLE_CHECKING
>    sparams->failed_insn = insn;
> -#endif
>  
>    /* If we're scheduling separate expr, in order to generate correct code
>       we need to stop the search at bookkeeping code generated with the
> @@ -6380,7 +6370,6 @@ code_motion_process_successors (insn_t insn, av_set_t orig_ops,
>          }
>      }
>  
> -#ifdef ENABLE_CHECKING
>    /* Here, RES==1 if original expr was found at least for one of the
>       successors.  After the loop, RES may happen to have zero value
>       only if at some point the expr searched is present in av_set, but is
> @@ -6388,12 +6377,10 @@ code_motion_process_successors (insn_t insn, av_set_t orig_ops,
>       The exception is when the original operation is blocked by
>       bookkeeping generated for another fence or for another path in current
>       move_op.  */
> -  gcc_assert (res == 1
> -	      || (res == 0
> -		  && av_set_could_be_blocked_by_bookkeeping_p (orig_ops,
> -							       static_params))
> -	      || res == -1);
> -#endif
> +  gcc_checking_assert (res == 1
> +		       || (res == 0
> +			    && av_set_could_be_blocked_by_bookkeeping_p (orig_ops, static_params))
> +		       || res == -1);
>  
>    /* Merge data, clean up, etc.  */
>    if (res != -1 && code_motion_path_driver_info->after_merge_succs)
> @@ -6695,9 +6682,7 @@ move_op (insn_t insn, av_set_t orig_ops, expr_t expr_vliw,
>    sparams.dest = dest;
>    sparams.c_expr = c_expr;
>    sparams.uid = INSN_UID (EXPR_INSN_RTX (expr_vliw));
> -#ifdef ENABLE_CHECKING
>    sparams.failed_insn = NULL;
> -#endif
>    sparams.was_renamed = false;
>    lparams.e1 = NULL;
>  
> diff --git a/gcc/ssa-iterators.h b/gcc/ssa-iterators.h
> index e04b630..fa7ad3b 100644
> --- a/gcc/ssa-iterators.h
> +++ b/gcc/ssa-iterators.h
> @@ -344,9 +344,7 @@ first_readonly_imm_use (imm_use_iterator *imm, tree var)
>  {
>    imm->end_p = &(SSA_NAME_IMM_USE_NODE (var));
>    imm->imm_use = imm->end_p->next;
> -#ifdef ENABLE_CHECKING
>    imm->iter_node.next = imm->imm_use->next;
> -#endif
>    if (end_readonly_imm_use_p (imm))
>      return NULL_USE_OPERAND_P;
>    return imm->imm_use;
> @@ -358,14 +356,15 @@ next_readonly_imm_use (imm_use_iterator *imm)
>  {
>    use_operand_p old = imm->imm_use;
>  
> -#ifdef ENABLE_CHECKING
>    /* If this assertion fails, it indicates the 'next' pointer has changed
>       since the last bump.  This indicates that the list is being modified
>       via stmt changes, or SET_USE, or somesuch thing, and you need to be
>       using the SAFE version of the iterator.  */
> -  gcc_assert (imm->iter_node.next == old->next);
> -  imm->iter_node.next = old->next->next;
> -#endif
> +  if (flag_checking)
> +    {
> +      gcc_assert (imm->iter_node.next == old->next);
> +      imm->iter_node.next = old->next->next;
> +    }
>  
>    imm->imm_use = old->next;
>    if (end_readonly_imm_use_p (imm))
> diff --git a/gcc/store-motion.c b/gcc/store-motion.c
> index ec3faa2..ed1a399 100644
> --- a/gcc/store-motion.c
> +++ b/gcc/store-motion.c
> @@ -644,9 +644,6 @@ compute_store_table (void)
>  {
>    int ret;
>    basic_block bb;
> -#ifdef ENABLE_CHECKING
> -  unsigned regno;
> -#endif
>    rtx_insn *insn;
>    rtx_insn *tmp;
>    df_ref def;
> @@ -692,11 +689,12 @@ compute_store_table (void)
>  	      last_set_in[DF_REF_REGNO (def)] = 0;
>  	}
>  
> -#ifdef ENABLE_CHECKING
> -      /* last_set_in should now be all-zero.  */
> -      for (regno = 0; regno < max_gcse_regno; regno++)
> -	gcc_assert (!last_set_in[regno]);
> -#endif
> +      if (flag_checking)
> +	{
> +	  /* last_set_in should now be all-zero.  */
> +	  for (unsigned regno = 0; regno < max_gcse_regno; regno++)
> +	    gcc_assert (!last_set_in[regno]);
> +	}
>  
>        /* Clear temporary marks.  */
>        for (ptr = first_st_expr (); ptr != NULL; ptr = next_st_expr (ptr))
> diff --git a/gcc/symbol-summary.h b/gcc/symbol-summary.h
> index eefbfd9..4a1a510 100644
> --- a/gcc/symbol-summary.h
> +++ b/gcc/symbol-summary.h
> @@ -39,14 +39,12 @@ public:
>    function_summary (symbol_table *symtab, bool ggc = false): m_ggc (ggc),
>      m_map (13, ggc), m_insertion_enabled (true), m_symtab (symtab)
>    {
> -#ifdef ENABLE_CHECKING
> -    cgraph_node *node;
> -
> -    FOR_EACH_FUNCTION (node)
> -    {
> -      gcc_checking_assert (node->summary_uid > 0);
> -    }
> -#endif
> +    if (flag_checking)
> +      {
> +	cgraph_node *node;
> +	FOR_EACH_FUNCTION (node)
> +	  gcc_assert (node->summary_uid > 0);
> +      }
>  
>      m_symtab_insertion_hook =
>        symtab->add_cgraph_insertion_hook
> diff --git a/gcc/target.h b/gcc/target.h
> index a79f424..ffc4d6a 100644
> --- a/gcc/target.h
> +++ b/gcc/target.h
> @@ -52,21 +52,21 @@
>  #include "tm.h"
>  #include "hard-reg-set.h"
>  
> -#ifdef ENABLE_CHECKING
> +#if CHECKING_P
>  
>  struct cumulative_args_t { void *magic; void *p; };
>  
> -#else /* !ENABLE_CHECKING */
> +#else /* !CHECKING_P */
>  
>  /* When using a GCC build compiler, we could use
>     __attribute__((transparent_union)) to get cumulative_args_t function
>     arguments passed like scalars where the ABI would mandate a less
>     efficient way of argument passing otherwise.  However, that would come
> -   at the cost of less type-safe !ENABLE_CHECKING compilation.  */
> +   at the cost of less type-safe !CHECKING_P compilation.  */
>  
>  union cumulative_args_t { void *p; };
>  
> -#endif /* !ENABLE_CHECKING */
> +#endif /* !CHECKING_P */
>  
>  /* Types used by the record_gcc_switches() target function.  */
>  enum print_switch_type
> @@ -200,9 +200,9 @@ extern struct gcc_target targetm;
>  static inline CUMULATIVE_ARGS *
>  get_cumulative_args (cumulative_args_t arg)
>  {
> -#ifdef ENABLE_CHECKING
> +#if CHECKING_P
>    gcc_assert (arg.magic == CUMULATIVE_ARGS_MAGIC);
> -#endif /* ENABLE_CHECKING */
> +#endif /* CHECKING_P */
>    return (CUMULATIVE_ARGS *) arg.p;
>  }
>  
> @@ -211,9 +211,9 @@ pack_cumulative_args (CUMULATIVE_ARGS *arg)
>  {
>    cumulative_args_t ret;
>  
> -#ifdef ENABLE_CHECKING
> +#if CHECKING_P
>    ret.magic = CUMULATIVE_ARGS_MAGIC;
> -#endif /* ENABLE_CHECKING */
> +#endif /* CHECKING_P */
>    ret.p = (void *) arg;
>    return ret;
>  }
> diff --git a/gcc/timevar.c b/gcc/timevar.c
> index 8249727..3543850 100644
> --- a/gcc/timevar.c
> +++ b/gcc/timevar.c
> @@ -22,6 +22,7 @@ along with GCC; see the file COPYING3.  If not see
>  #include "system.h"
>  #include "coretypes.h"
>  #include "timevar.h"
> +#include "options.h"
>  
>  #ifndef HAVE_CLOCK_T
>  typedef int clock_t;
> @@ -727,10 +728,13 @@ timer::print (FILE *fp)
>  #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
> +  if (flag_checking)
> +    {
> +      fprintf (fp, "Extra diagnostic checks enabled; "
> +		   "compiler may run slowly.\n");
> +      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");
> diff --git a/gcc/trans-mem.c b/gcc/trans-mem.c
> index 488c20e..d0b54ef 100644
> --- a/gcc/trans-mem.c
> +++ b/gcc/trans-mem.c
> @@ -5341,9 +5341,7 @@ ipa_tm_execute (void)
>    enum availability a;
>    unsigned int i;
>  
> -#ifdef ENABLE_CHECKING
> -  cgraph_node::verify_cgraph_nodes ();
> -#endif
> +  cgraph_node::checking_verify_cgraph_nodes ();
>  
>    bitmap_obstack_initialize (&tm_obstack);
>    initialize_original_copy_tables ();
> @@ -5589,9 +5587,7 @@ ipa_tm_execute (void)
>    FOR_EACH_FUNCTION (node)
>      node->aux = NULL;
>  
> -#ifdef ENABLE_CHECKING
> -  cgraph_node::verify_cgraph_nodes ();
> -#endif
> +  cgraph_node::checking_verify_cgraph_nodes ();
>  
>    return 0;
>  }
> diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
> index 40d5eb8..df8700d 100644
> --- a/gcc/tree-cfg.c
> +++ b/gcc/tree-cfg.c
> @@ -6465,14 +6465,12 @@ move_stmt_op (tree *tp, int *walk_subtrees, void *data)
>  	  || (p->orig_block == NULL_TREE
>  	      && block != NULL_TREE))
>  	TREE_SET_BLOCK (t, p->new_block);
> -#ifdef ENABLE_CHECKING
> -      else if (block != NULL_TREE)
> +      else if (flag_checking && block != NULL_TREE)
>  	{
>  	  while (block && TREE_CODE (block) == BLOCK && block != p->orig_block)
>  	    block = BLOCK_SUPERCONTEXT (block);
>  	  gcc_assert (block == p->orig_block);
>  	}
> -#endif
>      }
>    else if (DECL_P (t) || TREE_CODE (t) == SSA_NAME)
>      {
> @@ -7057,9 +7055,9 @@ move_sese_region_to_fn (struct function *dest_cfun, basic_block entry_bb,
>    bbs.create (0);
>    bbs.safe_push (entry_bb);
>    gather_blocks_in_sese_region (entry_bb, exit_bb, &bbs);
> -#ifdef ENABLE_CHECKING
> -  verify_sese (entry_bb, exit_bb, &bbs);
> -#endif
> +
> +  if (flag_checking)
> +    verify_sese (entry_bb, exit_bb, &bbs);
>  
>    /* The blocks that used to be dominated by something in BBS will now be
>       dominated by the new block.  */
> @@ -7901,13 +7899,11 @@ gimple_flow_call_edges_add (sbitmap blocks)
>  		     no edge to the exit block in CFG already.
>  		     Calling make_edge in such case would cause us to
>  		     mark that edge as fake and remove it later.  */
> -#ifdef ENABLE_CHECKING
> -		  if (stmt == last_stmt)
> +		  if (flag_checking && stmt == last_stmt)
>  		    {
>  		      e = find_edge (bb, EXIT_BLOCK_PTR_FOR_FN (cfun));
>  		      gcc_assert (e == NULL);
>  		    }
> -#endif
>  
>  		  /* Note that the following may create a new basic block
>  		     and renumber the existing basic blocks.  */
> diff --git a/gcc/tree-cfgcleanup.c b/gcc/tree-cfgcleanup.c
> index eeedd8a..aba8848 100644
> --- a/gcc/tree-cfgcleanup.c
> +++ b/gcc/tree-cfgcleanup.c
> @@ -729,9 +729,7 @@ cleanup_tree_cfg_noloop (void)
>      }
>    else
>      {
> -#ifdef ENABLE_CHECKING
> -      verify_dominators (CDI_DOMINATORS);
> -#endif
> +      checking_verify_dominators (CDI_DOMINATORS);
>        changed = false;
>      }
>  
> @@ -740,9 +738,7 @@ cleanup_tree_cfg_noloop (void)
>    gcc_assert (dom_info_available_p (CDI_DOMINATORS));
>    compact_blocks ();
>  
> -#ifdef ENABLE_CHECKING
> -  verify_flow_info ();
> -#endif
> +  checking_verify_flow_info ();
>  
>    timevar_pop (TV_TREE_CLEANUP_CFG);
>  
> @@ -777,9 +773,7 @@ repair_loop_structures (void)
>  
>    BITMAP_FREE (changed_bbs);
>  
> -#ifdef ENABLE_CHECKING
> -  verify_loop_structure ();
> -#endif
> +  checking_verify_loop_structure ();
>    scev_reset ();
>  
>    timevar_pop (TV_REPAIR_LOOPS);
> diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c
> index cb1f08a..f6c2d06 100644
> --- a/gcc/tree-eh.c
> +++ b/gcc/tree-eh.c
> @@ -703,7 +703,7 @@ maybe_record_in_goto_queue (struct leh_state *state, gimple *stmt)
>  }
>  
>  
> -#ifdef ENABLE_CHECKING
> +#if CHECKING_P
>  /* We do not process GIMPLE_SWITCHes for now.  As long as the original source
>     was in fact structured, and we've not yet done jump threading, then none
>     of the labels will leave outer GIMPLE_TRY_FINALLY nodes. Verify this.  */
> @@ -3921,9 +3921,8 @@ remove_unreachable_handlers (void)
>    sbitmap_free (r_reachable);
>    sbitmap_free (lp_reachable);
>  
> -#ifdef ENABLE_CHECKING
> -  verify_eh_tree (cfun);
> -#endif
> +  if (flag_checking)
> +    verify_eh_tree (cfun);
>  }
>  
>  /* Remove unreachable handlers if any landing pads have been removed after
> diff --git a/gcc/tree-if-conv.c b/gcc/tree-if-conv.c
> index f201ab5..ae79f0e 100644
> --- a/gcc/tree-if-conv.c
> +++ b/gcc/tree-if-conv.c
> @@ -2787,13 +2787,12 @@ pass_if_conversion::execute (function *fun)
>  	    && !loop->dont_vectorize))
>        todo |= tree_if_conversion (loop);
>  
> -#ifdef ENABLE_CHECKING
> -  {
> -    basic_block bb;
> -    FOR_EACH_BB_FN (bb, fun)
> -      gcc_assert (!bb->aux);
> -  }
> -#endif
> +  if (flag_checking)
> +    {
> +      basic_block bb;
> +      FOR_EACH_BB_FN (bb, fun)
> +	gcc_assert (!bb->aux);
> +    }
>  
>    return todo;
>  }
> diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
> index b8269ef..00c0c84 100644
> --- a/gcc/tree-inline.c
> +++ b/gcc/tree-inline.c
> @@ -4481,10 +4481,8 @@ expand_call_inline (basic_block bb, gimple *stmt, copy_body_data *id)
>    fn = cg_edge->callee->decl;
>    cg_edge->callee->get_untransformed_body ();
>  
> -#ifdef ENABLE_CHECKING
> -  if (cg_edge->callee->decl != id->dst_node->decl)
> +  if (flag_checking && cg_edge->callee->decl != id->dst_node->decl)
>      cg_edge->callee->verify ();
> -#endif
>  
>    /* We will be inlining this callee.  */
>    id->eh_lp_nr = lookup_stmt_eh_lp (stmt);
> @@ -4973,7 +4971,7 @@ optimize_inline_calls (tree fn)
>  
>    pop_gimplify_context (NULL);
>  
> -#ifdef ENABLE_CHECKING
> +  if (flag_checking)
>      {
>        struct cgraph_edge *e;
>  
> @@ -4983,7 +4981,6 @@ optimize_inline_calls (tree fn)
>        for (e = id.dst_node->callees; e; e = e->next_callee)
>  	gcc_assert (e->inline_failed);
>      }
> -#endif
>  
>    /* Fold queued statements.  */
>    fold_marked_statements (last, id.statements_to_fold);
> @@ -4999,9 +4996,8 @@ optimize_inline_calls (tree fn)
>    number_blocks (fn);
>  
>    delete_unreachable_blocks_update_callgraph (&id);
> -#ifdef ENABLE_CHECKING
> -  id.dst_node->verify ();
> -#endif
> +  if (flag_checking)
> +    id.dst_node->verify ();
>  
>    /* It would be nice to check SSA/CFG/statement consistency here, but it is
>       not possible yet - the IPA passes might make various functions to not
> diff --git a/gcc/tree-into-ssa.c b/gcc/tree-into-ssa.c
> index 9fd698d..732a571 100644
> --- a/gcc/tree-into-ssa.c
> +++ b/gcc/tree-into-ssa.c
> @@ -3169,44 +3169,45 @@ update_ssa (unsigned update_flags)
>    if (!need_ssa_update_p (cfun))
>      return;
>  
> -#ifdef ENABLE_CHECKING
> -  timevar_push (TV_TREE_STMT_VERIFY);
> +  if (flag_checking)
> +    {
> +      timevar_push (TV_TREE_STMT_VERIFY);
>  
> -  bool err = false;
> +      bool err = false;
>  
> -  FOR_EACH_BB_FN (bb, cfun)
> -    {
> -      gimple_stmt_iterator gsi;
> -      for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
> +      FOR_EACH_BB_FN (bb, cfun)
>  	{
> -	  gimple *stmt = gsi_stmt (gsi);
> -
> -	  ssa_op_iter i;
> -	  use_operand_p use_p;
> -	  FOR_EACH_SSA_USE_OPERAND (use_p, stmt, i, SSA_OP_ALL_USES)
> +	  gimple_stmt_iterator gsi;
> +	  for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
>  	    {
> -	      tree use = USE_FROM_PTR (use_p);
> -	      if (TREE_CODE (use) != SSA_NAME)
> -		continue;
> +	      gimple *stmt = gsi_stmt (gsi);
>  
> -	      if (SSA_NAME_IN_FREE_LIST (use))
> +	      ssa_op_iter i;
> +	      use_operand_p use_p;
> +	      FOR_EACH_SSA_USE_OPERAND (use_p, stmt, i, SSA_OP_ALL_USES)
>  		{
> -		  error ("statement uses released SSA name:");
> -		  debug_gimple_stmt (stmt);
> -		  fprintf (stderr, "The use of ");
> -		  print_generic_expr (stderr, use, 0);
> -		  fprintf (stderr," should have been replaced\n");
> -		  err = true;
> +		  tree use = USE_FROM_PTR (use_p);
> +		  if (TREE_CODE (use) != SSA_NAME)
> +		    continue;
> +
> +		  if (SSA_NAME_IN_FREE_LIST (use))
> +		    {
> +		      error ("statement uses released SSA name:");
> +		      debug_gimple_stmt (stmt);
> +		      fprintf (stderr, "The use of ");
> +		      print_generic_expr (stderr, use, 0);
> +		      fprintf (stderr," should have been replaced\n");
> +		      err = true;
> +		    }
>  		}
>  	    }
>  	}
> -    }
>  
> -  if (err)
> -    internal_error ("cannot update SSA form");
> +      if (err)
> +	internal_error ("cannot update SSA form");
>  
> -  timevar_pop (TV_TREE_STMT_VERIFY);
> -#endif
> +      timevar_pop (TV_TREE_STMT_VERIFY);
> +    }
>  
>    timevar_push (TV_TREE_SSA_INCREMENTAL);
>  
> @@ -3271,29 +3272,28 @@ update_ssa (unsigned update_flags)
>  	 placement heuristics.  */
>        prepare_block_for_update (start_bb, insert_phi_p);
>  
> -#ifdef ENABLE_CHECKING
> -      for (i = 1; i < num_ssa_names; ++i)
> -	{
> -	  tree name = ssa_name (i);
> -	  if (!name
> -	      || virtual_operand_p (name))
> -	    continue;
> -
> -	  /* For all but virtual operands, which do not have SSA names
> -	     with overlapping life ranges, ensure that symbols marked
> -	     for renaming do not have existing SSA names associated with
> -	     them as we do not re-write them out-of-SSA before going
> -	     into SSA for the remaining symbol uses.  */
> -	  if (marked_for_renaming (SSA_NAME_VAR (name)))
> -	    {
> -	      fprintf (stderr, "Existing SSA name for symbol marked for "
> -		       "renaming: ");
> -	      print_generic_expr (stderr, name, TDF_SLIM);
> -	      fprintf (stderr, "\n");
> -	      internal_error ("SSA corruption");
> -	    }
> -	}
> -#endif
> +      if (flag_checking)
> +	for (i = 1; i < num_ssa_names; ++i)
> +	  {
> +	    tree name = ssa_name (i);
> +	    if (!name
> +		|| virtual_operand_p (name))
> +	      continue;
> +
> +	    /* For all but virtual operands, which do not have SSA names
> +	       with overlapping life ranges, ensure that symbols marked
> +	       for renaming do not have existing SSA names associated with
> +	       them as we do not re-write them out-of-SSA before going
> +	       into SSA for the remaining symbol uses.  */
> +	    if (marked_for_renaming (SSA_NAME_VAR (name)))
> +	      {
> +		fprintf (stderr, "Existing SSA name for symbol marked for "
> +			 "renaming: ");
> +		print_generic_expr (stderr, name, TDF_SLIM);
> +		fprintf (stderr, "\n");
> +		internal_error ("SSA corruption");
> +	      }
> +	  }
>      }
>    else
>      {
> diff --git a/gcc/tree-loop-distribution.c b/gcc/tree-loop-distribution.c
> index 6f86d53..18025c8 100644
> --- a/gcc/tree-loop-distribution.c
> +++ b/gcc/tree-loop-distribution.c
> @@ -1821,9 +1821,7 @@ out:
>        rewrite_into_loop_closed_ssa (NULL, TODO_update_ssa);
>      }
>  
> -#ifdef ENABLE_CHECKING
> -  verify_loop_structure ();
> -#endif
> +  checking_verify_loop_structure ();
>  
>    return 0;
>  }
> diff --git a/gcc/tree-outof-ssa.c b/gcc/tree-outof-ssa.c
> index 8dc4908..1c4c63c 100644
> --- a/gcc/tree-outof-ssa.c
> +++ b/gcc/tree-outof-ssa.c
> @@ -841,24 +841,23 @@ eliminate_useless_phis (void)
>  	  result = gimple_phi_result (phi);
>  	  if (virtual_operand_p (result))
>  	    {
> -#ifdef ENABLE_CHECKING
> -	      size_t i;
>  	      /* There should be no arguments which are not virtual, or the
>  	         results will be incorrect.  */
> -	      for (i = 0; i < gimple_phi_num_args (phi); i++)
> -	        {
> -		  tree arg = PHI_ARG_DEF (phi, i);
> -		  if (TREE_CODE (arg) == SSA_NAME
> -		      && !virtual_operand_p (arg))
> -		    {
> -		      fprintf (stderr, "Argument of PHI is not virtual (");
> -		      print_generic_expr (stderr, arg, TDF_SLIM);
> -		      fprintf (stderr, "), but the result is :");
> -		      print_gimple_stmt (stderr, phi, 0, TDF_SLIM);
> -		      internal_error ("SSA corruption");
> -		    }
> -		}
> -#endif
> +	      if (flag_checking)
> +		for (size_t i = 0; i < gimple_phi_num_args (phi); i++)
> +		  {
> +		    tree arg = PHI_ARG_DEF (phi, i);
> +		    if (TREE_CODE (arg) == SSA_NAME
> +			&& !virtual_operand_p (arg))
> +		      {
> +			fprintf (stderr, "Argument of PHI is not virtual (");
> +			print_generic_expr (stderr, arg, TDF_SLIM);
> +			fprintf (stderr, "), but the result is :");
> +			print_gimple_stmt (stderr, phi, 0, TDF_SLIM);
> +			internal_error ("SSA corruption");
> +		      }
> +		  }
> +
>  	      remove_phi_node (&gsi, true);
>  	    }
>            else
> @@ -884,9 +883,11 @@ eliminate_useless_phis (void)
>     variable.  */
>  
>  static void
> -rewrite_trees (var_map map ATTRIBUTE_UNUSED)
> +rewrite_trees (var_map map)
>  {
> -#ifdef ENABLE_CHECKING
> +  if (!flag_checking)
> +    return;
> +
>    basic_block bb;
>    /* Search for PHIs where the destination has no partition, but one
>       or more arguments has a partition.  This should not happen and can
> @@ -918,7 +919,6 @@ rewrite_trees (var_map map ATTRIBUTE_UNUSED)
>  	    }
>  	}
>      }
> -#endif
>  }
>  
>  /* Given the out-of-ssa info object SA (with prepared partitions)
> diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c
> index 6781af4..300ec6b 100644
> --- a/gcc/tree-parloops.c
> +++ b/gcc/tree-parloops.c
> @@ -2784,9 +2784,7 @@ pass_parallelize_loops::execute (function *fun)
>      {
>        fun->curr_properties &= ~(PROP_gimple_eomp);
>  
> -#ifdef ENABLE_CHECKING
> -      verify_loop_structure ();
> -#endif
> +      checking_verify_loop_structure ();
>  
>        return TODO_update_ssa;
>      }
> diff --git a/gcc/tree-predcom.c b/gcc/tree-predcom.c
> index 4abac13..5f6e1b0 100644
> --- a/gcc/tree-predcom.c
> +++ b/gcc/tree-predcom.c
> @@ -896,13 +896,9 @@ suitable_component_p (struct loop *loop, struct component *comp)
>        if (!determine_offset (first->ref, a->ref, &a->offset))
>  	return false;
>  
> -#ifdef ENABLE_CHECKING
> -      {
> -	enum ref_step_type a_step;
> -	ok = suitable_reference_p (a->ref, &a_step);
> -	gcc_assert (ok && a_step == comp->comp_step);
> -      }
> -#endif
> +      enum ref_step_type a_step;
> +      gcc_checking_assert (suitable_reference_p (a->ref, &a_step)
> +			   && a_step == comp->comp_step);
>      }
>  
>    /* If there is a write inside the component, we must know whether the
> diff --git a/gcc/tree-profile.c b/gcc/tree-profile.c
> index 0d33c87..54bc644 100644
> --- a/gcc/tree-profile.c
> +++ b/gcc/tree-profile.c
> @@ -461,9 +461,8 @@ gimple_gen_const_delta_profiler (histogram_value value ATTRIBUTE_UNUSED,
>  			       unsigned base ATTRIBUTE_UNUSED)
>  {
>    /* FIXME implement this.  */
> -#ifdef ENABLE_CHECKING
> -  internal_error ("unimplemented functionality");
> -#endif
> +  if (flag_checking)
> +    internal_error ("unimplemented functionality");
>    gcc_unreachable ();
>  }
>  
> diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c
> index 3b8d594..a5bd831 100644
> --- a/gcc/tree-ssa-alias.c
> +++ b/gcc/tree-ssa-alias.c
> @@ -1442,12 +1442,7 @@ refs_may_alias_p_1 (ao_ref *ref1, ao_ref *ref2, bool tbaa_p)
>  				      ao_ref_alias_set (ref2), -1,
>  				      tbaa_p);
>  
> -  /* We really do not want to end up here, but returning true is safe.  */
> -#ifdef ENABLE_CHECKING
>    gcc_unreachable ();
> -#else
> -  return true;
> -#endif
>  }
>  
>  static bool
> diff --git a/gcc/tree-ssa-live.c b/gcc/tree-ssa-live.c
> index 25b548b..a61026d 100644
> --- a/gcc/tree-ssa-live.c
> +++ b/gcc/tree-ssa-live.c
> @@ -52,9 +52,7 @@ along with GCC; see the file COPYING3.  If not see
>  #include "ipa-utils.h"
>  #include "cfgloop.h"
>  
> -#ifdef ENABLE_CHECKING
> -static void  verify_live_on_entry (tree_live_info_p);
> -#endif
> +static void verify_live_on_entry (tree_live_info_p);
>  
>  
>  /* VARMAP maintains a mapping from SSA version number to real variables.
> @@ -1153,9 +1151,8 @@ calculate_live_ranges (var_map map, bool want_livein)
>  
>    live_worklist (live);
>  
> -#ifdef ENABLE_CHECKING
> -  verify_live_on_entry (live);
> -#endif
> +  if (flag_checking)
> +    verify_live_on_entry (live);
>  
>    calculate_live_on_exit (live);
>  
> @@ -1292,7 +1289,6 @@ debug (tree_live_info_d *ptr)
>  }
>  
>  
> -#ifdef ENABLE_CHECKING
>  /* Verify that SSA_VAR is a non-virtual SSA_NAME.  */
>  
>  void
> @@ -1422,4 +1418,3 @@ verify_live_on_entry (tree_live_info_p live)
>      }
>    gcc_assert (num <= 0);
>  }
> -#endif
> diff --git a/gcc/tree-ssa-live.h b/gcc/tree-ssa-live.h
> index 1f88358..0cb3a1a 100644
> --- a/gcc/tree-ssa-live.h
> +++ b/gcc/tree-ssa-live.h
> @@ -80,9 +80,7 @@ extern void remove_unused_locals (void);
>  extern void dump_var_map (FILE *, var_map);
>  extern void debug (_var_map &ref);
>  extern void debug (_var_map *ptr);
> -#ifdef ENABLE_CHECKING
>  extern void register_ssa_partition_check (tree ssa_var);
> -#endif
>  
>  
>  /* Return number of partitions in MAP.  */
> @@ -181,12 +179,10 @@ num_basevars (var_map map)
>     partitions may be filtered out by a view later.  */
>  
>  static inline void
> -register_ssa_partition (var_map map ATTRIBUTE_UNUSED,
> -			tree ssa_var ATTRIBUTE_UNUSED)
> +register_ssa_partition (var_map map ATTRIBUTE_UNUSED, tree ssa_var)
>  {
> -#if defined ENABLE_CHECKING
> -  register_ssa_partition_check (ssa_var);
> -#endif
> +  if (flag_checking)
> +    register_ssa_partition_check (ssa_var);
>  }
>  
>  
> diff --git a/gcc/tree-ssa-loop-ivcanon.c b/gcc/tree-ssa-loop-ivcanon.c
> index 38f7c3f..25f297c 100644
> --- a/gcc/tree-ssa-loop-ivcanon.c
> +++ b/gcc/tree-ssa-loop-ivcanon.c
> @@ -1376,10 +1376,8 @@ tree_unroll_loops_completely (bool may_increase_size, bool unroll_outer)
>  	  /* Clean up the information about numbers of iterations, since
>  	     complete unrolling might have invalidated it.  */
>  	  scev_reset ();
> -#ifdef ENABLE_CHECKING
> -	  if (loops_state_satisfies_p (LOOP_CLOSED_SSA))
> +	  if (flag_checking && loops_state_satisfies_p (LOOP_CLOSED_SSA))
>  	    verify_loop_closed_ssa (true);
> -#endif
>  	}
>        if (loop_closed_ssa_invalidated)
>          BITMAP_FREE (loop_closed_ssa_invalidated);
> diff --git a/gcc/tree-ssa-loop-manip.c b/gcc/tree-ssa-loop-manip.c
> index 27ba275..ba2340f 100644
> --- a/gcc/tree-ssa-loop-manip.c
> +++ b/gcc/tree-ssa-loop-manip.c
> @@ -278,22 +278,22 @@ add_exit_phi (basic_block exit, tree var)
>    edge e;
>    edge_iterator ei;
>  
> -#ifdef ENABLE_CHECKING
>    /* Check that at least one of the edges entering the EXIT block exits
>       the loop, or a superloop of that loop, that VAR is defined in.  */
> -  gimple *def_stmt = SSA_NAME_DEF_STMT (var);
> -  basic_block def_bb = gimple_bb (def_stmt);
> -  FOR_EACH_EDGE (e, ei, exit->preds)
> +  if (flag_checking)
>      {
> -      struct loop *aloop = find_common_loop (def_bb->loop_father,
> -					     e->src->loop_father);
> -      if (!flow_bb_inside_loop_p (aloop, e->dest))
> -	break;
> +      gimple *def_stmt = SSA_NAME_DEF_STMT (var);
> +      basic_block def_bb = gimple_bb (def_stmt);
> +      FOR_EACH_EDGE (e, ei, exit->preds)
> +	{
> +	  struct loop *aloop = find_common_loop (def_bb->loop_father,
> +						 e->src->loop_father);
> +	  if (!flow_bb_inside_loop_p (aloop, e->dest))
> +	    break;
> +	}
> +      gcc_assert (e);
>      }
>  
> -  gcc_checking_assert (e);
> -#endif
> -
>    phi = create_phi_node (NULL_TREE, exit);
>    create_new_def_for (var, phi, gimple_phi_result_ptr (phi));
>    FOR_EACH_EDGE (e, ei, exit->preds)
> @@ -1368,11 +1368,9 @@ tree_transform_and_unroll_loop (struct loop *loop, unsigned factor,
>    gimple_cond_set_rhs (exit_if, exit_bound);
>    update_stmt (exit_if);
>  
> -#ifdef ENABLE_CHECKING
> -  verify_flow_info ();
> -  verify_loop_structure ();
> -  verify_loop_closed_ssa (true);
> -#endif
> +  checking_verify_flow_info ();
> +  checking_verify_loop_structure ();
> +  checking_verify_loop_closed_ssa (true);
>  }
>  
>  /* Wrapper over tree_transform_and_unroll_loop for case we do not
> diff --git a/gcc/tree-ssa-loop-manip.h b/gcc/tree-ssa-loop-manip.h
> index 9285718..96b02a6 100644
> --- a/gcc/tree-ssa-loop-manip.h
> +++ b/gcc/tree-ssa-loop-manip.h
> @@ -27,6 +27,14 @@ extern void create_iv (tree, tree, tree, struct loop *, gimple_stmt_iterator *,
>  extern void rewrite_into_loop_closed_ssa (bitmap, unsigned);
>  extern void rewrite_virtuals_into_loop_closed_ssa (struct loop *);
>  extern void verify_loop_closed_ssa (bool);
> +
> +static inline void
> +checking_verify_loop_closed_ssa (bool verify_ssa_p)
> +{
> +  if (flag_checking)
> +    verify_loop_closed_ssa (verify_ssa_p);
> +}
> +
>  extern basic_block split_loop_exit_edge (edge);
>  extern basic_block ip_end_pos (struct loop *);
>  extern basic_block ip_normal_pos (struct loop *);
> diff --git a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c
> index 9223642..cb6c749 100644
> --- a/gcc/tree-ssa-math-opts.c
> +++ b/gcc/tree-ssa-math-opts.c
> @@ -541,10 +541,9 @@ pass_cse_reciprocals::execute (function *fun)
>    calculate_dominance_info (CDI_DOMINATORS);
>    calculate_dominance_info (CDI_POST_DOMINATORS);
>  
> -#ifdef ENABLE_CHECKING
> -  FOR_EACH_BB_FN (bb, fun)
> -    gcc_assert (!bb->aux);
> -#endif
> +  if (flag_checking)
> +    FOR_EACH_BB_FN (bb, fun)
> +      gcc_assert (!bb->aux);
>  
>    for (arg = DECL_ARGUMENTS (fun->decl); arg; arg = DECL_CHAIN (arg))
>      if (FLOAT_TYPE_P (TREE_TYPE (arg))
> diff --git a/gcc/tree-ssa-operands.c b/gcc/tree-ssa-operands.c
> index 544e9df..92d1ab2 100644
> --- a/gcc/tree-ssa-operands.c
> +++ b/gcc/tree-ssa-operands.c
> @@ -881,12 +881,13 @@ get_expr_operands (struct function *fn, gimple *stmt, tree *expr_p, int flags)
>      }
>  
>    /* If we get here, something has gone wrong.  */
> -#ifdef ENABLE_CHECKING
> -  fprintf (stderr, "unhandled expression in get_expr_operands():\n");
> -  debug_tree (expr);
> -  fputs ("\n", stderr);
> -#endif
> -  gcc_unreachable ();
> +  if (flag_checking)
> +    {
> +      fprintf (stderr, "unhandled expression in get_expr_operands():\n");
> +      debug_tree (expr);
> +      fputs ("\n", stderr);
> +      gcc_unreachable ();
> +    }
>  }
>  
>  
> diff --git a/gcc/tree-ssa-propagate.c b/gcc/tree-ssa-propagate.c
> index fbe41f9..363f439 100644
> --- a/gcc/tree-ssa-propagate.c
> +++ b/gcc/tree-ssa-propagate.c
> @@ -1501,14 +1501,14 @@ static void
>  replace_exp_1 (use_operand_p op_p, tree val,
>      	       bool for_propagation ATTRIBUTE_UNUSED)
>  {
> -#if defined ENABLE_CHECKING
> -  tree op = USE_FROM_PTR (op_p);
> -
> -  gcc_assert (!(for_propagation
> -		&& TREE_CODE (op) == SSA_NAME
> -		&& TREE_CODE (val) == SSA_NAME
> -		&& !may_propagate_copy (op, val)));
> -#endif
> +  if (flag_checking)
> +    {
> +      tree op = USE_FROM_PTR (op_p);
> +      gcc_assert (!(for_propagation
> +		  && TREE_CODE (op) == SSA_NAME
> +		  && TREE_CODE (val) == SSA_NAME
> +		  && !may_propagate_copy (op, val)));
> +    }
>  
>    if (TREE_CODE (val) == SSA_NAME)
>      SET_USE (op_p, val);
> diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c
> index 5e070bc..52b0813 100644
> --- a/gcc/tree-ssa-structalias.c
> +++ b/gcc/tree-ssa-structalias.c
> @@ -2544,10 +2544,11 @@ rewrite_constraints (constraint_graph_t graph,
>    int i;
>    constraint_t c;
>  
> -#ifdef ENABLE_CHECKING
> -  for (unsigned int j = 0; j < graph->size; j++)
> -    gcc_assert (find (j) == j);
> -#endif
> +  if (flag_checking)
> +    {
> +      for (unsigned int j = 0; j < graph->size; j++)
> +	gcc_assert (find (j) == j);
> +    }
>  
>    FOR_EACH_VEC_ELT (constraints, i, c)
>      {
> diff --git a/gcc/tree-ssa-ter.c b/gcc/tree-ssa-ter.c
> index 7a7bcc9..b2d19ed 100644
> --- a/gcc/tree-ssa-ter.c
> +++ b/gcc/tree-ssa-ter.c
> @@ -182,9 +182,7 @@ struct temp_expr_table
>  /* A place for the many, many bitmaps we create.  */
>  static bitmap_obstack ter_bitmap_obstack;
>  
> -#ifdef ENABLE_CHECKING
>  extern void debug_ter (FILE *, temp_expr_table *);
> -#endif
>  
>  
>  /* Create a new TER table for MAP.  */
> @@ -232,16 +230,16 @@ free_temp_expr_table (temp_expr_table *t)
>  {
>    bitmap ret = NULL;
>  
> -#ifdef ENABLE_CHECKING
> -  unsigned x;
> -  for (x = 0; x <= num_var_partitions (t->map); x++)
> -    gcc_assert (!t->kill_list[x]);
> -  for (x = 0; x < num_ssa_names; x++)
> +  if (flag_checking)
>      {
> -      gcc_assert (t->expr_decl_uids[x] == NULL);
> -      gcc_assert (t->partition_dependencies[x] == NULL);
> +      for (unsigned x = 0; x <= num_var_partitions (t->map); x++)
> +	gcc_assert (!t->kill_list[x]);
> +      for (unsigned x = 0; x < num_ssa_names; x++)
> +	{
> +	  gcc_assert (t->expr_decl_uids[x] == NULL);
> +	  gcc_assert (t->partition_dependencies[x] == NULL);
> +	}
>      }
> -#endif
>  
>    BITMAP_FREE (t->partition_in_use);
>    BITMAP_FREE (t->new_replaceable_dependencies);
> @@ -748,7 +746,6 @@ dump_replaceable_exprs (FILE *f, bitmap expr)
>  }
>  
>  
> -#ifdef ENABLE_CHECKING
>  /* Dump the status of the various tables in the expression table.  This is used
>     exclusively to debug TER.  F is the place to send debug info and T is the
>     table being debugged.  */
> @@ -796,4 +793,3 @@ debug_ter (FILE *f, temp_expr_table *t)
>  
>    fprintf (f, "\n----------\n");
>  }
> -#endif
> diff --git a/gcc/tree-ssa-threadupdate.c b/gcc/tree-ssa-threadupdate.c
> index 8e3437a..90a9172 100644
> --- a/gcc/tree-ssa-threadupdate.c
> +++ b/gcc/tree-ssa-threadupdate.c
> @@ -2510,9 +2510,8 @@ duplicate_thread_path (edge entry, edge exit,
>        scale_bbs_frequencies_int (region_copy, n_region, entry_freq, total_freq);
>      }
>  
> -#ifdef ENABLE_CHECKING
> -  verify_jump_thread (region_copy, n_region);
> -#endif
> +  if (flag_checking)
> +    verify_jump_thread (region_copy, n_region);
>  
>    /* Remove the last branch in the jump thread path.  */
>    remove_ctrl_stmt_and_useless_edges (region_copy[n_region - 1], exit->dest);
> diff --git a/gcc/tree-ssa.h b/gcc/tree-ssa.h
> index a2c90a0..5a409e5 100644
> --- a/gcc/tree-ssa.h
> +++ b/gcc/tree-ssa.h
> @@ -77,5 +77,13 @@ redirect_edge_var_map_location (edge_var_map *v)
>    return v->locus;
>  }
>  
> +/* Verify SSA invariants, if internal consistency checks are enabled.  */
> +
> +static inline void
> +checking_verify_ssa (bool check_modified_stmt, bool check_ssa_operands)
> +{
> +  if (flag_checking)
> +    verify_ssa (check_modified_stmt, check_ssa_operands);
> +}
>  
>  #endif /* GCC_TREE_SSA_H */
> diff --git a/gcc/tree-ssanames.c b/gcc/tree-ssanames.c
> index 804ec62..90d75b6 100644
> --- a/gcc/tree-ssanames.c
> +++ b/gcc/tree-ssanames.c
> @@ -336,9 +336,8 @@ release_ssa_name_fn (struct function *fn, tree var)
>        if (MAY_HAVE_DEBUG_STMTS)
>  	insert_debug_temp_for_var_def (NULL, var);
>  
> -#ifdef ENABLE_CHECKING
> -      verify_imm_links (stderr, var);
> -#endif
> +      if (flag_checking)
> +	verify_imm_links (stderr, var);
>        while (imm->next != imm)
>  	delink_imm_use (imm->next);
>  
> diff --git a/gcc/tree-stdarg.c b/gcc/tree-stdarg.c
> index 3e6d98c..a38443d 100644
> --- a/gcc/tree-stdarg.c
> +++ b/gcc/tree-stdarg.c
> @@ -1107,13 +1107,14 @@ expand_ifn_va_arg (function *fun)
>    if ((fun->curr_properties & PROP_gimple_lva) == 0)
>      expand_ifn_va_arg_1 (fun);
>  
> -#if ENABLE_CHECKING
> -  basic_block bb;
> -  gimple_stmt_iterator i;
> -  FOR_EACH_BB_FN (bb, fun)
> -    for (i = gsi_start_bb (bb); !gsi_end_p (i); gsi_next (&i))
> -      gcc_assert (!gimple_call_ifn_va_arg_p (gsi_stmt (i)));
> -#endif
> +  if (flag_checking)
> +    {
> +      basic_block bb;
> +      gimple_stmt_iterator i;
> +      FOR_EACH_BB_FN (bb, fun)
> +	for (i = gsi_start_bb (bb); !gsi_end_p (i); gsi_next (&i))
> +	  gcc_assert (!gimple_call_ifn_va_arg_p (gsi_stmt (i)));
> +    }
>  }
>  
>  namespace {
> diff --git a/gcc/tree-vect-loop-manip.c b/gcc/tree-vect-loop-manip.c
> index 11c3ae2..d9d01ec 100644
> --- a/gcc/tree-vect-loop-manip.c
> +++ b/gcc/tree-vect-loop-manip.c
> @@ -919,9 +919,7 @@ slpeel_tree_duplicate_loop_to_edge_cfg (struct loop *loop,
>    free (new_bbs);
>    free (bbs);
>  
> -#ifdef ENABLE_CHECKING
> -  verify_dominators (CDI_DOMINATORS);
> -#endif
> +  checking_verify_dominators (CDI_DOMINATORS);
>  
>    return new_loop;
>  }
> @@ -1003,11 +1001,13 @@ slpeel_can_duplicate_loop_p (const struct loop *loop, const_edge e)
>    return true;
>  }
>  
> -#ifdef ENABLE_CHECKING
>  static void
> -slpeel_verify_cfg_after_peeling (struct loop *first_loop,
> -                                 struct loop *second_loop)
> +slpeel_checking_verify_cfg_after_peeling (struct loop *first_loop,
> +					  struct loop *second_loop)
>  {
> +  if (!flag_checking)
> +    return;
> +
>    basic_block loop1_exit_bb = single_exit (first_loop)->dest;
>    basic_block loop2_entry_bb = loop_preheader_edge (second_loop)->src;
>    basic_block loop1_entry_bb = loop_preheader_edge (first_loop)->src;
> @@ -1035,7 +1035,6 @@ slpeel_verify_cfg_after_peeling (struct loop *first_loop,
>       second_loop.  */
>    /* TODO */
>  }
> -#endif
>  
>  /* If the run time cost model check determines that vectorization is
>     not profitable and hence scalar loop should be generated then set
> @@ -1773,9 +1772,7 @@ vect_do_peeling_for_loop_bound (loop_vec_info loop_vinfo,
>  				     0, LOOP_VINFO_VECT_FACTOR (loop_vinfo));
>    gcc_assert (new_loop);
>    gcc_assert (loop_num == loop->num);
> -#ifdef ENABLE_CHECKING
> -  slpeel_verify_cfg_after_peeling (loop, new_loop);
> -#endif
> +  slpeel_checking_verify_cfg_after_peeling (loop, new_loop);
>  
>    /* A guard that controls whether the new_loop is to be executed or skipped
>       is placed in LOOP->exit.  LOOP->exit therefore has two successors - one
> @@ -2032,9 +2029,7 @@ vect_do_peeling_for_alignment (loop_vec_info loop_vinfo, tree ni_name,
>  				   bound, 0);
>  
>    gcc_assert (new_loop);
> -#ifdef ENABLE_CHECKING
> -  slpeel_verify_cfg_after_peeling (new_loop, loop);
> -#endif
> +  slpeel_checking_verify_cfg_after_peeling (new_loop, loop);
>    /* For vectorization factor N, we need to copy at most N-1 values 
>       for alignment and this means N-2 loopback edge executions.  */
>    max_iter = LOOP_VINFO_VECT_FACTOR (loop_vinfo) - 2;
> diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
> index 0a47d35..3138ae7 100644
> --- a/gcc/tree-vrp.c
> +++ b/gcc/tree-vrp.c
> @@ -242,9 +242,7 @@ static inline bool
>  supports_overflow_infinity (const_tree type)
>  {
>    tree min = vrp_val_min (type), max = vrp_val_max (type);
> -#ifdef ENABLE_CHECKING
> -  gcc_assert (needs_overflow_infinity (type));
> -#endif
> +  gcc_checking_assert (needs_overflow_infinity (type));
>    return (min != NULL_TREE
>  	  && CONSTANT_CLASS_P (min)
>  	  && max != NULL_TREE
> @@ -373,9 +371,9 @@ static void
>  set_value_range (value_range *vr, enum value_range_type t, tree min,
>  		 tree max, bitmap equiv)
>  {
> -#if defined ENABLE_CHECKING
>    /* Check the validity of the range.  */
> -  if (t == VR_RANGE || t == VR_ANTI_RANGE)
> +  if (flag_checking
> +      && (t == VR_RANGE || t == VR_ANTI_RANGE))
>      {
>        int cmp;
>  
> @@ -395,12 +393,12 @@ set_value_range (value_range *vr, enum value_range_type t, tree min,
>  		    || !is_overflow_infinity (max));
>      }
>  
> -  if (t == VR_UNDEFINED || t == VR_VARYING)
> -    gcc_assert (min == NULL_TREE && max == NULL_TREE);
> -
> -  if (t == VR_UNDEFINED || t == VR_VARYING)
> -    gcc_assert (equiv == NULL || bitmap_empty_p (equiv));
> -#endif
> +  if (flag_checking
> +      && (t == VR_UNDEFINED || t == VR_VARYING))
> +    {
> +      gcc_assert (min == NULL_TREE && max == NULL_TREE);
> +      gcc_assert (equiv == NULL || bitmap_empty_p (equiv));
> +    }
>  
>    vr->type = t;
>    vr->min = min;
> diff --git a/gcc/tree.c b/gcc/tree.c
> index e77d4b8..530e7a9 100644
> --- a/gcc/tree.c
> +++ b/gcc/tree.c
> @@ -5952,10 +5952,11 @@ free_lang_data_in_cgraph (void)
>    /* Traverse every type found freeing its language data.  */
>    FOR_EACH_VEC_ELT (fld.types, i, t)
>      free_lang_data_in_type (t);
> -#ifdef ENABLE_CHECKING
> -  FOR_EACH_VEC_ELT (fld.types, i, t)
> -    verify_type (t);
> -#endif
> +  if (flag_checking)
> +    {
> +      FOR_EACH_VEC_ELT (fld.types, i, t)
> +	verify_type (t);
> +    }
>  
>    delete fld.pset;
>    fld.worklist.release ();
> diff --git a/gcc/value-prof.c b/gcc/value-prof.c
> index efdb434..e371c24 100644
> --- a/gcc/value-prof.c
> +++ b/gcc/value-prof.c
> @@ -230,9 +230,8 @@ gimple_remove_histogram_value (struct function *fun, gimple *stmt,
>        hist2->hvalue.next = hist->hvalue.next;
>      }
>    free (hist->hvalue.counters);
> -#ifdef ENABLE_CHECKING
> -  memset (hist, 0xab, sizeof (*hist));
> -#endif
> +  if (flag_checking)
> +    memset (hist, 0xab, sizeof (*hist));
>    free (hist);
>  }
>  
> @@ -595,9 +594,8 @@ free_hist (void **slot, void *data ATTRIBUTE_UNUSED)
>  {
>    histogram_value hist = *(histogram_value *) slot;
>    free (hist->hvalue.counters);
> -#ifdef ENABLE_CHECKING
> -  memset (hist, 0xab, sizeof (*hist));
> -#endif
> +  if (flag_checking)
> +    memset (hist, 0xab, sizeof (*hist));
>    free (hist);
>    return 1;
>  }
> diff --git a/gcc/var-tracking.c b/gcc/var-tracking.c
> index 8010ce1..60c0320 100644
> --- a/gcc/var-tracking.c
> +++ b/gcc/var-tracking.c
> @@ -399,7 +399,7 @@ struct variable
>  /* Macro to access MEM_OFFSET as an HOST_WIDE_INT.  Evaluates MEM twice.  */
>  #define INT_MEM_OFFSET(mem) (MEM_OFFSET_KNOWN_P (mem) ? MEM_OFFSET (mem) : 0)
>  
> -#if ENABLE_CHECKING && (GCC_VERSION >= 2007)
> +#if CHECKING_P && (GCC_VERSION >= 2007)
>  
>  /* Access VAR's Ith part's offset, checking that it's not a one-part
>     variable.  */
> @@ -3571,7 +3571,6 @@ loc_cmp (rtx x, rtx y)
>    return 0;
>  }
>  
> -#if ENABLE_CHECKING
>  /* Check the order of entries in one-part variables.   */
>  
>  int
> @@ -3603,7 +3602,6 @@ canonicalize_loc_order_check (variable **slot,
>  
>    return 1;
>  }
> -#endif
>  
>  /* Mark with VALUE_RECURSED_INTO values that have neighbors that are
>     more likely to be chosen as canonical for an equivalence set.
> @@ -3832,17 +3830,16 @@ canonicalize_values_star (variable **slot, dataflow_set *set)
>  	    else
>  	      gcc_unreachable ();
>  
> -#if ENABLE_CHECKING
> -	    while (list)
> -	      {
> -		if (list->offset == 0
> -		    && (dv_as_opaque (list->dv) == dv_as_opaque (dv)
> -			|| dv_as_opaque (list->dv) == dv_as_opaque (cdv)))
> -		  gcc_unreachable ();
> +	    if (flag_checking)
> +	      while (list)
> +		{
> +		  if (list->offset == 0
> +		      && (dv_as_opaque (list->dv) == dv_as_opaque (dv)
> +			  || dv_as_opaque (list->dv) == dv_as_opaque (cdv)))
> +		    gcc_unreachable ();
>  
> -		list = list->next;
> -	      }
> -#endif
> +		  list = list->next;
> +		}
>  	  }
>        }
>  
> @@ -6930,10 +6927,9 @@ compute_bb_dataflow (basic_block bb)
>  	->traverse <dataflow_set *, canonicalize_values_mark> (out);
>        shared_hash_htab (out->vars)
>  	->traverse <dataflow_set *, canonicalize_values_star> (out);
> -#if ENABLE_CHECKING
> -      shared_hash_htab (out->vars)
> -	->traverse <dataflow_set *, canonicalize_loc_order_check> (out);
> -#endif
> +      if (flag_checking)
> +	shared_hash_htab (out->vars)
> +	  ->traverse <dataflow_set *, canonicalize_loc_order_check> (out);
>      }
>    changed = dataflow_set_different (&old_out, out);
>    dataflow_set_destroy (&old_out);
> @@ -7038,13 +7034,14 @@ vt_find_locations (void)
>  		  if (adjust)
>  		    {
>  		      dataflow_post_merge_adjust (in, &VTI (bb)->permp);
> -#if ENABLE_CHECKING
> -		      /* Merge and merge_adjust should keep entries in
> -			 canonical order.  */
> -		      shared_hash_htab (in->vars)
> -			->traverse <dataflow_set *,
> -				    canonicalize_loc_order_check> (in);
> -#endif
> +
> +		      if (flag_checking)
> +			/* Merge and merge_adjust should keep entries in
> +			   canonical order.  */
> +			shared_hash_htab (in->vars)
> +			  ->traverse <dataflow_set *,
> +				      canonicalize_loc_order_check> (in);
> +
>  		      if (dst_can_be_shared)
>  			{
>  			  shared_hash_destroy (in->vars);
> @@ -9465,11 +9462,12 @@ vt_emit_notes (void)
>  	 again.  */
>        dataflow_set_clear (&VTI (bb)->in);
>      }
> -#ifdef ENABLE_CHECKING
> -  shared_hash_htab (cur.vars)
> -    ->traverse <variable_table_type *, emit_notes_for_differences_1>
> -      (shared_hash_htab (empty_shared_hash));
> -#endif
> +
> +  if (flag_checking)
> +    shared_hash_htab (cur.vars)
> +      ->traverse <variable_table_type *, emit_notes_for_differences_1>
> +	(shared_hash_htab (empty_shared_hash));
> +
>    dataflow_set_destroy (&cur);
>  
>    if (MAY_HAVE_DEBUG_INSNS)

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 6/9] ENABLE_CHECKING refactoring: generators
  2015-10-21 10:57       ` Richard Biener
@ 2015-10-28 16:32         ` Jeff Law
  0 siblings, 0 replies; 77+ messages in thread
From: Jeff Law @ 2015-10-28 16:32 UTC (permalink / raw)
  To: Richard Biener, Mikhail Maltsev; +Cc: gcc-patches mailing list

On 10/21/2015 04:49 AM, Richard Biener wrote:
> On Mon, Oct 19, 2015 at 1:55 AM, Mikhail Maltsev <maltsevm@gmail.com> wrote:
>> On 10/06/2015 03:56 PM, Richard Biener wrote:
>>> The generators should simply unconditionally check (not in generated
>>> files, of course).
>>> And the generated code parts should use flag_checking.
>>>
>>> Richard.
>>
>> genautomata has some macros similar to tree checks, so I avoided changing them.
>> genconditions for some reason #undef-s ENABLE_CHECKING in the generated code. I
>> did not look at it in details, but decided to simply #define CHECKING_P to 0 for
>> consistency.
>>
>> As for genextract and gengtype, I followed your recommendations, that is, used
>> flag_checking instead of CHECKING_P in genextract, and always enable debugging
>> functions in gengtype.
>
> diff --git a/gcc/genextract.c b/gcc/genextract.c
> index fe97701..a03ac97 100644
> --- a/gcc/genextract.c
> +++ b/gcc/genextract.c
> @@ -373,10 +373,11 @@ insn_extract (rtx_insn *insn)\n{\n\
>     rtx pat = PATTERN (insn);\n\
>     int i ATTRIBUTE_UNUSED; /* only for peepholes */\n\
>   \n\
> -#ifdef ENABLE_CHECKING\n\
> -  memset (ro, 0xab, sizeof (*ro) * MAX_RECOG_OPERANDS);\n\
> -  memset (ro_loc, 0xab, sizeof (*ro_loc) * MAX_RECOG_OPERANDS);\n\
> -#endif\n");
> +  if (flag_checking)\n\
> +    {\n\
> +      memset (ro, 0xab, sizeof (*ro) * MAX_RECOG_OPERANDS);\n\
> +      memset (ro_loc, 0xab, sizeof (*ro_loc) * MAX_RECOG_OPERANDS);\n\
> +    }\n");
>
>
>
> flag_checking will be never set, so as suggested make it do the checking bits
> unconditionally.
It can be set as this code ends up in insn-extract.c.  That's the way it 
looked to me.  Just to be sure, I shoved in an abort() in that path and 
sure enough it fires as soon as we start trying to configure the stage1 
target libraries :-)

I've fixed a couple comments on #else/#endif lines.  I've never been a 
fan of those, but i can hold my nose while I make those comments consistent.

I'm doing a bootstrap & config-all.mk test and expect to commit this for 
Mikhail later today.

jeff

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 6/9] ENABLE_CHECKING refactoring: generators
  2015-10-19  0:09     ` Mikhail Maltsev
  2015-10-21 10:57       ` Richard Biener
@ 2015-10-29 16:31       ` Jeff Law
  1 sibling, 0 replies; 77+ messages in thread
From: Jeff Law @ 2015-10-29 16:31 UTC (permalink / raw)
  To: Mikhail Maltsev, Richard Biener; +Cc: gcc-patches mailing list

On 10/18/2015 05:55 PM, Mikhail Maltsev wrote:
> On 10/06/2015 03:56 PM, Richard Biener wrote:
>> The generators should simply unconditionally check (not in generated
>> files, of course).
>> And the generated code parts should use flag_checking.
>>
>> Richard.
>
> genautomata has some macros similar to tree checks, so I avoided changing them.
> genconditions for some reason #undef-s ENABLE_CHECKING in the generated code. I
> did not look at it in details, but decided to simply #define CHECKING_P to 0 for
> consistency.
>
> As for genextract and gengtype, I followed your recommendations, that is, used
> flag_checking instead of CHECKING_P in genextract, and always enable debugging
> functions in gengtype.
I committed this with the trivial fixes to the comments after the 
#else/#endif lines.

Jeff

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 8/9] ENABLE_CHECKING refactoring: target-specific parts
  2015-10-06 12:48   ` Bernd Schmidt
@ 2015-10-29 19:43     ` Jeff Law
  0 siblings, 0 replies; 77+ messages in thread
From: Jeff Law @ 2015-10-29 19:43 UTC (permalink / raw)
  To: Bernd Schmidt, Mikhail Maltsev, gcc-patches mailing list, Richard Biener

On 10/06/2015 06:48 AM, Bernd Schmidt wrote:
> On 10/06/2015 01:40 AM, Mikhail Maltsev wrote:
>>
>> -#ifdef ENABLE_CHECKING
>> +#if CHECKING_P
>>         /* Check that the addresses are consecutive.  */
>>         e = XEXP (SET_DEST (e), 0);
>>         if (GET_CODE (e) == PLUS)
>> diff --git a/gcc/config/bfin/bfin.c b/gcc/config/bfin/bfin.c
>> index a131053..e53fe6d 100644
>> --- a/gcc/config/bfin/bfin.c
>> +++ b/gcc/config/bfin/bfin.c
>> @@ -3811,8 +3811,7 @@ hwloop_optimize (hwloop_info loop)
>>         edge e;
>>         edge_iterator ei;
>>
>> -#ifdef ENABLE_CHECKING
>> -      if (loop->head != loop->incoming_dest)
>> +      if (CHECKING_P && loop->head != loop->incoming_dest)
>>       {
>
> This stuff also seems inconsistent. Why use CHECKING_P instead of
> flag_checking? Why use #if sometimes and if in other cases?
No idea :-)

I think we ought to go through this patch and convert the #if stuff to 
(flag_checking) as much as possible.  Given I've got a config-list.mk 
build ready to go, I'll go ahead and do that update now so it'll pick up 
those changes and see what falls out.


jeff

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 8/9] ENABLE_CHECKING refactoring: target-specific parts
  2015-10-05 23:40 ` [PATCH 8/9] ENABLE_CHECKING refactoring: target-specific parts Mikhail Maltsev
  2015-10-06 12:48   ` Bernd Schmidt
@ 2015-10-29 21:23   ` Jeff Law
  2015-10-30  4:13   ` Jeff Law
  2 siblings, 0 replies; 77+ messages in thread
From: Jeff Law @ 2015-10-29 21:23 UTC (permalink / raw)
  To: Mikhail Maltsev, gcc-patches mailing list, Richard Biener

On 10/05/2015 05:40 PM, Mikhail Maltsev wrote:
> gcc/ChangeLog:
>
> 2015-10-05  Mikhail Maltsev  <maltsevm@gmail.com>
>
> 	* config/alpha/alpha.c (alpha_function_arg): Use gcc_checking_assert.
> 	* config/arm/arm.c (arm_unwind_emit_sequence): Adjust to use CHECKING_P.
> 	* config/bfin/bfin.c (hwloop_optimize): Likewise.
> 	* config/i386/i386.c (ix86_print_operand_address,
> 	output_387_binary_op): Likewise.
> 	* config/ia64/ia64.c (ia64_sched_init, bundling): Likewise.
> 	* config/m68k/m68k.c (m68k_sched_md_init_global): Likewise.
> 	* config/rs6000/rs6000.c (htm_expand_builtin, rs6000_emit_prologue):
> 	Likewise.
> 	* config/rs6000/rs6000.h: Likewise.
> 	* config/visium/visium.c (visium_setup_incoming_varargs): Likewise.
>
I think I remember why some stuff was left with a #if rather than 
converting to if (flag_checking) -- formatting.

I believe Mikhail mentioned he left some things as #if that would have 
required reformatting if turned into a runtime conditional.  I believe I 
said that was initially OK, but would need to be fixed.  After all it's 
just formatting.

 From looking at this patch, the only one that's at all painful is the 
ia64 bits.  I can see what the code is doing and pretty sure I can 
convert it correctly, but would suggest we do so as a separate follow-up 
-- where we'll allocate a beaker box so we can bootstrap test it for 
deeper testing than we get from config-list.mk.


Jeff

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 8/9] ENABLE_CHECKING refactoring: target-specific parts
  2015-10-05 23:40 ` [PATCH 8/9] ENABLE_CHECKING refactoring: target-specific parts Mikhail Maltsev
  2015-10-06 12:48   ` Bernd Schmidt
  2015-10-29 21:23   ` Jeff Law
@ 2015-10-30  4:13   ` Jeff Law
  2015-10-30  4:20     ` Jeff Law
  2 siblings, 1 reply; 77+ messages in thread
From: Jeff Law @ 2015-10-30  4:13 UTC (permalink / raw)
  To: Mikhail Maltsev, gcc-patches mailing list, Richard Biener

[-- Attachment #1: Type: text/plain, Size: 1229 bytes --]

On 10/05/2015 05:40 PM, Mikhail Maltsev wrote:
> gcc/ChangeLog:
>
> 2015-10-05  Mikhail Maltsev  <maltsevm@gmail.com>
>
> 	* config/alpha/alpha.c (alpha_function_arg): Use gcc_checking_assert.
> 	* config/arm/arm.c (arm_unwind_emit_sequence): Adjust to use CHECKING_P.
> 	* config/bfin/bfin.c (hwloop_optimize): Likewise.
> 	* config/i386/i386.c (ix86_print_operand_address,
> 	output_387_binary_op): Likewise.
> 	* config/ia64/ia64.c (ia64_sched_init, bundling): Likewise.
> 	* config/m68k/m68k.c (m68k_sched_md_init_global): Likewise.
> 	* config/rs6000/rs6000.c (htm_expand_builtin, rs6000_emit_prologue):
> 	Likewise.
> 	* config/rs6000/rs6000.h: Likewise.
> 	* config/visium/visium.c (visium_setup_incoming_varargs): Likewise.
>
Thanks.  I've removed most of the inconsistencies Bernd pointed out.  I 
left one bit in ia64.c as I'd like to do a deeper test on removal of 
that conditional compilation.

I bootstrapped and regression tested this patch on x86_64-linux-gnu as 
building config-list.mk.  I'm installing this patch on the trunk.

For reference, you'll find the actual patch committed attached to this 
message, as well as one created ignoring whitespace changes which shows 
the real changes more clearly.

Jeff

[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 15455 bytes --]

commit 1d674b45031bb4650ef80a91ac1956764a4ab271
Author: law <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Fri Oct 30 04:08:15 2015 +0000

    [PATCH 8/9] ENABLE_CHECKING refactoring: target-specific parts
    
    	* config/alpha/alpha.c (alpha_function_arg): Use gcc_checking_assert,
    	flag_checking and/or CHECKING_P to eliminate conditional compilation
    	on ENABLE_CHECKING.
    	* config/arm/arm.c (arm_unwind_emit_sequence): Likewise.
    	* config/bfin/bfin.c (hwloop_optimize): Likewise.
    	* config/i386/i386.c (ix86_print_operand_address): Likewise.
    	(output_387_binary_op): Likewise.
    	* config/ia64/ia64.c (ia64_sched_init, bundling): Likewise.
    	* config/m68k/m68k.c (m68k_sched_md_init_global): Likewise.
    	* config/rs6000/rs6000.c (htm_expand_builtin, rs6000_emit_prologue):
    	Likewise.
    	* config/rs6000/rs6000.h: Likewise.
    	* config/visium/visium.c (visium_setup_incoming_varargs): Likewise.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229567 138bc75d-0d04-0410-961f-82ee72b054a4

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c9250b6..934711b 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,19 @@
+2015-10-29  Mikhail Maltsev  <maltsevm@gmail.com>
+
+	* config/alpha/alpha.c (alpha_function_arg): Use gcc_checking_assert,
+	flag_checking and/or CHECKING_P to eliminate conditional compilation
+	on ENABLE_CHECKING.
+	* config/arm/arm.c (arm_unwind_emit_sequence): Likewise.
+	* config/bfin/bfin.c (hwloop_optimize): Likewise.
+	* config/i386/i386.c (ix86_print_operand_address): Likewise.
+	(output_387_binary_op): Likewise.
+	* config/ia64/ia64.c (ia64_sched_init, bundling): Likewise.
+	* config/m68k/m68k.c (m68k_sched_md_init_global): Likewise.
+	* config/rs6000/rs6000.c (htm_expand_builtin, rs6000_emit_prologue):
+	Likewise.
+	* config/rs6000/rs6000.h: Likewise.
+	* config/visium/visium.c (visium_setup_incoming_varargs): Likewise.
+
 2015-10-29  Kaz Kojima  <kkojima@gcc.gnu.org>
 
 	* config/sh/sh.opt (mfdpic): Add missing period.
diff --git a/gcc/config/alpha/alpha.c b/gcc/config/alpha/alpha.c
index d22bf67..11da372 100644
--- a/gcc/config/alpha/alpha.c
+++ b/gcc/config/alpha/alpha.c
@@ -5558,11 +5558,9 @@ alpha_function_arg (cumulative_args_t cum_v, machine_mode mode,
     basereg = 16;
   else
     {
-#ifdef ENABLE_CHECKING
       /* With alpha_split_complex_arg, we shouldn't see any raw complex
 	 values here.  */
-      gcc_assert (!COMPLEX_MODE_P (mode));
-#endif
+      gcc_checking_assert (!COMPLEX_MODE_P (mode));
 
       /* Set up defaults for FP operands passed in FP registers, and
 	 integral operands passed in integer registers.  */
diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index a598c84..7c72a81 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -26857,20 +26857,21 @@ arm_unwind_emit_sequence (FILE * asm_out_file, rtx p)
       else
 	asm_fprintf (asm_out_file, "%r", reg);
 
-#ifdef ENABLE_CHECKING
-      /* Check that the addresses are consecutive.  */
-      e = XEXP (SET_DEST (e), 0);
-      if (GET_CODE (e) == PLUS)
-	gcc_assert (REG_P (XEXP (e, 0))
-		    && REGNO (XEXP (e, 0)) == SP_REGNUM
-		    && CONST_INT_P (XEXP (e, 1))
-		    && offset == INTVAL (XEXP (e, 1)));
-      else
-	gcc_assert (i == 1
-		    && REG_P (e)
-		    && REGNO (e) == SP_REGNUM);
-      offset += reg_size;
-#endif
+      if (flag_checking)
+	{
+	  /* Check that the addresses are consecutive.  */
+	  e = XEXP (SET_DEST (e), 0);
+	  if (GET_CODE (e) == PLUS)
+	    gcc_assert (REG_P (XEXP (e, 0))
+			&& REGNO (XEXP (e, 0)) == SP_REGNUM
+			&& CONST_INT_P (XEXP (e, 1))
+			&& offset == INTVAL (XEXP (e, 1)));
+	  else
+	    gcc_assert (i == 1
+			&& REG_P (e)
+			&& REGNO (e) == SP_REGNUM);
+	  offset += reg_size;
+	}
     }
   fprintf (asm_out_file, "}\n");
   if (padfirst)
diff --git a/gcc/config/bfin/bfin.c b/gcc/config/bfin/bfin.c
index 7334a52..6a5f90a 100644
--- a/gcc/config/bfin/bfin.c
+++ b/gcc/config/bfin/bfin.c
@@ -3792,8 +3792,7 @@ hwloop_optimize (hwloop_info loop)
       edge e;
       edge_iterator ei;
 
-#ifdef ENABLE_CHECKING
-      if (loop->head != loop->incoming_dest)
+      if (flag_checking && loop->head != loop->incoming_dest)
 	{
 	  /* We aren't entering the loop at the top.  Since we've established
 	     that the loop is entered only at one point, this means there
@@ -3803,7 +3802,6 @@ hwloop_optimize (hwloop_info loop)
 	  FOR_EACH_EDGE (e, ei, loop->head->preds)
 	    gcc_assert (!(e->flags & EDGE_FALLTHRU));
 	}
-#endif
 
       emit_insn_before (seq, BB_HEAD (loop->head));
       seq = emit_label_before (gen_label_rtx (), seq);
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 8476677..913dc00 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -17348,22 +17348,23 @@ ix86_print_operand_address (FILE *file, rtx addr)
       /* Print SImode register names to force addr32 prefix.  */
       if (SImode_address_operand (addr, VOIDmode))
 	{
-#ifdef ENABLE_CHECKING
-	  gcc_assert (TARGET_64BIT);
-	  switch (GET_CODE (addr))
+	  if (flag_checking)
 	    {
-	    case SUBREG:
-	      gcc_assert (GET_MODE (addr) == SImode);
-	      gcc_assert (GET_MODE (SUBREG_REG (addr)) == DImode);
-	      break;
-	    case ZERO_EXTEND:
-	    case AND:
-	      gcc_assert (GET_MODE (addr) == DImode);
-	      break;
-	    default:
-	      gcc_unreachable ();
+	      gcc_assert (TARGET_64BIT);
+	      switch (GET_CODE (addr))
+		{
+		case SUBREG:
+		  gcc_assert (GET_MODE (addr) == SImode);
+		  gcc_assert (GET_MODE (SUBREG_REG (addr)) == DImode);
+		  break;
+		case ZERO_EXTEND:
+		case AND:
+		  gcc_assert (GET_MODE (addr) == DImode);
+		  break;
+		default:
+		  gcc_unreachable ();
+		}
 	    }
-#endif
 	  gcc_assert (!code);
 	  code = 'k';
 	}
@@ -17620,10 +17621,10 @@ output_387_binary_op (rtx insn, rtx *operands)
   const char *ssep;
   int is_sse = SSE_REG_P (operands[0]) || SSE_REG_P (operands[1]) || SSE_REG_P (operands[2]);
 
-#ifdef ENABLE_CHECKING
   /* Even if we do not want to check the inputs, this documents input
      constraints.  Which helps in understanding the following code.  */
-  if (STACK_REG_P (operands[0])
+  if (flag_checking
+      && STACK_REG_P (operands[0])
       && ((REG_P (operands[1])
 	   && REGNO (operands[0]) == REGNO (operands[1])
 	   && (STACK_REG_P (operands[2]) || MEM_P (operands[2])))
@@ -17633,8 +17634,7 @@ output_387_binary_op (rtx insn, rtx *operands)
       && (STACK_TOP_P (operands[1]) || STACK_TOP_P (operands[2])))
     ; /* ok */
   else
-    gcc_assert (is_sse);
-#endif
+    gcc_checking_assert (is_sse);
 
   switch (GET_CODE (operands[3]))
     {
diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c
index 8791138..d92af17 100644
--- a/gcc/config/ia64/ia64.c
+++ b/gcc/config/ia64/ia64.c
@@ -6125,7 +6125,7 @@ struct reg_write_state
 
 /* Cumulative info for the current instruction group.  */
 struct reg_write_state rws_sum[NUM_REGS];
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
 /* Bitmap whether a register has been written in the current insn.  */
 HARD_REG_ELT_TYPE rws_insn[(NUM_REGS + HOST_BITS_PER_WIDEST_FAST_INT - 1)
 			   / HOST_BITS_PER_WIDEST_FAST_INT];
@@ -7293,15 +7293,13 @@ ia64_sched_init (FILE *dump ATTRIBUTE_UNUSED,
 		 int sched_verbose ATTRIBUTE_UNUSED,
 		 int max_ready ATTRIBUTE_UNUSED)
 {
-#ifdef ENABLE_CHECKING
-  rtx_insn *insn;
-
-  if (!sel_sched_p () && reload_completed)
-    for (insn = NEXT_INSN (current_sched_info->prev_head);
-	 insn != current_sched_info->next_tail;
-	 insn = NEXT_INSN (insn))
-      gcc_assert (!SCHED_GROUP_P (insn));
-#endif
+  if (flag_checking && !sel_sched_p () && reload_completed)
+    {
+      for (rtx_insn *insn = NEXT_INSN (current_sched_info->prev_head);
+	   insn != current_sched_info->next_tail;
+	   insn = NEXT_INSN (insn))
+	gcc_assert (!SCHED_GROUP_P (insn));
+    }
   last_scheduled_insn = NULL;
   init_insn_group_barriers ();
 
@@ -9299,54 +9297,52 @@ bundling (FILE *dump, int verbose, rtx_insn *prev_head_insn, rtx_insn *tail)
 	}
     }
 
-#ifdef ENABLE_CHECKING
-  {
-    /* Assert right calculation of middle_bundle_stops.  */
-    int num = best_state->middle_bundle_stops;
-    bool start_bundle = true, end_bundle = false;
-
-    for (insn = NEXT_INSN (prev_head_insn);
-	 insn && insn != tail;
-	 insn = NEXT_INSN (insn))
-      {
-	if (!INSN_P (insn))
-	  continue;
-	if (recog_memoized (insn) == CODE_FOR_bundle_selector)
-	  start_bundle = true;
-	else
-	  {
-	    rtx_insn *next_insn;
-
-	    for (next_insn = NEXT_INSN (insn);
-		 next_insn && next_insn != tail;
-		 next_insn = NEXT_INSN (next_insn))
-	      if (INSN_P (next_insn)
-		  && (ia64_safe_itanium_class (next_insn)
-		      != ITANIUM_CLASS_IGNORE
-		      || recog_memoized (next_insn)
-		      == CODE_FOR_bundle_selector)
-		  && GET_CODE (PATTERN (next_insn)) != USE
-		  && GET_CODE (PATTERN (next_insn)) != CLOBBER)
-		break;
+  if (flag_checking)
+    {
+      /* Assert right calculation of middle_bundle_stops.  */
+      int num = best_state->middle_bundle_stops;
+      bool start_bundle = true, end_bundle = false;
 
-	    end_bundle = next_insn == NULL_RTX
-	     || next_insn == tail
-	     || (INSN_P (next_insn)
-		 && recog_memoized (next_insn)
-		 == CODE_FOR_bundle_selector);
-	    if (recog_memoized (insn) == CODE_FOR_insn_group_barrier
-		&& !start_bundle && !end_bundle
-		&& next_insn
-		&& !unknown_for_bundling_p (next_insn))
-	      num--;
-
-	    start_bundle = false;
-	  }
-      }
+      for (insn = NEXT_INSN (prev_head_insn);
+	   insn && insn != tail;
+	   insn = NEXT_INSN (insn))
+	{
+	  if (!INSN_P (insn))
+	    continue;
+	  if (recog_memoized (insn) == CODE_FOR_bundle_selector)
+	    start_bundle = true;
+	  else
+	    {
+	      rtx_insn *next_insn;
+
+	      for (next_insn = NEXT_INSN (insn);
+		   next_insn && next_insn != tail;
+		   next_insn = NEXT_INSN (next_insn))
+		if (INSN_P (next_insn)
+		    && (ia64_safe_itanium_class (next_insn)
+			!= ITANIUM_CLASS_IGNORE
+			|| recog_memoized (next_insn)
+			== CODE_FOR_bundle_selector)
+		    && GET_CODE (PATTERN (next_insn)) != USE
+		    && GET_CODE (PATTERN (next_insn)) != CLOBBER)
+		  break;
+
+	      end_bundle = next_insn == NULL_RTX
+		|| next_insn == tail
+		|| (INSN_P (next_insn)
+		    && recog_memoized (next_insn) == CODE_FOR_bundle_selector);
+	      if (recog_memoized (insn) == CODE_FOR_insn_group_barrier
+		  && !start_bundle && !end_bundle
+		  && next_insn
+		  && !unknown_for_bundling_p (next_insn))
+		num--;
+
+	      start_bundle = false;
+	    }
+	}
 
-    gcc_assert (num == 0);
-  }
-#endif
+      gcc_assert (num == 0);
+    }
 
   free (index_to_bundle_states);
   finish_bundle_state_table ();
diff --git a/gcc/config/m68k/m68k.c b/gcc/config/m68k/m68k.c
index bfc19f3..37b1af2 100644
--- a/gcc/config/m68k/m68k.c
+++ b/gcc/config/m68k/m68k.c
@@ -6118,28 +6118,27 @@ m68k_sched_md_init_global (FILE *sched_dump ATTRIBUTE_UNUSED,
 			   int sched_verbose ATTRIBUTE_UNUSED,
 			   int n_insns ATTRIBUTE_UNUSED)
 {
-#ifdef ENABLE_CHECKING
   /* Check that all instructions have DFA reservations and
      that all instructions can be issued from a clean state.  */
-  {
-    rtx_insn *insn;
-    state_t state;
+  if (flag_checking)
+    {
+      rtx_insn *insn;
+      state_t state;
 
-    state = alloca (state_size ());
+      state = alloca (state_size ());
 
-    for (insn = get_insns (); insn != NULL; insn = NEXT_INSN (insn))
-      {
- 	if (INSN_P (insn) && recog_memoized (insn) >= 0)
-	  {
- 	    gcc_assert (insn_has_dfa_reservation_p (insn));
+      for (insn = get_insns (); insn != NULL; insn = NEXT_INSN (insn))
+	{
+	  if (INSN_P (insn) && recog_memoized (insn) >= 0)
+	    {
+	      gcc_assert (insn_has_dfa_reservation_p (insn));
 
- 	    state_reset (state);
- 	    if (state_transition (state, insn) >= 0)
- 	      gcc_unreachable ();
- 	  }
-      }
-  }
-#endif
+	      state_reset (state);
+	      if (state_transition (state, insn) >= 0)
+		gcc_unreachable ();
+	    }
+	}
+    }
 
   /* Setup target cpu.  */
 
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index bbdd142..53b86af 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -12906,15 +12906,13 @@ htm_expand_builtin (tree exp, rtx target, bool * expandedp)
 	  case HTM_BUILTIN_TENDALL:  /* Alias for: tend. 1  */
 	  case HTM_BUILTIN_TRESUME:  /* Alias for: tsr. 1  */
 	    op[nopnds++] = GEN_INT (1);
-#ifdef ENABLE_CHECKING
-	    attr |= RS6000_BTC_UNARY;
-#endif
+	    if (flag_checking)
+	      attr |= RS6000_BTC_UNARY;
 	    break;
 	  case HTM_BUILTIN_TSUSPEND: /* Alias for: tsr. 0  */
 	    op[nopnds++] = GEN_INT (0);
-#ifdef ENABLE_CHECKING
-	    attr |= RS6000_BTC_UNARY;
-#endif
+	    if (flag_checking)
+	      attr |= RS6000_BTC_UNARY;
 	    break;
 	  default:
 	    break;
@@ -12935,21 +12933,23 @@ htm_expand_builtin (tree exp, rtx target, bool * expandedp)
 	    op[nopnds++] = cr;
 	  }
 
-#ifdef ENABLE_CHECKING
-	int expected_nopnds = 0;
-	if ((attr & RS6000_BTC_TYPE_MASK) == RS6000_BTC_UNARY)
-	  expected_nopnds = 1;
-	else if ((attr & RS6000_BTC_TYPE_MASK) == RS6000_BTC_BINARY)
-	  expected_nopnds = 2;
-	else if ((attr & RS6000_BTC_TYPE_MASK) == RS6000_BTC_TERNARY)
-	  expected_nopnds = 3;
-	if (!(attr & RS6000_BTC_VOID))
-	  expected_nopnds += 1;
-	if (uses_spr)
-	  expected_nopnds += 2;
+	if (flag_checking)
+	  {
+	    int expected_nopnds = 0;
+	    if ((attr & RS6000_BTC_TYPE_MASK) == RS6000_BTC_UNARY)
+	      expected_nopnds = 1;
+	    else if ((attr & RS6000_BTC_TYPE_MASK) == RS6000_BTC_BINARY)
+	      expected_nopnds = 2;
+	    else if ((attr & RS6000_BTC_TYPE_MASK) == RS6000_BTC_TERNARY)
+	      expected_nopnds = 3;
+	    if (!(attr & RS6000_BTC_VOID))
+	      expected_nopnds += 1;
+	    if (uses_spr)
+	      expected_nopnds += 2;
 
-	gcc_assert (nopnds == expected_nopnds && nopnds <= MAX_HTM_OPERANDS);
-#endif
+	    gcc_assert (nopnds == expected_nopnds
+			&& nopnds <= MAX_HTM_OPERANDS);
+	  }
 
 	switch (nopnds)
 	  {
@@ -24325,7 +24325,7 @@ rs6000_emit_prologue (void)
      prior to it, when r12 is not used here for other purposes.  */
   rtx_insn *sp_adjust = 0;
 
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
   /* Track and check usage of r0, r11, r12.  */
   int reg_inuse = using_static_chain_p ? 1 << 11 : 0;
 #define START_USE(R) do \
diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h
index cad1551..02da097 100644
--- a/gcc/config/rs6000/rs6000.h
+++ b/gcc/config/rs6000/rs6000.h
@@ -1479,15 +1479,10 @@ enum reg_class
 
 extern enum reg_class rs6000_regno_regclass[FIRST_PSEUDO_REGISTER];
 
-#if ENABLE_CHECKING
 #define REGNO_REG_CLASS(REGNO) 						\
-  (gcc_assert (IN_RANGE ((REGNO), 0, FIRST_PSEUDO_REGISTER-1)),		\
+  (gcc_checking_assert (IN_RANGE ((REGNO), 0, FIRST_PSEUDO_REGISTER-1)),\
    rs6000_regno_regclass[(REGNO)])
 
-#else
-#define REGNO_REG_CLASS(REGNO) rs6000_regno_regclass[(REGNO)]
-#endif
-
 /* Register classes for various constraints that are based on the target
    switches.  */
 enum r6000_reg_class_enum {
diff --git a/gcc/config/visium/visium.c b/gcc/config/visium/visium.c
index 5e7b944..d1b580e 100644
--- a/gcc/config/visium/visium.c
+++ b/gcc/config/visium/visium.c
@@ -1338,7 +1338,7 @@ visium_setup_incoming_varargs (cumulative_args_t pcum_v,
   local_args_so_far.p = &local_copy;
   locargs = get_cumulative_args (pcum_v);
 
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
   local_args_so_far.magic = CUMULATIVE_ARGS_MAGIC;
 #endif
 

[-- Attachment #3: patch.nowhitespace --]
[-- Type: text/plain, Size: 11215 bytes --]

commit 1d674b45031bb4650ef80a91ac1956764a4ab271
Author: law <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Fri Oct 30 04:08:15 2015 +0000

    [PATCH 8/9] ENABLE_CHECKING refactoring: target-specific parts
    
    	* config/alpha/alpha.c (alpha_function_arg): Use gcc_checking_assert,
    	flag_checking and/or CHECKING_P to eliminate conditional compilation
    	on ENABLE_CHECKING.
    	* config/arm/arm.c (arm_unwind_emit_sequence): Likewise.
    	* config/bfin/bfin.c (hwloop_optimize): Likewise.
    	* config/i386/i386.c (ix86_print_operand_address): Likewise.
    	(output_387_binary_op): Likewise.
    	* config/ia64/ia64.c (ia64_sched_init, bundling): Likewise.
    	* config/m68k/m68k.c (m68k_sched_md_init_global): Likewise.
    	* config/rs6000/rs6000.c (htm_expand_builtin, rs6000_emit_prologue):
    	Likewise.
    	* config/rs6000/rs6000.h: Likewise.
    	* config/visium/visium.c (visium_setup_incoming_varargs): Likewise.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229567 138bc75d-0d04-0410-961f-82ee72b054a4

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c9250b6..934711b 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,19 @@
+2015-10-29  Mikhail Maltsev  <maltsevm@gmail.com>
+
+	* config/alpha/alpha.c (alpha_function_arg): Use gcc_checking_assert,
+	flag_checking and/or CHECKING_P to eliminate conditional compilation
+	on ENABLE_CHECKING.
+	* config/arm/arm.c (arm_unwind_emit_sequence): Likewise.
+	* config/bfin/bfin.c (hwloop_optimize): Likewise.
+	* config/i386/i386.c (ix86_print_operand_address): Likewise.
+	(output_387_binary_op): Likewise.
+	* config/ia64/ia64.c (ia64_sched_init, bundling): Likewise.
+	* config/m68k/m68k.c (m68k_sched_md_init_global): Likewise.
+	* config/rs6000/rs6000.c (htm_expand_builtin, rs6000_emit_prologue):
+	Likewise.
+	* config/rs6000/rs6000.h: Likewise.
+	* config/visium/visium.c (visium_setup_incoming_varargs): Likewise.
+
 2015-10-29  Kaz Kojima  <kkojima@gcc.gnu.org>
 
 	* config/sh/sh.opt (mfdpic): Add missing period.
diff --git a/gcc/config/alpha/alpha.c b/gcc/config/alpha/alpha.c
index d22bf67..11da372 100644
--- a/gcc/config/alpha/alpha.c
+++ b/gcc/config/alpha/alpha.c
@@ -5558,11 +5558,9 @@ alpha_function_arg (cumulative_args_t cum_v, machine_mode mode,
     basereg = 16;
   else
     {
-#ifdef ENABLE_CHECKING
       /* With alpha_split_complex_arg, we shouldn't see any raw complex
 	 values here.  */
-      gcc_assert (!COMPLEX_MODE_P (mode));
-#endif
+      gcc_checking_assert (!COMPLEX_MODE_P (mode));
 
       /* Set up defaults for FP operands passed in FP registers, and
 	 integral operands passed in integer registers.  */
diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index a598c84..7c72a81 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -26857,7 +26857,8 @@ arm_unwind_emit_sequence (FILE * asm_out_file, rtx p)
       else
 	asm_fprintf (asm_out_file, "%r", reg);
 
-#ifdef ENABLE_CHECKING
+      if (flag_checking)
+	{
 	  /* Check that the addresses are consecutive.  */
 	  e = XEXP (SET_DEST (e), 0);
 	  if (GET_CODE (e) == PLUS)
@@ -26870,7 +26871,7 @@ arm_unwind_emit_sequence (FILE * asm_out_file, rtx p)
 			&& REG_P (e)
 			&& REGNO (e) == SP_REGNUM);
 	  offset += reg_size;
-#endif
+	}
     }
   fprintf (asm_out_file, "}\n");
   if (padfirst)
diff --git a/gcc/config/bfin/bfin.c b/gcc/config/bfin/bfin.c
index 7334a52..6a5f90a 100644
--- a/gcc/config/bfin/bfin.c
+++ b/gcc/config/bfin/bfin.c
@@ -3792,8 +3792,7 @@ hwloop_optimize (hwloop_info loop)
       edge e;
       edge_iterator ei;
 
-#ifdef ENABLE_CHECKING
-      if (loop->head != loop->incoming_dest)
+      if (flag_checking && loop->head != loop->incoming_dest)
 	{
 	  /* We aren't entering the loop at the top.  Since we've established
 	     that the loop is entered only at one point, this means there
@@ -3803,7 +3802,6 @@ hwloop_optimize (hwloop_info loop)
 	  FOR_EACH_EDGE (e, ei, loop->head->preds)
 	    gcc_assert (!(e->flags & EDGE_FALLTHRU));
 	}
-#endif
 
       emit_insn_before (seq, BB_HEAD (loop->head));
       seq = emit_label_before (gen_label_rtx (), seq);
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 8476677..913dc00 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -17348,7 +17348,8 @@ ix86_print_operand_address (FILE *file, rtx addr)
       /* Print SImode register names to force addr32 prefix.  */
       if (SImode_address_operand (addr, VOIDmode))
 	{
-#ifdef ENABLE_CHECKING
+	  if (flag_checking)
+	    {
 	      gcc_assert (TARGET_64BIT);
 	      switch (GET_CODE (addr))
 		{
@@ -17363,7 +17364,7 @@ ix86_print_operand_address (FILE *file, rtx addr)
 		default:
 		  gcc_unreachable ();
 		}
-#endif
+	    }
 	  gcc_assert (!code);
 	  code = 'k';
 	}
@@ -17620,10 +17621,10 @@ output_387_binary_op (rtx insn, rtx *operands)
   const char *ssep;
   int is_sse = SSE_REG_P (operands[0]) || SSE_REG_P (operands[1]) || SSE_REG_P (operands[2]);
 
-#ifdef ENABLE_CHECKING
   /* Even if we do not want to check the inputs, this documents input
      constraints.  Which helps in understanding the following code.  */
-  if (STACK_REG_P (operands[0])
+  if (flag_checking
+      && STACK_REG_P (operands[0])
       && ((REG_P (operands[1])
 	   && REGNO (operands[0]) == REGNO (operands[1])
 	   && (STACK_REG_P (operands[2]) || MEM_P (operands[2])))
@@ -17633,8 +17634,7 @@ output_387_binary_op (rtx insn, rtx *operands)
       && (STACK_TOP_P (operands[1]) || STACK_TOP_P (operands[2])))
     ; /* ok */
   else
-    gcc_assert (is_sse);
-#endif
+    gcc_checking_assert (is_sse);
 
   switch (GET_CODE (operands[3]))
     {
diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c
index 8791138..d92af17 100644
--- a/gcc/config/ia64/ia64.c
+++ b/gcc/config/ia64/ia64.c
@@ -6125,7 +6125,7 @@ struct reg_write_state
 
 /* Cumulative info for the current instruction group.  */
 struct reg_write_state rws_sum[NUM_REGS];
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
 /* Bitmap whether a register has been written in the current insn.  */
 HARD_REG_ELT_TYPE rws_insn[(NUM_REGS + HOST_BITS_PER_WIDEST_FAST_INT - 1)
 			   / HOST_BITS_PER_WIDEST_FAST_INT];
@@ -7293,15 +7293,13 @@ ia64_sched_init (FILE *dump ATTRIBUTE_UNUSED,
 		 int sched_verbose ATTRIBUTE_UNUSED,
 		 int max_ready ATTRIBUTE_UNUSED)
 {
-#ifdef ENABLE_CHECKING
-  rtx_insn *insn;
-
-  if (!sel_sched_p () && reload_completed)
-    for (insn = NEXT_INSN (current_sched_info->prev_head);
+  if (flag_checking && !sel_sched_p () && reload_completed)
+    {
+      for (rtx_insn *insn = NEXT_INSN (current_sched_info->prev_head);
 	   insn != current_sched_info->next_tail;
 	   insn = NEXT_INSN (insn))
 	gcc_assert (!SCHED_GROUP_P (insn));
-#endif
+    }
   last_scheduled_insn = NULL;
   init_insn_group_barriers ();
 
@@ -9299,7 +9297,7 @@ bundling (FILE *dump, int verbose, rtx_insn *prev_head_insn, rtx_insn *tail)
 	}
     }
 
-#ifdef ENABLE_CHECKING
+  if (flag_checking)
     {
       /* Assert right calculation of middle_bundle_stops.  */
       int num = best_state->middle_bundle_stops;
@@ -9332,8 +9330,7 @@ bundling (FILE *dump, int verbose, rtx_insn *prev_head_insn, rtx_insn *tail)
 	      end_bundle = next_insn == NULL_RTX
 		|| next_insn == tail
 		|| (INSN_P (next_insn)
-		 && recog_memoized (next_insn)
-		 == CODE_FOR_bundle_selector);
+		    && recog_memoized (next_insn) == CODE_FOR_bundle_selector);
 	      if (recog_memoized (insn) == CODE_FOR_insn_group_barrier
 		  && !start_bundle && !end_bundle
 		  && next_insn
@@ -9346,7 +9343,6 @@ bundling (FILE *dump, int verbose, rtx_insn *prev_head_insn, rtx_insn *tail)
 
       gcc_assert (num == 0);
     }
-#endif
 
   free (index_to_bundle_states);
   finish_bundle_state_table ();
diff --git a/gcc/config/m68k/m68k.c b/gcc/config/m68k/m68k.c
index bfc19f3..37b1af2 100644
--- a/gcc/config/m68k/m68k.c
+++ b/gcc/config/m68k/m68k.c
@@ -6118,9 +6118,9 @@ m68k_sched_md_init_global (FILE *sched_dump ATTRIBUTE_UNUSED,
 			   int sched_verbose ATTRIBUTE_UNUSED,
 			   int n_insns ATTRIBUTE_UNUSED)
 {
-#ifdef ENABLE_CHECKING
   /* Check that all instructions have DFA reservations and
      that all instructions can be issued from a clean state.  */
+  if (flag_checking)
     {
       rtx_insn *insn;
       state_t state;
@@ -6139,7 +6139,6 @@ m68k_sched_md_init_global (FILE *sched_dump ATTRIBUTE_UNUSED,
 	    }
 	}
     }
-#endif
 
   /* Setup target cpu.  */
 
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index bbdd142..53b86af 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -12906,15 +12906,13 @@ htm_expand_builtin (tree exp, rtx target, bool * expandedp)
 	  case HTM_BUILTIN_TENDALL:  /* Alias for: tend. 1  */
 	  case HTM_BUILTIN_TRESUME:  /* Alias for: tsr. 1  */
 	    op[nopnds++] = GEN_INT (1);
-#ifdef ENABLE_CHECKING
+	    if (flag_checking)
 	      attr |= RS6000_BTC_UNARY;
-#endif
 	    break;
 	  case HTM_BUILTIN_TSUSPEND: /* Alias for: tsr. 0  */
 	    op[nopnds++] = GEN_INT (0);
-#ifdef ENABLE_CHECKING
+	    if (flag_checking)
 	      attr |= RS6000_BTC_UNARY;
-#endif
 	    break;
 	  default:
 	    break;
@@ -12935,7 +12933,8 @@ htm_expand_builtin (tree exp, rtx target, bool * expandedp)
 	    op[nopnds++] = cr;
 	  }
 
-#ifdef ENABLE_CHECKING
+	if (flag_checking)
+	  {
 	    int expected_nopnds = 0;
 	    if ((attr & RS6000_BTC_TYPE_MASK) == RS6000_BTC_UNARY)
 	      expected_nopnds = 1;
@@ -12948,8 +12947,9 @@ htm_expand_builtin (tree exp, rtx target, bool * expandedp)
 	    if (uses_spr)
 	      expected_nopnds += 2;
 
-	gcc_assert (nopnds == expected_nopnds && nopnds <= MAX_HTM_OPERANDS);
-#endif
+	    gcc_assert (nopnds == expected_nopnds
+			&& nopnds <= MAX_HTM_OPERANDS);
+	  }
 
 	switch (nopnds)
 	  {
@@ -24325,7 +24325,7 @@ rs6000_emit_prologue (void)
      prior to it, when r12 is not used here for other purposes.  */
   rtx_insn *sp_adjust = 0;
 
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
   /* Track and check usage of r0, r11, r12.  */
   int reg_inuse = using_static_chain_p ? 1 << 11 : 0;
 #define START_USE(R) do \
diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h
index cad1551..02da097 100644
--- a/gcc/config/rs6000/rs6000.h
+++ b/gcc/config/rs6000/rs6000.h
@@ -1479,15 +1479,10 @@ enum reg_class
 
 extern enum reg_class rs6000_regno_regclass[FIRST_PSEUDO_REGISTER];
 
-#if ENABLE_CHECKING
 #define REGNO_REG_CLASS(REGNO) 						\
-  (gcc_assert (IN_RANGE ((REGNO), 0, FIRST_PSEUDO_REGISTER-1)),		\
+  (gcc_checking_assert (IN_RANGE ((REGNO), 0, FIRST_PSEUDO_REGISTER-1)),\
    rs6000_regno_regclass[(REGNO)])
 
-#else
-#define REGNO_REG_CLASS(REGNO) rs6000_regno_regclass[(REGNO)]
-#endif
-
 /* Register classes for various constraints that are based on the target
    switches.  */
 enum r6000_reg_class_enum {
diff --git a/gcc/config/visium/visium.c b/gcc/config/visium/visium.c
index 5e7b944..d1b580e 100644
--- a/gcc/config/visium/visium.c
+++ b/gcc/config/visium/visium.c
@@ -1338,7 +1338,7 @@ visium_setup_incoming_varargs (cumulative_args_t pcum_v,
   local_args_so_far.p = &local_copy;
   locargs = get_cumulative_args (pcum_v);
 
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
   local_args_so_far.magic = CUMULATIVE_ARGS_MAGIC;
 #endif
 

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 8/9] ENABLE_CHECKING refactoring: target-specific parts
  2015-10-30  4:13   ` Jeff Law
@ 2015-10-30  4:20     ` Jeff Law
  0 siblings, 0 replies; 77+ messages in thread
From: Jeff Law @ 2015-10-30  4:20 UTC (permalink / raw)
  To: Mikhail Maltsev, gcc-patches mailing list, Richard Biener

On 10/29/2015 10:10 PM, Jeff Law wrote:
> On 10/05/2015 05:40 PM, Mikhail Maltsev wrote:
>> gcc/ChangeLog:
>>
>> 2015-10-05  Mikhail Maltsev  <maltsevm@gmail.com>
>>
>>     * config/alpha/alpha.c (alpha_function_arg): Use gcc_checking_assert.
>>     * config/arm/arm.c (arm_unwind_emit_sequence): Adjust to use
>> CHECKING_P.
>>     * config/bfin/bfin.c (hwloop_optimize): Likewise.
>>     * config/i386/i386.c (ix86_print_operand_address,
>>     output_387_binary_op): Likewise.
>>     * config/ia64/ia64.c (ia64_sched_init, bundling): Likewise.
>>     * config/m68k/m68k.c (m68k_sched_md_init_global): Likewise.
>>     * config/rs6000/rs6000.c (htm_expand_builtin, rs6000_emit_prologue):
>>     Likewise.
>>     * config/rs6000/rs6000.h: Likewise.
>>     * config/visium/visium.c (visium_setup_incoming_varargs): Likewise.
One  more note Mikhail.  If you could do another pass on cleaning up 
ENABLE_CHECKING macros it'd be appreciated.

They're still in:
find . -type f -print | xargs grep ENABLE_CHECKING | grep -v ChangeLog
./config.in:#undef ENABLE_CHECKING
./c-family/c-omp.c:#ifdef ENABLE_CHECKING
./tree-ssa-loop-manip.c:#ifdef ENABLE_CHECKING
./genconditions.c:#undef ENABLE_CHECKING\n\
./configure.ac:  AC_DEFINE(ENABLE_CHECKING, 1,
./configure:$as_echo "#define ENABLE_CHECKING 1" >>confdefs.h
./cp/tree.c:#ifdef ENABLE_CHECKING
./cp/parser.c:#ifdef ENABLE_CHECKING
./cp/mangle.c:#if ENABLE_CHECKING
./cp/mangle.c:#endif /* ENABLE_CHECKING */
./cp/method.c:#ifdef ENABLE_CHECKING
./cp/typeck.c:#ifdef ENABLE_CHECKING
./cp/constexpr.c:#ifdef ENABLE_CHECKING
./cp/constexpr.c:#ifdef ENABLE_CHECKING
./cp/call.c:#ifdef ENABLE_CHECKING
./cp/call.c:#endif /* ENABLE_CHECKING */
./cp/decl2.c:#ifdef ENABLE_CHECKING
./cp/decl2.c:#endif /* ENABLE_CHECKING */
./cp/typeck2.c:#ifdef ENABLE_CHECKING
./cp/pt.c:#ifdef ENABLE_CHECKING
./cp/pt.c:#ifdef ENABLE_CHECKING
./cp/pt.c:#ifdef ENABLE_CHECKING
./cp/pt.c:#ifdef ENABLE_CHECKING
./cp/pt.c:#ifdef ENABLE_CHECKING
./cp/pt.c:#ifdef ENABLE_CHECKING
./cp/pt.c:      /* We shouldn't get here, but keep going if 
!ENABLE_CHECKING.  */
./cp/pt.c:#ifdef ENABLE_CHECKING
./cp/pt.c:#ifdef ENABLE_CHECKING
./cp/cp-tree.h:#ifdef ENABLE_CHECKING
./cp/cp-tree.h:#ifdef ENABLE_CHECKING
./cp/cp-tree.h:#endif /* ENABLE_CHECKING */
./sese.h:#ifdef ENABLE_CHECKING
./cfganal.c:#if ENABLE_CHECKING


Then we can go through the #if CHECKING_P stuff and see what can/should 
be converted to a runtime test.  Then sort out the right form of the 
flag_checking test we want to use to get the __builtin_expect bits the 
way we want.

Thanks again for your effort on this work.  It is greatly appreciated.

jeff

^ permalink raw reply	[flat|nested] 77+ messages in thread

* [PATCH 9/9] ENABLE_CHECKING refactoring: C family front ends
  2015-10-05 23:27 [PATCH 1/9] ENABLE_CHECKING refactoring Mikhail Maltsev
                   ` (9 preceding siblings ...)
  2015-10-13 21:33 ` Jeff Law
@ 2015-11-01 14:58 ` Mikhail Maltsev
  2015-11-02 23:34   ` Jeff Law
  2015-11-01 20:19 ` [PATCH 10/9] ENABLE_CHECKING refactoring: remove remaining occurrences Mikhail Maltsev
  11 siblings, 1 reply; 77+ messages in thread
From: Mikhail Maltsev @ 2015-11-01 14:58 UTC (permalink / raw)
  To: gcc-patches mailing list, Jason Merrill, Richard Biener, Jeff Law

[-- Attachment #1: Type: text/plain, Size: 2754 bytes --]

Hi all!

This patch was intended to be the last one in this series (but I'll send one
more cleanup patch today). It removes ENABLE_CHECKING macros in the C++ front
end (and also touches a small piece of common C family code in OpenMP).

I could convert most of "#ifdef ENABLE_CHECKING" conditions into checks
performed at run time (i.e. flag_checking), except for
GET_NON_DEFAULT_TEMPLATE_ARGS_COUNT logic. The definition of this macro depends
on ENABLE_CHECKING (now CHECKING_P) and frankly speaking I don't know how these
checks should work (though I did not try hard to understand the details, I hope
Jason will give some comments), so I left them as-is, just got rid of
conditional compilation (i.e., used CHECKING_P).

Also, the patch renames 'check_unstripped_args' into 'verify_unstripped_args'
because I think it's more consistent with names of other internal state checking
functions.

Bootstrapped and regtested on x86_64-pc-linux-gnu with --enable-checking=yes and
--enable-checking=release. (there were some problems with languages other than C
and C++, not related to the patch, but ISTM they were fixed, so I'm currently
running a second check after rebasing).

OK for trunk?

-- 
Regards,
    Mikhail Maltsev

gcc/c-family/ChangeLog:

2015-10-31  Mikhail Maltsev  <maltsevm@gmail.com>

        * c-omp.c (c_omp_split_clauses): Remove conditional compilation. Use
        flag_checking.

gcc/cp/ChangeLog:

2015-10-31  Mikhail Maltsev  <maltsevm@gmail.com>

        * call.c (validate_conversion_obstack): Define unconditionally.
        * constexpr.c (maybe_constant_value, fold_non_dependent_expr): Use
        gcc_checking_assert.
        * cp-tree.h: Use CHECKING_P instead of ENABLE_CHECKING.
        * decl2.c (cxx_post_compilation_parsing_cleanups): Use flag_checking.
        * mangle.c (add_substitution): Likewise.
        * method.c (maybe_explain_implicit_delete): Likewise.
        * parser.c (cp_parser_template_argument_list): Remove conditional
        compilation.
        * pt.c (check_unstripped_args): Rename to...
        (verify_unstripped_args): ...this and remove conditional compilation.
        (retrieve_specialization): Guard call of verify_unstripped_args with
        flag_checking.
        (template_parm_to_arg): Remove conditional compilation.
        (template_parms_to_args, coerce_template_parameter_pack,
        coerce_template_parms): Likewise.
        (tsubst_copy): Use flag_checking.
        (type_unification_real): Remove conditional compilation.
        (build_non_dependent_expr): Use flag_checking.
        * tree.c (build_target_expr): Remove conditional compilation, use
        gcc_checking_assert.
        * typeck.c (comptypes): Likewise.
        * typeck2.c (digest_init_r): Likewise.



[-- Attachment #2: flag_checking_cfamily.patch --]
[-- Type: text/x-patch, Size: 13332 bytes --]

diff --git a/gcc/c-family/c-omp.c b/gcc/c-family/c-omp.c
index 133d079..ca64eda 100644
--- a/gcc/c-family/c-omp.c
+++ b/gcc/c-family/c-omp.c
@@ -1135,7 +1135,10 @@ c_omp_split_clauses (location_t loc, enum tree_code code,
       OMP_CLAUSE_CHAIN (clauses) = cclauses[s];
       cclauses[s] = clauses;
     }
-#ifdef ENABLE_CHECKING
+
+  if (!flag_checking)
+    return;
+
   if ((mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_MAP)) == 0)
     gcc_assert (cclauses[C_OMP_CLAUSE_SPLIT_TARGET] == NULL_TREE);
   if ((mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NUM_TEAMS)) == 0)
@@ -1150,7 +1153,6 @@ c_omp_split_clauses (location_t loc, enum tree_code code,
     gcc_assert (cclauses[C_OMP_CLAUSE_SPLIT_FOR] == NULL_TREE);
   if (code != OMP_SIMD)
     gcc_assert (cclauses[C_OMP_CLAUSE_SPLIT_SIMD] == NULL_TREE);
-#endif
 }
 
 
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 9178188..0b7d143 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -724,8 +724,6 @@ alloc_conversion (conversion_kind kind)
   return c;
 }
 
-#ifdef ENABLE_CHECKING
-
 /* Make sure that all memory on the conversion obstack has been
    freed.  */
 
@@ -737,8 +735,6 @@ validate_conversion_obstack (void)
 		 == obstack_base (&conversion_obstack)));
 }
 
-#endif /* ENABLE_CHECKING */
-
 /* Dynamically allocate an array of N conversions.  */
 
 static conversion **
diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index 038c6f5..51fae5a 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -3856,13 +3856,11 @@ maybe_constant_value (tree t, tree decl)
     }
 
   r = cxx_eval_outermost_constant_expr (t, true, true, decl);
-#ifdef ENABLE_CHECKING
-  gcc_assert (r == t
-	      || CONVERT_EXPR_P (t)
-	      || TREE_CODE (t) == VIEW_CONVERT_EXPR
-	      || (TREE_CONSTANT (t) && !TREE_CONSTANT (r))
-	      || !cp_tree_equal (r, t));
-#endif
+  gcc_checking_assert (r == t
+		       || CONVERT_EXPR_P (t)
+		       || TREE_CODE (t) == VIEW_CONVERT_EXPR
+		       || (TREE_CONSTANT (t) && !TREE_CONSTANT (r))
+		       || !cp_tree_equal (r, t));
   return r;
 }
 
@@ -3906,14 +3904,12 @@ fold_non_dependent_expr (tree t)
 	    }
 
 	  tree r = cxx_eval_outermost_constant_expr (t, true, true, NULL_TREE);
-#ifdef ENABLE_CHECKING
 	  /* cp_tree_equal looks through NOPs, so allow them.  */
-	  gcc_assert (r == t
-		      || CONVERT_EXPR_P (t)
-		      || TREE_CODE (t) == VIEW_CONVERT_EXPR
-		      || (TREE_CONSTANT (t) && !TREE_CONSTANT (r))
-		      || !cp_tree_equal (r, t));
-#endif
+	  gcc_checking_assert (r == t
+			       || CONVERT_EXPR_P (t)
+			       || TREE_CODE (t) == VIEW_CONVERT_EXPR
+			       || (TREE_CONSTANT (t) && !TREE_CONSTANT (r))
+			       || !cp_tree_equal (r, t));
 	  return r;
 	}
       else if (TREE_OVERFLOW_P (t))
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index adb4bae..3c54e76 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -3010,7 +3010,7 @@ extern void decl_shadowed_for_var_insert (tree, tree);
    property.  */
 #define SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT(NODE, INT_VALUE) \
   NON_DEFAULT_TEMPLATE_ARGS_COUNT(NODE) = build_int_cst (NULL_TREE, INT_VALUE)
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
 #define GET_NON_DEFAULT_TEMPLATE_ARGS_COUNT(NODE) \
     int_cst_value (NON_DEFAULT_TEMPLATE_ARGS_COUNT (NODE))
 #else
@@ -5517,9 +5517,7 @@ extern tree build_cxx_call			(tree, int, tree *,
 						 tsubst_flags_t);
 extern bool is_std_init_list			(tree);
 extern bool is_list_ctor			(tree);
-#ifdef ENABLE_CHECKING
 extern void validate_conversion_obstack		(void);
-#endif /* ENABLE_CHECKING */
 extern void mark_versions_used			(tree);
 extern tree get_function_version_dispatcher	(tree);
 
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 01d4607..23f59eb 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -4923,9 +4923,8 @@ cxx_post_compilation_parsing_cleanups (void)
 
   input_location = locus_at_end_of_parsing;
 
-#ifdef ENABLE_CHECKING
-  validate_conversion_obstack ();
-#endif /* ENABLE_CHECKING */
+  if (flag_checking)
+    validate_conversion_obstack ();
 
   timevar_stop (TV_PHASE_LATE_PARSING_CLEANUPS);
 }
diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c
index b6b9f38..182e605 100644
--- a/gcc/cp/mangle.c
+++ b/gcc/cp/mangle.c
@@ -396,20 +396,19 @@ add_substitution (tree node)
 	     get_tree_code_name (TREE_CODE (node)), (void *) node);
   node = c;
 
-#if ENABLE_CHECKING
   /* Make sure NODE isn't already a candidate.  */
-  {
-    int i;
-    tree candidate;
+  if (flag_checking)
+    {
+      int i;
+      tree candidate;
 
-    FOR_EACH_VEC_SAFE_ELT (G.substitutions, i, candidate)
-      {
-	gcc_assert (!(DECL_P (node) && node == candidate));
-	gcc_assert (!(TYPE_P (node) && TYPE_P (candidate)
+      FOR_EACH_VEC_SAFE_ELT (G.substitutions, i, candidate)
+	{
+	  gcc_assert (!(DECL_P (node) && node == candidate));
+	  gcc_assert (!(TYPE_P (node) && TYPE_P (candidate)
 		      && same_type_p (node, candidate)));
-      }
-  }
-#endif /* ENABLE_CHECKING */
+	}
+    }
 
   /* Put the decl onto the varray of substitution candidates.  */
   vec_safe_push (G.substitutions, node);
diff --git a/gcc/cp/method.c b/gcc/cp/method.c
index 4de6cc2..97643b7 100644
--- a/gcc/cp/method.c
+++ b/gcc/cp/method.c
@@ -1645,10 +1645,8 @@ maybe_explain_implicit_delete (tree decl)
 		    "deleted because its exception-specification does not "
 		    "match the implicit exception-specification %qX",
 		    decl, raises);
-#ifdef ENABLE_CHECKING
-	  else
+	  else if (flag_checking)
 	    gcc_unreachable ();
-#endif
 
 	  pop_scope (scope);
 	}
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 19e306d..613ed6e 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -14854,9 +14854,8 @@ cp_parser_template_argument_list (cp_parser* parser)
   parser->non_integral_constant_expression_p = saved_non_ice_p;
   parser->integral_constant_expression_p = saved_ice_p;
   parser->in_template_argument_list_p = saved_in_template_argument_list_p;
-#ifdef ENABLE_CHECKING
-  SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT (vec, TREE_VEC_LENGTH (vec));
-#endif
+  if (CHECKING_P)
+    SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT (vec, TREE_VEC_LENGTH (vec));
   return vec;
 }
 
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index e836ec7..afb33ce 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -1134,9 +1134,8 @@ optimize_specialization_lookup_p (tree tmpl)
    gone through coerce_template_parms by now.  */
 
 static void
-check_unstripped_args (tree args ATTRIBUTE_UNUSED)
+verify_unstripped_args (tree args)
 {
-#ifdef ENABLE_CHECKING
   ++processing_template_decl;
   if (!any_dependent_template_arguments_p (args))
     {
@@ -1156,7 +1155,6 @@ check_unstripped_args (tree args ATTRIBUTE_UNUSED)
 	}
     }
   --processing_template_decl;
-#endif
 }
 
 /* Retrieve the specialization (in the sense of [temp.spec] - a
@@ -1192,7 +1190,8 @@ retrieve_specialization (tree tmpl, tree args, hashval_t hash)
 		  ? TMPL_PARMS_DEPTH (DECL_TEMPLATE_PARMS (tmpl))
 		  : template_class_depth (DECL_CONTEXT (tmpl))));
 
-  check_unstripped_args (args);
+  if (flag_checking)
+    verify_unstripped_args (args);
 
   if (optimize_specialization_lookup_p (tmpl))
     {
@@ -4201,10 +4200,9 @@ template_parm_to_arg (tree t)
 	  /* Turn this argument into a TYPE_ARGUMENT_PACK
 	     with a single element, which expands T.  */
 	  tree vec = make_tree_vec (1);
-#ifdef ENABLE_CHECKING
-	  SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT
-	    (vec, TREE_VEC_LENGTH (vec));
-#endif
+	  if (CHECKING_P)
+	    SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT (vec, TREE_VEC_LENGTH (vec));
+
 	  TREE_VEC_ELT (vec, 0) = make_pack_expansion (t);
 
 	  t = cxx_make_type (TYPE_ARGUMENT_PACK);
@@ -4221,10 +4219,9 @@ template_parm_to_arg (tree t)
 	     with a single element, which expands T.  */
 	  tree vec = make_tree_vec (1);
 	  tree type = TREE_TYPE (TEMPLATE_PARM_DECL (t));
-#ifdef ENABLE_CHECKING
-	  SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT
-	    (vec, TREE_VEC_LENGTH (vec));
-#endif
+	  if (CHECKING_P)
+	    SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT (vec, TREE_VEC_LENGTH (vec));
+
 	  t = convert_from_reference (t);
 	  TREE_VEC_ELT (vec, 0) = make_pack_expansion (t);
 
@@ -4265,9 +4262,8 @@ template_parms_to_args (tree parms)
       for (i = TREE_VEC_LENGTH (a) - 1; i >= 0; --i)
 	TREE_VEC_ELT (a, i) = template_parm_to_arg (TREE_VEC_ELT (a, i));
 
-#ifdef ENABLE_CHECKING
-      SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT (a, TREE_VEC_LENGTH (a));
-#endif
+      if (CHECKING_P)
+	SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT (a, TREE_VEC_LENGTH (a));
 
       if (length > 1)
 	TREE_VEC_ELT (args, --l) = a;
@@ -7385,10 +7381,9 @@ coerce_template_parameter_pack (tree parms,
     }
 
   SET_ARGUMENT_PACK_ARGS (argument_pack, packed_args);
-#ifdef ENABLE_CHECKING
-  SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT (packed_args,
-				       TREE_VEC_LENGTH (packed_args));
-#endif
+  if (CHECKING_P)
+    SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT (packed_args,
+					 TREE_VEC_LENGTH (packed_args));
   return argument_pack;
 }
 
@@ -7695,11 +7690,9 @@ coerce_template_parms (tree parms,
   if (lost)
     return error_mark_node;
 
-#ifdef ENABLE_CHECKING
-  if (!NON_DEFAULT_TEMPLATE_ARGS_COUNT (new_inner_args))
+  if (CHECKING_P && !NON_DEFAULT_TEMPLATE_ARGS_COUNT (new_inner_args))
     SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT (new_inner_args,
 					 TREE_VEC_LENGTH (new_inner_args));
-#endif
 
   return new_inner_args;
 }
@@ -14279,8 +14272,9 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl)
       return tsubst_binary_right_fold (t, args, complain, in_decl);
 
     default:
-      /* We shouldn't get here, but keep going if !ENABLE_CHECKING.  */
-      gcc_checking_assert (false);
+      /* We shouldn't get here, but keep going if !flag_checking.  */
+      if (!flag_checking)
+	gcc_unreachable ();
       return t;
     }
 }
@@ -18188,10 +18182,9 @@ type_unification_real (tree tparms,
       if (saw_undeduced++ == 1)
 	goto again;
     }
-#ifdef ENABLE_CHECKING
-  if (!NON_DEFAULT_TEMPLATE_ARGS_COUNT (targs))
+
+  if (CHECKING_P && !NON_DEFAULT_TEMPLATE_ARGS_COUNT (targs))
     SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT (targs, TREE_VEC_LENGTH (targs));
-#endif
 
   return unify_success (explain_p);
 }
@@ -23239,12 +23232,10 @@ build_non_dependent_expr (tree expr)
 {
   tree inner_expr;
 
-#ifdef ENABLE_CHECKING
   /* Try to get a constant value for all non-dependent expressions in
       order to expose bugs in *_dependent_expression_p and constexpr.  */
-  if (cxx_dialect >= cxx11)
+  if (flag_checking && cxx_dialect >= cxx11)
     fold_non_dependent_expr (expr);
-#endif
 
   /* Preserve OVERLOADs; the functions must be available to resolve
      types.  */
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 11bd129..4311212 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -321,15 +321,13 @@ build_target_expr (tree decl, tree value, tsubst_flags_t complain)
   tree t;
   tree type = TREE_TYPE (decl);
 
-#ifdef ENABLE_CHECKING
-  gcc_assert (VOID_TYPE_P (TREE_TYPE (value))
-	      || TREE_TYPE (decl) == TREE_TYPE (value)
-	      /* On ARM ctors return 'this'.  */
-	      || (TYPE_PTR_P (TREE_TYPE (value))
-		  && TREE_CODE (value) == CALL_EXPR)
-	      || useless_type_conversion_p (TREE_TYPE (decl),
-					    TREE_TYPE (value)));
-#endif
+  gcc_checking_assert (VOID_TYPE_P (TREE_TYPE (value))
+		       || TREE_TYPE (decl) == TREE_TYPE (value)
+		       /* On ARM ctors return 'this'.  */
+		       || (TYPE_PTR_P (TREE_TYPE (value))
+			   && TREE_CODE (value) == CALL_EXPR)
+		       || useless_type_conversion_p (TREE_TYPE (decl),
+						     TREE_TYPE (value)));
 
   t = cxx_maybe_build_cleanup (decl, complain);
   if (t == error_mark_node)
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index e68e9df..0501e4d 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -1418,8 +1418,7 @@ comptypes (tree t1, tree t2, int strict)
 	   perform a deep check. */
 	return structural_comptypes (t1, t2, strict);
 
-#ifdef ENABLE_CHECKING
-      if (USE_CANONICAL_TYPES)
+      if (flag_checking && USE_CANONICAL_TYPES)
 	{
 	  bool result = structural_comptypes (t1, t2, strict);
 	  
@@ -1440,10 +1439,8 @@ comptypes (tree t1, tree t2, int strict)
 	  
 	  return result;
 	}
-#else
-      if (USE_CANONICAL_TYPES)
+      if (!flag_checking && USE_CANONICAL_TYPES)
 	return TYPE_CANONICAL (t1) == TYPE_CANONICAL (t2);
-#endif
       else
 	return structural_comptypes (t1, t2, strict);
     }
diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
index b717ea9..000f5e3 100644
--- a/gcc/cp/typeck2.c
+++ b/gcc/cp/typeck2.c
@@ -1075,11 +1075,11 @@ digest_init_r (tree type, tree init, bool nested, int flags,
 	      || TREE_CODE (type) == UNION_TYPE
 	      || TREE_CODE (type) == COMPLEX_TYPE);
 
-#ifdef ENABLE_CHECKING
   /* "If T is a class type and the initializer list has a single
      element of type cv U, where U is T or a class derived from T,
      the object is initialized from that element."  */
-  if (cxx_dialect >= cxx11
+  if (flag_checking
+      && cxx_dialect >= cxx11
       && BRACE_ENCLOSED_INITIALIZER_P (init)
       && CONSTRUCTOR_NELTS (init) == 1
       && ((CLASS_TYPE_P (type) && !CLASSTYPE_NON_AGGREGATE (type))
@@ -1090,7 +1090,6 @@ digest_init_r (tree type, tree init, bool nested, int flags,
 	/* We should have fixed this in reshape_init.  */
 	gcc_unreachable ();
     }
-#endif
 
   if (BRACE_ENCLOSED_INITIALIZER_P (init)
       && !TYPE_NON_AGGREGATE_CLASS (type))


^ permalink raw reply	[flat|nested] 77+ messages in thread

* [PATCH 10/9] ENABLE_CHECKING refactoring: remove remaining occurrences
  2015-10-05 23:27 [PATCH 1/9] ENABLE_CHECKING refactoring Mikhail Maltsev
                   ` (10 preceding siblings ...)
  2015-11-01 14:58 ` [PATCH 9/9] ENABLE_CHECKING refactoring: C family front ends Mikhail Maltsev
@ 2015-11-01 20:19 ` Mikhail Maltsev
  2015-11-02 23:35   ` Jeff Law
       [not found]   ` <C5BB0125-FB5F-46C6-B16D-74C3D0F07C10@gmail.com>
  11 siblings, 2 replies; 77+ messages in thread
From: Mikhail Maltsev @ 2015-11-01 20:19 UTC (permalink / raw)
  To: gcc-patches mailing list, Jeff Law, Richard Biener

[-- Attachment #1: Type: text/plain, Size: 1067 bytes --]

This patch cleans up remaining bits related to ENABLE_CHECKING. After applying
this patch (on top of part 9) we will no longer have any references to
ENABLE_CHECKING in the source code.

Bootstrapped and regtested (on top of part 9) on x86_64-pc-linux-gnu with
--enable-checking=yes and --enable-checking=release.

libcpp/ChangeLog:

2015-11-01  Mikhail Maltsev  <maltsevm@gmail.com>

        * config.in: Regenerate.
        * configure: Regenerate.
        * configure.ac: Remove ENABLE_CHECKING.

gcc/ChangeLog:

2015-11-01  Mikhail Maltsev  <maltsevm@gmail.com>

        * cfganal.c (inverted_post_order_compute): Remove conditional
        compilation, use flag_checking.
        * config.in: Regenerate.
        * configure: Regenerate.
        * configure.ac: Remove ENABLE_CHECKING.
        * genconditions.c: Do not #undef ENABLE_CHECKING.
        * sese.h (bb_in_region): Comment out broken check.
        * tree-ssa-loop-manip.c (rewrite_into_loop_closed_ssa_1): Remove
        conditional compilation, use flag_checking.

-- 
Regards,
    Mikhail Maltsev

[-- Attachment #2: enable_checking_rest.patch --]
[-- Type: text/x-patch, Size: 5507 bytes --]

diff --git a/gcc/cfganal.c b/gcc/cfganal.c
index 6f3e348..0f26038 100644
--- a/gcc/cfganal.c
+++ b/gcc/cfganal.c
@@ -784,9 +784,8 @@ inverted_post_order_compute (int *post_order)
   int post_order_num = 0;
   sbitmap visited;
 
-#if ENABLE_CHECKING
-  verify_no_unreachable_blocks ();
-#endif
+  if (flag_checking)
+    verify_no_unreachable_blocks ();
 
   /* Allocate stack for back-tracking up CFG.  */
   stack = XNEWVEC (edge_iterator, n_basic_blocks_for_fn (cfun) + 1);
diff --git a/gcc/config.in b/gcc/config.in
index 48d7e64..6f46f70 100644
--- a/gcc/config.in
+++ b/gcc/config.in
@@ -76,13 +76,6 @@
 #endif
 
 
-/* Define if you want more run-time sanity checks. This one gets a grab bag of
-   miscellaneous but relatively cheap checks. */
-#ifndef USED_FOR_TARGET
-#undef ENABLE_CHECKING
-#endif
-
-
 /* Define to 1 to specify that we are using the BID decimal floating point
    format instead of DPD */
 #ifndef USED_FOR_TARGET
diff --git a/gcc/configure b/gcc/configure
index 92bda6c..1d2e8f2 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -7098,9 +7098,6 @@ IFS="$ac_save_IFS"
 nocommon_flag=""
 if test x$ac_checking != x ; then
 
-$as_echo "#define ENABLE_CHECKING 1" >>confdefs.h
-
-
 $as_echo "#define CHECKING_P 1" >>confdefs.h
 
   nocommon_flag=-fno-common
@@ -18405,7 +18402,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 18408 "configure"
+#line 18405 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -18511,7 +18508,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 18514 "configure"
+#line 18511 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 7e22267..d03a0bd 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -566,9 +566,6 @@ IFS="$ac_save_IFS"
 
 nocommon_flag=""
 if test x$ac_checking != x ; then
-  AC_DEFINE(ENABLE_CHECKING, 1,
-[Define if you want more run-time sanity checks.  This one gets a grab
-   bag of miscellaneous but relatively cheap checks.])
   AC_DEFINE(CHECKING_P, 1,
 [Define to 1 if you want more run-time sanity checks.  This one gets a grab
    bag of miscellaneous but relatively cheap checks.])
diff --git a/gcc/genconditions.c b/gcc/genconditions.c
index 7481ab4..dd5bc92 100644
--- a/gcc/genconditions.c
+++ b/gcc/genconditions.c
@@ -59,7 +59,6 @@ write_header (void)
 #if GCC_VERSION >= 3001\n\
 \n\
 /* Do not allow checking to confuse the issue.  */\n\
-#undef ENABLE_CHECKING\n\
 #undef CHECKING_P\n\
 #define CHECKING_P 0\n\
 #undef ENABLE_TREE_CHECKING\n\
diff --git a/gcc/sese.h b/gcc/sese.h
index d2ad9bd..98ab491 100644
--- a/gcc/sese.h
+++ b/gcc/sese.h
@@ -108,16 +108,18 @@ sese_nb_params (sese_info_p region)
 static inline bool
 bb_in_region (basic_block bb, basic_block entry, basic_block exit)
 {
-#ifdef ENABLE_CHECKING
-  {
-    edge e;
-    edge_iterator ei;
-
-    /* Check that there are no edges coming in the region: all the
-       predecessors of EXIT are dominated by ENTRY.  */
-    FOR_EACH_EDGE (e, ei, exit->preds)
-      dominated_by_p (CDI_DOMINATORS, e->src, entry);
-  }
+  /* FIXME: PR67842.  */
+#if 0
+  if (flag_checking)
+    {
+      edge e;
+      edge_iterator ei;
+
+      /* Check that there are no edges coming in the region: all the
+	 predecessors of EXIT are dominated by ENTRY.  */
+      FOR_EACH_EDGE (e, ei, exit->preds)
+	gcc_assert (dominated_by_p (CDI_DOMINATORS, e->src, entry));
+    }
 #endif
 
   return dominated_by_p (CDI_DOMINATORS, bb, entry)
diff --git a/gcc/tree-ssa-loop-manip.c b/gcc/tree-ssa-loop-manip.c
index db797cc..b614412 100644
--- a/gcc/tree-ssa-loop-manip.c
+++ b/gcc/tree-ssa-loop-manip.c
@@ -616,14 +616,10 @@ rewrite_into_loop_closed_ssa_1 (bitmap changed_bbs, unsigned update_flag,
 
   /* If the pass has caused the SSA form to be out-of-date, update it
      now.  */
-  if (update_flag == 0)
-    {
-#ifdef ENABLE_CHECKING
-      verify_ssa (true, true);
-#endif
-    }
-  else
+  if (update_flag != 0)
     update_ssa (update_flag);
+  else if (flag_checking)
+    verify_ssa (true, true);
 
   bitmap_obstack_initialize (&loop_renamer_obstack);
 
diff --git a/libcpp/config.in b/libcpp/config.in
index 5865eb3..e02ac5e 100644
--- a/libcpp/config.in
+++ b/libcpp/config.in
@@ -17,9 +17,6 @@
 /* Define to enable system headers canonicalization. */
 #undef ENABLE_CANONICAL_SYSTEM_HEADERS
 
-/* Define if you want more run-time sanity checks. */
-#undef ENABLE_CHECKING
-
 /* Define to 1 if translation of program messages to the user's native
    language is requested. */
 #undef ENABLE_NLS
diff --git a/libcpp/configure b/libcpp/configure
index 1c70c75..0342f16 100755
--- a/libcpp/configure
+++ b/libcpp/configure
@@ -7298,9 +7298,7 @@ IFS="$ac_save_IFS"
 
 if test x$ac_checking != x ; then
 
-$as_echo "#define ENABLE_CHECKING 1" >>confdefs.h
-
-  $as_echo "#define CHECKING_P 1" >>confdefs.h
+$as_echo "#define CHECKING_P 1" >>confdefs.h
 
 else
   $as_echo "#define CHECKING_P 0" >>confdefs.h
diff --git a/libcpp/configure.ac b/libcpp/configure.ac
index 3fcbe84..0005c58 100644
--- a/libcpp/configure.ac
+++ b/libcpp/configure.ac
@@ -164,8 +164,6 @@ done
 IFS="$ac_save_IFS"
                 
 if test x$ac_checking != x ; then
-  AC_DEFINE(ENABLE_CHECKING, 1,
-[Define if you want more run-time sanity checks.])
   AC_DEFINE(CHECKING_P, 1,
 [Define to 1 if you want more run-time sanity checks.])
 else

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 9/9] ENABLE_CHECKING refactoring: C family front ends
  2015-11-01 14:58 ` [PATCH 9/9] ENABLE_CHECKING refactoring: C family front ends Mikhail Maltsev
@ 2015-11-02 23:34   ` Jeff Law
  2015-11-04 14:41     ` Mikhail Maltsev
  0 siblings, 1 reply; 77+ messages in thread
From: Jeff Law @ 2015-11-02 23:34 UTC (permalink / raw)
  To: Mikhail Maltsev, gcc-patches mailing list, Jason Merrill, Richard Biener

On 11/01/2015 07:58 AM, Mikhail Maltsev wrote:
> Hi all!
>
> This patch was intended to be the last one in this series (but I'll send one
> more cleanup patch today). It removes ENABLE_CHECKING macros in the C++ front
> end (and also touches a small piece of common C family code in OpenMP).
>
> I could convert most of "#ifdef ENABLE_CHECKING" conditions into checks
> performed at run time (i.e. flag_checking), except for
> GET_NON_DEFAULT_TEMPLATE_ARGS_COUNT logic. The definition of this macro depends
> on ENABLE_CHECKING (now CHECKING_P) and frankly speaking I don't know how these
> checks should work (though I did not try hard to understand the details, I hope
> Jason will give some comments), so I left them as-is, just got rid of
> conditional compilation (i.e., used CHECKING_P).
>
> Also, the patch renames 'check_unstripped_args' into 'verify_unstripped_args'
> because I think it's more consistent with names of other internal state checking
> functions.
>
> Bootstrapped and regtested on x86_64-pc-linux-gnu with --enable-checking=yes and
> --enable-checking=release. (there were some problems with languages other than C
> and C++, not related to the patch, but ISTM they were fixed, so I'm currently
> running a second check after rebasing).
>

> @@ -14279,8 +14272,9 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl)
>         return tsubst_binary_right_fold (t, args, complain, in_decl);
>
>       default:
> -      /* We shouldn't get here, but keep going if !ENABLE_CHECKING.  */
> -      gcc_checking_assert (false);
> +      /* We shouldn't get here, but keep going if !flag_checking.  */
> +      if (!flag_checking)
> +	gcc_unreachable ();
>         return t;
>       }
>   }
I think this condition was reversed, right?

Please fix that and install on the trunk.

Thanks again!

jeff

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 10/9] ENABLE_CHECKING refactoring: remove remaining occurrences
  2015-11-01 20:19 ` [PATCH 10/9] ENABLE_CHECKING refactoring: remove remaining occurrences Mikhail Maltsev
@ 2015-11-02 23:35   ` Jeff Law
  2015-11-04 15:03     ` Mikhail Maltsev
       [not found]   ` <C5BB0125-FB5F-46C6-B16D-74C3D0F07C10@gmail.com>
  1 sibling, 1 reply; 77+ messages in thread
From: Jeff Law @ 2015-11-02 23:35 UTC (permalink / raw)
  To: Mikhail Maltsev, gcc-patches mailing list, Richard Biener

On 11/01/2015 01:19 PM, Mikhail Maltsev wrote:
> This patch cleans up remaining bits related to ENABLE_CHECKING. After applying
> this patch (on top of part 9) we will no longer have any references to
> ENABLE_CHECKING in the source code.
>
> Bootstrapped and regtested (on top of part 9) on x86_64-pc-linux-gnu with
> --enable-checking=yes and --enable-checking=release.
>
> libcpp/ChangeLog:
>
> 2015-11-01  Mikhail Maltsev  <maltsevm@gmail.com>
>
>          * config.in: Regenerate.
>          * configure: Regenerate.
>          * configure.ac: Remove ENABLE_CHECKING.
>
> gcc/ChangeLog:
>
> 2015-11-01  Mikhail Maltsev  <maltsevm@gmail.com>
>
>          * cfganal.c (inverted_post_order_compute): Remove conditional
>          compilation, use flag_checking.
>          * config.in: Regenerate.
>          * configure: Regenerate.
>          * configure.ac: Remove ENABLE_CHECKING.
>          * genconditions.c: Do not #undef ENABLE_CHECKING.
>          * sese.h (bb_in_region): Comment out broken check.
>          * tree-ssa-loop-manip.c (rewrite_into_loop_closed_ssa_1): Remove
>          conditional compilation, use flag_checking.
>
This is good fore the trunk too.  Please install.

Thanks!

jeff

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 9/9] ENABLE_CHECKING refactoring: C family front ends
  2015-11-02 23:34   ` Jeff Law
@ 2015-11-04 14:41     ` Mikhail Maltsev
  0 siblings, 0 replies; 77+ messages in thread
From: Mikhail Maltsev @ 2015-11-04 14:41 UTC (permalink / raw)
  To: Jeff Law, gcc-patches mailing list, Jason Merrill, Richard Biener

On 11/03/2015 02:34 AM, Jeff Law wrote:
> 
>> @@ -14279,8 +14272,9 @@ tsubst_copy (tree t, tree args, tsubst_flags_t
>> complain, tree in_decl)
>>         return tsubst_binary_right_fold (t, args, complain, in_decl);
>>
>>       default:
>> -      /* We shouldn't get here, but keep going if !ENABLE_CHECKING.  */
>> -      gcc_checking_assert (false);
>> +      /* We shouldn't get here, but keep going if !flag_checking.  */
>> +      if (!flag_checking)
>> +    gcc_unreachable ();
>>         return t;
>>       }
>>   }
> I think this condition was reversed, right?
> 
> Please fix that and install on the trunk.
> 
> Thanks again!
> 
> jeff

Fixed and committed as r229756.

-- 
Regards,
    Mikhail Maltsev

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 10/9] ENABLE_CHECKING refactoring: remove remaining occurrences
  2015-11-02 23:35   ` Jeff Law
@ 2015-11-04 15:03     ` Mikhail Maltsev
  2016-02-23 15:21       ` Richard Biener
  0 siblings, 1 reply; 77+ messages in thread
From: Mikhail Maltsev @ 2015-11-04 15:03 UTC (permalink / raw)
  To: Jeff Law, gcc-patches mailing list, Richard Biener

On 11/03/2015 02:35 AM, Jeff Law wrote:
> This is good fore the trunk too.  Please install.
> 
> Thanks!
> 
> jeff

Committed as r229758.

-- 
Regards,
    Mikhail Maltsev

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 1/9] ENABLE_CHECKING refactoring
  2015-10-21 16:28               ` Jeff Law
@ 2015-11-07 22:42                 ` Gerald Pfeifer
  0 siblings, 0 replies; 77+ messages in thread
From: Gerald Pfeifer @ 2015-11-07 22:42 UTC (permalink / raw)
  To: Jeff Law
  Cc: Richard Biener, Bernd Schmidt, Mikhail Maltsev, gcc-patches mailing list

On Wed, 21 Oct 2015, Jeff Law wrote:
> I might even claim it's already helping.  While we're still seeing 
> syntax errors in the conditionally compiled code, it doesn't feel like 
> we're seeing it as often as in the past.  That's purely anecdotal based 
> on what I've seen fly by over the last couple years.

In the past, when I was offline (or at least off GCC) for two weeks, 
perhaps three, there were usually one, if not two, instances of my 
daily bootstrap on i386 and FreeBSD failing.

This is rarely the case anymore these days, and if anything happens,
usually it's fixed the following day.

So it seems things have quite improved.

Gerald

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 10/9] ENABLE_CHECKING refactoring: remove remaining occurrences
       [not found]   ` <C5BB0125-FB5F-46C6-B16D-74C3D0F07C10@gmail.com>
@ 2015-11-08 15:37     ` Mikhail Maltsev
  0 siblings, 0 replies; 77+ messages in thread
From: Mikhail Maltsev @ 2015-11-08 15:37 UTC (permalink / raw)
  To: Bernhard Reutner-Fischer, Jeff Law, Richard Biener,
	gcc-patches mailing list

On 11/01/2015 11:34 PM, Bernhard Reutner-Fischer wrote:
> Mikhail,
> 
> On November 1, 2015 9:19:19 PM GMT+01:00, Mikhail Maltsev <maltsevm@gmail.com> wrote:
>> This patch cleans up remaining bits related to ENABLE_CHECKING. After
>> applying
>> this patch (on top of part 9) we will no longer have any references to
>> ENABLE_CHECKING in the source code.
> 
> I don't remember if you sent size(1) comparison for the frontends and driver, BTW. How bad is it?
> 
> TIA,
> 

Here are the results for r228786 "base" (bootstrapped with
--enable-checking=release) and for the same revision after applying
ENABLE_CHECKING-related patches "head":

                   text   data      bss       dec
filename rev
cc1      base  21442165  70624  1343960  22856749
         head  21489220  70624  1343992  22903836
cc1plus  base  22772252  70712  1369624  24212588
         head  22820770  70712  1369656  24261138
f951     base  22230769  80136  1349592  23660497
         head  22277096  80136  1349624  23706856
lto1     base  20611962  69792  1342008  22023762
         head  20658721  69792  1342040  22070553
gcc      base   1606938  28400    17056   1652394
         head   1608434  28400    17056   1653890

Relative difference:

              text  data       bss       dec
filename
cc1       0.002195     0  0.000024  0.002060
cc1plus   0.002131     0  0.000023  0.002005
f951      0.002084     0  0.000024  0.001959
lto1      0.002269     0  0.000024  0.002125
gcc       0.000931     0  0.000000  0.000905

-- 
Regards,
    Mikhail Maltsev

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 10/9] ENABLE_CHECKING refactoring: remove remaining occurrences
  2015-11-04 15:03     ` Mikhail Maltsev
@ 2016-02-23 15:21       ` Richard Biener
  2016-02-24 14:17         ` Martin Liška
  0 siblings, 1 reply; 77+ messages in thread
From: Richard Biener @ 2016-02-23 15:21 UTC (permalink / raw)
  To: Mikhail Maltsev; +Cc: Jeff Law, gcc-patches mailing list

On Wed, Nov 4, 2015 at 4:03 PM, Mikhail Maltsev <maltsevm@gmail.com> wrote:
> On 11/03/2015 02:35 AM, Jeff Law wrote:
>> This is good fore the trunk too.  Please install.
>>
>> Thanks!
>>
>> jeff
>
> Committed as r229758.

> grep ENABLE_CHECKING *.[ch]
dwarf2out.c:#if ENABLE_CHECKING
dwarf2out.c:#if ENABLE_CHECKING
dwarf2out.c:#if ENABLE_CHECKING
dwarf2out.h:#if ENABLE_CHECKING
hsa-gen.c:#ifdef ENABLE_CHECKING
hsa-regalloc.c:#ifdef ENABLE_CHECKING
> grep ENABLE_CHECKING ada/gcc-interface/*.[ch]
ada/gcc-interface/utils.c:#ifdef ENABLE_CHECKING


> --
> Regards,
>     Mikhail Maltsev

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 10/9] ENABLE_CHECKING refactoring: remove remaining occurrences
  2016-02-23 15:21       ` Richard Biener
@ 2016-02-24 14:17         ` Martin Liška
  2016-02-24 14:27           ` Michael Matz
  2016-02-25  9:24           ` Richard Biener
  0 siblings, 2 replies; 77+ messages in thread
From: Martin Liška @ 2016-02-24 14:17 UTC (permalink / raw)
  To: Richard Biener, Mikhail Maltsev; +Cc: Jeff Law, gcc-patches mailing list

On 02/23/2016 04:21 PM, Richard Biener wrote:
> On Wed, Nov 4, 2015 at 4:03 PM, Mikhail Maltsev <maltsevm@gmail.com> wrote:
>> On 11/03/2015 02:35 AM, Jeff Law wrote:
>>> This is good fore the trunk too.  Please install.
>>>
>>> Thanks!
>>>
>>> jeff
>>
>> Committed as r229758.
> 
>> grep ENABLE_CHECKING *.[ch]
> dwarf2out.c:#if ENABLE_CHECKING
> dwarf2out.c:#if ENABLE_CHECKING
> dwarf2out.c:#if ENABLE_CHECKING
> dwarf2out.h:#if ENABLE_CHECKING

Hi Richi.

Removal in dwarf2out.c is not possible due to assignment (and read) of
a struct member that is conditional in dwarf2out.h:

struct GTY((chain_next ("%h.dw_loc_next"))) dw_loc_descr_node {
...
#if ENABLE_CHECKING
  /* When translating a function into a DWARF procedure, contains the frame
     offset *before* evaluating this operation.  It is -1 when not yet
     initialized.  */
  int dw_loc_frame_offset;
#endif
};


> hsa-gen.c:#ifdef ENABLE_CHECKING
> hsa-regalloc.c:#ifdef ENABLE_CHECKING
>> grep ENABLE_CHECKING ada/gcc-interface/*.[ch]
> ada/gcc-interface/utils.c:#ifdef ENABLE_CHECKING

I've just prepared patches for remaining files., btw. is it an acceptable stage4 material?

Thanks,
Martin

> 
> 
>> --
>> Regards,
>>     Mikhail Maltsev

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 10/9] ENABLE_CHECKING refactoring: remove remaining occurrences
  2016-02-24 14:17         ` Martin Liška
@ 2016-02-24 14:27           ` Michael Matz
  2016-02-24 14:53             ` Martin Liška
  2016-02-25  9:24           ` Richard Biener
  1 sibling, 1 reply; 77+ messages in thread
From: Michael Matz @ 2016-02-24 14:27 UTC (permalink / raw)
  To: Martin Liška
  Cc: Richard Biener, Mikhail Maltsev, Jeff Law, gcc-patches mailing list

[-- Attachment #1: Type: text/plain, Size: 897 bytes --]

Hi,

On Wed, 24 Feb 2016, Martin Liška wrote:

> >> grep ENABLE_CHECKING *.[ch]
> > dwarf2out.c:#if ENABLE_CHECKING
> > dwarf2out.c:#if ENABLE_CHECKING
> > dwarf2out.c:#if ENABLE_CHECKING
> > dwarf2out.h:#if ENABLE_CHECKING
> 
> Hi Richi.
> 
> Removal in dwarf2out.c is not possible due to assignment (and read) of
> a struct member that is conditional in dwarf2out.h:
> 
> struct GTY((chain_next ("%h.dw_loc_next"))) dw_loc_descr_node {
> ...
> #if ENABLE_CHECKING
>   /* When translating a function into a DWARF procedure, contains the frame
>      offset *before* evaluating this operation.  It is -1 when not yet
>      initialized.  */
>   int dw_loc_frame_offset;
> #endif
> };

But nothing can set ENABLE_CHECKING anymore (the macro is meanwhile called 
CHECKING_P), so all that code is dead anyway.  So either the new macro 
should be used or that code should be removed.


Ciao,
Michael.

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 10/9] ENABLE_CHECKING refactoring: remove remaining occurrences
  2016-02-24 14:27           ` Michael Matz
@ 2016-02-24 14:53             ` Martin Liška
  2016-02-24 15:43               ` Pierre-Marie de Rodat
  0 siblings, 1 reply; 77+ messages in thread
From: Martin Liška @ 2016-02-24 14:53 UTC (permalink / raw)
  To: Michael Matz
  Cc: Richard Biener, Mikhail Maltsev, Jeff Law,
	gcc-patches mailing list, pmderodat

On 02/24/2016 03:27 PM, Michael Matz wrote:
> But nothing can set ENABLE_CHECKING anymore (the macro is meanwhile called 
> CHECKING_P), so all that code is dead anyway.  So either the new macro 
> should be used or that code should be removed.
> 
> 
> Ciao,
> Michael.

Good point, well the change is quite recent (12-2015). I'm adding
the author of the code to make a decision about it.

Thanks,
Martin

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 10/9] ENABLE_CHECKING refactoring: remove remaining occurrences
  2016-02-24 14:53             ` Martin Liška
@ 2016-02-24 15:43               ` Pierre-Marie de Rodat
  2016-02-25  9:24                 ` Richard Biener
  0 siblings, 1 reply; 77+ messages in thread
From: Pierre-Marie de Rodat @ 2016-02-24 15:43 UTC (permalink / raw)
  To: Martin Liška, Michael Matz
  Cc: Richard Biener, Mikhail Maltsev, Jeff Law, gcc-patches mailing list

On 02/24/2016 03:53 PM, Martin Liška wrote:
> On 02/24/2016 03:27 PM, Michael Matz wrote:
>> But nothing can set ENABLE_CHECKING anymore (the macro is meanwhile called
>> CHECKING_P), so all that code is dead anyway.  So either the new macro
>> should be used or that code should be removed.
>
> Good point, well the change is quite recent (12-2015). I'm adding
> the author of the code to make a decision about it.

Thanks for the heads up! That’s kind of funny: the check associated with 
this dw_loc_frame_offset field revealed a bug to us (at AdaCore) very 
recently, so I think we should keep it in one form or another.

This field takes one int slot in the dw_loc_descr_node structure, so I 
guess not having it in release mode is important (that’s what Jason said 
in <https://gcc.gnu.org/ml/gcc-patches/2015-11/msg02267.html>). Here’s 
what I think:

   * This field is used only in the resolve_args_picking graph traversal
     for a consistency check in already visited nodes.

   * resolve_args_picking has a hash set to remember the already visited
     nodes.

   * The consistency check itself has almost no runtime cost: we’re
     doing the graph traversal in release mode anyway.

So what about removing the field (in struct dw_loc_descr_node) and 
replacing the visited hash set with a frame_offset hash map (in 
resolve_args_picking)? This hash map would remember the information we 
currently store in the field.

This is a little change, but I can take care of this if you want. I’m a 
little bit desynchronized with the development pace these days: would 
this be for stage 4 or GCC 7?

-- 
Pierre-Marie de Rodat

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 10/9] ENABLE_CHECKING refactoring: remove remaining occurrences
  2016-02-24 14:17         ` Martin Liška
  2016-02-24 14:27           ` Michael Matz
@ 2016-02-25  9:24           ` Richard Biener
  1 sibling, 0 replies; 77+ messages in thread
From: Richard Biener @ 2016-02-25  9:24 UTC (permalink / raw)
  To: Martin Liška; +Cc: Mikhail Maltsev, Jeff Law, gcc-patches mailing list

On Wed, Feb 24, 2016 at 3:16 PM, Martin Liška <mliska@suse.cz> wrote:
> On 02/23/2016 04:21 PM, Richard Biener wrote:
>> On Wed, Nov 4, 2015 at 4:03 PM, Mikhail Maltsev <maltsevm@gmail.com> wrote:
>>> On 11/03/2015 02:35 AM, Jeff Law wrote:
>>>> This is good fore the trunk too.  Please install.
>>>>
>>>> Thanks!
>>>>
>>>> jeff
>>>
>>> Committed as r229758.
>>
>>> grep ENABLE_CHECKING *.[ch]
>> dwarf2out.c:#if ENABLE_CHECKING
>> dwarf2out.c:#if ENABLE_CHECKING
>> dwarf2out.c:#if ENABLE_CHECKING
>> dwarf2out.h:#if ENABLE_CHECKING
>
> Hi Richi.
>
> Removal in dwarf2out.c is not possible due to assignment (and read) of
> a struct member that is conditional in dwarf2out.h:
>
> struct GTY((chain_next ("%h.dw_loc_next"))) dw_loc_descr_node {
> ...
> #if ENABLE_CHECKING
>   /* When translating a function into a DWARF procedure, contains the frame
>      offset *before* evaluating this operation.  It is -1 when not yet
>      initialized.  */
>   int dw_loc_frame_offset;
> #endif
> };
>
>
>> hsa-gen.c:#ifdef ENABLE_CHECKING
>> hsa-regalloc.c:#ifdef ENABLE_CHECKING
>>> grep ENABLE_CHECKING ada/gcc-interface/*.[ch]
>> ada/gcc-interface/utils.c:#ifdef ENABLE_CHECKING
>
> I've just prepared patches for remaining files., btw. is it an acceptable stage4 material?

I think so - we should then poison ENABLE_CHECKING in system.h

Richard.

> Thanks,
> Martin
>
>>
>>
>>> --
>>> Regards,
>>>     Mikhail Maltsev
>

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 10/9] ENABLE_CHECKING refactoring: remove remaining occurrences
  2016-02-24 15:43               ` Pierre-Marie de Rodat
@ 2016-02-25  9:24                 ` Richard Biener
  2016-02-25 10:14                   ` Pierre-Marie de Rodat
  0 siblings, 1 reply; 77+ messages in thread
From: Richard Biener @ 2016-02-25  9:24 UTC (permalink / raw)
  To: Pierre-Marie de Rodat
  Cc: Martin Liška, Michael Matz, Mikhail Maltsev, Jeff Law,
	gcc-patches mailing list

On Wed, Feb 24, 2016 at 4:43 PM, Pierre-Marie de Rodat
<derodat@adacore.com> wrote:
> On 02/24/2016 03:53 PM, Martin Liška wrote:
>>
>> On 02/24/2016 03:27 PM, Michael Matz wrote:
>>>
>>> But nothing can set ENABLE_CHECKING anymore (the macro is meanwhile
>>> called
>>> CHECKING_P), so all that code is dead anyway.  So either the new macro
>>> should be used or that code should be removed.
>>
>>
>> Good point, well the change is quite recent (12-2015). I'm adding
>> the author of the code to make a decision about it.
>
>
> Thanks for the heads up! That’s kind of funny: the check associated with
> this dw_loc_frame_offset field revealed a bug to us (at AdaCore) very
> recently, so I think we should keep it in one form or another.
>
> This field takes one int slot in the dw_loc_descr_node structure, so I guess
> not having it in release mode is important (that’s what Jason said in
> <https://gcc.gnu.org/ml/gcc-patches/2015-11/msg02267.html>). Here’s what I
> think:
>
>   * This field is used only in the resolve_args_picking graph traversal
>     for a consistency check in already visited nodes.
>
>   * resolve_args_picking has a hash set to remember the already visited
>     nodes.
>
>   * The consistency check itself has almost no runtime cost: we’re
>     doing the graph traversal in release mode anyway.
>
> So what about removing the field (in struct dw_loc_descr_node) and replacing
> the visited hash set with a frame_offset hash map (in resolve_args_picking)?
> This hash map would remember the information we currently store in the
> field.

Sounds reasonable.

> This is a little change, but I can take care of this if you want. I’m a
> little bit desynchronized with the development pace these days: would this
> be for stage 4 or GCC 7?

Technically it's GCC 7 material.  Can you either change the ENABLE_CHECKING
use to CHECKING_P for GCC 6 or remove the guarded code/fields?

Thanks,
Richard.

> --
> Pierre-Marie de Rodat

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 10/9] ENABLE_CHECKING refactoring: remove remaining occurrences
  2016-02-25  9:24                 ` Richard Biener
@ 2016-02-25 10:14                   ` Pierre-Marie de Rodat
  2016-02-25 10:15                     ` Martin Liška
  0 siblings, 1 reply; 77+ messages in thread
From: Pierre-Marie de Rodat @ 2016-02-25 10:14 UTC (permalink / raw)
  To: Richard Biener
  Cc: Martin Liška, Michael Matz, Mikhail Maltsev, Jeff Law,
	gcc-patches mailing list

On 02/25/2016 10:24 AM, Richard Biener wrote:
>> So what about removing the field (in struct dw_loc_descr_node) and replacing
>> the visited hash set with a frame_offset hash map (in resolve_args_picking)?
>> This hash map would remember the information we currently store in the
>> field.
>
> Sounds reasonable.

Thanks. I will prepare the patch and submit it for GCC 7, then.

> Technically it's GCC 7 material.  Can you either change the ENABLE_CHECKING
> use to CHECKING_P for GCC 6 or remove the guarded code/fields?

Understood. Martin, as the ENABLE_CHECKING refactoring is not comitted 
yet, could you do the substitution ENABLE_CHECKING → CHECKING_P for 
these dwarf2out.* occurences as part of it?

-- 
Pierre-Marie de Rodat

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 10/9] ENABLE_CHECKING refactoring: remove remaining occurrences
  2016-02-25 10:14                   ` Pierre-Marie de Rodat
@ 2016-02-25 10:15                     ` Martin Liška
  2016-02-25 10:16                       ` Pierre-Marie de Rodat
  0 siblings, 1 reply; 77+ messages in thread
From: Martin Liška @ 2016-02-25 10:15 UTC (permalink / raw)
  To: Pierre-Marie de Rodat, Richard Biener
  Cc: Michael Matz, Mikhail Maltsev, Jeff Law, gcc-patches mailing list

On 02/25/2016 11:14 AM, Pierre-Marie de Rodat wrote:
> Understood. Martin, as the ENABLE_CHECKING refactoring is not comitted yet, could you do the substitution ENABLE_CHECKING → CHECKING_P for these dwarf2out.* occurences as part of it?

Sure. Just working on that.

Martin

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 10/9] ENABLE_CHECKING refactoring: remove remaining occurrences
  2016-02-25 10:15                     ` Martin Liška
@ 2016-02-25 10:16                       ` Pierre-Marie de Rodat
  0 siblings, 0 replies; 77+ messages in thread
From: Pierre-Marie de Rodat @ 2016-02-25 10:16 UTC (permalink / raw)
  To: Martin Liška, Richard Biener
  Cc: Michael Matz, Mikhail Maltsev, Jeff Law, gcc-patches mailing list

On 02/25/2016 11:15 AM, Martin Liška wrote:
> Sure. Just working on that.

Great, thank you!

-- 
Pierre-Marie de Rodat

^ permalink raw reply	[flat|nested] 77+ messages in thread

end of thread, other threads:[~2016-02-25 10:16 UTC | newest]

Thread overview: 77+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-05 23:27 [PATCH 1/9] ENABLE_CHECKING refactoring Mikhail Maltsev
2015-10-05 23:29 ` [PATCH 2/9] ENABLE_CHECKING refactoring: libcpp Mikhail Maltsev
2015-10-06 12:40   ` Bernd Schmidt
2015-10-12 20:57     ` Jeff Law
2015-10-19  1:18       ` Mikhail Maltsev
2015-10-21 22:29         ` Jeff Law
2015-10-21 21:19     ` Jeff Law
2015-10-05 23:30 ` [PATCH 3/9] ENABLE_CHECKING refactoring: Java and Ada Mikhail Maltsev
2015-10-22 19:25   ` Jeff Law
2015-10-05 23:31 ` [PATCH 4/9] ENABLE_CHECKING refactoring: Fortran Mikhail Maltsev
2015-10-23 22:38   ` Jeff Law
2015-10-05 23:32 ` [PATCH 5/9] ENABLE_CHECKING refactoring: pool allocators Mikhail Maltsev
2015-10-06 12:41   ` Bernd Schmidt
2015-10-06 12:45     ` Richard Biener
2015-10-19  0:47       ` Mikhail Maltsev
2015-10-21 11:02         ` Richard Biener
2015-10-26  2:07           ` Mikhail Maltsev
2015-10-26  9:48             ` Richard Biener
2015-10-26 10:57               ` Mikhail Maltsev
2015-10-05 23:34 ` [PATCH 6/9] ENABLE_CHECKING refactoring: generators Mikhail Maltsev
2015-10-06 12:57   ` Richard Biener
2015-10-19  0:09     ` Mikhail Maltsev
2015-10-21 10:57       ` Richard Biener
2015-10-28 16:32         ` Jeff Law
2015-10-29 16:31       ` Jeff Law
2015-10-05 23:39 ` [PATCH 7/9] ENABLE_CHECKING refactoring: middle-end, LTO FE Mikhail Maltsev
2015-10-06 12:46   ` Bernd Schmidt
2015-10-06 12:59     ` Richard Biener
2015-10-06 12:59     ` Richard Biener
2015-10-19  0:56       ` Mikhail Maltsev
2015-10-19 12:19         ` Bernd Schmidt
2015-10-26 17:04           ` Jeff Law
2015-10-26 17:15             ` Bernd Schmidt
2015-10-26 19:05               ` Jeff Law
2015-10-28  1:17                 ` Jeff Law
2015-10-28  2:12                   ` Trevor Saunders
2015-10-05 23:40 ` [PATCH 8/9] ENABLE_CHECKING refactoring: target-specific parts Mikhail Maltsev
2015-10-06 12:48   ` Bernd Schmidt
2015-10-29 19:43     ` Jeff Law
2015-10-29 21:23   ` Jeff Law
2015-10-30  4:13   ` Jeff Law
2015-10-30  4:20     ` Jeff Law
2015-10-06 12:53 ` [PATCH 1/9] ENABLE_CHECKING refactoring Richard Biener
2015-10-12 20:48 ` Jeff Law
2015-10-13 21:33 ` Jeff Law
2015-10-18  8:25   ` Mikhail Maltsev
2015-10-19 11:14     ` Bernd Schmidt
2015-10-19 13:54       ` Mikhail Maltsev
2015-10-21 15:59         ` Jeff Law
2015-10-21 16:06           ` Bernd Schmidt
2015-10-21 16:18             ` Richard Biener
2015-10-21 16:28               ` Jeff Law
2015-11-07 22:42                 ` Gerald Pfeifer
2015-10-21 16:19             ` Jeff Law
2015-10-21 16:22               ` Bernd Schmidt
2015-10-21 16:44                 ` Jakub Jelinek
2015-10-22  7:58                   ` Richard Biener
2015-10-21 20:06                 ` Jeff Law
2015-10-20 16:14     ` Jeff Law
2015-10-21 21:17     ` Jeff Law
2015-11-01 14:58 ` [PATCH 9/9] ENABLE_CHECKING refactoring: C family front ends Mikhail Maltsev
2015-11-02 23:34   ` Jeff Law
2015-11-04 14:41     ` Mikhail Maltsev
2015-11-01 20:19 ` [PATCH 10/9] ENABLE_CHECKING refactoring: remove remaining occurrences Mikhail Maltsev
2015-11-02 23:35   ` Jeff Law
2015-11-04 15:03     ` Mikhail Maltsev
2016-02-23 15:21       ` Richard Biener
2016-02-24 14:17         ` Martin Liška
2016-02-24 14:27           ` Michael Matz
2016-02-24 14:53             ` Martin Liška
2016-02-24 15:43               ` Pierre-Marie de Rodat
2016-02-25  9:24                 ` Richard Biener
2016-02-25 10:14                   ` Pierre-Marie de Rodat
2016-02-25 10:15                     ` Martin Liška
2016-02-25 10:16                       ` Pierre-Marie de Rodat
2016-02-25  9:24           ` Richard Biener
     [not found]   ` <C5BB0125-FB5F-46C6-B16D-74C3D0F07C10@gmail.com>
2015-11-08 15:37     ` Mikhail Maltsev

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).