From patchwork Thu Nov 11 15:42:44 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 70827 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 0132EB7142 for ; Fri, 12 Nov 2010 02:42:59 +1100 (EST) Received: (qmail 24396 invoked by alias); 11 Nov 2010 15:42:57 -0000 Received: (qmail 24380 invoked by uid 22791); 11 Nov 2010 15:42:56 -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; Thu, 11 Nov 2010 15:42:49 +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 oABFglNn030221 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 11 Nov 2010 10:42:47 -0500 Received: from redhat.com (vpn-8-70.rdu.redhat.com [10.11.8.70]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oABFgiWt018103 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Thu, 11 Nov 2010 10:42:46 -0500 Date: Thu, 11 Nov 2010 10:42:44 -0500 From: Aldy Hernandez To: rth@redhat.com, gcc-patches@gcc.gnu.org Subject: [trans-mem] handle constructors in build_tm_store Message-ID: <20101111154241.GA15704@redhat.com> MIME-Version: 1.0 Content-Disposition: inline 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 This is another ICE distilled from a variation of the testcase in PR/46269. The problem here is that build_tm_store() creates invalid gimple by wrapping an empty constructor with a VIEW_CONVERT_EXPR to make it sane for the TM store builtin: D.2241_8 = VIEW_CONVERT_EXPR({}); The empty constructor is trivially handled by passing a 0 to the TM store, and avoiding the conversion altogether. Anything more complicated we can punt to the caller and let it use tm-memmove. Tested on x86-64 Linux. OK for branch? * trans-mem.c (build_tm_store): Handle constructors. Index: testsuite/g++.dg/20101111.c =================================================================== --- testsuite/g++.dg/20101111.c (revision 0) +++ testsuite/g++.dg/20101111.c (revision 0) @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-fgnu-tm" } */ + +template class shared_ptr +{ +public: + shared_ptr( T * p ) { } +}; + +class BuildingCompletedEvent +{ +public: + __attribute__((transaction_callable)) void updateBuildingSite(void); +}; + +void +BuildingCompletedEvent::updateBuildingSite() +{ + shared_ptr event(new BuildingCompletedEvent()); +} Index: trans-mem.c =================================================================== --- trans-mem.c (revision 166496) +++ trans-mem.c (working copy) @@ -2004,7 +2004,21 @@ build_tm_store (location_t loc, tree lhs simple_type = TREE_VALUE (TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (fn)))); - if (!useless_type_conversion_p (simple_type, type)) + if (TREE_CODE (rhs) == CONSTRUCTOR) + { + /* Handle the easy initialization to zero. */ + if (CONSTRUCTOR_ELTS (rhs) == 0) + rhs = integer_zero_node; + else + { + /* ...otherwise punt to the caller and probably use + BUILT_IN_TM_MEMMOVE, because we can't wrap a + VIEW_CONVERT_EXPR around a CONSTRUCTOR (below) and produce + valid gimple. */ + return NULL; + } + } + else if (!useless_type_conversion_p (simple_type, type)) { gimple g; tree temp;