This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Verify GIMPLE_MODIFY_STMT
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Diego Novillo <dnovillo at google dot com>
- Date: Wed, 2 Jul 2008 22:58:14 +0200 (CEST)
- Subject: [PATCH] Verify GIMPLE_MODIFY_STMT
This is not verified at all and fails badly. The following patch adds
the verification and fixes the most obvious problems (nested functions
remain broken). It seems like the DECL_GIMPLE_FORMAL_TEMP_P concept
is broken somewhat.
I'm currently bootstrapping the patch, I know that
gcc.c-torture/compile/20030418-1.c fails (nested functions with invalid
gimple).
Ok for trunk if this doesn't break bootstrap?
Thanks,
Richard.
2008-07-02 Richard Guenther <rguenther@suse.de>
* tree-gimple.c (is_gimple_addressable): Allow TARGET_MEM_REF.
* gimplify.c (pop_gimplify_context): Do not reset
DECL_GIMPLE_FORMAL_TEMP_P.
(build_stack_save_restore): Set DECL_GIMPLE_FORMAL_TEMP_P on the temp.
* tree-cfg.c (verify_expr): Verify GIMPLE_MODIFY_STMT properly.
Index: tree-gimple.c
===================================================================
*** tree-gimple.c (revision 137252)
--- tree-gimple.c (working copy)
*************** bool
*** 162,168 ****
is_gimple_addressable (tree t)
{
return (is_gimple_id (t) || handled_component_p (t)
! || INDIRECT_REF_P (t));
}
/* Return true if T is a valid gimple constant. */
--- 162,169 ----
is_gimple_addressable (tree t)
{
return (is_gimple_id (t) || handled_component_p (t)
! || INDIRECT_REF_P (t)
! || TREE_CODE (t) == TARGET_MEM_REF);
}
/* Return true if T is a valid gimple constant. */
Index: gimplify.c
===================================================================
*** gimplify.c (revision 137252)
--- gimplify.c (working copy)
*************** pop_gimplify_context (tree body)
*** 194,202 ****
gcc_assert (c && !c->current_bind_expr);
gimplify_ctxp = c->prev_context;
- for (t = c->temps; t ; t = TREE_CHAIN (t))
- DECL_GIMPLE_FORMAL_TEMP_P (t) = 0;
-
if (body)
declare_vars (c->temps, body, false);
else
--- 194,199 ----
*************** build_stack_save_restore (tree *save, tr
*** 1070,1075 ****
--- 1067,1073 ----
save_call =
build_call_expr (implicit_built_in_decls[BUILT_IN_STACK_SAVE], 0);
tmp_var = create_tmp_var (ptr_type_node, "saved_stack");
+ DECL_GIMPLE_FORMAL_TEMP_P (tmp_var) = 1;
*save = build_gimple_modify_stmt (tmp_var, save_call);
*restore =
Index: tree-cfg.c
===================================================================
*** tree-cfg.c (revision 137252)
--- tree-cfg.c (working copy)
*************** verify_expr (tree *tp, int *walk_subtree
*** 3197,3202 ****
--- 3197,3207 ----
gcc_unreachable ();
case GIMPLE_MODIFY_STMT:
+ if (!rhs_predicate_for (GIMPLE_STMT_OPERAND (t, 0))(GIMPLE_STMT_OPERAND (t, 1)))
+ {
+ error ("Invalid rhs for GIMPLE_MODIFY_STMT lhs");
+ return t;
+ }
x = GIMPLE_STMT_OPERAND (t, 0);
if (TREE_CODE (x) == BIT_FIELD_REF
&& is_gimple_reg (TREE_OPERAND (x, 0)))