diff mbox

[trans-mem] fix problems with same body aliases

Message ID 4EA8788B.8030807@redhat.com
State New
Headers show

Commit Message

Aldy Hernandez Oct. 26, 2011, 9:15 p.m. UTC
The merge broke base/complete dtor transactional clones that we 
originally implemented here:

http://gcc.gnu.org/ml/gcc-patches/2010-06/msg00590.html

First, ipa_tm_execute() was putting __comp_dtor's into tm_callees, which 
wasn't happening pre-merge.  Handling this __comp_dtor caused an ICE 
tree_function_versioning() because ENTRY_BLOCK_PTR_FOR_FUNCTION is 
invalid, since the CFG field for the original decl's cfun has not been set.

The patch below excludes such aliases from tm_callees since we can't 
handle them in ipa_tm_create_version.

Second, ipa_tm_create_version() marks aliases of the original decl as 
needed in callback_mark_needed().  Unfortunately, this "needed" bit does 
not persist until the end of compilation because whole program IPA will 
remove the bit here:

       /* Frontends and alias code marks nodes as needed before parsing 
is finished.
	 We may end up marking as node external nodes where this flag is 
meaningless
	 strip it.  */
       if (node->needed
	  && (DECL_EXTERNAL (node->decl) || !node->analyzed))
	node->needed = 0;

Consequently, the alias will not show up in the .tm_clone_table.

The patch below sets the "analyzed" bit to keep this from happening. 
With it, g++.dg/tm/alias.C works again.

No regressions elsewhere.

OK?
* trans-mem.c (ipa_tm_execute): Do not include aliases in
	tm_callees.
	(callback_mark_needed): Set analyzed bit.

Comments

Richard Henderson Oct. 27, 2011, 10:05 p.m. UTC | #1
On 10/26/2011 02:15 PM, Aldy Hernandez wrote:
> 	* trans-mem.c (ipa_tm_execute): Do not include aliases in
> 	tm_callees.
> 	(callback_mark_needed): Set analyzed bit.

Ok.


r~
diff mbox

Patch

Index: trans-mem.c
===================================================================
--- trans-mem.c	(revision 180439)
+++ trans-mem.c	(working copy)
@@ -4137,7 +4137,13 @@  callback_mark_needed (struct cgraph_node
       record_tm_clone_pair (node->decl, tm_alias);
 
       if (info->old_node->needed)
-	cgraph_mark_needed_node (cgraph_get_node (tm_alias));
+	{
+	  struct cgraph_node *alias = cgraph_get_node (tm_alias);
+	  cgraph_mark_needed_node (alias);
+	  /* Needed so function_and_variable_visibility() won't reset
+	     the needed bit.  */
+	  alias->analyzed = 1;
+	}
     }
   return false;
 }
@@ -4592,6 +4598,7 @@  ipa_tm_execute (void)
   /* For all local functions marked tm_callable, queue them.  */
   for (node = cgraph_nodes; node; node = node->next)
     if (is_tm_callable (node->decl)
+	&& !node->alias
 	&& cgraph_function_body_availability (node) >= AVAIL_OVERWRITABLE)
       {
 	d = get_cg_data (node);