Hi! On Sat, Apr 25, 2020 at 12:03:10PM +0200, Jakub Jelinek wrote: > As reported by Iain and David, powerpc-darwin and powerpc-aix* have C++14 > vs. C++17 ABI incompatibilities which are not fixed by mere adding of > cxx17_empty_base_field_p calls. Unlike the issues that were seen on other > targets where the artificial empty base field affected function argument > passing or returning of values, on these two targets the difference is > during class layout, not afterwards (e.g. > struct empty_base {}; > struct S : public empty_base { unsigned long long l[2]; }; > will have different __alignof__ (S) between C++14 and C++17 (or possibly > with double instead of unsigned long long too)). > > The aim of the calls.c (cxx17_empty_base_field_p) was not to match random > artificial fields with zero size, because they could be created by something > else for some other reason, thus the DECL_SIZE is bitsize_zero but TYPE_SIZE > is non-zero check. Unfortunately, during the class layout, the empty base > fields have a different type, one which has zero size, so the predicate only > works after the class is laid out completely. > > This patch adds a langhook, which will return true for those cases. It > shouldn't be problematic with LTO, because lto1 should see only > structures/classes that are already laid out, or if it does some structure > layout, it won't be something that has C++17 empty base artificial fields.
Ah okay. Maybe this *whole* thing should have been a langhook? > Tested with cross to powerpc-darwin12 on a simple testcase given from Iain, > but otherwise untested. > Iain/David, could you please test this on your targets? The rs6000 part is fine (and the rest looks good, too). If Iain and David agree of course :-) Segher > 2020-04-25 Jakub Jelinek <ja...@redhat.com> > > PR target/94707 > * langhooks.h (struct lang_hooks_for_decls): Add > cxx17_empty_base_field_p member. > * langhooks-def.h (LANG_HOOKS_CXX17_EMPTY_BASE_FIELD_P): Define. > (LANG_HOOKS_DECLS): Use it. > * calls.c (cxx17_empty_base_field_p): Use > langhooks.decls.cxx17_empty_base_field_p. > * config/rs6000/rs6000.c (rs6000_special_round_type_align, > darwin_rs6000_special_round_type_align): Skip cxx17_empty_base_field_p > fields. > cp/ > * cp-objcp-common.h (cp_cxx17_empty_base_field_p): Declare. > (LANG_HOOKS_CXX17_EMPTY_BASE_FIELD_P): Redefine. > * class.c (cp_cxx17_empty_base_field_p): New function.