diff options
author | Richard Guenther <rguenther@suse.de> | 2012-10-04 11:48:21 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2012-10-04 11:48:21 +0000 |
commit | 678771ad9cf341b31f3a7717eefb868cac2221ec (patch) | |
tree | dd9d76cd0e700400bbb123ca0bf30bce743ece75 | |
parent | 5c1eb617e427a417dd7e1f79eee15b38362dbf53 (diff) | |
download | gcc-678771ad9cf341b31f3a7717eefb868cac2221ec.zip gcc-678771ad9cf341b31f3a7717eefb868cac2221ec.tar.gz gcc-678771ad9cf341b31f3a7717eefb868cac2221ec.tar.bz2 |
re PR tree-optimization/54735 (Segmentation fault in walk_aliased_vdefs_1)
2012-10-04 Richard Guenther <rguenther@suse.de>
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.
From-SVN: r192078
-rw-r--r-- | gcc/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/torture/pr54735.C | 179 | ||||
-rw-r--r-- | gcc/tree-ssa-pre.c | 10 |
4 files changed, 199 insertions, 3 deletions
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 <rguenther@suse.de> - 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 <rguenther@suse.de> + + 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 <rguenther@suse.de> + + PR middle-end/54735 + * g++.dg/torture/pr54735.C: New testcase. + 2012-10-04 Eric Botcazou <ebotcazou@adacore.com> 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); +}; +template<typename>struct A; +template<typename, int, int, int = 0 ? : 0, int = 0, int = 0>class N; +template<typename>class O; +template<typename>struct B; +struct C +{ + enum + { value }; +}; +class D +{ +public: + enum + { ret }; +}; +struct F +{ + enum + { ret = 0 ? : 0 }; +}; +template<typename Derived>struct G +{ + typedef O<Derived>type; +}; +struct H +{ + void operator * (); +}; +struct I +{ + enum + { RequireInitialization = C::value ? : 0, ReadCost }; +}; +template<typename Derived>struct J +{ + enum + { ret = A<Derived>::InnerStrideAtCompileTime }; +}; +template<typename Derived>struct K +{ + enum + { ret = A<Derived>::OuterStrideAtCompileTime }; +}; +template<typename Derived>class P : H +{ +public: + using H::operator *; + typedef typename A<Derived>::Scalar Scalar; + enum + { RowsAtCompileTime = + A<Derived>::RowsAtCompileTime, ColsAtCompileTime = + A<Derived>::ColsAtCompileTime, SizeAtCompileTime = + F::ret, MaxRowsAtCompileTime = + A<Derived>::MaxRowsAtCompileTime, MaxColsAtCompileTime = + A<Derived>::MaxColsAtCompileTime, MaxSizeAtCompileTime = + F::ret, Flags = + A<Derived>::Flags ? : 0 ? : 0, CoeffReadCost = + A<Derived>::CoeffReadCost, InnerStrideAtCompileTime = + J<Derived>::ret, OuterStrideAtCompileTime = K<Derived>::ret }; + B<Derived> operator << (const Scalar&); +}; + +template<typename Derived>class O : public P<Derived> +{}; + +template<int _Cols>class L +{ +public: + + int cols() + { + return _Cols; + } +}; +template<typename Derived>class Q : public G<Derived>::type +{ +public: + typedef typename G<Derived>::type Base; + typedef typename A<Derived>::Index Index; + typedef typename A<Derived>::Scalar Scalar; + L<Base::ColsAtCompileTime> m_storage; + Index cols() + { + return m_storage.cols(); + } + + Scalar& coeffRef(Index, + Index); +}; + +template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, + int _MaxCols>struct A<N<_Scalar, _Rows, _Cols, _Options, _MaxRows, + _MaxCols> > +{ + typedef _Scalar Scalar; + typedef int Index; + enum + { RowsAtCompileTime, ColsAtCompileTime = + _Cols, MaxRowsAtCompileTime, MaxColsAtCompileTime, Flags = + D::ret, CoeffReadCost = + I::ReadCost, InnerStrideAtCompileTime, OuterStrideAtCompileTime = + 0 ? : 0 }; +}; +template<typename _Scalar, int, int _Cols, int, int, + int>class N : public Q<N<_Scalar, 0, _Cols> > +{ +public: + Q<N> Base; + template<typename T0, typename T1>N(const T0&, + const T1&); +}; +void +__assert_fail(int) +throw() __attribute__((__noreturn__)); +template<typename XprType>struct 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<void>(0) : __assert_fail(0); + } + m_col < m_xpr.cols() + && "Too " ? static_cast<void>(0) : __assert_fail(1); + m_currentBlockRows ? static_cast<void>(0) : __assert_fail(4); + m_xpr.coeffRef(0, m_col++) = 0; + return *this; + } + ~B() + { + 1 + m_currentBlockRows && m_col + && "Too " ? static_cast<void>(0) : __assert_fail(0); + } + + XprType& m_xpr; + Index m_col; + Index m_currentBlockRows; +}; + +template<typename Derived>B<Derived>P< + Derived >::operator << (const Scalar&) +{ + return B<Derived>(*static_cast<Derived *>(this), 0); +} + +template<class NT, int s>void + check_() +{ + N<NT, 0, s>m(0, 0); + m << 0, 0, 0, 0; +} + +template<class NT>void check() +{ + check_<NT, 3>(); +} + +int main() +{ + check<M>(); +} 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 */ } }; |