From patchwork Wed Nov 10 21:43:51 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 70693 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 DAF5AB710A for ; Thu, 11 Nov 2010 08:44:07 +1100 (EST) Received: (qmail 28031 invoked by alias); 10 Nov 2010 21:44:04 -0000 Received: (qmail 28021 invoked by uid 22791); 10 Nov 2010 21:44:03 -0000 X-SWARE-Spam-Status: No, hits=-6.2 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; Wed, 10 Nov 2010 21:43:56 +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.13.8/8.13.8) with ESMTP id oAALhsPX024263 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 10 Nov 2010 16:43:54 -0500 Received: from redhat.com (vpn-9-39.rdu.redhat.com [10.11.9.39]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id oAALhpI3010470 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Wed, 10 Nov 2010 16:43:53 -0500 Date: Wed, 10 Nov 2010 16:43:51 -0500 From: Aldy Hernandez To: rth@redhat.com Cc: gcc-patches@gcc.gnu.org Subject: Re: [Bug c++/46269] [trans-mem] internal compiler error in expand_block_tm of trans-mem.c Message-ID: <20101110214350.GA15556@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-08-17) 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 The following patch fixes the referenced PR. The problem is an ICE on an asm statement brought in by inlining. Richard suggested we go into serial irrevocable before the asm. > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46269 > > --- Comment #4 from Richard Henderson 2010-11-09 18:06:35 UTC --- > Since updateBuildingSite is transaction_callable, not > transaction_safe, we should handle this no matter how > the other functions are annotated. > > When atomic_exchange_and_add is not annotated, we should > transition to serial-irrevocable mode before the asm, > just as we would do when calling any other unknown function. > > When atomic_exchange_and_add is annotated pure, we should > believe it and not process anything inside. We do not > currently support a general TM escape mechanism on a per- > block basis, so the only way to really ignore stuff inside > transaction_pure functions is to *not* inline them. That sounds too easy. You mean like this? I didn't update the edges because I see we don't do so either for the GIMPLE_CALL case above (in expand_call_tm). I always get confused whether I should update the edges or not. Tested on x86-64 Linux. Ok for branch? PR/46269 * trans-mem.c (expand_block_tm): Handle GIMPLE_ASM. Index: testsuite/g++.dg/tm/pr46269.C =================================================================== --- testsuite/g++.dg/tm/pr46269.C (revision 0) +++ testsuite/g++.dg/tm/pr46269.C (revision 0) @@ -0,0 +1,30 @@ +// { dg-do compile } +// { dg-options "-fgnu-tm" } + +static inline void atomic_exchange_and_add() +{ + __asm__ ("blah"); +} + +template class shared_ptr +{ +public: + shared_ptr( T * p ) + { + atomic_exchange_and_add(); + } +}; + +class BuildingCompletedEvent +{ + public: + __attribute__((transaction_callable)) void updateBuildingSite(void); + __attribute__((transaction_pure)) BuildingCompletedEvent(); +}; + +void BuildingCompletedEvent::updateBuildingSite(void) +{ + shared_ptr event(new BuildingCompletedEvent()); +} + Index: trans-mem.c =================================================================== --- trans-mem.c (revision 166496) +++ trans-mem.c (working copy) @@ -2196,7 +2196,14 @@ expand_block_tm (struct tm_region *regio break; case GIMPLE_ASM: - gcc_unreachable (); + { + gimple g; + g = gimple_build_call (built_in_decls[BUILT_IN_TM_IRREVOCABLE], 0); + gimple_set_location (g, gimple_location (stmt)); + gsi_insert_before (&gsi, g, GSI_SAME_STMT); + transaction_subcode_ior (region, GTMA_MAY_ENTER_IRREVOCABLE); + break; + } default: break;