[c++] typeinfo for target types

Marc Glisse marc.glisse@inria.fr
Thu Apr 24 13:25:00 GMT 2014


On Thu, 24 Apr 2014, Ramana Radhakrishnan wrote:

> On Wed, Apr 23, 2014 at 8:43 PM, Marc Glisse <marc.glisse@inria.fr> wrote:
>> On Wed, 23 Apr 2014, Richard Henderson wrote:
>>
>>> On 04/13/2014 01:41 AM, Marc Glisse wrote:
>>>>
>>>> Hello,
>>>>
>>>> this patch generates typeinfo for target types. On x86_64, it adds these
>>>> 6
>>>> lines to nm -C libsupc++.a. A follow-up patch will be needed to export
>>>> and
>>>> version those in the shared library.
>>>>
>>>> +0000000000000000 V typeinfo for __float128
>>>> +0000000000000000 V typeinfo for __float128 const*
>>>> +0000000000000000 V typeinfo for __float128*
>>>> +0000000000000000 V typeinfo name for __float128
>>>> +0000000000000000 V typeinfo name for __float128 const*
>>>> +0000000000000000 V typeinfo name for __float128*
>>>>
>>>> Bootstrap and testsuite on x86_64-linux-gnu (a bit of noise in
>>>> tsan/tls_race.c).
>>>>
>>>> 2014-04-13  Marc Glisse  <marc.glisse@inria.fr>
>>>>
>>>>     PR libstdc++/43622
>>>> gcc/c-family/
>>>>     * c-common.c (registered_builtin_types): Make non-static.
>>>>     * c-common.h (registered_builtin_types): Declare.
>>>> gcc/cp/
>>>>     * rtti.c (emit_support_tinfo_1): New function, extracted from
>>>>     emit_support_tinfos.
>>>>     (emit_support_tinfos): Call it and iterate on
>>>> registered_builtin_types.
>>>>
>>>
>>> This is causing aarch64 builds to break.
>>
>>
>> If it is causing too much trouble, we could ifdef out the last 2 lines of
>> emit_support_tinfos and revert the libstdc++ changes (or even revert the
>> whole thing).
>>
>>
>>> Any c++ compilation aborts at
>>
>>
>> That's surprising, the code I touched is only ever supposed to run while
>> compiling one file in libsupc++, if I understand correctly.
>>
>>
>>> #0  fancy_abort (file=0x14195c8 "../../git-rh/gcc/cp/mangle.c", line=2303,
>>>    function=0x1419ff8 <write_builtin_type(tree_node*)::__FUNCTION__>
>>>    "write_builtin_type") at ../../git-rh/gcc/diagnostic.c:1190
>>> #1  0x00000000007ce2b4 in write_builtin_type (
>>>    type=<real_type 0x7fb1653540 __builtin_aarch64_simd_df>)
>>>    at ../../git-rh/gcc/cp/mangle.c:2303
>>> #2  0x00000000007cc85c in write_type (
>>>    type=<real_type 0x7fb1653540 __builtin_aarch64_simd_df>)
>>>    at ../../git-rh/gcc/cp/mangle.c:1969
>>> #3  0x00000000007d4d98 in mangle_special_for_type (
>>>    type=<real_type 0x7fb1653540 __builtin_aarch64_simd_df>,
>>>    code=0x1419a98 "TI") at ../../git-rh/gcc/cp/mangle.c:3569
>>> #4  0x00000000007d4dcc in mangle_typeinfo_for_type (
>>>    type=<real_type 0x7fb1653540 __builtin_aarch64_simd_df>)
>>>    at ../../git-rh/gcc/cp/mangle.c:3585
>>> #5  0x000000000070618c in get_tinfo_decl (
>>>    type=<real_type 0x7fb1653540 __builtin_aarch64_simd_df>)
>>>    at ../../git-rh/gcc/cp/rtti.c:422
>>> #6  0x0000000000709ff0 in emit_support_tinfo_1 (
>>>    bltn=<real_type 0x7fb1653540 __builtin_aarch64_simd_df>)
>>>    at ../../git-rh/gcc/cp/rtti.c:1485
>>> #7  0x000000000070a344 in emit_support_tinfos ()
>>>    at ../../git-rh/gcc/cp/rtti.c:1550
>>>
>>> Presumably the backend needs to grow some mangling support for its
>>> builtins,
>>
>>
>> aarch64 has complicated builtins... __builtin_aarch64_simd_df uses
>> double_aarch64_type_node which is not the same as double_type_node. I mostly
>> looked at the x86 backend, so I didn't notice that aarch64 registers a lot
>> more builtins.
>>
>>
>>> but in the meantime can we do something less drastic than abort?
>>
>>
>> Sounds good, but I am not sure how exactly. We could use a separate hook
>> (register_builtin_type_for_typeinfo?) so back-ends have to explicitly say
>> they want typeinfo, but it is ugly having to register types multiple times.
>> We could add a parameter to the existing register_builtin_type saying
>> whether we want typeinfo, but that means updating all back-ends.

We could also make typeinfo_in_lib_p more strict so for REAL_TYPE it only 
returns true for the types listed in fundamentals.

> Well some of these scalar types are not really user visible which is
> where I believe the problem is coming from and prima-facie I don't
> think we should be inventing mangling for some of these "internal"
> types.

If the types are not user-visible, it is not clear to me why they need to 
be registered with the front-end...

>>  We could
>> get the mangling functions to take a parameter that says whether errors
>> should be fatal and skip generating the typeinfo when we can't mangle, but
>> there is no convenient way to communicate this mangling failure (0 bytes
>> written?).
>>
>> Would mangling the aarch64 builtins be a lot of work? Did other platforms
>> break as well?
>
> It's not a lot of work but I'd like to make sure we're doing the right
> thing on both AArch32 and AArch64. So, for now can we just revert this
> till the thing is sorted out.

Ok, I'll commit the attached as soon as I've checked it isn't too broken. 
It is not a complete revert: splitting the rtti function is still cleaner, 
and the int128 symbols are still there.

2014-04-24  Marc Glisse  <marc.glisse@inria.fr>

         PR libstdc++/43622
gcc/cp/
 	* rtti.c (emit_support_tinfos): Do not iterate on
 	registered_builtin_types (partial revert).
libstdc++/
 	* config/abi/pre/gnu.ver (CXXABI_1.3.9): Remove __float128 symbols.
 	* config/abi/pre/gnu-versioned-namespace.ver: Likewise.
 	* config/abi/post/x86_64-linux-gnu/baseline_symbols.txt: Update.

-- 
Marc Glisse
-------------- next part --------------
Index: gcc/cp/rtti.c
===================================================================
--- gcc/cp/rtti.c	(revision 209747)
+++ gcc/cp/rtti.c	(working copy)
@@ -1539,22 +1539,20 @@ emit_support_tinfos (void)
 			/*tag_scope=*/ts_current, false);
   pop_abi_namespace ();
   if (!COMPLETE_TYPE_P (bltn_type))
     return;
   dtor = CLASSTYPE_DESTRUCTORS (bltn_type);
   if (!dtor || DECL_EXTERNAL (dtor))
     return;
   doing_runtime = 1;
   for (ix = 0; fundamentals[ix]; ix++)
     emit_support_tinfo_1 (*fundamentals[ix]);
-  for (tree t = registered_builtin_types; t; t = TREE_CHAIN (t))
-    emit_support_tinfo_1 (TREE_VALUE (t));
 }
 
 /* Finish a type info decl. DECL_PTR is a pointer to an unemitted
    tinfo decl.  Determine whether it needs emitting, and if so
    generate the initializer.  */
 
 bool
 emit_tinfo_decl (tree decl)
 {
   tree type = TREE_TYPE (DECL_NAME (decl));
Index: libstdc++-v3/config/abi/post/x86_64-linux-gnu/baseline_symbols.txt
===================================================================
--- libstdc++-v3/config/abi/post/x86_64-linux-gnu/baseline_symbols.txt	(revision 209747)
+++ libstdc++-v3/config/abi/post/x86_64-linux-gnu/baseline_symbols.txt	(working copy)
@@ -2618,21 +2618,20 @@ OBJECT:16:_ZTISt16nested_exception@@CXXA
 OBJECT:16:_ZTISt8ios_base@@GLIBCXX_3.4
 OBJECT:16:_ZTISt9exception@@GLIBCXX_3.4
 OBJECT:16:_ZTISt9time_base@@GLIBCXX_3.4
 OBJECT:16:_ZTISt9type_info@@GLIBCXX_3.4
 OBJECT:16:_ZTIa@@CXXABI_1.3
 OBJECT:16:_ZTIb@@CXXABI_1.3
 OBJECT:16:_ZTIc@@CXXABI_1.3
 OBJECT:16:_ZTId@@CXXABI_1.3
 OBJECT:16:_ZTIe@@CXXABI_1.3
 OBJECT:16:_ZTIf@@CXXABI_1.3
-OBJECT:16:_ZTIg@@CXXABI_1.3.9
 OBJECT:16:_ZTIh@@CXXABI_1.3
 OBJECT:16:_ZTIi@@CXXABI_1.3
 OBJECT:16:_ZTIj@@CXXABI_1.3
 OBJECT:16:_ZTIl@@CXXABI_1.3
 OBJECT:16:_ZTIm@@CXXABI_1.3
 OBJECT:16:_ZTIn@@CXXABI_1.3.5
 OBJECT:16:_ZTIo@@CXXABI_1.3.5
 OBJECT:16:_ZTIs@@CXXABI_1.3
 OBJECT:16:_ZTIt@@CXXABI_1.3
 OBJECT:16:_ZTIv@@CXXABI_1.3
@@ -3119,21 +3118,20 @@ OBJECT:2:_ZNSt10ctype_base5printE@@GLIBC
 OBJECT:2:_ZNSt10ctype_base5punctE@@GLIBCXX_3.4
 OBJECT:2:_ZNSt10ctype_base5spaceE@@GLIBCXX_3.4
 OBJECT:2:_ZNSt10ctype_base5upperE@@GLIBCXX_3.4
 OBJECT:2:_ZNSt10ctype_base6xdigitE@@GLI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I_1.3.5
 OBJECT:32:_ZTIPKo@@CXXABI_1.3.5
 OBJECT:32:_ZTIPKs@@CXXABI_1.3
 OBJECT:32:_ZTIPKt@@CXXABI_1.3
 OBJECT:32:_ZTIPKv@@CXXABI_1.3
 OBJECT:32:_ZTIPKw@@CXXABI_1.3
 OBJECT:32:_ZTIPKx@@CXXABI_1.3
 OBJECT:32:_ZTIPKy@@CXXABI_1.3
 OBJECT:32:_ZTIPa@@CXXABI_1.3
 OBJECT:32:_ZTIPb@@CXXABI_1.3
 OBJECT:32:_ZTIPc@@CXXABI_1.3
 OBJECT:32:_ZTIPd@@CXXABI_1.3
 OBJECT:32:_ZTIPe@@CXXABI_1.3
 OBJECT:32:_ZTIPf@@CXXABI_1.3
-OBJECT:32:_ZTIPg@@CXXABI_1.3.9
 OBJECT:32:_ZTIPh@@CXXABI_1.3
 OBJECT:32:_ZTIPi@@CXXABI_1.3
 OBJECT:32:_ZTIPj@@CXXABI_1.3
 OBJECT:32:_ZTIPl@@CXXABI_1.3
 OBJECT:32:_ZTIPm@@CXXABI_1.3
 OBJECT:32:_ZTIPn@@CXXABI_1.3.5
 OBJECT:32:_ZTIPo@@CXXABI_1.3.5
 OBJECT:32:_ZTIPs@@CXXABI_1.3
 OBJECT:32:_ZTIPt@@CXXABI_1.3
 OBJECT:32:_ZTIPv@@CXXABI_1.3
@@ -3228,21 +3224,20 @@ OBJECT:39:_ZTSSt13basic_filebufIwSt11cha
 OBJECT:39:_ZTSSt13basic_fstreamIcSt11char_traitsIcEE@@GLIBCXX_3.4
 OBJECT:39:_ZTSSt13basic_fstreamIwSt11char_traitsIwEE@@GLIBCXX_3.4
 OBJECT:39:_ZTSSt13basic_istreamIwSt11char_traitsIwEE@@GLIBCXX_3.4
 OBJECT:39:_ZTSSt13basic_ostreamIwSt11char_traitsIwEE@@GLIBCXX_3.4
 OBJECT:3:_ZTSPa@@CXXABI_1.3
 OBJECT:3:_ZTSPb@@CXXABI_1.3
 OBJECT:3:_ZTSPc@@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I_1.3.9
 OBJECT:4:_ZTSPKs@@CXXABI_1.3
 OBJECT:4:_ZTSPKt@@CXXABI_1.3
 OBJECT:4:_ZTSPKv@@CXXABI_1.3
Index: libstdc++-v3/config/abi/pre/gnu-versioned-namespace.ver
===================================================================
--- libstdc++-v3/config/abi/pre/gnu-versioned-namespace.ver	(revision 209747)
+++ libstdc++-v3/config/abi/pre/gnu-versioned-namespace.ver	(working copy)
@@ -314,24 +314,24 @@ CXXABI_2.0 {
     # typeinfo for decimal floating point types
     _ZTID[fde];
     _ZTIPD[fde];
     _ZTIPKD[fde];
 
     # typeinfo for decltype(nullptr)
     _ZTIDn;
     _ZTIPDn;
     _ZTIPKDn;
 
-    # typeinfo for __int128, unsigned __int128 and __float128
-    _ZTI[gno];
-    _ZTIP[gno];
-    _ZTIPK[gno];
+    # typeinfo for __int128 and unsigned __int128
+    _ZTI[no];
+    _ZTIP[no];
+    _ZTIPK[no];
 
     # virtual table
     _ZTVN10__cxxabiv117__array_type_infoE;
     _ZTVN10__cxxabiv117__class_type_infoE;
     _ZTVN10__cxxabiv116__enum_type_infoE;
     _ZTVN10__cxxabiv120__function_type_infoE;
     _ZTVN10__cxxabiv123__fundamental_type_infoE;
     _ZTVN10__cxxabiv117__pbase_type_infoE;
     _ZTVN10__cxxabiv129__pointer_to_member_type_infoE;
     _ZTVN10__cxxabiv119__pointer_type_infoE;
Index: libstdc++-v3/config/abi/pre/gnu.ver
===================================================================
--- libstdc++-v3/config/abi/pre/gnu.ver	(revision 209747)
+++ libstdc++-v3/config/abi/pre/gnu.ver	(working copy)
@@ -1579,29 +1579,24 @@ CXXABI_1.3.8 {
     _Z16__VLTRegisterSet*;
     _Z21__VLTRegisterSetDebug*;
     _Z24__VLTVerifyVtablePointer*;
     _Z29__VLTVerifyVtablePointerDebug*;
     __VLTChangePermission;
 
 } CXXABI_1.3.7;
 
 CXXABI_1.3.9 {
 
-    # typeinfo name for __int128, unsigned __int128 and __float128
-    _ZTS[gno];
-    _ZTSP[gno];
-    _ZTSPK[gno];
-
-    # typeinfo for __float128
-    _ZTIg;
-    _ZTIPg;
-    _ZTIPKg;
+    # typeinfo name for __int128 and unsigned __int128
+    _ZTS[no];
+    _ZTSP[no];
+    _ZTSPK[no];
 
 } CXXABI_1.3.8;
 
 # Symbols in the support library (libsupc++) supporting transactional memory.
 CXXABI_TM_1 {
 
   global:
     __cxa_tm_cleanup;
 
 };


More information about the Gcc-patches mailing list