diff options
author | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-09-01 06:35:08 +0000 |
---|---|---|
committer | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-09-01 06:35:08 +0000 |
commit | a30fe044170c44da9e441535e2167ca8e885b3cb (patch) | |
tree | 2ebaaed9567b6d2c562b45ef1d92bcb5cb136795 /gcc/cgraph.c | |
parent | ddda25955ee583217ccbd7ad5c33c6bb9f304649 (diff) | |
download | gcc-a30fe044170c44da9e441535e2167ca8e885b3cb.tar.gz |
2008-09-01 Basile Starynkevitch <basile@starynkevitch.net>
MERGED WITH TRUNK rev139820
* gcc/melt/warmelt-first.bysl: added location argument to inform.
* gcc/warmelt-first-0.c: regenerated.
* gcc/warmelt-macro-0.c: regenerated.
* gcc/warmelt-normal-0.c: regenerated.
* gcc/warmelt-genobj-0.c: regenerated.
* gcc/warmelt-outobj-0.c: regenerated.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@139849 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cgraph.c')
-rw-r--r-- | gcc/cgraph.c | 57 |
1 files changed, 53 insertions, 4 deletions
diff --git a/gcc/cgraph.c b/gcc/cgraph.c index 37ad9f1606f..fdc156dfe33 100644 --- a/gcc/cgraph.c +++ b/gcc/cgraph.c @@ -173,6 +173,8 @@ struct cgraph_node_hook_list *first_cgraph_node_removal_hook; struct cgraph_2edge_hook_list *first_cgraph_edge_duplicated_hook; /* List of hooks triggered when a node is duplicated. */ struct cgraph_2node_hook_list *first_cgraph_node_duplicated_hook; +/* List of hooks triggered when an function is inserted. */ +struct cgraph_node_hook_list *first_cgraph_function_insertion_hook; /* Register HOOK to be called with DATA on each removed edge. */ @@ -255,6 +257,46 @@ cgraph_call_node_removal_hooks (struct cgraph_node *node) } } +/* Register HOOK to be called with DATA on each removed node. */ +struct cgraph_node_hook_list * +cgraph_add_function_insertion_hook (cgraph_node_hook hook, void *data) +{ + struct cgraph_node_hook_list *entry; + struct cgraph_node_hook_list **ptr = &first_cgraph_function_insertion_hook; + + entry = (struct cgraph_node_hook_list *) xmalloc (sizeof (*entry)); + entry->hook = hook; + entry->data = data; + entry->next = NULL; + while (*ptr) + ptr = &(*ptr)->next; + *ptr = entry; + return entry; +} + +/* Remove ENTRY from the list of hooks called on removing nodes. */ +void +cgraph_remove_function_insertion_hook (struct cgraph_node_hook_list *entry) +{ + struct cgraph_node_hook_list **ptr = &first_cgraph_function_insertion_hook; + + while (*ptr != entry) + ptr = &(*ptr)->next; + *ptr = entry->next; +} + +/* Call all node removal hooks. */ +void +cgraph_call_function_insertion_hooks (struct cgraph_node *node) +{ + struct cgraph_node_hook_list *entry = first_cgraph_function_insertion_hook; + while (entry) + { + entry->hook (node, entry->data); + entry = entry->next; + } +} + /* Register HOOK to be called with DATA on each duplicated edge. */ struct cgraph_2edge_hook_list * cgraph_add_edge_duplication_hook (cgraph_2edge_hook hook, void *data) @@ -516,7 +558,7 @@ cgraph_edge (struct cgraph_node *node, gimple call_stmt) if (node->call_site_hash) return (struct cgraph_edge *) htab_find_with_hash (node->call_site_hash, call_stmt, - htab_hash_pointer (call_stmt)); + htab_hash_pointer (call_stmt)); /* This loop may turn out to be performance problem. In such case adding hashtables into call nodes with very many edges is probably best @@ -815,6 +857,7 @@ cgraph_remove_node (struct cgraph_node *node) { void **slot; bool kill_body = false; + struct cgraph_node *n; cgraph_call_node_removal_hooks (node); cgraph_node_remove_callers (node); @@ -823,8 +866,9 @@ cgraph_remove_node (struct cgraph_node *node) /* Incremental inlining access removed nodes stored in the postorder list. */ node->needed = node->reachable = false; - while (node->nested) - cgraph_remove_node (node->nested); + for (n = node->nested; n; n = n->next_nested) + n->origin = NULL; + node->nested = NULL; if (node->origin) { struct cgraph_node **node2 = &node->origin->nested; @@ -1208,7 +1252,12 @@ cgraph_clone_node (struct cgraph_node *n, gcov_type count, int freq, new_node->master_clone = n->master_clone; new_node->count = count; if (n->count) - count_scale = new_node->count * REG_BR_PROB_BASE / n->count; + { + if (new_node->count > n->count) + count_scale = REG_BR_PROB_BASE; + else + count_scale = new_node->count * REG_BR_PROB_BASE / n->count; + } else count_scale = 0; if (update_original) |