From: Jan Hubicka Date: Wed, 18 Apr 2018 11:29:26 +0000 (+0200) Subject: re PR lto/85391 (ICE in add_type_duplicate, at ipa-devirt.c:1887) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7d6051b12507a69c82e21fbea867dd8b0eda22c8;p=gcc.git re PR lto/85391 (ICE in add_type_duplicate, at ipa-devirt.c:1887) PR lto/85391 * lto.c (lto_read_decls): Do not test TYPE_CANONICAL before registering odr types. * g++.dg/lto/pr83121_0.C: Update template. * g++.dg/lto/pr83121_1.C: Update template. * g++.dg/lto/pr84805_0.C: Update template. * g++.dg/lto/pr84805_1.C: Update template. * g++.dg/lto/pr84805_2.C: Update template. Co-Authored-By: Martin Liska From-SVN: r259464 --- diff --git a/gcc/lto/ChangeLog b/gcc/lto/ChangeLog index d2b2511710c..fc0ecb79450 100644 --- a/gcc/lto/ChangeLog +++ b/gcc/lto/ChangeLog @@ -1,3 +1,10 @@ +2018-04-18 Jan Hubicka + Martin Liska + + PR lto/85391 + * lto.c (lto_read_decls): Do not test TYPE_CANONICAL before registering odr + types. + 2018-04-11 Martin Liska * lto-symtab.c (lto_symtab_merge_p): Use attribute_value_equal diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c index 97266136aa0..0099398ece9 100644 --- a/gcc/lto/lto.c +++ b/gcc/lto/lto.c @@ -1772,12 +1772,13 @@ lto_read_decls (struct lto_file_decl_data *decl_data, const void *data, seen_type = true; num_prevailing_types++; lto_fixup_prevailing_type (t); - } - /* Compute the canonical type of all types. - ??? Should be able to assert that !TYPE_CANONICAL. */ - if (TYPE_P (t) && !TYPE_CANONICAL (t)) - { - gimple_register_canonical_type (t); + + /* Compute the canonical type of all types. + Because SCC components ar estreame in random (hash) order + we may have enountered the type before while registering + type canonical of a derived type in the same SCC. */ + if (!TYPE_CANONICAL (t)) + gimple_register_canonical_type (t); if (odr_type_p (t)) register_odr_type (t); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8e2a0156f6e..179b4422ecf 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,12 @@ +2018-04-18 Jan Hubicka + Martin Liska + + * g++.dg/lto/pr83121_0.C: Update template. + * g++.dg/lto/pr83121_1.C: Update template. + * g++.dg/lto/pr84805_0.C: Update template. + * g++.dg/lto/pr84805_1.C: Update template. + * g++.dg/lto/pr84805_2.C: Update template. + 2018-04-18 Paolo Carlini PR c++/84630 diff --git a/gcc/testsuite/g++.dg/lto/pr83121_0.C b/gcc/testsuite/g++.dg/lto/pr83121_0.C index ef894c7c868..358b55b8fbd 100644 --- a/gcc/testsuite/g++.dg/lto/pr83121_0.C +++ b/gcc/testsuite/g++.dg/lto/pr83121_0.C @@ -4,8 +4,8 @@ from being optimized away. */ struct Environment { // { dg-lto-warning "8: type 'struct Environment' violates the C\\+\\+ One Definition Rule" } - struct AsyncHooks { - int providers_[2]; // { dg-lto-message "a field of same name but different type is defined in another translation unit" } + struct AsyncHooks { // { dg-lto-warning "10: type 'struct AsyncHooks' violates the C\\+\\+ One Definition Rule" } + int providers_[2]; // { dg-lto-message "the first difference of corresponding definitions is field 'providers_'" } }; AsyncHooks async_hooks_; }; diff --git a/gcc/testsuite/g++.dg/lto/pr83121_1.C b/gcc/testsuite/g++.dg/lto/pr83121_1.C index 2aef1b50957..01b05f4e762 100644 --- a/gcc/testsuite/g++.dg/lto/pr83121_1.C +++ b/gcc/testsuite/g++.dg/lto/pr83121_1.C @@ -1,8 +1,8 @@ struct Environment { - struct AsyncHooks { // { dg-lto-warning "10: type 'struct AsyncHooks' violates the C\\+\\+ One Definition Rule" } - int providers_[1]; // { dg-lto-message "the first difference of corresponding definitions is field 'providers_'" } + struct AsyncHooks { + int providers_[1]; }; - AsyncHooks async_hooks_; + AsyncHooks async_hooks_; // { dg-lto-message "a field of same name but different type is defined in another translation unit" } }; void fn1() { Environment a; } int main () diff --git a/gcc/testsuite/g++.dg/lto/pr84805_0.C b/gcc/testsuite/g++.dg/lto/pr84805_0.C index c34c6340201..34828043d2e 100644 --- a/gcc/testsuite/g++.dg/lto/pr84805_0.C +++ b/gcc/testsuite/g++.dg/lto/pr84805_0.C @@ -1,5 +1,5 @@ // { dg-lto-do link } -// { dg-lto-options {{-O2 -fPIC -shared -flto}} } +// { dg-lto-options {{-O0 -fPIC -shared -flto}} } template < typename _Tp, _Tp __v > struct integral_constant { static constexpr _Tp value = __v; @@ -9,7 +9,7 @@ struct __is_void_helper : false_type {}; struct is_void : __is_void_helper {}; template < typename > struct is_array : false_type {}; namespace __gnu_cxx { -enum _Lock_policy { _S_single, _S_mutex, _S_atomic }; +enum _Lock_policy { _S_single, _S_mutex, _S_atomic }; // { dg-lto-warning "6: type '_Lock_policy' violates the C\\+\\+ One Definition Rule" } const _Lock_policy __default_lock_policy = _S_atomic; } namespace std { using __gnu_cxx::_Lock_policy; @@ -21,7 +21,7 @@ template < typename _Tp, _Lock_policy, bool = is_array< _Tp >::value, bool = is_void::value > class __shared_ptr_access {}; template < typename _Tp, _Lock_policy _Lp > -class __shared_ptr : __shared_ptr_access< _Tp, _Lp > { +class __shared_ptr : __shared_ptr_access< _Tp, _Lp > { // { dg-lto-warning "7: type 'struct __shared_ptr' violates the C\\+\\+ One Definition Rule" } using element_type = _Tp; element_type *_M_ptr; __shared_count< _Lp > _M_refcount; @@ -88,7 +88,7 @@ class ExtNameBuff; class ExtSheetBuffer; class ExcelToSc; class XclImpColRowSettings; -struct RootData { +struct RootData { // { dg-lto-warning "8: type 'struct RootData' violates the C\\+\\+ One Definition Rule" } BiffTyp eDateiTyp; ExtSheetBuffer *pExtSheetBuff; SharedFormulaBuffer *pShrfmlaBuff; diff --git a/gcc/testsuite/g++.dg/lto/pr84805_1.C b/gcc/testsuite/g++.dg/lto/pr84805_1.C index c59a37c5fc0..2d8a45c001a 100644 --- a/gcc/testsuite/g++.dg/lto/pr84805_1.C +++ b/gcc/testsuite/g++.dg/lto/pr84805_1.C @@ -3,7 +3,7 @@ public: virtual ~XclRoot(); }; class XclImpRoot : XclRoot {}; -struct RootData { // { dg-lto-warning "8: type 'struct RootData' violates the C\\+\\+ One Definition Rule" } +struct RootData { XclImpRoot pIR; }; class ExcRoot { diff --git a/gcc/testsuite/g++.dg/lto/pr84805_2.C b/gcc/testsuite/g++.dg/lto/pr84805_2.C index a043dac6674..a1c1a6a8901 100644 --- a/gcc/testsuite/g++.dg/lto/pr84805_2.C +++ b/gcc/testsuite/g++.dg/lto/pr84805_2.C @@ -15,7 +15,7 @@ template < _Lock_policy > class __shared_count { _Sp_counted_base<> *_M_pi; }; template < typename a, _Lock_policy, bool = g< a >::d, bool = t::d > class __shared_ptr_access {}; template < typename a, _Lock_policy l > -class __shared_ptr : __shared_ptr_access< a, l > { // { dg-lto-warning "7: type 'struct __shared_ptr' violates the C\\+\\+ One Definition Rule" } +class __shared_ptr : __shared_ptr_access< a, l > { using m = a; m *_M_ptr; __shared_count< l > _M_refcount;