Patchwork [trans-mem] PR46714

login
register
mail settings
Submitter Aldy Hernandez
Date Dec. 14, 2010, 12:04 p.m.
Message ID <4D075D3E.9050109@redhat.com>
Download mbox | patch
Permalink /patch/75486/
State New
Headers show

Comments

Aldy Hernandez - Dec. 14, 2010, 12:04 p.m.
What happens here is that if we have any weak references in the source, 
finish_aliases_1 (via cgraph_node_for_asm) will initialize the 
assembler_name_hash WITHOUT the the TM clones because they have not yet 
been created.

What should happen is that when ipa_tm_create_version() runs later, it 
should set the DECL_ASSEMBLER_NAME before creating the cgraph_node, so 
we update the assembler_name_hash correctly.

OK for branch?
PR/46714
	* trans-mem.c (ipa_tm_create_version): Set DECL_ASSEMBLER_NAME
	before creating new node.
Aldy Hernandez - Dec. 14, 2010, 1:14 p.m.
On 12/14/10 13:04, Aldy Hernandez wrote:
> What happens here is that if we have any weak references in the 
> source, finish_aliases_1 (via cgraph_node_for_asm) will initialize the 
> assembler_name_hash WITHOUT the the TM clones because they have not 
> yet been created.
>
> What should happen is that when ipa_tm_create_version() runs later, it 
> should set the DECL_ASSEMBLER_NAME before creating the cgraph_node, so 
> we update the assembler_name_hash correctly.
>
> OK for branch?
>
Approved over coffee with the caveat that I should add a comment to the 
code.

Committed.

Patch

Index: testsuite/g++.dg/tm/pr46714.C
===================================================================
--- testsuite/g++.dg/tm/pr46714.C	(revision 0)
+++ testsuite/g++.dg/tm/pr46714.C	(revision 0)
@@ -0,0 +1,14 @@ 
+// { dg-do compile }
+// { dg-options "-fgnu-tm -O" }
+
+static int asdf __attribute__ ((__weakref__("funky")));
+  
+class Building
+{	
+public:
+  __attribute__((transaction_safe)) ~Building(void);
+};
+
+Building::~Building()
+{
+}
Index: trans-mem.c
===================================================================
--- trans-mem.c	(revision 167793)
+++ trans-mem.c	(working copy)
@@ -4021,6 +4021,12 @@  ipa_tm_create_version (struct cgraph_nod
 
   old_decl = old_node->decl;
   new_decl = copy_node (old_decl);
+
+  tm_name = tm_mangle (old_decl);
+  SET_DECL_ASSEMBLER_NAME (new_decl, get_identifier (tm_name));
+  SET_DECL_RTL (new_decl, NULL);
+  free (tm_name);
+
   new_node = cgraph_copy_node_for_versioning (old_node, new_decl, NULL);
   get_cg_data (old_node)->clone = new_node;
 
@@ -4031,11 +4037,6 @@  ipa_tm_create_version (struct cgraph_nod
      bits in cgraph to calculate all this.  */
   DECL_IS_TM_CLONE (new_decl) = 1;
 
-  tm_name = tm_mangle (old_decl);
-  SET_DECL_ASSEMBLER_NAME (new_decl, get_identifier (tm_name));
-  SET_DECL_RTL (new_decl, NULL);
-  free (tm_name);
-
   record_tm_clone_pair (old_decl, new_decl);
 
   cgraph_call_function_insertion_hooks (new_node);