diff mbox

19/n: trans-mem: middle end/misc patches (LAST PATCH)

Message ID 4EB80172.1010606@redhat.com
State New
Headers show

Commit Message

Aldy Hernandez Nov. 7, 2011, 4:04 p.m. UTC
>> I can certainly move this to expand_call_stmt() if you prefer.  Do you have
>> an objection to the RTL walk?  This isn't my code, but I'm open to
>> suggestions on an alternative to implement.
>
> It just catched my eye...  moving it to expand_call_stmt would be nice
> indeed, but I was suggesting to add that note where we produce the
> CALL rtx, not sure if that's reasonably straight-forward (I suppose there
> was a reason to go with the hack above ...).

Sure.

OK pending tests?

Comments

Richard Henderson Nov. 7, 2011, 4:08 p.m. UTC | #1
On 11/07/2011 08:04 AM, Aldy Hernandez wrote:
> @@ -1812,6 +1844,8 @@ expand_call_stmt (gimple stmt)
>    bool builtin_p;
>    size_t i;
>  
> +  mark_transaction_restart_calls (stmt);
> +
>    if (gimple_call_internal_p (stmt))
>      {
>        expand_internal_call (stmt);

You're calling it too early, Aldy.  The call you're searching
for hasn't been generated yet.


r~
diff mbox

Patch

Index: ChangeLog.tm-merge
===================================================================
--- ChangeLog.tm-merge	(revision 181067)
+++ ChangeLog.tm-merge	(working copy)
@@ -58,8 +58,10 @@ 
 	* calls.c (is_tm_builtin): New.
 	(flags_from_decl_or_type): Add ECF_TM_OPS for TM clones.
 	* cfgbuild.c (make_edges): Add edges for REG_TM notes.
-	* cfgexpand.c (expand_gimple_stmt): Add REG_TM notes.
+	* cfgexpand.c (expand_call_stmt): Call
+	mark_transaction_restart_calls.
 	(gimple_expand_cfg): Free the tm_restart map.
+	(mark_transaction_restart_calls): New.
 	* cfgrtl.c (purge_dead_edges): Look for REG_TM notes.
 	* cgraph.c (dump_cgraph_node): Handle tm_clone.
 	* cgraph.h (struct cgraph_node): Add tm_clone field.
Index: cfgexpand.c
===================================================================
--- cfgexpand.c	(revision 181067)
+++ cfgexpand.c	(working copy)
@@ -1802,6 +1802,38 @@  expand_gimple_cond (basic_block bb, gimp
   return new_bb;
 }
 
+/* Mark all calls that can have a transaction restart.  */
+
+static void
+mark_transaction_restart_calls (gimple stmt)
+{
+  struct tm_restart_node dummy;
+  void **slot;
+
+  if (!cfun->gimple_df->tm_restart)
+    return;
+
+  dummy.stmt = stmt;
+  slot = htab_find_slot (cfun->gimple_df->tm_restart, &dummy, NO_INSERT);
+  if (slot)
+    {
+      struct tm_restart_node *n = (struct tm_restart_node *) *slot;
+      tree list = n->label_or_list;
+      rtx insn;
+
+      for (insn = next_real_insn (get_last_insn ());
+	   !CALL_P (insn);
+	   insn = next_real_insn (insn))
+	continue;
+
+      if (TREE_CODE (list) == LABEL_DECL)
+	add_reg_note (insn, REG_TM, label_rtx (list));
+      else
+	for (; list ; list = TREE_CHAIN (list))
+	  add_reg_note (insn, REG_TM, label_rtx (TREE_VALUE (list)));
+    }
+}
+
 /* A subroutine of expand_gimple_stmt_1, expanding one GIMPLE_CALL
    statement STMT.  */
 
@@ -1812,6 +1844,8 @@  expand_call_stmt (gimple stmt)
   bool builtin_p;
   size_t i;
 
+  mark_transaction_restart_calls (stmt);
+
   if (gimple_call_internal_p (stmt))
     {
       expand_internal_call (stmt);
@@ -2096,32 +2130,6 @@  expand_gimple_stmt (gimple stmt)
 	}
     }
 
-  /* Mark all calls that can have a transaction restart.  */
-  if (cfun->gimple_df->tm_restart && is_gimple_call (stmt))
-    {
-      struct tm_restart_node dummy;
-      void **slot;
-
-      dummy.stmt = stmt;
-      slot = htab_find_slot (cfun->gimple_df->tm_restart, &dummy, NO_INSERT);
-      if (slot)
-	{
-	  struct tm_restart_node *n = (struct tm_restart_node *) *slot;
-	  tree list = n->label_or_list;
-	  rtx insn;
-
-	  for (insn = next_real_insn (last); !CALL_P (insn);
-	       insn = next_real_insn (insn))
-	    continue;
-
-	  if (TREE_CODE (list) == LABEL_DECL)
-	    add_reg_note (insn, REG_TM, label_rtx (list));
-	  else
-	    for (; list ; list = TREE_CHAIN (list))
-	      add_reg_note (insn, REG_TM, label_rtx (TREE_VALUE (list)));
-	}
-    }
-
   return last;
 }