This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[trans-mem] fix link error with clone table


Hi.

Currently we do not generate code for static unused TM clones, even
though the original function will be generated.  See
cgraph_decide_is_function_needed():

     When not optimizing, also output the static functions. (see
     PR24561), but don't do so for always_inline functions, functions

Since the original function is marked as needed, finish_tm_clone_pairs()
will output an entry in the .tm_clone_table section.  This will cause a
link error because we are referencing a function we did not output.

The easiest thing is to output the clone body as well.

OK for branch?

BTW, I no longer check for externally_visible because
cgraph_decide_is_function_needed() will check for it, thus setting the
needed bit.

	* trans-mem.c (ipa_tm_create_version): Mark as needed if original
	node is needed.

Index: testsuite/gcc.dg/tm/unused.c
===================================================================
--- testsuite/gcc.dg/tm/unused.c	(revision 0)
+++ testsuite/gcc.dg/tm/unused.c	(revision 0)
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-fgnu-tm -Wall" } */
+
+__attribute__((transaction_safe))
+static int unused_func ()	/* { dg-warning "defined but not used" } */
+{
+  return 12345;
+}
+
+int main()
+{
+  return 0;
+}
+
+/* { dg-final { scan-assembler "_ZGTt11unused_func:" } } */
Index: trans-mem.c
===================================================================
--- trans-mem.c	(revision 158551)
+++ trans-mem.c	(working copy)
@@ -3807,7 +3807,7 @@ ipa_tm_create_version (struct cgraph_nod
   record_tm_clone_pair (old_decl, new_decl);
 
   cgraph_call_function_insertion_hooks (new_node);
-  if (new_node->local.externally_visible)
+  if (old_node->needed)
     cgraph_mark_needed_node (new_node);
 }
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]