diff options
author | Jan Hubicka <jh@suse.cz> | 2012-04-17 12:53:22 +0200 |
---|---|---|
committer | Jan Hubicka <hubicka@gcc.gnu.org> | 2012-04-17 10:53:22 +0000 |
commit | 1ab24192d5e8e4fcee353bb5c024995e5439f5e3 (patch) | |
tree | 74a135bcf142920c4746545d97004d6d4f499f76 /gcc/varpool.c | |
parent | 332781bba582208a138ae93c2f20e45d202fc3e5 (diff) | |
download | gcc-1ab24192d5e8e4fcee353bb5c024995e5439f5e3.zip gcc-1ab24192d5e8e4fcee353bb5c024995e5439f5e3.tar.gz gcc-1ab24192d5e8e4fcee353bb5c024995e5439f5e3.tar.bz2 |
cgraph.c (cgraph_hash, [...]): Remove.
* cgraph.c (cgraph_hash, assembler_name_hash): Remove.
(hash_node, eq_node): Remove.
(cgraph_create_node): Do not handle hashtable.
(cgraph_get_node): Remove.
(cgraph_insert_node_to_hashtable): Remove.
(hash_node_by_assembler_name): Remove.
(eq_assembler_name): Remove.
(cgraph_node_for_asm): Rewrite.
(cgraph_find_replacement_node): Break out from ...
(cgraph_remove_node): ... here; do not maintain hashtables.
(change_decl_assembler_name): Remove.
(cgraph_clone_node): Do not maintain hashtables.
* cgraph.h (const_symtab_node): New typedef.
(cgraph_insert_node_to_hashtable): Remove.
(symtab_get_node, symtab_node_for_asm,
symtab_insert_node_to_hashtable): Declare.
(cgraph_find_replacement_node): Declare.
(cgraph_get_node, varpool_get_node): Turn into inlines.
(cgraph, varpool): Work sanely on NULL pointers.
(FOR_EACH_SYMBOL): New walker.
* ipa-inline-transform.c (save_inline_function_body): Use
symtab_insert_node_to_hashtable.
* symtab.c: Include ggc.h and diagnostics.h
(symtab_hash, assembler_name_hash): New static vars;
(hash_node, eq_node, hash_node_by_assembler_name,
eq_assembler_name, insert_to_assembler_name_hash,
unlink_from_assembler_name_hash): New.
(symtab_register_node): Update hashtables.
(symtab_insert_node_to_hashtable): New.
(symtab_unregister_node): Update hashtables.
(symtab_get_node): New.
(symtab_node_for_asm): New.
(change_decl_assembler_name): New.
* Makefile.in (symtab.o): Needs GTY.
* varpool.c (varpool_hash): Remove.
(hash_varpool_node, eq_varpool_node, varpool_get_node): Remove.
(varpool_node): Rewrite using varpool_get_node.
(varpool_remove_node): DO not maintain hashtables.
(varpool_node_for_asm); Rewrite.
From-SVN: r186525
Diffstat (limited to 'gcc/varpool.c')
-rw-r--r-- | gcc/varpool.c | 68 |
1 files changed, 6 insertions, 62 deletions
diff --git a/gcc/varpool.c b/gcc/varpool.c index 8fd9e8a..e41a780 100644 --- a/gcc/varpool.c +++ b/gcc/varpool.c @@ -48,9 +48,6 @@ along with GCC; see the file COPYING3. If not see All variables supposed to be output into final file needs to be explicitly marked by frontend via VARPOOL_FINALIZE_DECL function. */ -/* Hash table used to convert declarations into nodes. */ -static GTY((param_is (union symtab_node_def))) htab_t varpool_hash; - /* Queue of cgraph nodes scheduled to be lowered and output. The queue is maintained via mark_needed_node, linked via node->next_needed pointer. @@ -84,66 +81,20 @@ varpool_node_name (struct varpool_node *node) return lang_hooks.decl_printable_name (node->symbol.decl, 2); } -/* Returns a hash code for P. */ -static hashval_t -hash_varpool_node (const void *p) -{ - const struct varpool_node *n = (const struct varpool_node *) p; - return (hashval_t) DECL_UID (n->symbol.decl); -} - -/* Returns nonzero if P1 and P2 are equal. */ -static int -eq_varpool_node (const void *p1, const void *p2) -{ - const struct varpool_node *n1 = - (const struct varpool_node *) p1; - const struct varpool_node *n2 = - (const struct varpool_node *) p2; - return DECL_UID (n1->symbol.decl) == DECL_UID (n2->symbol.decl); -} - -/* Return varpool node assigned to DECL without creating new one. */ -struct varpool_node * -varpool_get_node (const_tree decl) -{ - struct varpool_node key, **slot; - - gcc_assert (TREE_CODE (decl) == VAR_DECL - && (TREE_STATIC (decl) || DECL_EXTERNAL (decl))); - - if (!varpool_hash) - return NULL; - key.symbol.decl = CONST_CAST2 (tree, const_tree, decl); - slot = (struct varpool_node **) - htab_find_slot (varpool_hash, &key, NO_INSERT); - if (!slot) - return NULL; - return *slot; -} - /* Return varpool node assigned to DECL. Create new one when needed. */ struct varpool_node * varpool_node (tree decl) { - struct varpool_node key, *node, **slot; - + struct varpool_node *node = varpool_get_node (decl); gcc_assert (TREE_CODE (decl) == VAR_DECL && (TREE_STATIC (decl) || DECL_EXTERNAL (decl) || in_lto_p)); + if (node) + return node; - if (!varpool_hash) - varpool_hash = htab_create_ggc (10, hash_varpool_node, - eq_varpool_node, NULL); - key.symbol.decl = decl; - slot = (struct varpool_node **) - htab_find_slot (varpool_hash, &key, INSERT); - if (*slot) - return *slot; node = ggc_alloc_cleared_varpool_node (); node->symbol.type = SYMTAB_VARIABLE; node->symbol.decl = decl; symtab_register_node ((symtab_node)node); - *slot = node; return node; } @@ -151,10 +102,6 @@ varpool_node (tree decl) void varpool_remove_node (struct varpool_node *node) { - void **slot; - slot = htab_find_slot (varpool_hash, node, NO_INSERT); - gcc_assert (*slot == node); - htab_clear_slot (varpool_hash, slot); gcc_assert (!varpool_assembled_nodes_queue); symtab_unregister_node ((symtab_node)node); if (varpool_first_unanalyzed_node == node) @@ -238,12 +185,9 @@ debug_varpool (void) struct varpool_node * varpool_node_for_asm (tree asmname) { - struct varpool_node *node; - - FOR_EACH_VARIABLE (node) - if (decl_assembler_name_equal (node->symbol.decl, asmname)) - return node; - + symtab_node node = symtab_node_for_asm (asmname); + if (node && symtab_variable_p (node)) + return varpool (node); return NULL; } |