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

login
register
mail settings
Submitter Martin Jambor
Date June 26, 2013, 4:19 p.m.
Message ID <20130626161900.GI31242@virgil.suse>
Download mbox | patch
Permalink /patch/254801/
State New
Headers show

Comments

Martin Jambor - June 26, 2013, 4:19 p.m.
Hi,

On Tue, Jun 25, 2013 at 03:14:47PM +0200, Jan Hubicka wrote:
> > 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.
> >

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

OK, so unless someone objects, I will commit the following tomorrow.
Tested and bootstrapped on x86_64-linux.

Thanks,

Martin


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

	PR lto/57208
	* ipa-ref.h (ipa_maybe_record_reference): Declare.
	* ipa-ref.c (ipa_maybe_record_reference): New function.
	* cgraphclones.c (cgraph_create_virtual_clone): Use it.
	* ipa-cp.c (create_specialized_node): Record potential references from
	aggvals.
	* Makefile.in (ipa-ref.o): Add IPA_REF_H to dependencies.

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,10 @@  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)
+    ipa_maybe_record_reference ((symtab_node) new_node, av->value,
+				IPA_REF_ADDR, NULL);
+
   if (dump_file && (dump_flags & TDF_DETAILS))
     {
       fprintf (dump_file, "     the new node is %s/%i.\n",
Index: src/gcc/Makefile.in
===================================================================
--- src.orig/gcc/Makefile.in
+++ src/gcc/Makefile.in
@@ -2933,7 +2933,8 @@  ipa-prop.o : ipa-prop.c $(CONFIG_H) $(SY
    $(DATA_STREAMER_H) $(TREE_STREAMER_H) $(PARAMS_H)
 ipa-ref.o : ipa-ref.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
    langhooks.h $(GGC_H) $(TARGET_H) $(CGRAPH_H)  $(TREE_H) $(TARGET_H) \
-   $(TREE_FLOW_H) $(TM_H) $(TREE_PASS_H) $(FLAGS_H) $(TREE_H) $(GGC_H) 
+   $(TREE_FLOW_H) $(TM_H) $(TREE_PASS_H) $(FLAGS_H) $(TREE_H) $(GGC_H) \
+   $(IPA_UTILS_H)
 ipa-cp.o : ipa-cp.c $(CONFIG_H) $(SYSTEM_H) coretypes.h  \
    $(TREE_H) $(TARGET_H) $(GIMPLE_H) $(CGRAPH_H) $(IPA_PROP_H) $(TREE_FLOW_H) \
    $(TREE_PASS_H) $(FLAGS_H) $(DIAGNOSTIC_H) \
Index: src/gcc/cgraphclones.c
===================================================================
--- src.orig/gcc/cgraphclones.c
+++ src/gcc/cgraphclones.c
@@ -341,27 +341,8 @@  cgraph_create_virtual_clone (struct cgra
       || in_lto_p)
     new_node->symbol.unique_name = true;
   FOR_EACH_VEC_SAFE_ELT (tree_map, i, map)
-    {
-      tree var = map->new_tree;
-      symtab_node ref_node;
-
-      STRIP_NOPS (var);
-      if (TREE_CODE (var) != ADDR_EXPR)
-	continue;
-      var = get_base_var (var);
-      if (!var)
-	continue;
-      if (TREE_CODE (var) != FUNCTION_DECL
-	  && TREE_CODE (var) != VAR_DECL)
-	continue;
-
-      /* Record references of the future statement initializing the constant
-	 argument.  */
-      ref_node = symtab_get_node (var);
-      gcc_checking_assert (ref_node);
-      ipa_record_reference ((symtab_node)new_node, (symtab_node)ref_node,
-			    IPA_REF_ADDR, NULL);
-    }
+    ipa_maybe_record_reference ((symtab_node) new_node, map->new_tree,
+				IPA_REF_ADDR, NULL);
   if (!args_to_skip)
     new_node->clone.combined_args_to_skip = old_node->clone.combined_args_to_skip;
   else if (old_node->clone.combined_args_to_skip)
Index: src/gcc/ipa-ref.c
===================================================================
--- src.orig/gcc/ipa-ref.c
+++ src/gcc/ipa-ref.c
@@ -25,6 +25,7 @@  along with GCC; see the file COPYING3.
 #include "ggc.h"
 #include "target.h"
 #include "cgraph.h"
+#include "ipa-utils.h"
 
 static const char *ipa_ref_use_name[] = {"read","write","addr","alias"};
 
@@ -67,6 +68,30 @@  ipa_record_reference (symtab_node referr
   return ref;
 }
 
+/* If VAL is a refeerence to a function or a variable, add a reference from
+   REFERRING_NODE to the corresponding symbol table node.  USE_TYPE specify
+   type of the use and STMT the statement (if it exists).  Return the new
+   reference or NULL if none was created.  */
+
+struct ipa_ref *
+ipa_maybe_record_reference (symtab_node referring_node, tree val,
+			    enum ipa_ref_use use_type, gimple stmt)
+{
+  STRIP_NOPS (val);
+  if (TREE_CODE (val) != ADDR_EXPR)
+    return NULL;
+  val = get_base_var (val);
+  if (val && (TREE_CODE (val) == FUNCTION_DECL
+	       || TREE_CODE (val) == VAR_DECL))
+    {
+      symtab_node referred = symtab_get_node (val);
+      gcc_checking_assert (referred);
+      return ipa_record_reference (referring_node, referred,
+				   use_type, stmt);
+    }
+  return NULL;
+}
+
 /* Remove reference REF.  */
 
 void
Index: src/gcc/ipa-ref.h
===================================================================
--- src.orig/gcc/ipa-ref.h
+++ src/gcc/ipa-ref.h
@@ -61,6 +61,8 @@  struct GTY(()) ipa_ref_list
 struct ipa_ref * ipa_record_reference (symtab_node,
 				       symtab_node,
 				       enum ipa_ref_use, gimple);
+struct ipa_ref * ipa_maybe_record_reference (symtab_node, tree,
+					     enum ipa_ref_use, gimple);
 
 void ipa_remove_reference (struct ipa_ref *);
 void ipa_remove_all_references (struct ipa_ref_list *);