diff options
author | Richard Guenther <rguenther@suse.de> | 2011-02-08 10:44:06 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2011-02-08 10:44:06 +0000 |
commit | 034b8ae4f8c89314b13879ef2d403c14daa5c4fd (patch) | |
tree | 5a479057359965e6469131ee3ff8041f18fa3e2e /gcc | |
parent | 298362c83f1e4250dc2598fa11e8f6a3bacd6153 (diff) | |
download | gcc-034b8ae4f8c89314b13879ef2d403c14daa5c4fd.zip gcc-034b8ae4f8c89314b13879ef2d403c14daa5c4fd.tar.gz gcc-034b8ae4f8c89314b13879ef2d403c14daa5c4fd.tar.bz2 |
re PR tree-optimization/47632 (ICE: verify_flow_info failed: BB 4 can not throw but has an EH edge with -fnon-call-exceptions -ftrapv and operator new[])
2011-02-08 Richard Guenther <rguenther@suse.de>
PR tree-optimization/47632
* tree-ssa-forwprop.c (remove_prop_source_from_use): Remove
unused up_to_stmt parameter, return whether cfg-cleanup is
necessary, remove EH info properly.
(forward_propagate_into_gimple_cond): Adjust caller.
(forward_propagate_into_cond): Likewise.
(forward_propagate_comparison): Likewise.
(tree_ssa_forward_propagate_single_use_vars): Make
forward_propagate_comparison case similar to the two others.
* g++.dg/opt/pr47632.C: New testcase.
From-SVN: r169917
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 12 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/opt/pr47632.C | 18 | ||||
-rw-r--r-- | gcc/tree-ssa-forwprop.c | 47 |
4 files changed, 54 insertions, 28 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3fd6d02..c485326 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,15 @@ +2011-02-08 Richard Guenther <rguenther@suse.de> + + PR tree-optimization/47632 + * tree-ssa-forwprop.c (remove_prop_source_from_use): Remove + unused up_to_stmt parameter, return whether cfg-cleanup is + necessary, remove EH info properly. + (forward_propagate_into_gimple_cond): Adjust caller. + (forward_propagate_into_cond): Likewise. + (forward_propagate_comparison): Likewise. + (tree_ssa_forward_propagate_single_use_vars): Make + forward_propagate_comparison case similar to the two others. + 2011-02-08 Nick Clifton <nickc@redhat.com> * config/mn10300/mn10300.opt (mliw): New command line option. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index fef7869..51b225f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-02-08 Richard Guenther <rguenther@suse.de> + + PR tree-optimization/47632 + * g++.dg/opt/pr47632.C: New testcase. + 2011-02-07 Ulrich Weigand <Ulrich.Weigand@de.ibm.com> * g++.dg/abi/packed1.C: Expect warning on spu-*-* as well. diff --git a/gcc/testsuite/g++.dg/opt/pr47632.C b/gcc/testsuite/g++.dg/opt/pr47632.C new file mode 100644 index 0000000..4b0572a --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/pr47632.C @@ -0,0 +1,18 @@ +// { dg-do compile } +// { dg-options "-O -fnon-call-exceptions -ftrapv" } + +template < typename > struct S +{ + int n; + void bar () + { + int *i = new int[n]; + } +}; + +void +foo (S < char >*s) +{ + s->bar (); +} + diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c index ee12e40..f183159 100644 --- a/gcc/tree-ssa-forwprop.c +++ b/gcc/tree-ssa-forwprop.c @@ -299,34 +299,34 @@ can_propagate_from (gimple def_stmt) return true; } -/* Remove a copy chain ending in NAME along the defs but not - further or including UP_TO_STMT. If NAME was replaced in - its only use then this function can be used to clean up - dead stmts. Returns true if UP_TO_STMT can be removed - as well, otherwise false. */ +/* Remove a copy chain ending in NAME along the defs. + If NAME was replaced in its only use then this function can be used + to clean up dead stmts. Returns true if cleanup-cfg has to run. */ static bool -remove_prop_source_from_use (tree name, gimple up_to_stmt) +remove_prop_source_from_use (tree name) { gimple_stmt_iterator gsi; gimple stmt; + bool cfg_changed = false; do { + basic_block bb; + if (!has_zero_uses (name)) - return false; + return cfg_changed; stmt = SSA_NAME_DEF_STMT (name); - if (stmt == up_to_stmt) - return true; - gsi = gsi_for_stmt (stmt); + bb = gimple_bb (stmt); release_defs (stmt); gsi_remove (&gsi, true); + cfg_changed |= gimple_purge_dead_eh_edges (bb); name = (gimple_assign_copy_p (stmt)) ? gimple_assign_rhs1 (stmt) : NULL; } while (name && TREE_CODE (name) == SSA_NAME); - return false; + return cfg_changed; } /* Return the rhs of a gimple_assign STMT in a form of a single tree, @@ -468,9 +468,8 @@ forward_propagate_into_gimple_cond (gimple stmt) update_stmt (stmt); /* Remove defining statements. */ - remove_prop_source_from_use (name, NULL); - - if (is_gimple_min_invariant (tmp)) + if (remove_prop_source_from_use (name) + || is_gimple_min_invariant (tmp)) did_something = 2; else if (did_something == 0) did_something = 1; @@ -579,9 +578,8 @@ forward_propagate_into_cond (gimple_stmt_iterator *gsi_p) update_stmt (stmt); /* Remove defining statements. */ - remove_prop_source_from_use (name, NULL); - - if (is_gimple_min_invariant (tmp)) + if (remove_prop_source_from_use (name) + || is_gimple_min_invariant (tmp)) did_something = 2; else if (did_something == 0) did_something = 1; @@ -1207,9 +1205,6 @@ forward_propagate_comparison (gimple stmt) update_stmt (use_stmt); } - /* Remove defining statements. */ - remove_prop_source_from_use (name, stmt); - if (dump_file && (dump_flags & TDF_DETAILS)) { tree old_rhs = rhs_to_tree (TREE_TYPE (gimple_assign_lhs (stmt)), @@ -1221,7 +1216,8 @@ forward_propagate_comparison (gimple stmt) fprintf (dump_file, "'\n"); } - return true; + /* Remove defining statements. */ + return remove_prop_source_from_use (name); } return false; @@ -2051,13 +2047,8 @@ tree_ssa_forward_propagate_single_use_vars (void) == tcc_comparison) { if (forward_propagate_comparison (stmt)) - { - release_defs (stmt); - todoflags |= TODO_remove_unused_locals; - gsi_remove (&gsi, true); - } - else - gsi_next (&gsi); + cfg_changed = true; + gsi_next (&gsi); } else if (gimple_assign_rhs_code (stmt) == BIT_AND_EXPR) { |