From patchwork Thu Nov 11 15:42:44 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [trans-mem] handle constructors in build_tm_store X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 70827 Message-Id: <20101111154241.GA15704@redhat.com> To: rth@redhat.com, gcc-patches@gcc.gnu.org Date: Thu, 11 Nov 2010 10:42:44 -0500 From: Aldy Hernandez List-Id: 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;