Comments
Patch
===================================================================
@@ -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());
+}
===================================================================
@@ -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;
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.