From patchwork Tue Dec 14 12:04:14 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 75486 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]) by ozlabs.org (Postfix) with SMTP id EE12CB6EDF for ; Tue, 14 Dec 2010 23:04:27 +1100 (EST) Received: (qmail 13105 invoked by alias); 14 Dec 2010 12:04:23 -0000 Received: (qmail 13086 invoked by uid 22791); 14 Dec 2010 12:04:22 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 14 Dec 2010 12:04:17 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oBEC4F36022114 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 14 Dec 2010 07:04:15 -0500 Received: from ganesh.quesejoda.com (vpn-8-24.rdu.redhat.com [10.11.8.24]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oBEC4EIa012217; Tue, 14 Dec 2010 07:04:14 -0500 Message-ID: <4D075D3E.9050109@redhat.com> Date: Tue, 14 Dec 2010 13:04:14 +0100 From: Aldy Hernandez User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.12) Gecko/20101103 Fedora/1.0-0.33.b2pre.fc14 Lightning/1.0b3pre Thunderbird/3.1.6 MIME-Version: 1.0 To: Richard Henderson , gcc-patches@gcc.gnu.org Subject: [trans-mem] PR46714 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 What happens here is that if we have any weak references in the source, finish_aliases_1 (via cgraph_node_for_asm) will initialize the assembler_name_hash WITHOUT the the TM clones because they have not yet been created. What should happen is that when ipa_tm_create_version() runs later, it should set the DECL_ASSEMBLER_NAME before creating the cgraph_node, so we update the assembler_name_hash correctly. OK for branch? PR/46714 * trans-mem.c (ipa_tm_create_version): Set DECL_ASSEMBLER_NAME before creating new node. Index: testsuite/g++.dg/tm/pr46714.C =================================================================== --- testsuite/g++.dg/tm/pr46714.C (revision 0) +++ testsuite/g++.dg/tm/pr46714.C (revision 0) @@ -0,0 +1,14 @@ +// { dg-do compile } +// { dg-options "-fgnu-tm -O" } + +static int asdf __attribute__ ((__weakref__("funky"))); + +class Building +{ +public: + __attribute__((transaction_safe)) ~Building(void); +}; + +Building::~Building() +{ +} Index: trans-mem.c =================================================================== --- trans-mem.c (revision 167793) +++ trans-mem.c (working copy) @@ -4021,6 +4021,12 @@ ipa_tm_create_version (struct cgraph_nod old_decl = old_node->decl; new_decl = copy_node (old_decl); + + tm_name = tm_mangle (old_decl); + SET_DECL_ASSEMBLER_NAME (new_decl, get_identifier (tm_name)); + SET_DECL_RTL (new_decl, NULL); + free (tm_name); + new_node = cgraph_copy_node_for_versioning (old_node, new_decl, NULL); get_cg_data (old_node)->clone = new_node; @@ -4031,11 +4037,6 @@ ipa_tm_create_version (struct cgraph_nod bits in cgraph to calculate all this. */ DECL_IS_TM_CLONE (new_decl) = 1; - tm_name = tm_mangle (old_decl); - SET_DECL_ASSEMBLER_NAME (new_decl, get_identifier (tm_name)); - SET_DECL_RTL (new_decl, NULL); - free (tm_name); - record_tm_clone_pair (old_decl, new_decl); cgraph_call_function_insertion_hooks (new_node);