From patchwork Sun Apr 13 08:41:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Glisse X-Patchwork-Id: 338735 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 6F94514008A for ; Sun, 13 Apr 2014 18:41:58 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=TzDfpjA9sIVxSoHBtqNZVrjLQW5tlDqEo4Z6cgAgXcJRxHir3y Se6LKfsDTx8DNxc8GsSFPjjDlqkJPezwUzzoaIhlhaHzMiwJv66osnI/xC6JLbdg x/qJKZR0xr6mze6EjIRYXw+9m5cSQyD2KRcuF/0Gsr7bdXjjBSdxxll+Q= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=KhTZrMmGc6iNt94JCVeqYP0gkpc=; b=OKKQlLhLoqUueS8z5vRv I7DUwZyNHJxyI1sBrjNFLTuESH3KwQB/Et3siJNuly69dNVBx22fGVxONbbIauRG +GPN1XQyRCb564ylN3u1DkWzKt/8d1IaEMTJ8bPHaADrS63NJf+L0ctXygq9Aywv rjsD6awK4b8Bf9r56sON/F8= Received: (qmail 11828 invoked by alias); 13 Apr 2014 08:41:50 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 11807 invoked by uid 89); 13 Apr 2014 08:41:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.8 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mail2-relais-roc.national.inria.fr Received: from mail2-relais-roc.national.inria.fr (HELO mail2-relais-roc.national.inria.fr) (192.134.164.83) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Sun, 13 Apr 2014 08:41:46 +0000 Received: from stedding.saclay.inria.fr ([193.55.250.194]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES128-SHA; 13 Apr 2014 10:41:42 +0200 Received: from glisse (helo=localhost) by stedding.saclay.inria.fr with local-esmtp (Exim 4.82) (envelope-from ) id 1WZFyw-0007Hb-L1; Sun, 13 Apr 2014 10:41:42 +0200 Date: Sun, 13 Apr 2014 10:41:42 +0200 (CEST) From: Marc Glisse To: gcc-patches@gcc.gnu.org cc: jason@redhat.com Subject: [c++] typeinfo for target types Message-ID: User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 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 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. Index: gcc/c-family/c-common.c =================================================================== --- gcc/c-family/c-common.c (revision 209345) +++ gcc/c-family/c-common.c (working copy) @@ -3462,21 +3462,21 @@ c_common_fixed_point_type_for_size (unsi "fixed-point types that have too many integral and " "fractional bits together"); return 0; } return c_common_type_for_mode (mode, satp); } /* Used for communication between c_common_type_for_mode and c_register_builtin_type. */ -static GTY(()) tree registered_builtin_types; +tree registered_builtin_types; /* Return a data type that has machine mode MODE. If the mode is an integer, then UNSIGNEDP selects between signed and unsigned types. If the mode is a fixed-point mode, then UNSIGNEDP selects between saturating and nonsaturating types. */ tree c_common_type_for_mode (enum machine_mode mode, int unsignedp) { Index: gcc/c-family/c-common.h =================================================================== --- gcc/c-family/c-common.h (revision 209345) +++ gcc/c-family/c-common.h (working copy) @@ -1006,20 +1006,24 @@ extern void do_warn_double_promotion (tr extern void set_underlying_type (tree); extern void record_locally_defined_typedef (tree); extern void maybe_record_typedef_use (tree); extern void maybe_warn_unused_local_typedefs (void); extern vec *make_tree_vector (void); extern void release_tree_vector (vec *); extern vec *make_tree_vector_single (tree); extern vec *make_tree_vector_from_list (tree); extern vec *make_tree_vector_copy (const vec *); +/* Used for communication between c_common_type_for_mode and + c_register_builtin_type. */ +extern GTY(()) tree registered_builtin_types; + /* In c-gimplify.c */ extern void c_genericize (tree); extern int c_gimplify_expr (tree *, gimple_seq *, gimple_seq *); extern tree c_build_bind_expr (location_t, tree, tree); /* In c-pch.c */ extern void pch_init (void); extern void pch_cpp_save_state (void); extern int c_common_valid_pch (cpp_reader *pfile, const char *name, int fd); extern void c_common_read_pch (cpp_reader *pfile, const char *name, int fd, Index: gcc/cp/rtti.c =================================================================== --- gcc/cp/rtti.c (revision 209345) +++ gcc/cp/rtti.c (working copy) @@ -1458,20 +1458,58 @@ create_tinfo_types (void) FIELD_DECL, NULL_TREE, integer_type_node), build_decl (BUILTINS_LOCATION, FIELD_DECL, NULL_TREE, type_info_ptr_type), build_decl (BUILTINS_LOCATION, FIELD_DECL, NULL_TREE, type_info_ptr_type), NULL); pop_abi_namespace (); } +/* Helper for emit_support_tinfos. Emits the type_info descriptor of + a single type. */ + +void +emit_support_tinfo_1 (tree bltn) +{ + tree types[3]; + + if (bltn == NULL_TREE) + return; + types[0] = bltn; + types[1] = build_pointer_type (bltn); + types[2] = build_pointer_type (cp_build_qualified_type (bltn, + TYPE_QUAL_CONST)); + + for (int i = 0; i < 3; ++i) + { + tree tinfo = get_tinfo_decl (types[i]); + TREE_USED (tinfo) = 1; + mark_needed (tinfo); + /* The C++ ABI requires that these objects be COMDAT. But, + On systems without weak symbols, initialized COMDAT + objects are emitted with internal linkage. (See + comdat_linkage for details.) Since we want these objects + to have external linkage so that copies do not have to be + emitted in code outside the runtime library, we make them + non-COMDAT here. + + It might also not be necessary to follow this detail of the + ABI. */ + if (!flag_weak || ! targetm.cxx.library_rtti_comdat ()) + { + gcc_assert (TREE_PUBLIC (tinfo) && !DECL_COMDAT (tinfo)); + DECL_INTERFACE_KNOWN (tinfo) = 1; + } + } +} + /* Emit the type_info descriptors which are guaranteed to be in the runtime support. Generating them here guarantees consistency with the other structures. We use the following heuristic to determine when the runtime is being generated. If std::__fundamental_type_info is defined, and its destructor is defined, then the runtime is being built. */ void emit_support_tinfos (void) { /* Dummy static variable so we can put nullptr in the array; it will be @@ -1500,56 +1538,23 @@ emit_support_tinfos (void) get_identifier ("__fundamental_type_info"), /*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++) - { - tree bltn = *fundamentals[ix]; - tree types[3]; - int i; - - if (bltn == NULL_TREE) - continue; - types[0] = bltn; - types[1] = build_pointer_type (bltn); - types[2] = build_pointer_type (cp_build_qualified_type (bltn, - TYPE_QUAL_CONST)); - - for (i = 0; i < 3; ++i) - { - tree tinfo; - - tinfo = get_tinfo_decl (types[i]); - TREE_USED (tinfo) = 1; - mark_needed (tinfo); - /* The C++ ABI requires that these objects be COMDAT. But, - On systems without weak symbols, initialized COMDAT - objects are emitted with internal linkage. (See - comdat_linkage for details.) Since we want these objects - to have external linkage so that copies do not have to be - emitted in code outside the runtime library, we make them - non-COMDAT here. - - It might also not be necessary to follow this detail of the - ABI. */ - if (!flag_weak || ! targetm.cxx.library_rtti_comdat ()) - { - gcc_assert (TREE_PUBLIC (tinfo) && !DECL_COMDAT (tinfo)); - DECL_INTERFACE_KNOWN (tinfo) = 1; - } - } - } + 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));