aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimple-fold.c
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2010-10-05 10:37:12 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2010-10-05 10:37:12 +0000
commit6e5723262255ea4d43d14d7c959e4dcc28cd01c3 (patch)
tree05ebfcb5ef936e811e19a264334216b2b41c4b19 /gcc/gimple-fold.c
parentce417b8f3fd61e8cbf0bc5cbedac464b009458d4 (diff)
downloadgcc-6e5723262255ea4d43d14d7c959e4dcc28cd01c3.zip
gcc-6e5723262255ea4d43d14d7c959e4dcc28cd01c3.tar.gz
gcc-6e5723262255ea4d43d14d7c959e4dcc28cd01c3.tar.bz2
re PR middle-end/45877 (invalid write in gimplify_and_update_call_from_tree)
2010-10-05 Richard Guenther <rguenther@suse.de> PR middle-end/45877 * gimple-fold.c (gimplify_and_update_call_from_tree): Handle case where gimplification optimizes away the stmt. * g++.dg/torture/pr45877.C: New testcase. From-SVN: r164984
Diffstat (limited to 'gcc/gimple-fold.c')
-rw-r--r--gcc/gimple-fold.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c
index 0a6c746..d412eb2 100644
--- a/gcc/gimple-fold.c
+++ b/gcc/gimple-fold.c
@@ -932,7 +932,21 @@ gimplify_and_update_call_from_tree (gimple_stmt_iterator *si_p, tree expr)
push_gimplify_context (&gctx);
if (lhs == NULL_TREE)
- gimplify_and_add (expr, &stmts);
+ {
+ gimplify_and_add (expr, &stmts);
+ /* We can end up with folding a memcpy of an empty class assignment
+ which gets optimized away by C++ gimplification. */
+ if (gimple_seq_empty_p (stmts))
+ {
+ if (gimple_in_ssa_p (cfun))
+ {
+ unlink_stmt_vdef (stmt);
+ release_defs (stmt);
+ }
+ gsi_remove (si_p, true);
+ return;
+ }
+ }
else
tmp = get_initialized_tmp_var (expr, &stmts, NULL);