From 9aef53ee4c5daf5ce1137f816680e4c70fdb535c Mon Sep 17 00:00:00 2001 From: Richard Guenther Date: Wed, 27 Apr 2011 10:36:35 +0000 Subject: [PATCH] re PR tree-optimization/48772 (ICE: SIGSEGV in walk_non_aliased_vuses (gimple.h:1100) with -O -fnon-call-exceptions -fno-tree-ccp -fno-tree-dce) 2011-04-27 Richard Guenther PR tree-optimization/48772 * tree-ssa-pre.c (eliminate): Update call stmts after elimination only. * g++.dg/pr48772.C: New testcase. From-SVN: r173019 --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/pr48772.C | 35 ++++++++++++++++++++++++++++++++++ gcc/tree-ssa-pre.c | 10 +++++++++- 4 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/pr48772.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 492a92dad53..276ef484ece 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2011-04-27 Richard Guenther + + PR tree-optimization/48772 + * tree-ssa-pre.c (eliminate): Update call stmts after elimination + only. + 2011-04-27 Richard Guenther * tree-ssa-alias.c (indirect_refs_may_alias_p): Fix diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 19fd6de0cba..4be7479c57a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-04-27 Richard Guenther + + PR tree-optimization/48772 + * g++.dg/pr48772.C: New testcase. + 2011-04-27 Jakub Jelinek PR c/48742 diff --git a/gcc/testsuite/g++.dg/pr48772.C b/gcc/testsuite/g++.dg/pr48772.C new file mode 100644 index 00000000000..39c1094e810 --- /dev/null +++ b/gcc/testsuite/g++.dg/pr48772.C @@ -0,0 +1,35 @@ +// { dg-do compile } +// { dg-options "-O -fnon-call-exceptions -fno-tree-ccp -fno-tree-dce" } + +extern "C" void abort (); + +struct A +{ + void foo () + { + this->bar (); + } + virtual void bar () + { + abort (); + } + ~A () + { + } +}; + +struct B:A +{ + virtual void bar () + { + } +}; + +int +main () +{ + B b; + b.foo (); + return 0; +} + diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c index a833a041bbb..51d9dcde9af 100644 --- a/gcc/tree-ssa-pre.c +++ b/gcc/tree-ssa-pre.c @@ -4186,6 +4186,7 @@ static unsigned int eliminate (void) { VEC (gimple, heap) *to_remove = NULL; + VEC (gimple, heap) *to_update = NULL; basic_block b; unsigned int todo = 0; gimple_stmt_iterator gsi; @@ -4411,7 +4412,7 @@ eliminate (void) } gimple_call_set_fn (stmt, fn); - update_stmt (stmt); + VEC_safe_push (gimple, heap, to_update, stmt); /* When changing a call into a noreturn call, cfg cleanup is needed to fix up the noreturn call. */ @@ -4563,6 +4564,13 @@ eliminate (void) } VEC_free (gimple, heap, to_remove); + /* We cannot update call statements with virtual operands during + SSA walk. This might remove them which in turn makes our + VN lattice invalid. */ + FOR_EACH_VEC_ELT (gimple, to_update, i, stmt) + update_stmt (stmt); + VEC_free (gimple, heap, to_update); + return todo; } -- 2.30.2