diff options
author | tbsaunde <tbsaunde@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-08-02 11:23:49 +0000 |
---|---|---|
committer | tbsaunde <tbsaunde@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-08-02 11:23:49 +0000 |
commit | 431205b753bfa26d1711e40ce478d9e92fd157da (patch) | |
tree | f0fb192e856fa98b7d91e225ff958dfcc1f602df /gcc/ipa.c | |
parent | 69d7692e60d4a7c61b4d3581f3285a866ec3abb1 (diff) | |
download | linaro-gcc-431205b753bfa26d1711e40ce478d9e92fd157da.tar.gz linaro-gcc-431205b753bfa26d1711e40ce478d9e92fd157da.tar.bz2 linaro-gcc-431205b753bfa26d1711e40ce478d9e92fd157da.zip |
add a hash_set based on hash_table
This allows us to replace the usage of pointer_set outside of
pointer_map with a nicer interface.
gcc/ada/
* gcc-interface/trans.c: Use hash_set instead of pointer_set.
gcc/c-family/
* c-gimplify.c: Use hash_set instead of pointer_set.
gcc/c/
* c-decl.c: Use hash_set instead of pointer_set.
gcc/cp/
* class.c, cp-gimplify.c, cp-tree.h, decl.c, decl2.c, error.c,
method.c, name-lookup.c, pt.c, semantics.c, tree.c: Use hash_set
instead of pointer_set.
gcc/fortran/
* openmp.c, trans-decl.c: Use hash_set instead of pointer_set.
gcc/
* hash-set.h: new File.
* cfgexpand.c, cfgloop.c, cgraph.c, cgraphbuild.c, cgraphunit.c,
cprop.c, cse.c, gimple-walk.c, gimple-walk.h, gimplify.c, godump.c,
ipa-devirt.c, ipa-pure-const.c, ipa-visibility.c, ipa.c, lto-cgraph.c,
lto-streamer-out.c, stmt.c, tree-cfg.c, tree-core.h, tree-eh.c,
tree-inline.c, tree-inline.h, tree-nested.c, tree-pretty-print.c,
tree-ssa-loop-niter.c, tree-ssa-phiopt.c, tree-ssa-threadedge.c,
tree-ssa-uninit.c, tree.c, tree.h, value-prof.c, varasm.c,
varpool.c: Use hash_set instead of pointer_set.
gcc/lto/
* lto-partition.c, lto-partition.h: Use hash_set instead of
pointer_set.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@213516 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ipa.c')
-rw-r--r-- | gcc/ipa.c | 77 |
1 files changed, 36 insertions, 41 deletions
diff --git a/gcc/ipa.c b/gcc/ipa.c index 8198b174920..1081e89d945 100644 --- a/gcc/ipa.c +++ b/gcc/ipa.c @@ -27,7 +27,7 @@ along with GCC; see the file COPYING3. If not see #include "cgraph.h" #include "tree-pass.h" #include "hash-map.h" -#include "pointer-set.h" +#include "hash-set.h" #include "gimple-expr.h" #include "gimplify.h" #include "flags.h" @@ -84,14 +84,14 @@ update_inlined_to_pointer (struct cgraph_node *node, struct cgraph_node *inlined static void enqueue_node (symtab_node *node, symtab_node **first, - struct pointer_set_t *reachable) + hash_set<symtab_node *> *reachable) { /* Node is still in queue; do nothing. */ if (node->aux && node->aux != (void *) 2) return; /* Node was already processed as unreachable, re-enqueue only if it became reachable now. */ - if (node->aux == (void *)2 && !pointer_set_contains (reachable, node)) + if (node->aux == (void *)2 && !reachable->contains (node)) return; node->aux = *first; *first = node; @@ -103,7 +103,7 @@ static void process_references (symtab_node *snode, symtab_node **first, bool before_inlining_p, - struct pointer_set_t *reachable) + hash_set<symtab_node *> *reachable) { int i; struct ipa_ref *ref = NULL; @@ -124,7 +124,7 @@ process_references (symtab_node *snode, && flag_wpa && ctor_for_folding (node->decl) != error_mark_node)))) - pointer_set_insert (reachable, node); + reachable->add (node); enqueue_node (node, first, reachable); } } @@ -138,10 +138,11 @@ process_references (symtab_node *snode, possible. */ static void -walk_polymorphic_call_targets (pointer_set_t *reachable_call_targets, +walk_polymorphic_call_targets (hash_set<void *> *reachable_call_targets, struct cgraph_edge *edge, symtab_node **first, - pointer_set_t *reachable, bool before_inlining_p) + hash_set<symtab_node *> *reachable, + bool before_inlining_p) { unsigned int i; void *cache_token; @@ -150,8 +151,7 @@ walk_polymorphic_call_targets (pointer_set_t *reachable_call_targets, = possible_polymorphic_call_targets (edge, &final, &cache_token); - if (!pointer_set_insert (reachable_call_targets, - cache_token)) + if (!reachable_call_targets->add (cache_token)) { for (i = 0; i < targets.length (); i++) { @@ -172,7 +172,7 @@ walk_polymorphic_call_targets (pointer_set_t *reachable_call_targets, && (cgraph_state < CGRAPH_STATE_IPA_SSA || !lookup_attribute ("always_inline", DECL_ATTRIBUTES (n->decl))))) - pointer_set_insert (reachable, n); + reachable->add (n); /* Even after inlining we want to keep the possible targets in the boundary, so late passes can still produce direct call even if @@ -276,9 +276,9 @@ symtab_remove_unreachable_nodes (bool before_inlining_p, FILE *file) struct cgraph_node *node, *next; varpool_node *vnode, *vnext; bool changed = false; - struct pointer_set_t *reachable = pointer_set_create (); - struct pointer_set_t *body_needed_for_clonning = pointer_set_create (); - struct pointer_set_t *reachable_call_targets = pointer_set_create (); + hash_set<symtab_node *> reachable; + hash_set<tree> body_needed_for_clonning; + hash_set<void *> reachable_call_targets; timevar_push (TV_IPA_UNREACHABLE); if (optimize && flag_devirtualize) @@ -304,8 +304,8 @@ symtab_remove_unreachable_nodes (bool before_inlining_p, FILE *file) && !node->can_remove_if_no_direct_calls_and_refs_p ()) { gcc_assert (!node->global.inlined_to); - pointer_set_insert (reachable, node); - enqueue_node (node, &first, reachable); + reachable.add (node); + enqueue_node (node, &first, &reachable); } else gcc_assert (!node->aux); @@ -316,14 +316,14 @@ symtab_remove_unreachable_nodes (bool before_inlining_p, FILE *file) if (!vnode->can_remove_if_no_refs_p() && !vnode->in_other_partition) { - pointer_set_insert (reachable, vnode); - enqueue_node (vnode, &first, reachable); + reachable.add (vnode); + enqueue_node (vnode, &first, &reachable); } /* Perform reachability analysis. */ while (first != (symtab_node *) (void *) 1) { - bool in_boundary_p = !pointer_set_contains (reachable, first); + bool in_boundary_p = !reachable.contains (first); symtab_node *node = first; first = (symtab_node *)first->aux; @@ -340,7 +340,7 @@ symtab_remove_unreachable_nodes (bool before_inlining_p, FILE *file) struct cgraph_node *origin_node = cgraph_node::get_create (DECL_ABSTRACT_ORIGIN (node->decl)); origin_node->used_as_abstract_origin = true; - enqueue_node (origin_node, &first, reachable); + enqueue_node (origin_node, &first, &reachable); } /* If any symbol in a comdat group is reachable, force all externally visible symbols in the same comdat @@ -353,11 +353,11 @@ symtab_remove_unreachable_nodes (bool before_inlining_p, FILE *file) next != node; next = next->same_comdat_group) if (!next->comdat_local_p () - && !pointer_set_insert (reachable, next)) - enqueue_node (next, &first, reachable); + && !reachable.add (next)) + enqueue_node (next, &first, &reachable); } /* Mark references as reachable. */ - process_references (node, &first, before_inlining_p, reachable); + process_references (node, &first, before_inlining_p, &reachable); } if (cgraph_node *cnode = dyn_cast <cgraph_node *> (node)) @@ -375,8 +375,8 @@ symtab_remove_unreachable_nodes (bool before_inlining_p, FILE *file) { next = e->next_callee; if (e->indirect_info->polymorphic) - walk_polymorphic_call_targets (reachable_call_targets, - e, &first, reachable, + walk_polymorphic_call_targets (&reachable_call_targets, + e, &first, &reachable, before_inlining_p); } } @@ -394,17 +394,16 @@ symtab_remove_unreachable_nodes (bool before_inlining_p, FILE *file) if (DECL_EXTERNAL (e->callee->decl) && e->callee->alias && before_inlining_p) - pointer_set_insert (reachable, - e->callee->function_symbol ()); - pointer_set_insert (reachable, e->callee); + reachable.add (e->callee->function_symbol ()); + reachable.add (e->callee); } - enqueue_node (e->callee, &first, reachable); + enqueue_node (e->callee, &first, &reachable); } /* When inline clone exists, mark body to be preserved so when removing offline copy of the function we don't kill it. */ if (cnode->global.inlined_to) - pointer_set_insert (body_needed_for_clonning, cnode->decl); + body_needed_for_clonning.add (cnode->decl); /* For non-inline clones, force their origins to the boundary and ensure that body is not removed. */ @@ -414,8 +413,8 @@ symtab_remove_unreachable_nodes (bool before_inlining_p, FILE *file) cnode = cnode->clone_of; if (noninline) { - pointer_set_insert (body_needed_for_clonning, cnode->decl); - enqueue_node (cnode, &first, reachable); + body_needed_for_clonning.add (cnode->decl); + enqueue_node (cnode, &first, &reachable); } } @@ -429,8 +428,8 @@ symtab_remove_unreachable_nodes (bool before_inlining_p, FILE *file) next; next = next->simdclone->next_clone) if (in_boundary_p - || !pointer_set_insert (reachable, next)) - enqueue_node (next, &first, reachable); + || !reachable.add (next)) + enqueue_node (next, &first, &reachable); } } /* When we see constructor of external variable, keep referred nodes in the @@ -444,7 +443,7 @@ symtab_remove_unreachable_nodes (bool before_inlining_p, FILE *file) { struct ipa_ref *ref = NULL; for (int i = 0; node->iterate_reference (i, ref); i++) - enqueue_node (ref->referred, &first, reachable); + enqueue_node (ref->referred, &first, &reachable); } } @@ -462,9 +461,9 @@ symtab_remove_unreachable_nodes (bool before_inlining_p, FILE *file) changed = true; } /* If node is unreachable, remove its body. */ - else if (!pointer_set_contains (reachable, node)) + else if (!reachable.contains (node)) { - if (!pointer_set_contains (body_needed_for_clonning, node->decl)) + if (!body_needed_for_clonning.contains (node->decl)) node->release_body (); else if (!node->clone_of) gcc_assert (in_lto_p || DECL_RESULT (node->decl)); @@ -530,7 +529,7 @@ symtab_remove_unreachable_nodes (bool before_inlining_p, FILE *file) vnode->remove (); changed = true; } - else if (!pointer_set_contains (reachable, vnode)) + else if (!reachable.contains (vnode)) { tree init; if (vnode->definition) @@ -557,10 +556,6 @@ symtab_remove_unreachable_nodes (bool before_inlining_p, FILE *file) vnode->aux = NULL; } - pointer_set_destroy (reachable); - pointer_set_destroy (body_needed_for_clonning); - pointer_set_destroy (reachable_call_targets); - /* Now update address_taken flags and try to promote functions to be local. */ if (file) fprintf (file, "\nClearing address taken flags:"); |