diff options
author | Martin Liska <mliska@suse.cz> | 2018-06-08 14:26:57 +0200 |
---|---|---|
committer | Martin Liska <marxin@gcc.gnu.org> | 2018-06-08 12:26:57 +0000 |
commit | 746447567a82ce2987f579770fd296ace60f87b1 (patch) | |
tree | c22de406a2a163de859df4f8b0c31de0e34a74a3 /gcc/passes.c | |
parent | 9d3e0adc2a0e657b2aa384f1392dd2fac77a62d4 (diff) | |
download | gcc-746447567a82ce2987f579770fd296ace60f87b1.zip gcc-746447567a82ce2987f579770fd296ace60f87b1.tar.gz gcc-746447567a82ce2987f579770fd296ace60f87b1.tar.bz2 |
Remove cgraph_node::summary_uid and make cgraph_node::uid really unique.
2018-06-08 Martin Liska <mliska@suse.cz>
* cgraph.c (cgraph_node::remove): Do not recycle uid.
* cgraph.h (symbol_table::release_symbol): Do not pass uid.
(symbol_table::allocate_cgraph_symbol): Do not set uid.
* passes.c (uid_hash_t): Record removed_nodes by their uids.
(remove_cgraph_node_from_order): Use the removed_nodes set.
(do_per_function_toporder): Likwise.
* symbol-summary.h (symtab_insertion): Use cgraph_node::uid
instead of summary_uid.
(symtab_removal): Likewise.
(symtab_duplication): Likewise.
2018-06-08 Martin Liska <mliska@suse.cz>
* lto-partition.c (lto_balanced_map): Use cgraph_node::uid
instead of summary_uid.
From-SVN: r261315
Diffstat (limited to 'gcc/passes.c')
-rw-r--r-- | gcc/passes.c | 37 |
1 files changed, 12 insertions, 25 deletions
diff --git a/gcc/passes.c b/gcc/passes.c index ee42009..537e95a 100644 --- a/gcc/passes.c +++ b/gcc/passes.c @@ -1635,22 +1635,16 @@ do_per_function (void (*callback) (function *, void *data), void *data) static int nnodes; static GTY ((length ("nnodes"))) cgraph_node **order; +#define uid_hash_t hash_set<int_hash <int, 0, -1>> + /* Hook called when NODE is removed and therefore should be - excluded from order vector. DATA is an array of integers. - DATA[0] holds max index it may be accessed by. For cgraph - node DATA[node->uid + 1] holds index of this node in order - vector. */ + excluded from order vector. DATA is a hash set with removed nodes. */ + static void remove_cgraph_node_from_order (cgraph_node *node, void *data) { - int *order_idx = (int *)data; - - if (node->uid >= order_idx[0]) - return; - - int idx = order_idx[node->uid + 1]; - if (idx >= 0 && idx < nnodes && order[idx] == node) - order[idx] = NULL; + uid_hash_t *removed_nodes = (uid_hash_t *)data; + removed_nodes->add (node->uid); } /* If we are in IPA mode (i.e., current_function_decl is NULL), call @@ -1667,30 +1661,23 @@ do_per_function_toporder (void (*callback) (function *, void *data), void *data) else { cgraph_node_hook_list *hook; - int *order_idx; + uid_hash_t removed_nodes; gcc_assert (!order); order = ggc_vec_alloc<cgraph_node *> (symtab->cgraph_count); - order_idx = XALLOCAVEC (int, symtab->cgraph_max_uid + 1); - memset (order_idx + 1, -1, sizeof (int) * symtab->cgraph_max_uid); - order_idx[0] = symtab->cgraph_max_uid; - nnodes = ipa_reverse_postorder (order); for (i = nnodes - 1; i >= 0; i--) - { - order[i]->process = 1; - order_idx[order[i]->uid + 1] = i; - } + order[i]->process = 1; hook = symtab->add_cgraph_removal_hook (remove_cgraph_node_from_order, - order_idx); + &removed_nodes); for (i = nnodes - 1; i >= 0; i--) { + cgraph_node *node = order[i]; + /* Function could be inlined and removed as unreachable. */ - if (!order[i]) + if (node == NULL || removed_nodes.contains (node->uid)) continue; - struct cgraph_node *node = order[i]; - /* Allow possibly removed nodes to be garbage collected. */ order[i] = NULL; node->process = 0; |