From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 83749 invoked by alias); 8 Dec 2015 19:53:49 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 83739 invoked by uid 89); 8 Dec 2015 19:53:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.2 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: nikam.ms.mff.cuni.cz Received: from nikam.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 08 Dec 2015 19:53:48 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 4C829542D3C; Tue, 8 Dec 2015 20:53:44 +0100 (CET) Date: Tue, 08 Dec 2015 19:53:00 -0000 From: Jan Hubicka To: gcc-patches@gcc.gnu.org Subject: Transparent alias suport part 2 (lto-partition fixes) Message-ID: <20151208195344.GA90993@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-SW-Source: 2015-12/txt/msg00913.txt.bz2 Hi, this patch fixes lto-partition WRT transparent aliases. Normal aliases are always put to the same partition as their target and in other partitions they become part of the boundary (so we know that the two symbols are in fact equivalent). Weakrefs and transparent aliases go only into the partitions that use them. Other issue is that while promoting a symbol to hidden you in fact also promote all transparent aliases. Bootstrapped/regtested x86_64-linux, will commit it shortly. Honza * lto-partition.c (add_symbol_to_partition_1): Transparent aliases are not part of the definition. (contained_in_symbol): Likewise. (promote_symbol): When promoting a symbol also promote all transparent aliases. (rename_statics): Weakref needs unique name, too. Index: lto/lto-partition.c =================================================================== --- lto/lto-partition.c (revision 231376) +++ lto/lto-partition.c (working copy) @@ -177,8 +177,20 @@ add_symbol_to_partition_1 (ltrans_partit /* Add all aliases associated with the symbol. */ FOR_EACH_ALIAS (node, ref) - if (!node->weakref) + if (!ref->referring->transparent_alias) add_symbol_to_partition_1 (part, ref->referring); + else + { + struct ipa_ref *ref2; + /* We do not need to add transparent aliases if they are not used. + However we must add aliases of transparent aliases if they exist. */ + FOR_EACH_ALIAS (ref->referring, ref2) + { + /* Nested transparent aliases are not permitted. */ + gcc_checking_assert (!ref2->referring->transparent_alias); + add_symbol_to_partition_1 (part, ref2->referring); + } + } /* Ensure that SAME_COMDAT_GROUP lists all allways added in a group. */ if (node->same_comdat_group) @@ -199,8 +211,10 @@ add_symbol_to_partition_1 (ltrans_partit static symtab_node * contained_in_symbol (symtab_node *node) { - /* Weakrefs are never contained in anything. */ - if (node->weakref) + /* There is no need to consider transparent aliases to be part of the + definition: they are only useful insite the partition they are output + and thus we will always see an explicit reference to it. */ + if (node->transparent_alias) return node; if (cgraph_node *cnode = dyn_cast (node)) { @@ -967,6 +981,23 @@ promote_symbol (symtab_node *node) TREE_PUBLIC (node->decl) = 1; DECL_VISIBILITY (node->decl) = VISIBILITY_HIDDEN; DECL_VISIBILITY_SPECIFIED (node->decl) = true; + ipa_ref *ref; + + /* Promoting a symbol also promotes all trasparent aliases with exception + of weakref where the visibility flags are always wrong and set to + !PUBLIC. */ + for (unsigned i = 0; node->iterate_direct_aliases (i, ref); i++) + { + struct symtab_node *alias = ref->referring; + if (alias->transparent_alias && !alias->weakref) + { + TREE_PUBLIC (alias->decl) = 1; + DECL_VISIBILITY (alias->decl) = VISIBILITY_HIDDEN; + DECL_VISIBILITY_SPECIFIED (alias->decl) = true; + } + gcc_assert (!alias->weakref || TREE_PUBLIC (alias->decl)); + } + if (symtab->dump_file) fprintf (symtab->dump_file, "Promoting as hidden: %s\n", node->name ()); @@ -974,7 +1005,8 @@ promote_symbol (symtab_node *node) /* Return true if NODE needs named section even if it won't land in the partition symbol table. - FIXME: we should really not use named sections for inline clones and master clones. */ + FIXME: we should really not use named sections for inline clones and master + clones. */ static bool may_need_named_section_p (lto_symtab_encoder_t encoder, symtab_node *node) @@ -1004,7 +1036,7 @@ rename_statics (lto_symtab_encoder_t enc tree name = DECL_ASSEMBLER_NAME (decl); /* See if this is static symbol. */ - if ((node->externally_visible + if (((node->externally_visible && !node->weakref) /* FIXME: externally_visible is somewhat illogically not set for external symbols (i.e. those not defined). Remove this test once this is fixed. */