Patchwork 19/n: trans-mem: compiler tree/gimple stuff

login
register
mail settings
Submitter Aldy Hernandez
Date Nov. 6, 2011, 3:41 a.m.
Message ID <4EB601ED.2000007@redhat.com>
Download mbox | patch
Permalink /patch/123911/
State New
Headers show

Comments

Aldy Hernandez - Nov. 6, 2011, 3:41 a.m.
> Well - we usually don't grab bits off the tree nodes lightly.  Especially if
> the cgraph seems to be more fit.
>
>> If this is a suggestion, I can put it on my laundry list of future things
>> todo (after merge, 4.8?, etc).
>
> There are not many consumers of the flag, so fixing it shouldn't be hard.
> For 4.7 definitely.

Fair enough.

The following patch puts the bit in the cgraph structure.

There was a comment originally that we may be able to calculate this bit 
from the CFG, but I'm not sure whether this applies any more, or how 
much work it would be.  I left the comment in.

Tested on x86-64 Linux.

OK for branch?
* cgraph.c (dump_cgraph_node): Handle tm_clone.
	* cgraph.h (struct cgraph_node): Add tm_clone field.
	(decl_is_tm_clone): New.
	* tree.h (DECL_IS_TM_CLONE): Remove.
	* trans-mem.c (execute_lower_tm): Rename DECL_IS_TM_CLONE to
	decl_is_tm_clone.
	(gate_tm_init): Same.
	(ipa_tm_create_version_alias): Set tm_clone.
	(ipa_tm_create_version): Same.
	(ipa_tm_transform_calls_redirect): Rename DECL_IS_TM_CLONE to
	decl_is_tm_clone.
	* calls.c (is_tm_builtin): Same.
	* tree-cfg.c (dump_function_to_file): Same.
	* print-tree.c (print_node): Same.
	* gimple-pretty-print.c (dump_gimple_call): Same.
Richard Guenther - Nov. 6, 2011, 10:11 a.m.
On Sun, Nov 6, 2011 at 4:41 AM, Aldy Hernandez <aldyh@redhat.com> wrote:
>
>> Well - we usually don't grab bits off the tree nodes lightly.  Especially
>> if
>> the cgraph seems to be more fit.
>>
>>> If this is a suggestion, I can put it on my laundry list of future things
>>> todo (after merge, 4.8?, etc).
>>
>> There are not many consumers of the flag, so fixing it shouldn't be hard.
>> For 4.7 definitely.
>
> Fair enough.
>
> The following patch puts the bit in the cgraph structure.
>
> There was a comment originally that we may be able to calculate this bit
> from the CFG, but I'm not sure whether this applies any more, or how much
> work it would be.  I left the comment in.
>
> Tested on x86-64 Linux.
>
> OK for branch?

Ok.

Thanks,
Richard.

Patch

Index: cgraph.c
===================================================================
--- cgraph.c	(revision 181017)
+++ cgraph.c	(working copy)
@@ -1840,6 +1840,8 @@  dump_cgraph_node (FILE *f, struct cgraph
     fprintf (f, " only_called_at_exit");
   else if (node->alias)
     fprintf (f, " alias");
+  if (node->tm_clone)
+    fprintf (f, " tm_clone");
 
   fprintf (f, "\n");
 
Index: cgraph.h
===================================================================
--- cgraph.h	(revision 181017)
+++ cgraph.h	(working copy)
@@ -248,6 +248,11 @@  struct GTY((chain_next ("%h.next"), chai
   unsigned only_called_at_startup : 1;
   /* True when function can only be called at startup (from static dtor).  */
   unsigned only_called_at_exit : 1;
+  /* True when function is the transactional clone of a function which
+     is called only from inside transactions.  */
+  /* ?? We should be able to remove this.  We have enough bits in
+     cgraph to calculate it.  */
+  unsigned tm_clone : 1;
 };
 
 typedef struct cgraph_node *cgraph_node_ptr;
@@ -1087,4 +1092,14 @@  cgraph_edge_recursive_p (struct cgraph_e
   else
     return e->caller->decl == callee->decl;
 }
+
+/* Return true if the TM_CLONE bit is set for a given FNDECL.  */
+static inline bool
+decl_is_tm_clone (const_tree fndecl)
+{
+  struct cgraph_node *n = cgraph_get_node (fndecl);
+  if (n)
+    return n->tm_clone;
+  return false;
+}
 #endif  /* GCC_CGRAPH_H  */
Index: tree.h
===================================================================
--- tree.h	(revision 181017)
+++ tree.h	(working copy)
@@ -3466,11 +3466,6 @@  struct GTY(())
 #define DECL_NO_INLINE_WARNING_P(NODE) \
   (FUNCTION_DECL_CHECK (NODE)->function_decl.no_inline_warning_flag)
 
-/* Nonzero in a FUNCTION_DECL means this function is the transactional
-   clone of a function - called only from inside transactions.  */
-#define DECL_IS_TM_CLONE(NODE) \
-  (FUNCTION_DECL_CHECK (NODE)->function_decl.tm_clone_flag)
-
 /* Nonzero if a FUNCTION_CODE is a TM load/store.  */
 #define BUILTIN_TM_LOAD_STORE_P(FN) \
   ((FN) >= BUILT_IN_TM_STORE_1 && (FN) <= BUILT_IN_TM_LOAD_RFW_LDOUBLE)
Index: gimple-pretty-print.c
===================================================================
--- gimple-pretty-print.c	(revision 181017)
+++ gimple-pretty-print.c	(working copy)
@@ -701,7 +701,7 @@  dump_gimple_call (pretty_printer *buffer
   /* Dump the arguments of _ITM_beginTransaction sanely.  */
   if (TREE_CODE (fn) == ADDR_EXPR)
     fn = TREE_OPERAND (fn, 0);
-  if (TREE_CODE (fn) == FUNCTION_DECL && DECL_IS_TM_CLONE (fn))
+  if (TREE_CODE (fn) == FUNCTION_DECL && decl_is_tm_clone (fn))
     pp_string (buffer, " [tm-clone]");
   if (TREE_CODE (fn) == FUNCTION_DECL
       && DECL_BUILT_IN_CLASS (fn) == BUILT_IN_NORMAL
Index: trans-mem.c
===================================================================
--- trans-mem.c	(revision 181017)
+++ trans-mem.c	(working copy)
@@ -1683,7 +1683,7 @@  execute_lower_tm (void)
   struct walk_stmt_info wi;
 
   /* Transactional clones aren't created until a later pass.  */
-  gcc_assert (!DECL_IS_TM_CLONE (current_function_decl));
+  gcc_assert (!decl_is_tm_clone (current_function_decl));
 
   memset (&wi, 0, sizeof (wi));
   walk_gimple_seq (gimple_body (current_function_decl),
@@ -1901,7 +1901,7 @@  gate_tm_init (void)
   bitmap_obstack_initialize (&tm_obstack);
 
   /* If the function is a TM_CLONE, then the entire function is the region.  */
-  if (DECL_IS_TM_CLONE (current_function_decl))
+  if (decl_is_tm_clone (current_function_decl))
     {
       struct tm_region *region = (struct tm_region *)
 	obstack_alloc (&tm_obstack.obstack, sizeof (struct tm_region));
@@ -4194,11 +4194,8 @@  ipa_tm_create_version_alias (struct cgra
   if (DECL_COMDAT (new_decl))
     DECL_COMDAT_GROUP (new_decl) = tm_mangle (DECL_COMDAT_GROUP (old_decl));
 
-  /* ??? We should be able to remove DECL_IS_TM_CLONE.  We have enough
-     bits in cgraph to calculate all this.  */
-  DECL_IS_TM_CLONE (new_decl) = 1;
-
   new_node = cgraph_same_body_alias (NULL, new_decl, info->new_decl);
+  new_node->tm_clone = true;
   get_cg_data (node)->clone = new_node;
 
   record_tm_clone_pair (old_decl, new_decl);
@@ -4232,11 +4229,8 @@  ipa_tm_create_version (struct cgraph_nod
   if (DECL_COMDAT (new_decl))
     DECL_COMDAT_GROUP (new_decl) = tm_mangle (DECL_COMDAT_GROUP (old_decl));
 
-  /* ??? We should be able to remove DECL_IS_TM_CLONE.  We have enough
-     bits in cgraph to calculate all this.  */
-  DECL_IS_TM_CLONE (new_decl) = 1;
-
   new_node = cgraph_copy_node_for_versioning (old_node, new_decl, NULL, NULL);
+  new_node->tm_clone = 1;
   get_cg_data (old_node)->clone = new_node;
 
   if (cgraph_function_body_availability (old_node) >= AVAIL_OVERWRITABLE)
@@ -4418,7 +4412,7 @@  ipa_tm_transform_calls_redirect (struct 
   /* Fixup recursive calls inside clones.  */
   /* ??? Why did cgraph_copy_node_for_versioning update the call edges 
      for recursion but not update the call statements themselves?  */
-  if (e->caller == e->callee && DECL_IS_TM_CLONE (current_function_decl))
+  if (e->caller == e->callee && decl_is_tm_clone (current_function_decl))
     {
       gimple_call_set_fndecl (stmt, current_function_decl);
       return;
Index: calls.c
===================================================================
--- calls.c	(revision 181017)
+++ calls.c	(working copy)
@@ -620,7 +620,7 @@  is_tm_builtin (const_tree fndecl)
   if (fndecl == NULL)
     return false;
 
-  if (DECL_IS_TM_CLONE (fndecl))
+  if (decl_is_tm_clone (fndecl))
     return true;
 
   if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL)
Index: print-tree.c
===================================================================
--- print-tree.c	(revision 181017)
+++ print-tree.c	(working copy)
@@ -424,7 +424,7 @@  print_node (FILE *file, const char *pref
 	fputs (" built-in", file);
       if (code == FUNCTION_DECL && DECL_STATIC_CHAIN (node))
 	fputs (" static-chain", file);
-      if (TREE_CODE (node) == FUNCTION_DECL && DECL_IS_TM_CLONE (node))
+      if (TREE_CODE (node) == FUNCTION_DECL && decl_is_tm_clone (node))
 	fputs (" tm-clone", file);
 
       if (code == FIELD_DECL && DECL_PACKED (node))
Index: tree-cfg.c
===================================================================
--- tree-cfg.c	(revision 181017)
+++ tree-cfg.c	(working copy)
@@ -6503,7 +6503,7 @@  dump_function_to_file (tree fn, FILE *fi
   bool ignore_topmost_bind = false, any_var = false;
   basic_block bb;
   tree chain;
-  bool tmclone = TREE_CODE (fn) == FUNCTION_DECL && DECL_IS_TM_CLONE (fn);
+  bool tmclone = TREE_CODE (fn) == FUNCTION_DECL && decl_is_tm_clone (fn);
 
   fprintf (file, "%s %s(", lang_hooks.decl_printable_name (fn, 2),
 	   tmclone ? "[tm-clone] " : "");