Commit 7e98624c by Richard Guenther Committed by Richard Biener

configure.ac: Add types checking to stage1 checking flags.

2007-07-26  Richard Guenther  <rguenther@suse.de>

	toplev/
	* configure.ac: Add types checking to stage1 checking flags.
	* configure: Regenerate.

        gcc/
	* tree-cfg.c (verify_gimple_unary_expr, verify_gimple_binary_expr,
	verify_gimple_min_lval, verify_gimple_reference, verify_gimple_expr,
	verify_gimple_modify_stmt, verify_gimple_stmt, verify_gimple_1,
	verify_gimple): New functions.
	* tree-flow.h (verify_gimple): Declare.
	(verify_gimple_1): Declare.
	* gimplify.c (cpt_same_type): Remove.
	(gimplify_addr_expr): Remove checking code.
	(check_pointer_types_r): Remove.
	(gimplify_body): Call verify_gimple_1 instead of check_pointer_types_r.
	Only verify if there were no errors.
	* configure.ac: Add types checking flag.
	* configure: Regenerate.
	* config.in: Regenerate.

From-SVN: r126951
parent 0ee0208e
2007-07-26 Richard Guenther <rguenther@suse.de>
* configure.ac: Add types checking to stage1 checking flags.
* configure: Regenerate.
2007-07-17 Nick Clifton <nickc@redhat.com> 2007-07-17 Nick Clifton <nickc@redhat.com>
* COPYING3: New file. Contains version 3 of the GNU General * COPYING3: New file. Contains version 3 of the GNU General
......
...@@ -11967,9 +11967,9 @@ if test "${enable_stage1_checking+set}" = set; then ...@@ -11967,9 +11967,9 @@ if test "${enable_stage1_checking+set}" = set; then
stage1_checking=--enable-checking=${enable_stage1_checking} stage1_checking=--enable-checking=${enable_stage1_checking}
else else
if test "x$enable_checking" = xno; then if test "x$enable_checking" = xno; then
stage1_checking=--enable-checking stage1_checking=--enable-checking=yes,types
else else
stage1_checking=--enable-checking${enable_checking+=}$enable_checking stage1_checking=--enable-checking=types${enable_checking+,}$enable_checking
fi fi
fi; fi;
......
...@@ -2593,9 +2593,9 @@ AC_ARG_ENABLE(stage1-checking, ...@@ -2593,9 +2593,9 @@ AC_ARG_ENABLE(stage1-checking,
of the compiler], of the compiler],
[stage1_checking=--enable-checking=${enable_stage1_checking}], [stage1_checking=--enable-checking=${enable_stage1_checking}],
[if test "x$enable_checking" = xno; then [if test "x$enable_checking" = xno; then
stage1_checking=--enable-checking stage1_checking=--enable-checking=yes,types
else else
stage1_checking=--enable-checking${enable_checking+=}$enable_checking stage1_checking=--enable-checking=types${enable_checking+,}$enable_checking
fi]) fi])
AC_SUBST(stage1_checking) AC_SUBST(stage1_checking)
......
...@@ -121,6 +121,12 @@ ...@@ -121,6 +121,12 @@
#endif #endif
/* Define if you want all gimple types to be verified after gimplifiation. */
#ifndef USED_FOR_TARGET
#undef ENABLE_TYPES_CHECKING
#endif
/* Define if you want to run subprograms and generated programs through /* Define if you want to run subprograms and generated programs through
valgrind (a memory checker). This is extremely expensive. */ valgrind (a memory checker). This is extremely expensive. */
#ifndef USED_FOR_TARGET #ifndef USED_FOR_TARGET
......
...@@ -868,7 +868,7 @@ Optional Features: ...@@ -868,7 +868,7 @@ Optional Features:
enable only specific categories of checks. enable only specific categories of checks.
Categories are: yes,no,all,none,release. Categories are: yes,no,all,none,release.
Flags are: assert,df,fold,gc,gcac,misc, Flags are: assert,df,fold,gc,gcac,misc,
rtlflag,rtl,runtime,tree,valgrind. rtlflag,rtl,runtime,tree,valgrind,types.
--enable-mapped-location location_t is fileline integer cookie --enable-mapped-location location_t is fileline integer cookie
--enable-coverage=LEVEL --enable-coverage=LEVEL
enable compiler's code coverage collection. enable compiler's code coverage collection.
...@@ -6429,22 +6429,26 @@ do ...@@ -6429,22 +6429,26 @@ do
ac_fold_checking= ; ac_gc_checking=1 ; ac_fold_checking= ; ac_gc_checking=1 ;
ac_gc_always_collect= ; ac_rtl_checking= ; ac_gc_always_collect= ; ac_rtl_checking= ;
ac_rtlflag_checking=1 ; ac_runtime_checking=1 ; ac_rtlflag_checking=1 ; ac_runtime_checking=1 ;
ac_tree_checking=1 ; ac_valgrind_checking= ;; ac_tree_checking=1 ; ac_valgrind_checking= ;
ac_types_checking= ;;
no|none) ac_assert_checking= ; ac_checking= ; ac_df_checking= ; no|none) ac_assert_checking= ; ac_checking= ; ac_df_checking= ;
ac_fold_checking= ; ac_gc_checking= ; ac_fold_checking= ; ac_gc_checking= ;
ac_gc_always_collect= ; ac_rtl_checking= ; ac_gc_always_collect= ; ac_rtl_checking= ;
ac_rtlflag_checking= ; ac_runtime_checking= ; ac_rtlflag_checking= ; ac_runtime_checking= ;
ac_tree_checking= ; ac_valgrind_checking= ;; ac_tree_checking= ; ac_valgrind_checking= ;
ac_types_checking= ;;
all) ac_assert_checking=1 ; ac_checking=1 ; ac_df_checking=1 ; all) ac_assert_checking=1 ; ac_checking=1 ; ac_df_checking=1 ;
ac_fold_checking=1 ; ac_gc_checking=1 ; ac_fold_checking=1 ; ac_gc_checking=1 ;
ac_gc_always_collect=1 ; ac_rtl_checking=1 ; ac_gc_always_collect=1 ; ac_rtl_checking=1 ;
ac_rtlflag_checking=1 ; ac_runtime_checking=1 ; ac_rtlflag_checking=1 ; ac_runtime_checking=1 ;
ac_tree_checking=1 ; ac_valgrind_checking= ;; ac_tree_checking=1 ; ac_valgrind_checking= ;
ac_types_checking=1 ;;
release) ac_assert_checking=1 ; ac_checking= ; ac_df_checking= ; release) ac_assert_checking=1 ; ac_checking= ; ac_df_checking= ;
ac_fold_checking= ; ac_gc_checking= ; ac_fold_checking= ; ac_gc_checking= ;
ac_gc_always_collect= ; ac_rtl_checking= ; ac_gc_always_collect= ; ac_rtl_checking= ;
ac_rtlflag_checking= ; ac_runtime_checking=1 ; ac_rtlflag_checking= ; ac_runtime_checking=1 ;
ac_tree_checking= ; ac_valgrind_checking= ;; ac_tree_checking= ; ac_valgrind_checking= ;
ac_types_checking= ;;
# these enable particular checks # these enable particular checks
assert) ac_assert_checking=1 ;; assert) ac_assert_checking=1 ;;
df) ac_df_checking=1 ;; df) ac_df_checking=1 ;;
...@@ -6456,6 +6460,7 @@ do ...@@ -6456,6 +6460,7 @@ do
rtlflag) ac_rtlflag_checking=1 ;; rtlflag) ac_rtlflag_checking=1 ;;
runtime) ac_runtime_checking=1 ;; runtime) ac_runtime_checking=1 ;;
tree) ac_tree_checking=1 ;; tree) ac_tree_checking=1 ;;
types) ac_types_checking=1 ;;
valgrind) ac_valgrind_checking=1 ;; valgrind) ac_valgrind_checking=1 ;;
*) { { echo "$as_me:$LINENO: error: unknown check category $check" >&5 *) { { echo "$as_me:$LINENO: error: unknown check category $check" >&5
echo "$as_me: error: unknown check category $check" >&2;} echo "$as_me: error: unknown check category $check" >&2;}
...@@ -6504,6 +6509,13 @@ _ACEOF ...@@ -6504,6 +6509,13 @@ _ACEOF
TREEBROWSER=tree-browser.o TREEBROWSER=tree-browser.o
fi fi
if test x$ac_types_checking != x ; then
cat >>confdefs.h <<\_ACEOF
#define ENABLE_TYPES_CHECKING 1
_ACEOF
fi
if test x$ac_rtl_checking != x ; then if test x$ac_rtl_checking != x ; then
......
...@@ -346,7 +346,7 @@ AC_ARG_ENABLE(checking, ...@@ -346,7 +346,7 @@ AC_ARG_ENABLE(checking,
enable only specific categories of checks. enable only specific categories of checks.
Categories are: yes,no,all,none,release. Categories are: yes,no,all,none,release.
Flags are: assert,df,fold,gc,gcac,misc, Flags are: assert,df,fold,gc,gcac,misc,
rtlflag,rtl,runtime,tree,valgrind.], rtlflag,rtl,runtime,tree,valgrind,types.],
[ac_checking_flags="${enableval}"],[ [ac_checking_flags="${enableval}"],[
# Determine the default checks. # Determine the default checks.
if test x$is_release = x ; then if test x$is_release = x ; then
...@@ -363,22 +363,26 @@ do ...@@ -363,22 +363,26 @@ do
ac_fold_checking= ; ac_gc_checking=1 ; ac_fold_checking= ; ac_gc_checking=1 ;
ac_gc_always_collect= ; ac_rtl_checking= ; ac_gc_always_collect= ; ac_rtl_checking= ;
ac_rtlflag_checking=1 ; ac_runtime_checking=1 ; ac_rtlflag_checking=1 ; ac_runtime_checking=1 ;
ac_tree_checking=1 ; ac_valgrind_checking= ;; ac_tree_checking=1 ; ac_valgrind_checking= ;
ac_types_checking= ;;
no|none) ac_assert_checking= ; ac_checking= ; ac_df_checking= ; no|none) ac_assert_checking= ; ac_checking= ; ac_df_checking= ;
ac_fold_checking= ; ac_gc_checking= ; ac_fold_checking= ; ac_gc_checking= ;
ac_gc_always_collect= ; ac_rtl_checking= ; ac_gc_always_collect= ; ac_rtl_checking= ;
ac_rtlflag_checking= ; ac_runtime_checking= ; ac_rtlflag_checking= ; ac_runtime_checking= ;
ac_tree_checking= ; ac_valgrind_checking= ;; ac_tree_checking= ; ac_valgrind_checking= ;
ac_types_checking= ;;
all) ac_assert_checking=1 ; ac_checking=1 ; ac_df_checking=1 ; all) ac_assert_checking=1 ; ac_checking=1 ; ac_df_checking=1 ;
ac_fold_checking=1 ; ac_gc_checking=1 ; ac_fold_checking=1 ; ac_gc_checking=1 ;
ac_gc_always_collect=1 ; ac_rtl_checking=1 ; ac_gc_always_collect=1 ; ac_rtl_checking=1 ;
ac_rtlflag_checking=1 ; ac_runtime_checking=1 ; ac_rtlflag_checking=1 ; ac_runtime_checking=1 ;
ac_tree_checking=1 ; ac_valgrind_checking= ;; ac_tree_checking=1 ; ac_valgrind_checking= ;
ac_types_checking=1 ;;
release) ac_assert_checking=1 ; ac_checking= ; ac_df_checking= ; release) ac_assert_checking=1 ; ac_checking= ; ac_df_checking= ;
ac_fold_checking= ; ac_gc_checking= ; ac_fold_checking= ; ac_gc_checking= ;
ac_gc_always_collect= ; ac_rtl_checking= ; ac_gc_always_collect= ; ac_rtl_checking= ;
ac_rtlflag_checking= ; ac_runtime_checking=1 ; ac_rtlflag_checking= ; ac_runtime_checking=1 ;
ac_tree_checking= ; ac_valgrind_checking= ;; ac_tree_checking= ; ac_valgrind_checking= ;
ac_types_checking= ;;
# these enable particular checks # these enable particular checks
assert) ac_assert_checking=1 ;; assert) ac_assert_checking=1 ;;
df) ac_df_checking=1 ;; df) ac_df_checking=1 ;;
...@@ -390,6 +394,7 @@ do ...@@ -390,6 +394,7 @@ do
rtlflag) ac_rtlflag_checking=1 ;; rtlflag) ac_rtlflag_checking=1 ;;
runtime) ac_runtime_checking=1 ;; runtime) ac_runtime_checking=1 ;;
tree) ac_tree_checking=1 ;; tree) ac_tree_checking=1 ;;
types) ac_types_checking=1 ;;
valgrind) ac_valgrind_checking=1 ;; valgrind) ac_valgrind_checking=1 ;;
*) AC_MSG_ERROR(unknown check category $check) ;; *) AC_MSG_ERROR(unknown check category $check) ;;
esac esac
...@@ -426,6 +431,12 @@ if test x$ac_tree_checking != x ; then ...@@ -426,6 +431,12 @@ if test x$ac_tree_checking != x ; then
]) ])
TREEBROWSER=tree-browser.o TREEBROWSER=tree-browser.o
fi fi
if test x$ac_types_checking != x ; then
AC_DEFINE(ENABLE_TYPES_CHECKING, 1,
[Define if you want all gimple types to be verified after gimplifiation.
This is cheap.
])
fi
AC_SUBST(TREEBROWSER) AC_SUBST(TREEBROWSER)
if test x$ac_rtl_checking != x ; then if test x$ac_rtl_checking != x ; then
AC_DEFINE(ENABLE_RTL_CHECKING, 1, AC_DEFINE(ENABLE_RTL_CHECKING, 1,
......
...@@ -112,9 +112,6 @@ typedef struct gimple_temp_hash_elt ...@@ -112,9 +112,6 @@ typedef struct gimple_temp_hash_elt
/* Forward declarations. */ /* Forward declarations. */
static enum gimplify_status gimplify_compound_expr (tree *, tree *, bool); static enum gimplify_status gimplify_compound_expr (tree *, tree *, bool);
#ifdef ENABLE_CHECKING
static bool cpt_same_type (tree a, tree b);
#endif
/* Mark X addressable. Unlike the langhook we expect X to be in gimple /* Mark X addressable. Unlike the langhook we expect X to be in gimple
form and we don't do any syntax checking. */ form and we don't do any syntax checking. */
...@@ -3985,19 +3982,7 @@ gimplify_addr_expr (tree *expr_p, tree *pre_p, tree *post_p) ...@@ -3985,19 +3982,7 @@ gimplify_addr_expr (tree *expr_p, tree *pre_p, tree *post_p)
tree t_op00 = TREE_TYPE (op00); tree t_op00 = TREE_TYPE (op00);
if (!useless_type_conversion_p (t_expr, t_op00)) if (!useless_type_conversion_p (t_expr, t_op00))
{ op00 = fold_convert (TREE_TYPE (expr), op00);
#ifdef ENABLE_CHECKING
tree t_op0 = TREE_TYPE (op0);
gcc_assert (POINTER_TYPE_P (t_expr)
&& (cpt_same_type (TREE_TYPE (t_expr), t_op0)
|| (TREE_CODE (t_op0) == ARRAY_TYPE
&& cpt_same_type (TREE_TYPE (t_expr),
TREE_TYPE (t_op0))))
&& POINTER_TYPE_P (t_op00)
&& cpt_same_type (t_op0, TREE_TYPE (t_op00)));
#endif
op00 = fold_convert (TREE_TYPE (expr), op00);
}
*expr_p = op00; *expr_p = op00;
ret = GS_OK; ret = GS_OK;
} }
...@@ -6393,84 +6378,6 @@ gimplify_one_sizepos (tree *expr_p, tree *stmt_p) ...@@ -6393,84 +6378,6 @@ gimplify_one_sizepos (tree *expr_p, tree *stmt_p)
} }
} }
#ifdef ENABLE_CHECKING
/* Compare types A and B for a "close enough" match. */
static bool
cpt_same_type (tree a, tree b)
{
if (useless_type_conversion_p (a, b))
return true;
/* ??? The C++ FE decomposes METHOD_TYPES to FUNCTION_TYPES and doesn't
link them together. This routine is intended to catch type errors
that will affect the optimizers, and the optimizers don't add new
dereferences of function pointers, so ignore it. */
if ((TREE_CODE (a) == FUNCTION_TYPE || TREE_CODE (a) == METHOD_TYPE)
&& (TREE_CODE (b) == FUNCTION_TYPE || TREE_CODE (b) == METHOD_TYPE))
return true;
/* ??? The C FE pushes type qualifiers after the fact into the type of
the element from the type of the array. See build_unary_op's handling
of ADDR_EXPR. This seems wrong -- if we were going to do this, we
should have done it when creating the variable in the first place.
Alternately, why aren't the two array types made variants? */
if (TREE_CODE (a) == ARRAY_TYPE && TREE_CODE (b) == ARRAY_TYPE)
return cpt_same_type (TREE_TYPE (a), TREE_TYPE (b));
/* And because of those, we have to recurse down through pointers. */
if (POINTER_TYPE_P (a) && POINTER_TYPE_P (b))
return cpt_same_type (TREE_TYPE (a), TREE_TYPE (b));
return false;
}
/* Check for some cases of the front end missing cast expressions.
The type of a dereference should correspond to the pointer type;
similarly the type of an address should match its object. */
static tree
check_pointer_types_r (tree *tp, int *walk_subtrees ATTRIBUTE_UNUSED,
void *data ATTRIBUTE_UNUSED)
{
tree t = *tp;
tree ptype, otype, dtype;
switch (TREE_CODE (t))
{
case INDIRECT_REF:
case ARRAY_REF:
otype = TREE_TYPE (t);
ptype = TREE_TYPE (TREE_OPERAND (t, 0));
dtype = TREE_TYPE (ptype);
gcc_assert (cpt_same_type (otype, dtype));
break;
case ADDR_EXPR:
ptype = TREE_TYPE (t);
otype = TREE_TYPE (TREE_OPERAND (t, 0));
dtype = TREE_TYPE (ptype);
if (!cpt_same_type (dtype, otype))
{
/* &array is allowed to produce a pointer to the element, rather than
a pointer to the array type. We must allow this in order to
properly represent assigning the address of an array in C into
pointer to the element type. */
gcc_assert (TREE_CODE (otype) == ARRAY_TYPE
&& POINTER_TYPE_P (ptype)
&& cpt_same_type (dtype, TREE_TYPE (otype)));
break;
}
break;
default:
return NULL_TREE;
}
return NULL_TREE;
}
#endif
/* Gimplify the body of statements pointed to by BODY_P. FNDECL is the /* Gimplify the body of statements pointed to by BODY_P. FNDECL is the
function decl containing BODY. */ function decl containing BODY. */
...@@ -6539,8 +6446,9 @@ gimplify_body (tree *body_p, tree fndecl, bool do_parms) ...@@ -6539,8 +6446,9 @@ gimplify_body (tree *body_p, tree fndecl, bool do_parms)
pop_gimplify_context (body); pop_gimplify_context (body);
gcc_assert (gimplify_ctxp == NULL); gcc_assert (gimplify_ctxp == NULL);
#ifdef ENABLE_CHECKING #ifdef ENABLE_TYPES_CHECKING
walk_tree (body_p, check_pointer_types_r, NULL, NULL); if (!errorcount && !sorrycount)
verify_gimple_1 (BIND_EXPR_BODY (*body_p));
#endif #endif
timevar_pop (TV_TREE_GIMPLIFY); timevar_pop (TV_TREE_GIMPLIFY);
......
...@@ -752,6 +752,8 @@ extern void bsi_commit_edge_inserts (void); ...@@ -752,6 +752,8 @@ extern void bsi_commit_edge_inserts (void);
extern void notice_special_calls (tree); extern void notice_special_calls (tree);
extern void clear_special_calls (void); extern void clear_special_calls (void);
extern void verify_stmts (void); extern void verify_stmts (void);
extern void verify_gimple (void);
extern void verify_gimple_1 (tree);
extern tree tree_block_label (basic_block); extern tree tree_block_label (basic_block);
extern void extract_true_false_edges_from_block (basic_block, edge *, edge *); extern void extract_true_false_edges_from_block (basic_block, edge *, edge *);
extern bool tree_duplicate_sese_region (edge, edge, basic_block *, unsigned, extern bool tree_duplicate_sese_region (edge, edge, basic_block *, unsigned,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment