Commit 8775a18b by Jan Hubicka Committed by Jan Hubicka

ipa-utils.c (postorder_stack): New structure.

	* ipa-utils.c (postorder_stack): New structure.
	(ipa_reverse_postorder): Handle aliases.

From-SVN: r174991
parent db1d217c
2011-06-13 Jan Hubicka <jh@suse.cz> 2011-06-13 Jan Hubicka <jh@suse.cz>
* ipa-utils.c (postorder_stack): New structure.
(ipa_reverse_postorder): Handle aliases.
2011-06-13 Jan Hubicka <jh@suse.cz>
* ipa-inline.c (reset_edge_caches): Walk aliases.
(update_caller_keys): Do not test inlinability of aliases.
* ipa-inline-analysis.c (do_estimate_edge_time): Look through alias.
(do_estimate_growth): Fix typo.
2011-06-13 Jan Hubicka <jh@suse.cz>
* ipa-inline-transform.c (+can_remove_node_now_p_1): Break out from... * ipa-inline-transform.c (+can_remove_node_now_p_1): Break out from...
(can_remove_node_now_p): ... here; handle same comdat groups. (can_remove_node_now_p): ... here; handle same comdat groups.
(clone_inlined_nodes): Update use of can_remove_node_now_p add TODO. (clone_inlined_nodes): Update use of can_remove_node_now_p add TODO.
......
...@@ -233,6 +233,13 @@ ipa_free_postorder_info (void) ...@@ -233,6 +233,13 @@ ipa_free_postorder_info (void)
} }
} }
struct postorder_stack
{
struct cgraph_node *node;
struct cgraph_edge *edge;
int ref;
};
/* Fill array order with all nodes with output flag set in the reverse /* Fill array order with all nodes with output flag set in the reverse
topological order. Return the number of elements in the array. topological order. Return the number of elements in the array.
FIXME: While walking, consider aliases, too. */ FIXME: While walking, consider aliases, too. */
...@@ -243,11 +250,12 @@ ipa_reverse_postorder (struct cgraph_node **order) ...@@ -243,11 +250,12 @@ ipa_reverse_postorder (struct cgraph_node **order)
struct cgraph_node *node, *node2; struct cgraph_node *node, *node2;
int stack_size = 0; int stack_size = 0;
int order_pos = 0; int order_pos = 0;
struct cgraph_edge *edge, last; struct cgraph_edge *edge;
int pass; int pass;
struct ipa_ref *ref;
struct cgraph_node **stack = struct postorder_stack *stack =
XCNEWVEC (struct cgraph_node *, cgraph_n_nodes); XCNEWVEC (struct postorder_stack, cgraph_n_nodes);
/* We have to deal with cycles nicely, so use a depth first traversal /* We have to deal with cycles nicely, so use a depth first traversal
output algorithm. Ignore the fact that some functions won't need output algorithm. Ignore the fact that some functions won't need
...@@ -261,47 +269,51 @@ ipa_reverse_postorder (struct cgraph_node **order) ...@@ -261,47 +269,51 @@ ipa_reverse_postorder (struct cgraph_node **order)
&& (pass && (pass
|| (!node->address_taken || (!node->address_taken
&& !node->global.inlined_to && !node->global.inlined_to
&& !cgraph_only_called_directly_or_aliased_p (node)))) && !node->alias && !node->thunk.thunk_p
&& !cgraph_only_called_directly_p (node))))
{ {
node2 = node; stack_size = 0;
if (!node->callers) stack[stack_size].node = node;
node->aux = &last; stack[stack_size].edge = node->callers;
else stack[stack_size].ref = 0;
node->aux = node->callers; node->aux = (void *)(size_t)1;
while (node2) while (stack_size >= 0)
{ {
while (node2->aux != &last) while (true)
{ {
edge = (struct cgraph_edge *) node2->aux; node2 = NULL;
if (edge->next_caller) while (stack[stack_size].edge && !node2)
node2->aux = edge->next_caller; {
else edge = stack[stack_size].edge;
node2->aux = &last; node2 = edge->caller;
stack[stack_size].edge = edge->next_caller;
/* Break possible cycles involving always-inline /* Break possible cycles involving always-inline
functions by ignoring edges from always-inline functions by ignoring edges from always-inline
functions to non-always-inline functions. */ functions to non-always-inline functions. */
if (DECL_DISREGARD_INLINE_LIMITS (edge->caller->decl) if (DECL_DISREGARD_INLINE_LIMITS (edge->caller->decl)
&& !DECL_DISREGARD_INLINE_LIMITS (edge->callee->decl)) && !DECL_DISREGARD_INLINE_LIMITS
continue; (cgraph_function_node (edge->callee, NULL)->decl))
if (!edge->caller->aux) node2 = NULL;
{
if (!edge->caller->callers)
edge->caller->aux = &last;
else
edge->caller->aux = edge->caller->callers;
stack[stack_size++] = node2;
node2 = edge->caller;
break;
} }
for (;ipa_ref_list_refering_iterate (&stack[stack_size].node->ref_list,
stack[stack_size].ref,
ref) && !node2;
stack[stack_size].ref++)
{
if (ref->use == IPA_REF_ALIAS)
node2 = ipa_ref_refering_node (ref);
} }
if (node2->aux == &last) if (!node2)
break;
if (!node2->aux)
{ {
order[order_pos++] = node2; stack[++stack_size].node = node2;
if (stack_size) stack[stack_size].edge = node2->callers;
node2 = stack[--stack_size]; stack[stack_size].ref = 0;
else node2->aux = (void *)(size_t)1;
node2 = NULL; }
} }
order[order_pos++] = stack[stack_size--].node;
} }
} }
free (stack); free (stack);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment