diff options
author | hubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-05-24 22:00:14 +0000 |
---|---|---|
committer | hubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-05-24 22:00:14 +0000 |
commit | 8c0163928b8ac73298dc1ef3aca43e8921780832 (patch) | |
tree | 12ca2f5d9d68edce3aad0e13eb2c2fb693d94c86 /gcc/symtab.c | |
parent | 5f70fed563a6de012a39846859192ba2e40ba5c8 (diff) | |
download | gcc-8c0163928b8ac73298dc1ef3aca43e8921780832.tar.gz |
* tree-core.h (tree_decl_with_vis): Replace comdat_group by
symtab_node pointer.
* tree.c (copy_node_stat): Be sure tonot copy
symtab_node pointer.
(find_decls_types_r): Do not walk COMDAT_GROUP.
* tree.h (DECL_COMDAT_GROUP): Revamp to use decl_comdat_group.
* varasm.c (make_decl_one_only): Use set_comdat_group;
create node if needed.
* ipa-inline-transform.c (save_inline_function_body): Update
way we decl->symtab mapping.
* symtab.c (symtab_hash, hash_node, eq_node
symtab_insert_node_to_hashtable): Remove.
(symtab_register_node): Update.
(symtab_unregister_node): Update.
(symtab_get_node): Reimplement as inline function.
(symtab_add_to_same_comdat_group): Update.
(symtab_dissolve_same_comdat_group_list): Update.
(dump_symtab_base): Update.
(verify_symtab_base): Update.
(symtab_make_decl_local): Update.
(fixup_same_cpp_alias_visibility): Update.
(symtab_nonoverwritable_alias): Update.
* cgraphclones.c (set_new_clone_decl_and_node_flags): Update.
* ipa.c (update_visibility_by_resolution_info): UPdate.
* bb-reorder.c: Include cgraph.h
* lto-streamer-out.c (DFS_write_tree_body, hash_tree): Do not deal
with comdat groups.
* ipa-comdats.c (set_comdat_group, ipa_comdats): Update.
* cgraph.c (cgraph_get_create_node): Update.
* cgraph.h (struct symtab_node): Add get_comdat_group, set_comdat_group
and comdat_group_.
(symtab_get_node): Make inline.
(symtab_insert_node_to_hashtable): Remove.
(symtab_can_be_discarded): Update.
(decl_comdat_group): New function.
* tree-streamer-in.c (lto_input_ts_decl_with_vis_tree_pointers): Update.
* lto-cgraph.c (lto_output_node, lto_output_varpool_node): Stream out
comdat group name.
(read_comdat_group): New function.
(input_node, input_varpool_node): Use it.
* trans-mem.c (ipa_tm_create_version_alias): Update code creating
comdat groups.
* mips.c (mips_start_unique_function): Likewise.
(ix86_code_end): Likewise.
(rs6000_code_end): Likweise.
* tree-streamer-out.c (DECL_COMDAT_GROUP): Do not stream
comdat group.
* lto-symtab.c (lto_symtab_merge_symbols): Update code setting
symtab pointer.
* lto.c (compare_tree_sccs_1): Do not compare comdat groups.
* optmize.c (maybe_thunk_body): Use set_comdat_group.
(maybe_clone_body): Likewise.
* decl.c (duplicate_decls): Update code duplicating comdat group;
do not copy symtab pointer; before freeing newdecl remove it
from symtab.
* decl2.c (constrain_visibility): Use set_comdat_group.
* c-decl.c (merge_decls): Preserve symtab node pointers.
(duplicate_decls): Free new decl.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@210901 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/symtab.c')
-rw-r--r-- | gcc/symtab.c | 132 |
1 files changed, 24 insertions, 108 deletions
diff --git a/gcc/symtab.c b/gcc/symtab.c index 9d7c7e64b49..301f7e3bef8 100644 --- a/gcc/symtab.c +++ b/gcc/symtab.c @@ -57,8 +57,6 @@ const char * const ld_plugin_symbol_resolution_names[]= "prevailing_def_ironly_exp" }; -/* Hash table used to convert declarations into nodes. */ -static GTY((param_is (symtab_node))) htab_t symtab_hash; /* Hash table used to convert assembler names into nodes. */ static GTY((param_is (symtab_node))) htab_t assembler_name_hash; @@ -70,26 +68,6 @@ symtab_node *symtab_nodes; them, to support -fno-toplevel-reorder. */ int symtab_order; -/* Returns a hash code for P. */ - -static hashval_t -hash_node (const void *p) -{ - const symtab_node *n = (const symtab_node *) p; - return (hashval_t) DECL_UID (n->decl); -} - - -/* Returns nonzero if P1 and P2 are equal. */ - -static int -eq_node (const void *p1, const void *p2) -{ - const symtab_node *n1 = (const symtab_node *) p1; - const symtab_node *n2 = (const symtab_node *) p2; - return DECL_UID (n1->decl) == DECL_UID (n2->decl); -} - /* Hash asmnames ignoring the user specified marks. */ static hashval_t @@ -282,21 +260,14 @@ symtab_prevail_in_asm_name_hash (symtab_node *node) void symtab_register_node (symtab_node *node) { - struct symtab_node key; - symtab_node **slot; - node->next = symtab_nodes; node->previous = NULL; if (symtab_nodes) symtab_nodes->previous = node; symtab_nodes = node; - if (!symtab_hash) - symtab_hash = htab_create_ggc (10, hash_node, eq_node, NULL); - key.decl = node->decl; - slot = (symtab_node **) htab_find_slot (symtab_hash, &key, INSERT); - if (*slot == NULL) - *slot = node; + if (!node->decl->decl_with_vis.symtab_node) + node->decl->decl_with_vis.symtab_node = node; ipa_empty_ref_list (&node->ref_list); @@ -307,22 +278,6 @@ symtab_register_node (symtab_node *node) insert_to_assembler_name_hash (node, false); } -/* Make NODE to be the one symtab hash is pointing to. Used when reshaping tree - of inline clones. */ - -void -symtab_insert_node_to_hashtable (symtab_node *node) -{ - struct symtab_node key; - symtab_node **slot; - - if (!symtab_hash) - symtab_hash = htab_create_ggc (10, hash_node, eq_node, NULL); - key.decl = node->decl; - slot = (symtab_node **) htab_find_slot (symtab_hash, &key, INSERT); - *slot = node; -} - /* Remove NODE from same comdat group. */ void @@ -349,7 +304,6 @@ symtab_remove_from_same_comdat_group (symtab_node *node) void symtab_unregister_node (symtab_node *node) { - void **slot; ipa_remove_all_references (&node->ref_list); ipa_remove_all_referring (&node->ref_list); @@ -364,55 +318,20 @@ symtab_unregister_node (symtab_node *node) node->next = NULL; node->previous = NULL; - slot = htab_find_slot (symtab_hash, node, NO_INSERT); - /* During LTO symtab merging we temporarily corrupt decl to symtab node hash. */ - gcc_assert ((slot && *slot) || in_lto_p); - if (slot && *slot && *slot == node) + gcc_assert (node->decl->decl_with_vis.symtab_node || in_lto_p); + if (node->decl->decl_with_vis.symtab_node == node) { symtab_node *replacement_node = NULL; if (cgraph_node *cnode = dyn_cast <cgraph_node *> (node)) replacement_node = cgraph_find_replacement_node (cnode); - if (!replacement_node) - htab_clear_slot (symtab_hash, slot); - else - *slot = replacement_node; + node->decl->decl_with_vis.symtab_node = replacement_node; } if (!is_a <varpool_node *> (node) || !DECL_HARD_REGISTER (node->decl)) unlink_from_assembler_name_hash (node, false); } -/* Return symbol table node associated with DECL, if any, - and NULL otherwise. */ - -symtab_node * -symtab_get_node (const_tree decl) -{ - symtab_node **slot; - struct symtab_node key; - -#ifdef ENABLE_CHECKING - /* Check that we are called for sane type of object - functions - and static or external variables. */ - gcc_checking_assert (TREE_CODE (decl) == FUNCTION_DECL - || (TREE_CODE (decl) == VAR_DECL - && (TREE_STATIC (decl) || DECL_EXTERNAL (decl) - || in_lto_p))); -#endif - - if (!symtab_hash) - return NULL; - - key.decl = CONST_CAST2 (tree, const_tree, decl); - - slot = (symtab_node **) htab_find_slot (symtab_hash, &key, - NO_INSERT); - - if (slot) - return *slot; - return NULL; -} /* Remove symtab NODE from the symbol table. */ @@ -513,11 +432,11 @@ void symtab_add_to_same_comdat_group (symtab_node *new_node, symtab_node *old_node) { - gcc_assert (DECL_COMDAT_GROUP (old_node->decl)); + gcc_assert (old_node->get_comdat_group ()); gcc_assert (!new_node->same_comdat_group); gcc_assert (new_node != old_node); - DECL_COMDAT_GROUP (new_node->decl) = DECL_COMDAT_GROUP (old_node->decl); + new_node->set_comdat_group (old_node->get_comdat_group ()); new_node->same_comdat_group = old_node; if (!old_node->same_comdat_group) old_node->same_comdat_group = new_node; @@ -546,10 +465,10 @@ symtab_dissolve_same_comdat_group_list (symtab_node *node) { next = n->same_comdat_group; n->same_comdat_group = NULL; - /* Clear DECL_COMDAT_GROUP for comdat locals, since + /* Clear comdat_group for comdat locals, since make_decl_local doesn't. */ if (!TREE_PUBLIC (n->decl)) - DECL_COMDAT_GROUP (n->decl) = NULL_TREE; + n->set_comdat_group (NULL); n = next; } while (n != node); @@ -639,9 +558,9 @@ dump_symtab_base (FILE *f, symtab_node *node) fprintf (f, " dll_import"); if (DECL_COMDAT (node->decl)) fprintf (f, " comdat"); - if (DECL_COMDAT_GROUP (node->decl)) + if (node->get_comdat_group ()) fprintf (f, " comdat_group:%s", - IDENTIFIER_POINTER (DECL_COMDAT_GROUP (node->decl))); + IDENTIFIER_POINTER (node->get_comdat_group ())); if (DECL_ONE_ONLY (node->decl)) fprintf (f, " one_only"); if (DECL_SECTION_NAME (node->decl)) @@ -766,7 +685,7 @@ verify_symtab_base (symtab_node *node) hashed_node = symtab_get_node (node->decl); if (!hashed_node) { - error ("node not found in symtab decl hashtable"); + error ("node not found node->decl->decl_with_vis.symtab_node"); error_found = true; } if (hashed_node != node @@ -775,7 +694,7 @@ verify_symtab_base (symtab_node *node) || dyn_cast <cgraph_node *> (node)->clone_of->decl != node->decl)) { - error ("node differs from symtab decl hashtable"); + error ("node differs from node->decl->decl_with_vis.symtab_node"); error_found = true; } } @@ -832,12 +751,12 @@ verify_symtab_base (symtab_node *node) { symtab_node *n = node->same_comdat_group; - if (!DECL_COMDAT_GROUP (n->decl)) + if (!n->get_comdat_group ()) { - error ("node is in same_comdat_group list but has no DECL_COMDAT_GROUP"); + error ("node is in same_comdat_group list but has no comdat_group"); error_found = true; } - if (DECL_COMDAT_GROUP (n->decl) != DECL_COMDAT_GROUP (node->same_comdat_group->decl)) + if (n->get_comdat_group () != node->get_comdat_group ()) { error ("same_comdat_group list across different groups"); error_found = true; @@ -950,7 +869,7 @@ symtab_make_decl_local (tree decl) { rtx rtl, symbol; - /* Avoid clearing DECL_COMDAT_GROUP on comdat-local decls. */ + /* Avoid clearing comdat_groups on comdat-local decls. */ if (TREE_PUBLIC (decl) == 0) return; @@ -958,12 +877,11 @@ symtab_make_decl_local (tree decl) DECL_COMMON (decl) = 0; else gcc_assert (TREE_CODE (decl) == FUNCTION_DECL); - if (DECL_COMDAT_GROUP (decl) || DECL_COMDAT (decl)) + if (DECL_COMDAT (decl)) { DECL_SECTION_NAME (decl) = 0; DECL_COMDAT (decl) = 0; } - DECL_COMDAT_GROUP (decl) = 0; DECL_WEAK (decl) = 0; DECL_EXTERNAL (decl) = 0; DECL_VISIBILITY_SPECIFIED (decl) = 0; @@ -1097,11 +1015,13 @@ fixup_same_cpp_alias_visibility (symtab_node *node, symtab_node *target) DECL_VIRTUAL_P (node->decl) = DECL_VIRTUAL_P (target->decl); if (TREE_PUBLIC (node->decl)) { + tree group; + DECL_EXTERNAL (node->decl) = DECL_EXTERNAL (target->decl); DECL_COMDAT (node->decl) = DECL_COMDAT (target->decl); - DECL_COMDAT_GROUP (node->decl) - = DECL_COMDAT_GROUP (target->decl); - if (DECL_COMDAT_GROUP (target->decl) + group = target->get_comdat_group (); + node->set_comdat_group (group); + if (group && !node->same_comdat_group) symtab_add_to_same_comdat_group (node, target); } @@ -1231,9 +1151,6 @@ symtab_nonoverwritable_alias (symtab_node *node) /* Update the properties. */ DECL_EXTERNAL (new_decl) = 0; - if (DECL_COMDAT_GROUP (node->decl)) - DECL_SECTION_NAME (new_decl) = NULL; - DECL_COMDAT_GROUP (new_decl) = 0; TREE_PUBLIC (new_decl) = 0; DECL_COMDAT (new_decl) = 0; DECL_WEAK (new_decl) = 0; @@ -1246,8 +1163,7 @@ symtab_nonoverwritable_alias (symtab_node *node) (new_decl, node->decl); } else - new_node = varpool_create_variable_alias (new_decl, - node->decl); + new_node = varpool_create_variable_alias (new_decl, node->decl); symtab_resolve_alias (new_node, node); gcc_assert (decl_binds_to_current_def_p (new_decl)); return new_node; |