On Wed, Sep 23, 2026 at 08:57:49PM -0700, Andrea Pinski wrote:
> > > +/* Test mangling of basic builtin types.  */
> > > +
> > > +static void
> > > +test_typeinfo_basic_types ()
> > > +{
> > > +  ASSERT_STREQ ("v", kcfi_test_mangle (void_type_node).c_str ());
> > > +  ASSERT_STREQ ("c", kcfi_test_mangle (char_type_node).c_str ());
> > > +  ASSERT_STREQ ("a", kcfi_test_mangle (signed_char_type_node).c_str ());
> > > +  ASSERT_STREQ ("h", kcfi_test_mangle (unsigned_char_type_node).c_str 
> > > ());
> > > +  ASSERT_STREQ ("s", kcfi_test_mangle (short_integer_type_node).c_str 
> > > ());
> > > +  ASSERT_STREQ ("t", kcfi_test_mangle (short_unsigned_type_node).c_str 
> > > ());
> > > +  ASSERT_STREQ ("i", kcfi_test_mangle (integer_type_node).c_str ());
> > > +  ASSERT_STREQ ("j", kcfi_test_mangle (unsigned_type_node).c_str ());
> > > +  ASSERT_STREQ ("l", kcfi_test_mangle (long_integer_type_node).c_str ());
> > > +  ASSERT_STREQ ("m", kcfi_test_mangle (long_unsigned_type_node).c_str 
> > > ());
> > > +  ASSERT_STREQ ("x", kcfi_test_mangle 
> > > (long_long_integer_type_node).c_str ());
> > > +  ASSERT_STREQ ("y", kcfi_test_mangle 
> > > (long_long_unsigned_type_node).c_str ());
> > > +  ASSERT_STREQ ("f", kcfi_test_mangle (float_type_node).c_str ());
> > > +  ASSERT_STREQ ("d", kcfi_test_mangle (double_type_node).c_str ());
> > > +  ASSERT_STREQ ("e", kcfi_test_mangle (long_double_type_node).c_str ());
> >
> > I looked at this on s390x.  We actually change the mangling of long
> > double if we are on a target where long double is 128bit IEEE to a
> > "g".  This causes this self-test to fail.  I suggest to add this patch
> > on top of our patch to fix this:
> >
> > diff --git a/gcc/kcfi-typeinfo.cc b/gcc/kcfi-typeinfo.cc
> > index b6723fac48da..fab06249ae16 100644
> > --- a/gcc/kcfi-typeinfo.cc
> > +++ b/gcc/kcfi-typeinfo.cc
> > @@ -659,7 +659,14 @@ test_typeinfo_basic_types ()
> >    ASSERT_STREQ ("y", kcfi_test_mangle (long_long_unsigned_type_node).c_str 
> > ());
> >    ASSERT_STREQ ("f", kcfi_test_mangle (float_type_node).c_str ());
> >    ASSERT_STREQ ("d", kcfi_test_mangle (double_type_node).c_str ());
> > +#if defined (__s390x__)
> > +  if (TARGET_LONG_DOUBLE_128)
> > +    ASSERT_STREQ ("g", kcfi_test_mangle (long_double_type_node).c_str ());
> > +  else
> > +    ASSERT_STREQ ("e", kcfi_test_mangle (long_double_type_node).c_str ());
> > +#else
> >    ASSERT_STREQ ("e", kcfi_test_mangle (long_double_type_node).c_str ());
> > +#endif
> 
> Maybe we should use out the target hook here instead of hard coding
> the encoding.

Certainly.  Note, the ifdef is just wrong, that is testing the host
architecture, while it actually cares about the target architecture.
So, this would also fail miserably with cross-compilers (both from s390x
to something else, then TARGET_LONG_DOUBLE_128 macro wouldn't often even
exist), or from say x86_64 to s390x.
Also, it isn't really s390x specific, alpha also g or e based on options,
ia64 too, on rs6000 it can be e, g or u9__ieee128, on sparc also g or e.

        Jakub

Reply via email to