Patchwork [trans-mem] handle constructors in build_tm_store

login
register
mail settings
Submitter Aldy Hernandez
Date Nov. 11, 2010, 3:42 p.m.
Message ID <20101111154241.GA15704@redhat.com>
Download mbox | patch
Permalink /patch/70827/
State New
Headers show

Comments

Aldy Hernandez - Nov. 11, 2010, 3:42 p.m.
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<unsigned char>({});

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.
Richard Henderson - Nov. 11, 2010, 3:44 p.m.
On 11/11/2010 07:42 AM, Aldy Hernandez wrote:
> +	rhs = integer_zero_node;

build_int_cst (type, 0)

Ok with that change.


r~

Patch

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 T> class shared_ptr
+{
+public:
+  shared_ptr( T * p ) { }
+};
+
+class BuildingCompletedEvent
+{
+public:
+  __attribute__((transaction_callable)) void updateBuildingSite(void);
+};
+
+void
+BuildingCompletedEvent::updateBuildingSite()
+{
+  shared_ptr<BuildingCompletedEvent> 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;