From patchwork Mon Sep 2 20:36:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 272068 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "www.sourceware.org", Issuer "StartCom Class 1 Primary Intermediate Server CA" (not verified)) by ozlabs.org (Postfix) with ESMTPS id D7E522C0095 for ; Tue, 3 Sep 2013 06:36:53 +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:subject:message-id:mime-version:content-type; q=dns; s= default; b=xknUUS83v21nTD57ZkAGNbINem3IhrTGknEi3hlqQJnFvHmj6d7Ug eURbkCg3Qz+A05EAXg86yJ8LcfK1NDMR6UckjVBxemM7TA/z9ueifqK++7BrAtsw BQtP2FVNe6koGVhr8X6zkCYXUjZM0acP2lhKmi628W83NgGZ+BD0hg= 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:subject:message-id:mime-version:content-type; s= default; bh=SEfnW3cUBbOaqqzlJgwXJ0MwltI=; b=pZnjJjnOMrQZz1GTjVu4 MpA9u90L1lTxQ2dzBzI/UJxJ2nQMKypZmOwODgMPmzHgnIIJmFuofg2bbq1NMfg7 qYfdGUasbMTBxzgExgjSh+oLdTjzsr2EO9o9YcFfgLXGZr32TuC7WzB+JOI3LtDm U3kjT2rxAS55SV83qbZ5G2k= Received: (qmail 32733 invoked by alias); 2 Sep 2013 20:36:46 -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 32721 invoked by uid 89); 2 Sep 2013 20:36:46 -0000 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-SHA encrypted) ESMTPS; Mon, 02 Sep 2013 20:36:46 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, NO_RELAYS autolearn=ham version=3.3.2 X-HELO: nikam.ms.mff.cuni.cz Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 71D1D5430A8; Mon, 2 Sep 2013 22:36:41 +0200 (CEST) Date: Mon, 2 Sep 2013 22:36:41 +0200 From: Jan Hubicka To: gcc-patches@gcc.gnu.org Subject: Fix gcc.dg/lto/pr56297 failure Message-ID: <20130902203641.GA20650@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Hi, this patch fixes gcc.dg/lto/pr56297 failure. Here we have two modules defining global variable assigned to hard registers. Those variables do not go into assembler name hash because they have no real assembler name and consequentely they are not merged. We however may end up with two declarations being merged by tree merging and then symtab needs to compensate. We solve precisely same problem for builtins and abstract functions already. This patch thus makes us to do the right thing for variables, too. I also added comment since the code is bit weird. Bootstrapped/regtested x86_64-linux, will commit it shortly. Honza * lto-symtab.c (lto_symtab_merge_symbols): Add comments; merge duplicated nodes for assembler names. * symtab.c (symtab_unregister_node): Do not attempt to unlink hard registers from assembler name hash. Index: lto-symtab.c =================================================================== --- lto-symtab.c (revision 202182) +++ lto-symtab.c (working copy) @@ -586,6 +586,9 @@ lto_symtab_merge_symbols (void) FOR_EACH_SYMBOL (node) { cgraph_node *cnode, *cnode2; + varpool_node *vnode; + symtab_node node2; + if (!node->symbol.analyzed && node->symbol.alias_target) { symtab_node tgt = symtab_node_for_asm (node->symbol.alias_target); @@ -594,22 +597,37 @@ lto_symtab_merge_symbols (void) symtab_resolve_alias (node, tgt); } node->symbol.aux = NULL; - + if (!(cnode = dyn_cast (node)) || !cnode->clone_of || cnode->clone_of->symbol.decl != cnode->symbol.decl) { + /* Builtins are not merged via decl merging. It is however + possible that tree merging unified the declaration. We + do not want duplicate entries in symbol table. */ if (cnode && DECL_BUILT_IN (node->symbol.decl) && (cnode2 = cgraph_get_node (node->symbol.decl)) && cnode2 != cnode) lto_cgraph_replace_node (cnode2, cnode); + /* The user defined assembler variables are also not unified by their + symbol name (since it is irrelevant), but we need to unify symbol + nodes if tree merging occured. */ + if ((vnode = dyn_cast (node)) + && DECL_HARD_REGISTER (vnode->symbol.decl) + && (node2 = symtab_get_node (vnode->symbol.decl)) + && node2 != node) + lto_varpool_replace_node (dyn_cast (node2), + vnode); + + /* Abstract functions may have duplicated cgraph nodes attached; remove them. */ else if (cnode && DECL_ABSTRACT (cnode->symbol.decl) && (cnode2 = cgraph_get_node (node->symbol.decl)) && cnode2 != cnode) cgraph_remove_node (cnode2); + symtab_insert_node_to_hashtable ((symtab_node)node); } } Index: symtab.c =================================================================== --- symtab.c (revision 202182) +++ symtab.c (working copy) @@ -283,7 +283,8 @@ symtab_unregister_node (symtab_node node else *slot = replacement_node; } - unlink_from_assembler_name_hash (node, false); + if (!is_a (node) || !DECL_HARD_REGISTER (node->symbol.decl)) + unlink_from_assembler_name_hash (node, false); } /* Return symbol table node associated with DECL, if any,