Patchwork PR middle-end/53008 (trans-mem): output clone if function accessed indirectly

login
register
mail settings
Submitter Aldy Hernandez
Date May 25, 2012, 1:25 p.m.
Message ID <4FBF885B.9000809@redhat.com>
Download mbox | patch
Permalink /patch/161346/
State New
Headers show

Comments

Aldy Hernandez - May 25, 2012, 1:25 p.m.
This is a patch from Patrick, based on an earlier patch by Dave 
Boutcher.  Thanks folks.

In the failing testcase below we have a transaction_safe function being 
accessed indirectly, but for -O1 and above, the corresponding clone is 
not generated because we think it is unused.  Fixed by forcing the clone 
output if it is accessed indirectly.

Tested on x86-64 Linux.

OK?  Would this be acceptable for the 4.7 branch as well?
PR middle-end/53008
	* trans-mem.c (ipa_tm_create_version_alias): Output new_node if
	accessed indirectly.
	(ipa_tm_create_version): Same.
Richard Henderson - May 25, 2012, 3:55 p.m.
On 05/25/2012 06:25 AM, Aldy Hernandez wrote:
> OK?  Would this be acceptable for the 4.7 branch as well?
>
> curr
>
>
> 	PR middle-end/53008
> 	* trans-mem.c (ipa_tm_create_version_alias): Output new_node if
> 	accessed indirectly.
> 	(ipa_tm_create_version): Same.

Ok everywhere.


r~

Patch

Index: testsuite/gcc.dg/tm/pr53008.c
===================================================================
--- testsuite/gcc.dg/tm/pr53008.c	(revision 0)
+++ testsuite/gcc.dg/tm/pr53008.c	(revision 0)
@@ -0,0 +1,14 @@ 
+/* { dg-do compile } */
+/* { dg-options "-fgnu-tm -O" } */
+
+void __attribute__((transaction_safe)) (*fn)(void);
+
+static void __attribute__((transaction_safe))
+foo(void)
+{
+}
+
+void set_fn(void)
+{
+  fn = foo;
+}
Index: trans-mem.c
===================================================================
--- trans-mem.c	(revision 187729)
+++ trans-mem.c	(working copy)
@@ -4328,7 +4328,8 @@  ipa_tm_create_version_alias (struct cgra
 
   record_tm_clone_pair (old_decl, new_decl);
 
-  if (info->old_node->symbol.force_output)
+  if (info->old_node->symbol.force_output
+      || ipa_ref_list_first_referring (&info->old_node->symbol.ref_list))
     ipa_tm_mark_force_output_node (new_node);
   return false;
 }
@@ -4381,7 +4382,8 @@  ipa_tm_create_version (struct cgraph_nod
   record_tm_clone_pair (old_decl, new_decl);
 
   cgraph_call_function_insertion_hooks (new_node);
-  if (old_node->symbol.force_output)
+  if (old_node->symbol.force_output
+      || ipa_ref_list_first_referring (&old_node->symbol.ref_list))
     ipa_tm_mark_force_output_node (new_node);
 
   /* Do the same thing, but for any aliases of the original node.  */