+2010-01-07 Richard Guenther <rguenther@suse.de>
+
+ * gimple.h (gss_for_code): Wrap gcc_assert in ENABLE_CHECKING.
+ (gimple_op): Likewise.
+ (gimple_op_ptr): Likewise.
+ (gimple_assign_set_lhs): Remove gcc_assert.
+ (gimple_assign_set_rhs1): Likewise.
+ (gimple_assign_set_rhs2): Likewise.
+ (gimple_call_set_lhs): Likewise.
+ (gimple_call_set_fn): Likewise.
+ (gimple_call_set_fndecl): Likewise.
+ (gimple_call_fndecl): Likewise.
+ (gimple_call_return_type): Likewise.
+ (gimple_call_set_chain): Likewise.
+ (gimple_call_num_args): Likewise.
+ (gimple_call_set_arg): Likewise.
+ (gimple_cond_set_code): Likewise.
+ (gimple_cond_set_lhs): Likewise.
+ (gimple_cond_set_rhs): Likewise.
+ (gimple_cond_set_true_label): Likewise.
+ (gimple_cond_set_false_label): Likewise.
+ (gimple_label_set_label): Likewise.
+ (gimple_goto_set_dest): Likewise.
+ (gimple_debug_bind_get_var): Wrap gcc_assert in ENABLE_CHECKING.
+ (gimple_debug_bind_get_value): Likewise.
+ (gimple_debug_bind_get_value_ptr): Likewise.
+ (gimple_debug_bind_set_var): Likewise.
+ (gimple_debug_bind_set_value): Likewise.
+ (gimple_debug_bind_reset_value): Likewise.
+ (gimple_debug_bind_has_value_p): Likewise.
+ (gimple_return_retval_ptr): Remove gcc_assert.
+ (gimple_return_retval): Likewise.
+ (gimple_return_set_retval): Likewise.
+ * tree-flow.h (struct gimple_df): Remove nonlocal_all member.
+ (safe_referenced_var_iterator): Remove.
+ (FOR_EACH_REFERENCED_VAR_SAFE): Likewise.
+ * tree-flow-inline.h (gimple_nonlocal_all): Remove.
+ (fill_referenced_var_vec): Remove.
+ (first_readonly_imm_use): Remove redundant gcc_assert.
+ (phi_arg_index_from_use): Combine gcc_asserts.
+ (move_use_after_head): Wrap gcc_assert in ENABLE_CHECKING.
+ (first_imm_use_stmt): Remove redundant gcc_assert.
+ * tree-cfg.c (verify_gimple_call): Verify function and chain
+ operands. Verify arguments.
+ (verify_types_in_gimple_stmt): Verify condition code and labels.
+
2010-01-07 Richard Guenther <rguenther@suse.de>
PR tree-optimization/42641
static inline enum gimple_statement_structure_enum
gss_for_code (enum gimple_code code)
{
+#ifdef ENABLE_CHECKING
gcc_assert ((unsigned int)code < LAST_AND_UNUSED_GIMPLE_CODE);
+#endif
return gss_for_code_[code];
}
{
if (gimple_has_ops (gs))
{
+#ifdef ENABLE_CHECKING
gcc_assert (i < gimple_num_ops (gs));
+#endif
return gimple_ops (CONST_CAST_GIMPLE (gs))[i];
}
else
{
if (gimple_has_ops (gs))
{
+#ifdef ENABLE_CHECKING
gcc_assert (i < gimple_num_ops (gs));
+#endif
return gimple_ops (CONST_CAST_GIMPLE (gs)) + i;
}
else
gimple_assign_set_lhs (gimple gs, tree lhs)
{
GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
- gcc_assert (is_gimple_operand (lhs));
gimple_set_op (gs, 0, lhs);
if (lhs && TREE_CODE (lhs) == SSA_NAME)
{
GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
- /* If there are 3 or more operands, the 2 operands on the RHS must be
- GIMPLE values. */
- if (gimple_num_ops (gs) >= 3)
- gcc_assert (is_gimple_val (rhs));
- else
- gcc_assert (is_gimple_operand (rhs));
-
gimple_set_op (gs, 1, rhs);
}
{
GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
- /* The 2 operands on the RHS must be GIMPLE values. */
- gcc_assert (is_gimple_val (rhs));
-
gimple_set_op (gs, 2, rhs);
}
gimple_call_set_lhs (gimple gs, tree lhs)
{
GIMPLE_CHECK (gs, GIMPLE_CALL);
- gcc_assert (!lhs || is_gimple_operand (lhs));
gimple_set_op (gs, 0, lhs);
if (lhs && TREE_CODE (lhs) == SSA_NAME)
SSA_NAME_DEF_STMT (lhs) = gs;
gimple_call_set_fn (gimple gs, tree fn)
{
GIMPLE_CHECK (gs, GIMPLE_CALL);
- gcc_assert (is_gimple_operand (fn));
gimple_set_op (gs, 1, fn);
}
gimple_call_set_fndecl (gimple gs, tree decl)
{
GIMPLE_CHECK (gs, GIMPLE_CALL);
- gcc_assert (TREE_CODE (decl) == FUNCTION_DECL);
gimple_set_op (gs, 1, build_fold_addr_expr_loc (gimple_location (gs), decl));
}
{
tree addr = gimple_call_fn (gs);
if (TREE_CODE (addr) == ADDR_EXPR)
- {
- gcc_assert (TREE_CODE (TREE_OPERAND (addr, 0)) == FUNCTION_DECL);
- return TREE_OPERAND (addr, 0);
- }
+ return TREE_OPERAND (addr, 0);
return NULL_TREE;
}
tree type = TREE_TYPE (fn);
/* See through the pointer. */
- gcc_assert (POINTER_TYPE_P (type));
type = TREE_TYPE (type);
- gcc_assert (TREE_CODE (type) == FUNCTION_TYPE
- || TREE_CODE (type) == METHOD_TYPE);
-
/* The type returned by a FUNCTION_DECL is the type of its
function type. */
return TREE_TYPE (type);
gimple_call_set_chain (gimple gs, tree chain)
{
GIMPLE_CHECK (gs, GIMPLE_CALL);
- gcc_assert (chain == NULL
- || TREE_CODE (chain) == ADDR_EXPR
- || SSA_VAR_P (chain));
+
gimple_set_op (gs, 2, chain);
}
unsigned num_ops;
GIMPLE_CHECK (gs, GIMPLE_CALL);
num_ops = gimple_num_ops (gs);
- gcc_assert (num_ops >= 3);
return num_ops - 3;
}
gimple_call_set_arg (gimple gs, unsigned index, tree arg)
{
GIMPLE_CHECK (gs, GIMPLE_CALL);
- gcc_assert (is_gimple_operand (arg));
gimple_set_op (gs, index + 3, arg);
}
gimple_cond_set_code (gimple gs, enum tree_code code)
{
GIMPLE_CHECK (gs, GIMPLE_COND);
- gcc_assert (TREE_CODE_CLASS (code) == tcc_comparison);
gs->gsbase.subcode = code;
}
gimple_cond_set_lhs (gimple gs, tree lhs)
{
GIMPLE_CHECK (gs, GIMPLE_COND);
- gcc_assert (is_gimple_operand (lhs));
gimple_set_op (gs, 0, lhs);
}
gimple_cond_set_rhs (gimple gs, tree rhs)
{
GIMPLE_CHECK (gs, GIMPLE_COND);
- gcc_assert (is_gimple_operand (rhs));
gimple_set_op (gs, 1, rhs);
}
gimple_cond_set_true_label (gimple gs, tree label)
{
GIMPLE_CHECK (gs, GIMPLE_COND);
- gcc_assert (!label || TREE_CODE (label) == LABEL_DECL);
gimple_set_op (gs, 2, label);
}
gimple_cond_set_false_label (gimple gs, tree label)
{
GIMPLE_CHECK (gs, GIMPLE_COND);
- gcc_assert (!label || TREE_CODE (label) == LABEL_DECL);
gimple_set_op (gs, 3, label);
}
gimple_label_set_label (gimple gs, tree label)
{
GIMPLE_CHECK (gs, GIMPLE_LABEL);
- gcc_assert (TREE_CODE (label) == LABEL_DECL);
gimple_set_op (gs, 0, label);
}
gimple_goto_set_dest (gimple gs, tree dest)
{
GIMPLE_CHECK (gs, GIMPLE_GOTO);
- gcc_assert (is_gimple_operand (dest));
gimple_set_op (gs, 0, dest);
}
gimple_debug_bind_get_var (gimple dbg)
{
GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
+#ifdef ENABLE_CHECKING
gcc_assert (gimple_debug_bind_p (dbg));
+#endif
return gimple_op (dbg, 0);
}
gimple_debug_bind_get_value (gimple dbg)
{
GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
+#ifdef ENABLE_CHECKING
gcc_assert (gimple_debug_bind_p (dbg));
+#endif
return gimple_op (dbg, 1);
}
gimple_debug_bind_get_value_ptr (gimple dbg)
{
GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
+#ifdef ENABLE_CHECKING
gcc_assert (gimple_debug_bind_p (dbg));
+#endif
return gimple_op_ptr (dbg, 1);
}
gimple_debug_bind_set_var (gimple dbg, tree var)
{
GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
+#ifdef ENABLE_CHECKING
gcc_assert (gimple_debug_bind_p (dbg));
+#endif
gimple_set_op (dbg, 0, var);
}
gimple_debug_bind_set_value (gimple dbg, tree value)
{
GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
+#ifdef ENABLE_CHECKING
gcc_assert (gimple_debug_bind_p (dbg));
+#endif
gimple_set_op (dbg, 1, value);
}
gimple_debug_bind_reset_value (gimple dbg)
{
GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
+#ifdef ENABLE_CHECKING
gcc_assert (gimple_debug_bind_p (dbg));
+#endif
gimple_set_op (dbg, 1, GIMPLE_DEBUG_BIND_NOVALUE);
}
gimple_debug_bind_has_value_p (gimple dbg)
{
GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
+#ifdef ENABLE_CHECKING
gcc_assert (gimple_debug_bind_p (dbg));
+#endif
return gimple_op (dbg, 1) != GIMPLE_DEBUG_BIND_NOVALUE;
}
gimple_return_retval_ptr (const_gimple gs)
{
GIMPLE_CHECK (gs, GIMPLE_RETURN);
- gcc_assert (gimple_num_ops (gs) == 1);
return gimple_op_ptr (gs, 0);
}
gimple_return_retval (const_gimple gs)
{
GIMPLE_CHECK (gs, GIMPLE_RETURN);
- gcc_assert (gimple_num_ops (gs) == 1);
return gimple_op (gs, 0);
}
gimple_return_set_retval (gimple gs, tree retval)
{
GIMPLE_CHECK (gs, GIMPLE_RETURN);
- gcc_assert (gimple_num_ops (gs) == 1);
- gcc_assert (retval == NULL_TREE
- || TREE_CODE (retval) == RESULT_DECL
- || is_gimple_val (retval));
gimple_set_op (gs, 0, retval);
}
{
tree fn = gimple_call_fn (stmt);
tree fntype;
+ unsigned i;
+
+ if (TREE_CODE (fn) != OBJ_TYPE_REF
+ && !is_gimple_val (fn))
+ {
+ error ("invalid function in gimple call");
+ debug_generic_stmt (fn);
+ return true;
+ }
if (!POINTER_TYPE_P (TREE_TYPE (fn))
|| (TREE_CODE (TREE_TYPE (TREE_TYPE (fn))) != FUNCTION_TYPE
return true;
}
+ if (gimple_call_chain (stmt)
+ && !is_gimple_val (gimple_call_chain (stmt)))
+ {
+ error ("invalid static chain in gimple call");
+ debug_generic_stmt (gimple_call_chain (stmt));
+ return true;
+ }
+
/* If there is a static chain argument, this should not be an indirect
call, and the decl should have DECL_STATIC_CHAIN set. */
if (gimple_call_chain (stmt))
/* ??? The C frontend passes unpromoted arguments in case it
didn't see a function declaration before the call. So for now
- leave the call arguments unverified. Once we gimplify
+ leave the call arguments mostly unverified. Once we gimplify
unit-at-a-time we have a chance to fix this. */
+ for (i = 0; i < gimple_call_num_args (stmt); ++i)
+ {
+ tree arg = gimple_call_arg (stmt, i);
+ if (!is_gimple_operand (arg))
+ {
+ error ("invalid argument to gimple call");
+ debug_generic_expr (arg);
+ }
+ }
+
return false;
}
return verify_gimple_call (stmt);
case GIMPLE_COND:
+ if (TREE_CODE_CLASS (gimple_cond_code (stmt)) != tcc_comparison)
+ {
+ error ("invalid comparison code in gimple cond");
+ return true;
+ }
+ if (!(!gimple_cond_true_label (stmt)
+ || TREE_CODE (gimple_cond_true_label (stmt)) == LABEL_DECL)
+ || !(!gimple_cond_false_label (stmt)
+ || TREE_CODE (gimple_cond_false_label (stmt)) == LABEL_DECL))
+ {
+ error ("invalid labels in gimple cond");
+ return true;
+ }
+
return verify_gimple_comparison (boolean_type_node,
gimple_cond_lhs (stmt),
gimple_cond_rhs (stmt));
return fun->gimple_df->referenced_vars;
}
-/* Artificial variable used to model the effects of nonlocal
- variables. */
-static inline tree
-gimple_nonlocal_all (const struct function *fun)
-{
- gcc_assert (fun && fun->gimple_df);
- return fun->gimple_df->nonlocal_all;
-}
-
/* Artificial variable used for the virtual operand FUD chain. */
static inline tree
gimple_vop (const struct function *fun)
return (tree) next_htab_element (&iter->hti);
}
-/* Fill up VEC with the variables in the referenced vars hashtable. */
-
-static inline void
-fill_referenced_var_vec (VEC (tree, heap) **vec)
-{
- referenced_var_iterator rvi;
- tree var;
- *vec = NULL;
- FOR_EACH_REFERENCED_VAR (var, rvi)
- VEC_safe_push (tree, heap, *vec, var);
-}
-
/* Return the variable annotation for T, which must be a _DECL node.
Return NULL if the variable annotation doesn't already exist. */
static inline var_ann_t
static inline use_operand_p
first_readonly_imm_use (imm_use_iterator *imm, tree var)
{
- gcc_assert (TREE_CODE (var) == SSA_NAME);
-
imm->end_p = &(SSA_NAME_IMM_USE_NODE (var));
imm->imm_use = imm->end_p->next;
#ifdef ENABLE_CHECKING
#ifdef ENABLE_CHECKING
/* Make sure the calculation doesn't have any leftover bytes. If it does,
then imm_use is likely not the first element in phi_arg_d. */
- gcc_assert (
- (((char *)element - (char *)root) % sizeof (struct phi_arg_d)) == 0);
- gcc_assert (index < gimple_phi_capacity (phi));
+ gcc_assert ((((char *)element - (char *)root)
+ % sizeof (struct phi_arg_d)) == 0
+ && index < gimple_phi_capacity (phi));
#endif
return index;
move_use_after_head (use_operand_p use_p, use_operand_p head,
use_operand_p last_p)
{
+#ifdef ENABLE_CHECKING
gcc_assert (USE_FROM_PTR (use_p) == USE_FROM_PTR (head));
+#endif
/* Skip head when we find it. */
if (use_p != head)
{
static inline gimple
first_imm_use_stmt (imm_use_iterator *imm, tree var)
{
- gcc_assert (TREE_CODE (var) == SSA_NAME);
-
imm->end_p = &(SSA_NAME_IMM_USE_NODE (var));
imm->imm_use = imm->end_p->next;
imm->next_imm_name = NULL_USE_OPERAND_P;