Patchwork [PR,57208] Add ipa-cp created references to the symbol table

login
register
mail settings
Submitter Martin Jambor
Date June 25, 2013, 11 a.m.
Message ID <20130625110020.GH31242@virgil.suse>
Download mbox | patch
Permalink /patch/254111/
State New
Headers show

Comments

Martin Jambor - June 25, 2013, 11 a.m.
Hi,

the patch reportedly fixes an issue when LTO building chromium.  It
adds references that are created by IPA-CP when propagating references
from aggregates (the scalar case is handled by the call graph
infrastructure).

Bootstrapped and tested on x86_64-linux.  OK for trunk?

Thanks,

Martin


2013-06-24  Martin Jambor  <mjambor@suse.cz>

	PR lto/57208
	* ipa-cp.c (create_specialized_node): Add newly created references
	to the symbol table.
Jan Hubicka - June 25, 2013, 1:14 p.m.
> Hi,
> 
> the patch reportedly fixes an issue when LTO building chromium.  It
> adds references that are created by IPA-CP when propagating references
> from aggregates (the scalar case is handled by the call graph
> infrastructure).
> 
> Bootstrapped and tested on x86_64-linux.  OK for trunk?
> 
> Thanks,
> 
> Martin
> 
> 
> 2013-06-24  Martin Jambor  <mjambor@suse.cz>
> 
> 	PR lto/57208
> 	* ipa-cp.c (create_specialized_node): Add newly created references
> 	to the symbol table.
> 
> Index: src/gcc/ipa-cp.c
> ===================================================================
> --- src.orig/gcc/ipa-cp.c
> +++ src/gcc/ipa-cp.c
> @@ -2663,6 +2663,7 @@ create_specialized_node (struct cgraph_n
>  {
>    struct ipa_node_params *new_info, *info = IPA_NODE_REF (node);
>    vec<ipa_replace_map_p, va_gc> *replace_trees = NULL;
> +  struct ipa_agg_replacement_value *av;
>    struct cgraph_node *new_node;
>    int i, count = ipa_get_param_count (info);
>    bitmap args_to_skip;
> @@ -2704,6 +2705,23 @@ create_specialized_node (struct cgraph_n
>    new_node = cgraph_create_virtual_clone (node, callers, replace_trees,
>  					  args_to_skip, "constprop");
>    ipa_set_node_agg_value_chain (new_node, aggvals);
> +  for (av = aggvals; av; av = av->next)
> +    {
> +      tree base;
> +      if (TREE_CODE (av->value) != ADDR_EXPR)
> +	continue;
> +      base = get_base_var (av->value);
> +      if (base && (TREE_CODE (base) == FUNCTION_DECL
> +		   || TREE_CODE (base) == VAR_DECL))
> +	{
> +	  symtab_node referred = symtab_get_node (base);
> +
> +	  gcc_checking_assert (referred);
> +	  ipa_record_reference ((symtab_node) new_node, referred,
> +				IPA_REF_ADDR, NULL);

There is identical code in cgraphclones.c doing the same for non-agg values.
Can you commonize it to (perhaps ipa_maybe_record_reference that will take
value as a parameter)?
OK with that change.

Honza
> +	}
> +    }
> +
>    if (dump_file && (dump_flags & TDF_DETAILS))
>      {
>        fprintf (dump_file, "     the new node is %s/%i.\n",

Patch

Index: src/gcc/ipa-cp.c
===================================================================
--- src.orig/gcc/ipa-cp.c
+++ src/gcc/ipa-cp.c
@@ -2663,6 +2663,7 @@  create_specialized_node (struct cgraph_n
 {
   struct ipa_node_params *new_info, *info = IPA_NODE_REF (node);
   vec<ipa_replace_map_p, va_gc> *replace_trees = NULL;
+  struct ipa_agg_replacement_value *av;
   struct cgraph_node *new_node;
   int i, count = ipa_get_param_count (info);
   bitmap args_to_skip;
@@ -2704,6 +2705,23 @@  create_specialized_node (struct cgraph_n
   new_node = cgraph_create_virtual_clone (node, callers, replace_trees,
 					  args_to_skip, "constprop");
   ipa_set_node_agg_value_chain (new_node, aggvals);
+  for (av = aggvals; av; av = av->next)
+    {
+      tree base;
+      if (TREE_CODE (av->value) != ADDR_EXPR)
+	continue;
+      base = get_base_var (av->value);
+      if (base && (TREE_CODE (base) == FUNCTION_DECL
+		   || TREE_CODE (base) == VAR_DECL))
+	{
+	  symtab_node referred = symtab_get_node (base);
+
+	  gcc_checking_assert (referred);
+	  ipa_record_reference ((symtab_node) new_node, referred,
+				IPA_REF_ADDR, NULL);
+	}
+    }
+
   if (dump_file && (dump_flags & TDF_DETAILS))
     {
       fprintf (dump_file, "     the new node is %s/%i.\n",