public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* PR middle-end/53008 (trans-mem): output clone if function accessed indirectly
@ 2012-05-25 13:26 Aldy Hernandez
  2012-05-25 15:56 ` Richard Henderson
  0 siblings, 1 reply; 3+ messages in thread
From: Aldy Hernandez @ 2012-05-25 13:26 UTC (permalink / raw)
  To: Richard Henderson; +Cc: gcc-patches, MARLIER Patrick, daveboutcher

[-- Attachment #1: Type: text/plain, Size: 431 bytes --]

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?

[-- Attachment #2: curr --]
[-- Type: text/plain, Size: 1500 bytes --]

	PR middle-end/53008
	* trans-mem.c (ipa_tm_create_version_alias): Output new_node if
	accessed indirectly.
	(ipa_tm_create_version): Same.

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.  */

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: PR middle-end/53008 (trans-mem): output clone if function accessed indirectly
  2012-05-25 13:26 PR middle-end/53008 (trans-mem): output clone if function accessed indirectly Aldy Hernandez
@ 2012-05-25 15:56 ` Richard Henderson
  2012-05-30 22:13   ` Aldy Hernandez
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Henderson @ 2012-05-25 15:56 UTC (permalink / raw)
  To: Aldy Hernandez; +Cc: gcc-patches, MARLIER Patrick, daveboutcher

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~

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: PR middle-end/53008 (trans-mem): output clone if function accessed indirectly
  2012-05-25 15:56 ` Richard Henderson
@ 2012-05-30 22:13   ` Aldy Hernandez
  0 siblings, 0 replies; 3+ messages in thread
From: Aldy Hernandez @ 2012-05-30 22:13 UTC (permalink / raw)
  To: Richard Henderson; +Cc: gcc-patches, MARLIER Patrick, daveboutcher

[-- Attachment #1: Type: text/plain, Size: 539 bytes --]

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.

[-- Attachment #2: curr --]
[-- Type: text/plain, Size: 1492 bytes --]

	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.

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.  */

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-05-30 22:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-25 13:26 PR middle-end/53008 (trans-mem): output clone if function accessed indirectly Aldy Hernandez
2012-05-25 15:56 ` Richard Henderson
2012-05-30 22:13   ` Aldy Hernandez

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).