From 0e316dd6da6c6fa86e3f3a3a1d71d000dd25918f Mon Sep 17 00:00:00 2001 From: rguenth Date: Thu, 4 Oct 2012 11:48:21 +0000 Subject: [PATCH] 2012-10-04 Richard Guenther PR middle-end/54735 * tree-ssa-pre.c (do_pre): Make sure to update virtual SSA form before cleaning up the CFG. * g++.dg/torture/pr54735.C: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@192078 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 8 +- gcc/testsuite/ChangeLog | 5 + gcc/testsuite/g++.dg/torture/pr54735.C | 179 +++++++++++++++++++++++++++++++++ gcc/tree-ssa-pre.c | 10 +- 4 files changed, 199 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/g++.dg/torture/pr54735.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index da28a56..1e030d9 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,6 +1,12 @@ 2012-10-04 Richard Guenther - PR lto/47788 + PR middle-end/54735 + * tree-ssa-pre.c (do_pre): Make sure to update virtual SSA form before + cleaning up the CFG. + +2012-10-04 Richard Guenther + + PR lto/47799 * tree-streamer-out.c (write_ts_block_tree_pointers): For inlined functions outer scopes write the ultimate origin as BLOCK_ABSTRACT_ORIGIN and BLOCK_SOURCE_LOCATION. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ecb4d31..6b6963e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2012-10-04 Richard Guenther + + PR middle-end/54735 + * g++.dg/torture/pr54735.C: New testcase. + 2012-10-04 Eric Botcazou PR rtl-optimization/54739 diff --git a/gcc/testsuite/g++.dg/torture/pr54735.C b/gcc/testsuite/g++.dg/torture/pr54735.C new file mode 100644 index 0000000..0604ec5 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr54735.C @@ -0,0 +1,179 @@ +// { dg-do compile } + +class Gmpfr +{}; +class M : Gmpfr +{ +public: + Gmpfr infconst; + M(int); +}; +templatestruct A; +templateclass N; +templateclass O; +templatestruct B; +struct C +{ + enum + { value }; +}; +class D +{ +public: + enum + { ret }; +}; +struct F +{ + enum + { ret = 0 ? : 0 }; +}; +templatestruct G +{ + typedef Otype; +}; +struct H +{ + void operator * (); +}; +struct I +{ + enum + { RequireInitialization = C::value ? : 0, ReadCost }; +}; +templatestruct J +{ + enum + { ret = A::InnerStrideAtCompileTime }; +}; +templatestruct K +{ + enum + { ret = A::OuterStrideAtCompileTime }; +}; +templateclass P : H +{ +public: + using H::operator *; + typedef typename A::Scalar Scalar; + enum + { RowsAtCompileTime = + A::RowsAtCompileTime, ColsAtCompileTime = + A::ColsAtCompileTime, SizeAtCompileTime = + F::ret, MaxRowsAtCompileTime = + A::MaxRowsAtCompileTime, MaxColsAtCompileTime = + A::MaxColsAtCompileTime, MaxSizeAtCompileTime = + F::ret, Flags = + A::Flags ? : 0 ? : 0, CoeffReadCost = + A::CoeffReadCost, InnerStrideAtCompileTime = + J::ret, OuterStrideAtCompileTime = K::ret }; + B operator << (const Scalar&); +}; + +templateclass O : public P +{}; + +templateclass L +{ +public: + + int cols() + { + return _Cols; + } +}; +templateclass Q : public G::type +{ +public: + typedef typename G::type Base; + typedef typename A::Index Index; + typedef typename A::Scalar Scalar; + L m_storage; + Index cols() + { + return m_storage.cols(); + } + + Scalar& coeffRef(Index, + Index); +}; + +templatestruct A > +{ + typedef _Scalar Scalar; + typedef int Index; + enum + { RowsAtCompileTime, ColsAtCompileTime = + _Cols, MaxRowsAtCompileTime, MaxColsAtCompileTime, Flags = + D::ret, CoeffReadCost = + I::ReadCost, InnerStrideAtCompileTime, OuterStrideAtCompileTime = + 0 ? : 0 }; +}; +templateclass N : public Q > +{ +public: + Q Base; + templateN(const T0&, + const T1&); +}; +void +__assert_fail(int) +throw() __attribute__((__noreturn__)); +templatestruct B +{ + typedef typename XprType::Scalar Scalar; + typedef typename XprType::Index Index; + B(XprType & p1, const Scalar &) : m_xpr(p1), m_col(), + m_currentBlockRows(1) + {} B& operator, (const Scalar&) + { + Index a; + + if (m_col == m_xpr.cols()) + { + m_col = 0; + m_currentBlockRows = 1; + a && "Too " ? static_cast(0) : __assert_fail(0); + } + m_col < m_xpr.cols() + && "Too " ? static_cast(0) : __assert_fail(1); + m_currentBlockRows ? static_cast(0) : __assert_fail(4); + m_xpr.coeffRef(0, m_col++) = 0; + return *this; + } + ~B() + { + 1 + m_currentBlockRows && m_col + && "Too " ? static_cast(0) : __assert_fail(0); + } + + XprType& m_xpr; + Index m_col; + Index m_currentBlockRows; +}; + +templateBP< + Derived >::operator << (const Scalar&) +{ + return B(*static_cast(this), 0); +} + +templatevoid + check_() +{ + Nm(0, 0); + m << 0, 0, 0, 0; +} + +templatevoid check() +{ + check_(); +} + +int main() +{ + check(); +} diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c index 86c33d3..8dbbed2 100644 --- a/gcc/tree-ssa-pre.c +++ b/gcc/tree-ssa-pre.c @@ -4820,6 +4820,13 @@ do_pre (void) free_scc_vn (); + /* Tail merging invalidates the virtual SSA web, together with + cfg-cleanup opportunities exposed by PRE this will wreck the + SSA updating machinery. So make sure to run update-ssa + manually, before eventually scheduling cfg-cleanup as part of + the todo. */ + update_ssa (TODO_update_ssa_only_virtuals); + return todo; } @@ -4845,8 +4852,7 @@ struct gimple_opt_pass pass_pre = 0, /* properties_provided */ 0, /* properties_destroyed */ TODO_rebuild_alias, /* todo_flags_start */ - TODO_update_ssa_only_virtuals | TODO_ggc_collect - | TODO_verify_ssa /* todo_flags_finish */ + TODO_ggc_collect | TODO_verify_ssa /* todo_flags_finish */ } }; -- 2.7.4