From patchwork Mon Dec 19 19:30:39 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 132298 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 4B336B7032 for ; Tue, 20 Dec 2011 06:31:02 +1100 (EST) Received: (qmail 12967 invoked by alias); 19 Dec 2011 19:30:59 -0000 Received: (qmail 12956 invoked by uid 22791); 19 Dec 2011 19:30:58 -0000 X-SWARE-Spam-Status: No, hits=-5.4 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS 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; Mon, 19 Dec 2011 19:30:42 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id pBJJUfpw019009 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 19 Dec 2011 14:30:41 -0500 Received: from austin.quesejoda.com (vpn-8-176.rdu.redhat.com [10.11.8.176]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id pBJJUdDp015598; Mon, 19 Dec 2011 14:30:40 -0500 Message-ID: <4EEF90DF.7030801@redhat.com> Date: Mon, 19 Dec 2011 13:30:39 -0600 From: Aldy Hernandez User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:7.0.1) Gecko/20110930 Thunderbird/7.0.1 MIME-Version: 1.0 To: Jason Merrill CC: Patrick Marlier , Richard Henderson , gcc-patches Subject: Re: PR middle-end/51411: handle transaction_safe virtual inlined methods References: <4EE7B85D.8020303@redhat.com> <4EE7B8CF.6040808@redhat.com> <4EE7BA39.6050900@redhat.com> <4EE7BD52.1060706@redhat.com> <4EE7BDE7.6020401@redhat.com> <4EE7EBC1.7030107@gmail.com> <4EE89CFA.1040206@redhat.com> <4EE92065.5030606@gmail.com> <4EEA02B5.4010309@redhat.com> <4EEA1726.6000501@redhat.com> In-Reply-To: <4EEA1726.6000501@redhat.com> 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 >> Richard, Jason, are you ok with just unsetting DECL_WEAK? > > For now, yes. > >> I will come up with a suitable testcase for Patrick's case. > > Once there's a testcase, we can figure out why the other patch didn't work. > > Jason Hi Jason. I have made a testcase from Patrick's, and am committing the patch below. The first testcase tests the problem Patrick reports when we unset DECL_EXTERNAL and then we don't emit one of the clones. It is way beyond my template/C++/linking foo. I was hoping you could take a look at it. In the meantime, I am closing the PR as fixed. PR middle-end/51411 * trans-mem.c (ipa_tm_create_version): Unset DECL_WEAK. Index: testsuite/g++.dg/tm/pr51411-2.C =================================================================== --- testsuite/g++.dg/tm/pr51411-2.C (revision 0) +++ testsuite/g++.dg/tm/pr51411-2.C (revision 0) @@ -0,0 +1,49 @@ +// { dg-do compile } +// { dg-options "-fgnu-tm -O0" } + +namespace std { +template struct char_traits; + +template class allocator { +}; + +template struct less { + bool operator()(const _Tp& __x, const _Tp& __y) const { + return __x < __y; + } +}; + +template > class map { +public: + _Compare _M_key_compare; + bool find(const _Key& __x) { + return _M_key_compare(__x, __x); + } +}; + +template, typename _Alloc = allocator<_CharT> > class basic_string { +public: + bool compare(const basic_string& __str) const { + return 0; + } +}; + +typedef basic_string string; + +template +inline bool operator<(const basic_string<_CharT, _Traits>& __lhs, const basic_string<_CharT, _Traits>& __rhs) { + return __lhs.compare(__rhs); +} + +extern template class basic_string; + +} + +std::map units; + +__attribute__((transaction_callable)) +void get(const std::string &name) { + units.find(name); +} + +// { dg-final { scan-assembler "_ZGTtNKSs7compareERKSs:" } } Index: testsuite/g++.dg/tm/pr51411.C =================================================================== --- testsuite/g++.dg/tm/pr51411.C (revision 0) +++ testsuite/g++.dg/tm/pr51411.C (revision 0) @@ -0,0 +1,7 @@ +// { dg-do compile } +// { dg-options "-fgnu-tm -O" } + +struct A +{ + __attribute__ ((transaction_safe)) virtual void virtfoo () { } +}; Index: trans-mem.c =================================================================== --- trans-mem.c (revision 182491) +++ trans-mem.c (working copy) @@ -4260,6 +4260,7 @@ ipa_tm_create_version (struct cgraph_nod { DECL_EXTERNAL (new_decl) = 0; TREE_PUBLIC (new_decl) = 0; + DECL_WEAK (new_decl) = 0; } tree_function_versioning (old_decl, new_decl, NULL, false, NULL,