diff options
author | Michael Matz <matz@suse.de> | 2011-11-08 16:47:16 +0000 |
---|---|---|
committer | Michael Matz <matz@gcc.gnu.org> | 2011-11-08 16:47:16 +0000 |
commit | 47598145be96f39a73809240153e5af12bfbcedd (patch) | |
tree | 4dc2b97edd33ddeabf08fbbf07022528b2b4431c /gcc/gimplify.c | |
parent | a58a38b32c7ed8b4843e8d2b2658323204fa96ed (diff) | |
download | gcc-47598145be96f39a73809240153e5af12bfbcedd.zip gcc-47598145be96f39a73809240153e5af12bfbcedd.tar.gz gcc-47598145be96f39a73809240153e5af12bfbcedd.tar.bz2 |
gengtype.c (write_field_root): Avoid out-of-scope access of newv.
* gengtype.c (write_field_root): Avoid out-of-scope access of newv.
* tree-stdarg.c (execute_optimize_stdarg): Accept clobbers.
* tree.h (TREE_CLOBBER_P): New macro.
* gimple.h (gimple_clobber_p): New inline function.
* gimplify.c (gimplify_bind_expr): Add clobbers for all variables
that go out of scope and live in memory.
* tree-ssa-operands.c (get_expr_operands): Transfer volatility also
for constructors.
* cfgexpand.c (decl_to_stack_part): New static variable.
(add_stack_var): Allocate it, and remember mapping.
(fini_vars_expansion): Deallocate it.
(stack_var_conflict_p): Add early outs.
(visit_op, visit_conflict, add_scope_conflicts_1,
add_scope_conflicts): New static functions.
(expand_used_vars_for_block): Don't call add_stack_var_conflict, tidy.
(expand_used_vars): Add scope conflicts.
(expand_gimple_stmt_1): Expand clobbers to nothing.
(expand_debug_expr): Ditto.
* tree-pretty-print.c (dump_generic_node): Dump clobbers nicely.
* tree-ssa-live.c (remove_unused_locals): Remove clobbers that
refer to otherwise unused locals.
* tree-sra.c (build_accesses_from_assign): Ignore clobbers.
* tree-ssa-dce.c (mark_stmt_if_obviously_necessary): Clobbers of
SSA names aren't necessary.
(propagate_necessity): Accept and ignore constructors on the rhs,
tidy.
* gimple.c (walk_gimple_op): Accept constructors like mem_rhs.
* tree-ssa-structalias.c (find_func_aliases): Clobbers don't store
any known value.
* tree-ssa-sccvn.c (vn_reference_lookup_3): Ditto, in particular they
don't zero-initialize something.
* tree-ssa-phiopt.c (cond_if_else_store_replacement_1): Ignore
clobber RHS, we don't want PHI nodes with those.
testsuite/
* gcc.dg/tree-ssa/20031015-1.c: Adjust.
* g++.dg/tree-ssa/ehcleanup-1.C: Ditto.
* g++.dg/eh/builtin1.C: Rewrite to not use local variables.
* g++.dg/eh/builtin2.C: Ditto.
* g++.dg/eh/builtin3.C: Ditto.
From-SVN: r181172
Diffstat (limited to 'gcc/gimplify.c')
-rw-r--r-- | gcc/gimplify.c | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 99e0d0d..9845b69 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -1135,7 +1135,8 @@ gimplify_bind_expr (tree *expr_p, gimple_seq *pre_p) bool old_save_stack = gimplify_ctxp->save_stack; tree t; gimple gimple_bind; - gimple_seq body; + gimple_seq body, cleanup; + gimple stack_save; tree temp = voidify_wrapper_expr (bind_expr, NULL); @@ -1181,22 +1182,50 @@ gimplify_bind_expr (tree *expr_p, gimple_seq *pre_p) gimplify_stmt (&BIND_EXPR_BODY (bind_expr), &body); gimple_bind_set_body (gimple_bind, body); + cleanup = NULL; + stack_save = NULL; if (gimplify_ctxp->save_stack) { - gimple stack_save, stack_restore, gs; - gimple_seq cleanup, new_body; + gimple stack_restore; /* Save stack on entry and restore it on exit. Add a try_finally block to achieve this. Note that mudflap depends on the format of the emitted code: see mx_register_decls(). */ build_stack_save_restore (&stack_save, &stack_restore); - cleanup = new_body = NULL; gimplify_seq_add_stmt (&cleanup, stack_restore); + } + + /* Add clobbers for all variables that go out of scope. */ + for (t = BIND_EXPR_VARS (bind_expr); t ; t = DECL_CHAIN (t)) + { + if (TREE_CODE (t) == VAR_DECL + && !is_global_var (t) + && DECL_CONTEXT (t) == current_function_decl + && !DECL_HARD_REGISTER (t) + && !TREE_THIS_VOLATILE (t) + && !DECL_HAS_VALUE_EXPR_P (t) + /* Only care for variables that have to be in memory. Others + will be rewritten into SSA names, hence moved to the top-level. */ + && needs_to_live_in_memory (t)) + { + tree clobber = build_constructor (TREE_TYPE (t), NULL); + TREE_THIS_VOLATILE (clobber) = 1; + gimplify_seq_add_stmt (&cleanup, gimple_build_assign (t, clobber)); + } + } + + if (cleanup) + { + gimple gs; + gimple_seq new_body; + + new_body = NULL; gs = gimple_build_try (gimple_bind_body (gimple_bind), cleanup, GIMPLE_TRY_FINALLY); - gimplify_seq_add_stmt (&new_body, stack_save); + if (stack_save) + gimplify_seq_add_stmt (&new_body, stack_save); gimplify_seq_add_stmt (&new_body, gs); gimple_bind_set_body (gimple_bind, new_body); } |