diff mbox

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

Message ID 4FC69B64.9010103@redhat.com
State New
Headers show

Commit Message

Aldy Hernandez May 30, 2012, 10:12 p.m. UTC
On 05/25/12 10:55, Richard Henderson wrote:
> 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~

Thank you.

Committed to mainline.

I modified the patch slightly to apply it to the 4.7 branch.  Attached 
is the modified patch.

Tested on x86-64 Linux for 4.7 patch.  Committing to branch.
Backport from mainline
	2012-05-25  Aldy Hernandez  <aldyh@redhat.com>
	PR middle-end/53008
	* trans-mem.c (ipa_tm_create_version_alias): Output new_node if
	accessed indirectly.
	(ipa_tm_create_version): Same.
diff mbox

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 187887)
+++ trans-mem.c	(working copy)
@@ -4319,7 +4319,8 @@  ipa_tm_create_version_alias (struct cgra
 
   record_tm_clone_pair (old_decl, new_decl);
 
-  if (info->old_node->needed)
+  if (info->old_node->needed
+      || ipa_ref_list_first_refering (&info->old_node->ref_list))
     ipa_tm_mark_needed_node (new_node);
   return false;
 }
@@ -4372,7 +4373,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->needed)
+  if (old_node->needed
+      || ipa_ref_list_first_refering (&old_node->ref_list))
     ipa_tm_mark_needed_node (new_node);
 
   /* Do the same thing, but for any aliases of the original node.  */