This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[trans-mem] handle transaction local aggregates


Yo!

In the testcase below we generate aggregate moves for a save/restore
sequence.  This was causing an ICE because we were creating an SSA_NAME
for an aggregate, and this is invalid because aggregates should have a
virtual op (usually generated by the alias oracle).

We were dying in verify_ssa_name(), because aggregates are considered
virtual, yet the SSA_NAME_VAR for the aggregate was not an instance of
the gimple_vop:

  if (is_virtual && SSA_NAME_VAR (ssa_name) != gimple_vop (cfun))
    {
      error ("virtual SSA name for non-VOP decl");
      return true;
    }

I have fixed this by not calling make_ssa_name for aggregates, in which
case a VOP is created automagically and everything works fine.  And yes,
this fixes the ICE on transaction local aggregates.

OK for branch?

	* trans-mem.c (tm_log_emit_saves): Do not generate SSA names for
	aggregates.

Index: testsuite/gcc.dg/tm/memopt-7.c
===================================================================
--- testsuite/gcc.dg/tm/memopt-7.c	(revision 0)
+++ testsuite/gcc.dg/tm/memopt-7.c	(revision 0)
@@ -0,0 +1,22 @@
+/* { dg-do compile } */
+/* { dg-options "-fgnu-tm -O -fdump-tree-tmedge --param tm-max-aggregate-size=999" } */
+
+/* Test save/restore pairs for aggregates.  */
+
+struct large { int x[100]; };
+extern struct large foobie (void) __attribute__((transaction_safe));
+int asdf;
+
+int f()
+{
+  struct large lala;
+  struct large lacopy = foobie();
+  __transaction {
+    lala = lacopy;
+  }
+  return lala.x[asdf];
+}
+
+/* { dg-final { scan-tree-dump-times "tm_save.\[0-9_\]+ = lala" 1 "tmedge" } } */
+/* { dg-final { scan-tree-dump-times "lala = tm_save" 1 "tmedge" } } */
+/* { dg-final { cleanup-tree-dump "tmedge" } } */
Index: trans-mem.c
===================================================================
--- trans-mem.c	(revision 154339)
+++ trans-mem.c	(working copy)
@@ -1025,6 +1025,16 @@ tm_log_emit_saves (basic_block bb)
       gcc_assert (lp->save_var != NULL);
 
       stmt = gimple_build_assign (lp->save_var, unshare_expr (lp->addr));
+
+      /* Make sure we can create an SSA_NAME for this type.  For
+	 instance, aggregates aren't allowed, in which case the system
+	 will create a VOP for us and everything will just work.  */
+      if (is_gimple_reg_type (TREE_TYPE (lp->save_var)))
+	{
+	  lp->save_var = make_ssa_name (lp->save_var, stmt);
+	  gimple_assign_set_lhs (stmt, lp->save_var);
+	}
+
       lp->save_var = make_ssa_name (lp->save_var, stmt);
       gimple_assign_set_lhs (stmt, lp->save_var);
       gsi_insert_before (&gsi, stmt, GSI_SAME_STMT);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]