diff options
author | Jakub Jelinek <jakub@gcc.gnu.org> | 2004-09-23 23:01:02 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2004-09-23 23:01:02 +0200 |
commit | b28b16008e1771360fa4419827ce110159e3949a (patch) | |
tree | 934984b43a2628bfed60b4ccba666f1871a90be4 /gcc/tree-ssa-ccp.c | |
parent | 512baaea75c050149b35fc3bd1c0cc8ed546f53a (diff) | |
download | gcc-b28b16008e1771360fa4419827ce110159e3949a.zip gcc-b28b16008e1771360fa4419827ce110159e3949a.tar.gz gcc-b28b16008e1771360fa4419827ce110159e3949a.tar.bz2 |
tree-flow.h (find_new_referenced_vars): Add prototype.
2004-09-23 Diego Novillo <dnovillo@redhat.com>
Jakub Jelinek <jakub@redhat.com>
* tree-flow.h (find_new_referenced_vars): Add prototype.
* tree-sra.c (find_new_referenced_vars_1, find_new_referenced_vars):
Move to...
* tree-dfa.c (find_new_referenced_vars_1, find_new_referenced_vars):
... here.
(mark_new_vars_to_rename): Walk through all operands.
* tree-ssa-ccp.c (convert_to_gimple_builtin): New function.
(execute_fold_all_builtins): Use it.
(pass_fold_builtins): Add TODO_rename_vars to todo_flags_finish.
* gcc.c-torture/execute/builtins/strcpy-2.c: New test.
* gcc.c-torture/execute/builtins/strcpy-2-lib.c: New.
From-SVN: r87983
Diffstat (limited to 'gcc/tree-ssa-ccp.c')
-rw-r--r-- | gcc/tree-ssa-ccp.c | 44 |
1 files changed, 41 insertions, 3 deletions
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c index f268686..bb37fcf 100644 --- a/gcc/tree-ssa-ccp.c +++ b/gcc/tree-ssa-ccp.c @@ -2099,6 +2099,37 @@ fold_stmt (tree *stmt_p) } +/* Convert EXPR into a GIMPLE value suitable for substitution on the + RHS of an assignment. Insert the necessary statements before + iterator *SI_P. */ + +static tree +convert_to_gimple_builtin (block_stmt_iterator *si_p, tree expr) +{ + tree_stmt_iterator ti; + tree stmt = bsi_stmt (*si_p); + tree tmp, stmts = NULL; + + push_gimplify_context (); + tmp = get_initialized_tmp_var (expr, &stmts, NULL); + pop_gimplify_context (NULL); + + /* The replacement can expose previously unreferenced variables. */ + for (ti = tsi_start (stmts); !tsi_end_p (ti); tsi_next (&ti)) + { + find_new_referenced_vars (tsi_stmt_ptr (ti)); + mark_new_vars_to_rename (tsi_stmt (ti), vars_to_rename); + } + + if (EXPR_HAS_LOCATION (stmt)) + annotate_all_with_locus (&stmts, EXPR_LOCATION (stmt)); + + bsi_insert_before (si_p, stmts, BSI_SAME_STMT); + + return tmp; +} + + /* A simple pass that attempts to fold all builtin functions. This pass is run after we've propagated as many constants as we can. */ @@ -2142,8 +2173,13 @@ execute_fold_all_builtins (void) print_generic_stmt (dump_file, *stmtp, dump_flags); } - if (set_rhs (stmtp, result)) - modify_stmt (*stmtp); + if (!set_rhs (stmtp, result)) + { + result = convert_to_gimple_builtin (&i, result); + if (result && !set_rhs (stmtp, result)) + abort (); + } + modify_stmt (*stmtp); if (dump_file && (dump_flags & TDF_DETAILS)) { @@ -2169,6 +2205,8 @@ struct tree_opt_pass pass_fold_builtins = 0, /* properties_provided */ 0, /* properties_destroyed */ 0, /* todo_flags_start */ - TODO_dump_func | TODO_verify_ssa, /* todo_flags_finish */ + TODO_dump_func + | TODO_verify_ssa + | TODO_rename_vars, /* todo_flags_finish */ 0 /* letter */ }; |