From b3e2e29c19d3a3b8fae32db9cbec787d675b13f2 Mon Sep 17 00:00:00 2001 From: Daniel Berlin Date: Wed, 19 Oct 2005 03:34:50 +0000 Subject: [PATCH] re PR tree-optimization/24231 (SSA corruption with C++ code and exceptions and loads) 2005-10-18 Daniel Berlin Fix PR tree-optimization/24231 * tree-ssa-pre.c (try_look_through_load): Skip abnormal phi names (compute_avail): Ditto. From-SVN: r105594 --- gcc/ChangeLog | 7 ++++ gcc/testsuite/g++.dg/tree-ssa/pr24231-1.C | 42 +++++++++++++++++++++++ gcc/testsuite/g++.dg/tree-ssa/pr24231-2.C | 41 ++++++++++++++++++++++ gcc/testsuite/g++.dg/tree-ssa/pr24231-3.C | 28 +++++++++++++++ gcc/tree-ssa-pre.c | 7 ++-- 5 files changed, 123 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/tree-ssa/pr24231-1.C create mode 100644 gcc/testsuite/g++.dg/tree-ssa/pr24231-2.C create mode 100644 gcc/testsuite/g++.dg/tree-ssa/pr24231-3.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 88c5974f2070..38edb127c56c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2005-10-18 Daniel Berlin + + Fix PR tree-optimization/24231 + + * tree-ssa-pre.c (try_look_through_load): Skip abnormal phi names + (compute_avail): Ditto. + 2006-10-18 Richard Henderson PR target/24428 diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr24231-1.C b/gcc/testsuite/g++.dg/tree-ssa/pr24231-1.C new file mode 100644 index 000000000000..d3c053efd435 --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-ssa/pr24231-1.C @@ -0,0 +1,42 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* FRE testcase for PR 24231, problem with PRE coalescing abnormal phis. */ +struct f +{ + int i; +}; +struct h{h();}; +int g(void); +int g1(void) throw(); +int h2222(f*); +void ghh(int); + +int main(void) +{ + int i; + f t; + try + { + i = g1(); + try + { + i = g(); + }catch(...) + {} + int j = i; + try + { t.i = i; + i = g(); + }catch(...) + {} + i = 2; + int h = t.i; + ghh (h); + + g(); + }catch(...) + {} + return i; +} + + diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr24231-2.C b/gcc/testsuite/g++.dg/tree-ssa/pr24231-2.C new file mode 100644 index 000000000000..188b1a26b460 --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-ssa/pr24231-2.C @@ -0,0 +1,41 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* FRE testcase for PR 24231, problem with PRE coalescing abnormal phis. */ +struct f +{ + int i; +}; +struct h{h();}; +int g(void); +int g1(void) throw(); +int h2222(f*); +void ghh(int); + +int main(void) +{ + int i; + f t; + try + { + i = g1(); + try + { + i = g(); + }catch(...) + {} + int j = i; + try + { + i = g(); + }catch(...) + {} + t.i = j; + i = 2; + int h = t.i; + ghh (h); + + g(); + }catch(...) + {} + return i; +} diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr24231-3.C b/gcc/testsuite/g++.dg/tree-ssa/pr24231-3.C new file mode 100644 index 000000000000..a9ea58b1197e --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-ssa/pr24231-3.C @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* PRE testcase for PR 24231, problem with PRE coalescing abnormal phis. */ +struct MemoryManager { + virtual void deallocate() = 0; +}; +struct XalanVector { + ~XalanVector() { + m_memoryManager->deallocate(); + } + void swap(XalanVector& theOther) { + MemoryManager* const theTempManager = m_memoryManager; + m_memoryManager = theOther.m_memoryManager; + theOther.m_memoryManager = theTempManager; + theOther.m_size = 0; + } + void push_back() { + XalanVector theTemp(*this); + theTemp.push_back(); + swap(theTemp); + } + MemoryManager* m_memoryManager; + int m_size; +}; +void f(void) { + XalanVector tempVector; + tempVector.push_back(); +} diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c index b0e79535ee15..425d2204a3c2 100644 --- a/gcc/tree-ssa-pre.c +++ b/gcc/tree-ssa-pre.c @@ -2187,11 +2187,13 @@ try_look_through_load (tree lhs, tree mem_ref, tree stmt, basic_block block) that all of them come from the same statement STORE_STMT. See if there is a useful expression we can deduce from STORE_STMT. */ rhs = TREE_OPERAND (store_stmt, 1); - if (TREE_CODE (rhs) == SSA_NAME + if ((TREE_CODE (rhs) == SSA_NAME + && !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rhs)) || is_gimple_min_invariant (rhs) || TREE_CODE (rhs) == ADDR_EXPR || TREE_INVARIANT (rhs)) { + /* Yay! Compute a value number for the RHS of the statement and add its value to the AVAIL_OUT set for the block. Add the LHS to TMP_GEN. */ @@ -2322,7 +2324,8 @@ compute_avail (void) continue; } } - else if (TREE_CODE (rhs) == SSA_NAME + else if ((TREE_CODE (rhs) == SSA_NAME + && !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rhs)) || is_gimple_min_invariant (rhs) || TREE_CODE (rhs) == ADDR_EXPR || TREE_INVARIANT (rhs) -- 2.43.5