Commit 034b8ae4 by Richard Guenther Committed by Richard Biener

re PR tree-optimization/47632 (ICE: verify_flow_info failed: BB 4 can not throw…

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
parent 298362c8
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> 2011-02-08 Nick Clifton <nickc@redhat.com>
* config/mn10300/mn10300.opt (mliw): New command line option. * config/mn10300/mn10300.opt (mliw): New command line option.
......
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> 2011-02-07 Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
* g++.dg/abi/packed1.C: Expect warning on spu-*-* as well. * g++.dg/abi/packed1.C: Expect warning on spu-*-* as well.
......
// { 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 ();
}
...@@ -299,34 +299,34 @@ can_propagate_from (gimple def_stmt) ...@@ -299,34 +299,34 @@ can_propagate_from (gimple def_stmt)
return true; return true;
} }
/* Remove a copy chain ending in NAME along the defs but not /* Remove a copy chain ending in NAME along the defs.
further or including UP_TO_STMT. If NAME was replaced in If NAME was replaced in its only use then this function can be used
its only use then this function can be used to clean up to clean up dead stmts. Returns true if cleanup-cfg has to run. */
dead stmts. Returns true if UP_TO_STMT can be removed
as well, otherwise false. */
static bool 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_iterator gsi;
gimple stmt; gimple stmt;
bool cfg_changed = false;
do { do {
basic_block bb;
if (!has_zero_uses (name)) if (!has_zero_uses (name))
return false; return cfg_changed;
stmt = SSA_NAME_DEF_STMT (name); stmt = SSA_NAME_DEF_STMT (name);
if (stmt == up_to_stmt)
return true;
gsi = gsi_for_stmt (stmt); gsi = gsi_for_stmt (stmt);
bb = gimple_bb (stmt);
release_defs (stmt); release_defs (stmt);
gsi_remove (&gsi, true); gsi_remove (&gsi, true);
cfg_changed |= gimple_purge_dead_eh_edges (bb);
name = (gimple_assign_copy_p (stmt)) ? gimple_assign_rhs1 (stmt) : NULL; name = (gimple_assign_copy_p (stmt)) ? gimple_assign_rhs1 (stmt) : NULL;
} while (name && TREE_CODE (name) == SSA_NAME); } 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, /* 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) ...@@ -468,9 +468,8 @@ forward_propagate_into_gimple_cond (gimple stmt)
update_stmt (stmt); update_stmt (stmt);
/* Remove defining statements. */ /* Remove defining statements. */
remove_prop_source_from_use (name, NULL); if (remove_prop_source_from_use (name)
|| is_gimple_min_invariant (tmp))
if (is_gimple_min_invariant (tmp))
did_something = 2; did_something = 2;
else if (did_something == 0) else if (did_something == 0)
did_something = 1; did_something = 1;
...@@ -579,9 +578,8 @@ forward_propagate_into_cond (gimple_stmt_iterator *gsi_p) ...@@ -579,9 +578,8 @@ forward_propagate_into_cond (gimple_stmt_iterator *gsi_p)
update_stmt (stmt); update_stmt (stmt);
/* Remove defining statements. */ /* Remove defining statements. */
remove_prop_source_from_use (name, NULL); if (remove_prop_source_from_use (name)
|| is_gimple_min_invariant (tmp))
if (is_gimple_min_invariant (tmp))
did_something = 2; did_something = 2;
else if (did_something == 0) else if (did_something == 0)
did_something = 1; did_something = 1;
...@@ -1207,9 +1205,6 @@ forward_propagate_comparison (gimple stmt) ...@@ -1207,9 +1205,6 @@ forward_propagate_comparison (gimple stmt)
update_stmt (use_stmt); update_stmt (use_stmt);
} }
/* Remove defining statements. */
remove_prop_source_from_use (name, stmt);
if (dump_file && (dump_flags & TDF_DETAILS)) if (dump_file && (dump_flags & TDF_DETAILS))
{ {
tree old_rhs = rhs_to_tree (TREE_TYPE (gimple_assign_lhs (stmt)), tree old_rhs = rhs_to_tree (TREE_TYPE (gimple_assign_lhs (stmt)),
...@@ -1221,7 +1216,8 @@ forward_propagate_comparison (gimple stmt) ...@@ -1221,7 +1216,8 @@ forward_propagate_comparison (gimple stmt)
fprintf (dump_file, "'\n"); fprintf (dump_file, "'\n");
} }
return true; /* Remove defining statements. */
return remove_prop_source_from_use (name);
} }
return false; return false;
...@@ -2051,13 +2047,8 @@ tree_ssa_forward_propagate_single_use_vars (void) ...@@ -2051,13 +2047,8 @@ tree_ssa_forward_propagate_single_use_vars (void)
== tcc_comparison) == tcc_comparison)
{ {
if (forward_propagate_comparison (stmt)) if (forward_propagate_comparison (stmt))
{ cfg_changed = true;
release_defs (stmt); gsi_next (&gsi);
todoflags |= TODO_remove_unused_locals;
gsi_remove (&gsi, true);
}
else
gsi_next (&gsi);
} }
else if (gimple_assign_rhs_code (stmt) == BIT_AND_EXPR) else if (gimple_assign_rhs_code (stmt) == BIT_AND_EXPR)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment