diff options
author | Richard Guenther <rguenther@suse.de> | 2011-06-17 11:27:37 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2011-06-17 11:27:37 +0000 |
commit | 618b52002bbd8a4773f55661410b939bb8ddb766 (patch) | |
tree | 781cda0ad7f57e5977d1f586d2021c3651d6c07c /gcc/tree-ssa-alias.c | |
parent | 08ef34d03a4c88479663e1662b17566ce846780c (diff) | |
download | gcc-618b52002bbd8a4773f55661410b939bb8ddb766.tar.gz |
backport: re PR tree-optimization/49115 (invalid return value optimization (?) when exception is thrown and caught)
2011-06-17 Richard Guenther <rguenther@suse.de>
Backport from mainline
2011-05-23 Richard Guenther <rguenther@suse.de>
PR tree-optimization/49115
* tree-ssa-alias.c (stmt_kills_ref_p_1): If the assignment
is not necessarily carried out, do not claim it kills the ref.
* tree-ssa-dce.c (mark_aliased_reaching_defs_necessary_1): Likewise.
* g++.dg/torture/pr49115.C: New testcase.
From-SVN: r175148
Diffstat (limited to 'gcc/tree-ssa-alias.c')
-rw-r--r-- | gcc/tree-ssa-alias.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c index 1d213dfa31f..90aebc68dd0 100644 --- a/gcc/tree-ssa-alias.c +++ b/gcc/tree-ssa-alias.c @@ -1652,7 +1652,14 @@ static bool stmt_kills_ref_p_1 (gimple stmt, ao_ref *ref) { if (gimple_has_lhs (stmt) - && TREE_CODE (gimple_get_lhs (stmt)) != SSA_NAME) + && TREE_CODE (gimple_get_lhs (stmt)) != SSA_NAME + /* The assignment is not necessarily carried out if it can throw + and we can catch it in the current function where we could inspect + the previous value. + ??? We only need to care about the RHS throwing. For aggregate + assignments or similar calls and non-call exceptions the LHS + might throw as well. */ + && !stmt_can_throw_internal (stmt)) { tree base, lhs = gimple_get_lhs (stmt); HOST_WIDE_INT size, offset, max_size; |