diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3e11af83e08..fd752b62cef 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +2009-07-24 Martin Jambor + + * 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. + 2009-07-24 Andreas Krebbel * config/s390/s390.c (override_options): Default diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c index a376f45c7b3..1a7003295a2 100644 --- a/gcc/ipa-prop.c +++ b/gcc/ipa-prop.c @@ -45,6 +45,24 @@ static struct cgraph_node_hook_list *node_removal_hook_holder; 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 diff --git a/gcc/ipa-prop.h b/gcc/ipa-prop.h index c4c1ccc162a..fafadaca247 100644 --- a/gcc/ipa-prop.h +++ b/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 *);