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]

[PATCH, ipa-cp] Do not insert call graph nodes into the queue multiple times


Hi,

I have  noticed that the work  list we have in  ipa-cp happily inserts
the same node several times into  itself even when there's no point in
it.  The patch below adds a  flag to struct ipa_node_params so that we
don't do it any more.

Bootstrapped and tested on x86_64-linx.

OK for trunk?

Thanks,

Martin


2009-07-23  Martin Jambor  <mjambor@suse.cz>

	* ipa-prop.h (struct ipa_node_params): New flag node_enqued.
	(ipa_push_func_to_list_1): Declare.
	(ipa_push_func_to_list): New function.

	* ipa-prop.c (ipa_push_func_to_list_1): New function.
	(ipa_init_func_list): Call ipa_push_func_to_list_1.
	(ipa_push_func_to_list): Removed.
	(ipa_pop_func_from_list): Clear node_enqueued flag.


Index: icln/gcc/ipa-prop.c
===================================================================
--- icln.orig/gcc/ipa-prop.c
+++ icln/gcc/ipa-prop.c
@@ -45,6 +45,24 @@ static struct cgraph_node_hook_list *nod
 static struct cgraph_2edge_hook_list *edge_duplication_hook_holder;
 static struct cgraph_2node_hook_list *node_duplication_hook_holder;
 
+/* Add cgraph NODE described by INFO to the worklist WL regardless of whether
+   it is in one or not.  It should almost never be used directly, as opposed to
+   ipa_push_func_to_list.  */
+
+void
+ipa_push_func_to_list_1 (struct ipa_func_list **wl,
+			 struct cgraph_node *node,
+			 struct ipa_node_params *info)
+{
+  struct ipa_func_list *temp;
+
+  info->node_enqueued = 1;
+  temp = XCNEW (struct ipa_func_list);
+  temp->node = node;
+  temp->next = *wl;
+  *wl = temp;
+}
+
 /* Initialize worklist to contain all functions.  */
 
 struct ipa_func_list *
@@ -57,43 +75,33 @@ ipa_init_func_list (void)
   for (node = cgraph_nodes; node; node = node->next)
     if (node->analyzed)
       {
+	struct ipa_node_params *info = IPA_NODE_REF (node);
 	/* Unreachable nodes should have been eliminated before ipcp and
 	   inlining.  */
 	gcc_assert (node->needed || node->reachable);
-	ipa_push_func_to_list (&wl, node);
+	ipa_push_func_to_list_1 (&wl, node, info);
       }
 
   return wl;
 }
 
-/* Add cgraph node MT to the worklist. Set worklist element WL
-   to point to MT.  */
-
-void
-ipa_push_func_to_list (struct ipa_func_list **wl, struct cgraph_node *mt)
-{
-  struct ipa_func_list *temp;
-
-  temp = XCNEW (struct ipa_func_list);
-  temp->node = mt;
-  temp->next = *wl;
-  *wl = temp;
-}
-
-/* Remove a function from the worklist. WL points to the first
-   element in the list, which is removed.  */
+/* Remove a function from the worklist WL and return it.  */
 
 struct cgraph_node *
-ipa_pop_func_from_list (struct ipa_func_list ** wl)
+ipa_pop_func_from_list (struct ipa_func_list **wl)
 {
+  struct ipa_node_params *info;
   struct ipa_func_list *first;
-  struct cgraph_node *return_func;
+  struct cgraph_node *node;
 
   first = *wl;
   *wl = (*wl)->next;
-  return_func = first->node;
+  node = first->node;
   free (first);
-  return return_func;
+
+  info = IPA_NODE_REF (node);
+  info->node_enqueued = 0;
+  return node;
 }
 
 /* Return index of the formal whose tree is PTREE in function which corresponds
Index: icln/gcc/ipa-prop.h
===================================================================
--- icln.orig/gcc/ipa-prop.h
+++ icln/gcc/ipa-prop.h
@@ -167,6 +167,8 @@ struct ipa_node_params
   unsigned modification_analysis_done : 1;
   /* Whether the param uses analysis has already been performed.  */
   unsigned uses_analysis_done : 1;
+  /* Whether the function is enqueued in an ipa_func_list.  */
+  unsigned node_enqueued : 1;
 };
 
 /* ipa_node_params access functions.  Please use these to access fields that
@@ -369,9 +371,21 @@ struct ipa_func_list
 
 /* ipa_func_list interface.  */
 struct ipa_func_list *ipa_init_func_list (void);
-void ipa_push_func_to_list (struct ipa_func_list **, struct cgraph_node *);
+void ipa_push_func_to_list_1 (struct ipa_func_list **, struct cgraph_node *,
+			      struct ipa_node_params *);
 struct cgraph_node *ipa_pop_func_from_list (struct ipa_func_list **);
 
+/* Add cgraph NODE to the worklist WL if it is not already in one.  */
+
+static inline void
+ipa_push_func_to_list (struct ipa_func_list **wl, struct cgraph_node *node)
+{
+  struct ipa_node_params *info = IPA_NODE_REF (node);
+
+  if (!info->node_enqueued)
+    ipa_push_func_to_list_1 (wl, node, info);
+}
+
 /* Callsite related calculations.  */
 void ipa_compute_jump_functions (struct cgraph_edge *);
 void ipa_count_arguments (struct cgraph_edge *);


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