cgraph.h (symtab_node_base): Add next and previous pointers.
* cgraph.h (symtab_node_base): Add next and previous pointers.
(cgraph_node): Remove next and preivous pointers.
(varpool_node): Likewise; remove next/previous GTY marker;
it is not type safe.
(symtab_node_def): Update GTY marker
(x_cgraph_nodes, cgraph_nodes): Remove.
(symtab_nodes): New function.
(cgraph_order): Rename to ...
(symtab_order): ... this one.
(symtab_register_node, symtab_unregister_node, symtab_remove_node):
Declare.
(x_varpool_nodes, varpool_nodes): Remove.
(FOR_EACH_STATIC_VARIABLE): Update.
(symtab_function_p, symtab_variable_p): New function.
(FOR_EACH_VARIABLE): Update.
(varpool_first_variable, varpool_next_variable): New functions.
(FOR_EACH_VARIABLE): Update.
(cgraph_first_defined_function): Update.
(cgraph_next_defined_function, cgraph_next_defined_function): Update.
(FOR_EACH_DEFINED_FUNCTION, FOR_EACH_FUNCTION): Update.
(cgraph_first_function, cgraph_next_function): New.
(FOR_EACH_FUNCTION): Update.
(cgraph_first_function_with_gimple_body,
cgraph_next_function_with_gimple_body): Update.
* symtab.c: New file.
* cgraph.c: Update copyright dates.
(x_cgraph_nodes, cgraph_order): Remove.
(NEXT_FREE_NODE): Update.
(SET_NEXT_FREE_NODE): New.
(cgraph_create_node_1): Remove common code.
(cgraph_create_node); Remove common code; call symtab_register_node.
(cgraph_remove_node): Remove common code; call symtab_unregister-node.
(cgraph_add_asm_node); update.
(cgraph_clone_node): Register new node.
* cgraphunit.c (process_function_and_variable_attributes): Update.
(cgraph_analyze_functions): Update.
(cgraph_analyze_functions): Update.
(cgraph_output_in_order): Update.
* lto-cgraph.c (input_node, input_varpool_node, input_cgraph_1): Update.
* ipa-inline.c (recursive_inlining); update.
* lto-streamer-in.c (lto_input_toplevel_asms); Update.
* ipa.c (cgraph_remove_unreachable_nodes): Update.
* Makefile.in: Add symtab.o
* varpool.c (x_varpool_nodes): Remove
(varpool_node): Remove common code; call symtab_register_node.
(varpool_remove_node); Remove common code; call symtab_unregister_node.
From-SVN: r186496
2012-04-16 16:34:22 +02:00
|
|
|
/* Symbol table.
|
|
|
|
Copyright (C) 2012 Free Software Foundation, Inc.
|
|
|
|
Contributed by Jan Hubicka
|
|
|
|
|
|
|
|
This file is part of GCC.
|
|
|
|
|
|
|
|
GCC is free software; you can redistribute it and/or modify it under
|
|
|
|
the terms of the GNU General Public License as published by the Free
|
|
|
|
Software Foundation; either version 3, or (at your option) any later
|
|
|
|
version.
|
|
|
|
|
|
|
|
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with GCC; see the file COPYING3. If not see
|
|
|
|
<http://www.gnu.org/licenses/>. */
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "system.h"
|
|
|
|
#include "coretypes.h"
|
|
|
|
#include "tm.h"
|
|
|
|
#include "tree.h"
|
|
|
|
#include "tree-inline.h"
|
|
|
|
#include "hashtab.h"
|
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
2012-04-17 12:53:22 +02:00
|
|
|
#include "ggc.h"
|
cgraph.h (symtab_node_base): Add next and previous pointers.
* cgraph.h (symtab_node_base): Add next and previous pointers.
(cgraph_node): Remove next and preivous pointers.
(varpool_node): Likewise; remove next/previous GTY marker;
it is not type safe.
(symtab_node_def): Update GTY marker
(x_cgraph_nodes, cgraph_nodes): Remove.
(symtab_nodes): New function.
(cgraph_order): Rename to ...
(symtab_order): ... this one.
(symtab_register_node, symtab_unregister_node, symtab_remove_node):
Declare.
(x_varpool_nodes, varpool_nodes): Remove.
(FOR_EACH_STATIC_VARIABLE): Update.
(symtab_function_p, symtab_variable_p): New function.
(FOR_EACH_VARIABLE): Update.
(varpool_first_variable, varpool_next_variable): New functions.
(FOR_EACH_VARIABLE): Update.
(cgraph_first_defined_function): Update.
(cgraph_next_defined_function, cgraph_next_defined_function): Update.
(FOR_EACH_DEFINED_FUNCTION, FOR_EACH_FUNCTION): Update.
(cgraph_first_function, cgraph_next_function): New.
(FOR_EACH_FUNCTION): Update.
(cgraph_first_function_with_gimple_body,
cgraph_next_function_with_gimple_body): Update.
* symtab.c: New file.
* cgraph.c: Update copyright dates.
(x_cgraph_nodes, cgraph_order): Remove.
(NEXT_FREE_NODE): Update.
(SET_NEXT_FREE_NODE): New.
(cgraph_create_node_1): Remove common code.
(cgraph_create_node); Remove common code; call symtab_register_node.
(cgraph_remove_node): Remove common code; call symtab_unregister-node.
(cgraph_add_asm_node); update.
(cgraph_clone_node): Register new node.
* cgraphunit.c (process_function_and_variable_attributes): Update.
(cgraph_analyze_functions): Update.
(cgraph_analyze_functions): Update.
(cgraph_output_in_order): Update.
* lto-cgraph.c (input_node, input_varpool_node, input_cgraph_1): Update.
* ipa-inline.c (recursive_inlining); update.
* lto-streamer-in.c (lto_input_toplevel_asms); Update.
* ipa.c (cgraph_remove_unreachable_nodes): Update.
* Makefile.in: Add symtab.o
* varpool.c (x_varpool_nodes): Remove
(varpool_node): Remove common code; call symtab_register_node.
(varpool_remove_node); Remove common code; call symtab_unregister_node.
From-SVN: r186496
2012-04-16 16:34:22 +02:00
|
|
|
#include "cgraph.h"
|
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
2012-04-17 12:53:22 +02:00
|
|
|
#include "diagnostic.h"
|
|
|
|
|
|
|
|
/* Hash table used to convert declarations into nodes. */
|
|
|
|
static GTY((param_is (union symtab_node_def))) htab_t symtab_hash;
|
|
|
|
/* Hash table used to convert assembler names into nodes. */
|
|
|
|
static GTY((param_is (union symtab_node_def))) htab_t assembler_name_hash;
|
cgraph.h (symtab_node_base): Add next and previous pointers.
* cgraph.h (symtab_node_base): Add next and previous pointers.
(cgraph_node): Remove next and preivous pointers.
(varpool_node): Likewise; remove next/previous GTY marker;
it is not type safe.
(symtab_node_def): Update GTY marker
(x_cgraph_nodes, cgraph_nodes): Remove.
(symtab_nodes): New function.
(cgraph_order): Rename to ...
(symtab_order): ... this one.
(symtab_register_node, symtab_unregister_node, symtab_remove_node):
Declare.
(x_varpool_nodes, varpool_nodes): Remove.
(FOR_EACH_STATIC_VARIABLE): Update.
(symtab_function_p, symtab_variable_p): New function.
(FOR_EACH_VARIABLE): Update.
(varpool_first_variable, varpool_next_variable): New functions.
(FOR_EACH_VARIABLE): Update.
(cgraph_first_defined_function): Update.
(cgraph_next_defined_function, cgraph_next_defined_function): Update.
(FOR_EACH_DEFINED_FUNCTION, FOR_EACH_FUNCTION): Update.
(cgraph_first_function, cgraph_next_function): New.
(FOR_EACH_FUNCTION): Update.
(cgraph_first_function_with_gimple_body,
cgraph_next_function_with_gimple_body): Update.
* symtab.c: New file.
* cgraph.c: Update copyright dates.
(x_cgraph_nodes, cgraph_order): Remove.
(NEXT_FREE_NODE): Update.
(SET_NEXT_FREE_NODE): New.
(cgraph_create_node_1): Remove common code.
(cgraph_create_node); Remove common code; call symtab_register_node.
(cgraph_remove_node): Remove common code; call symtab_unregister-node.
(cgraph_add_asm_node); update.
(cgraph_clone_node): Register new node.
* cgraphunit.c (process_function_and_variable_attributes): Update.
(cgraph_analyze_functions): Update.
(cgraph_analyze_functions): Update.
(cgraph_output_in_order): Update.
* lto-cgraph.c (input_node, input_varpool_node, input_cgraph_1): Update.
* ipa-inline.c (recursive_inlining); update.
* lto-streamer-in.c (lto_input_toplevel_asms); Update.
* ipa.c (cgraph_remove_unreachable_nodes): Update.
* Makefile.in: Add symtab.o
* varpool.c (x_varpool_nodes): Remove
(varpool_node): Remove common code; call symtab_register_node.
(varpool_remove_node); Remove common code; call symtab_unregister_node.
From-SVN: r186496
2012-04-16 16:34:22 +02:00
|
|
|
|
|
|
|
/* Linked list of symbol table nodes. */
|
|
|
|
symtab_node symtab_nodes;
|
|
|
|
|
|
|
|
/* The order index of the next symtab node to be created. This is
|
|
|
|
used so that we can sort the cgraph nodes in order by when we saw
|
|
|
|
them, to support -fno-toplevel-reorder. */
|
|
|
|
int symtab_order;
|
|
|
|
|
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
2012-04-17 12:53:22 +02:00
|
|
|
/* 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->symbol.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->symbol.decl) == DECL_UID (n2->symbol.decl);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Returns a hash code for P. */
|
|
|
|
|
|
|
|
static hashval_t
|
|
|
|
hash_node_by_assembler_name (const void *p)
|
|
|
|
{
|
|
|
|
const_symtab_node n = (const_symtab_node) p;
|
|
|
|
return (hashval_t) decl_assembler_name_hash (DECL_ASSEMBLER_NAME (n->symbol.decl));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Returns nonzero if P1 and P2 are equal. */
|
|
|
|
|
|
|
|
static int
|
|
|
|
eq_assembler_name (const void *p1, const void *p2)
|
|
|
|
{
|
|
|
|
const_symtab_node n1 = (const_symtab_node) p1;
|
|
|
|
const_tree name = (const_tree)p2;
|
|
|
|
return (decl_assembler_name_equal (n1->symbol.decl, name));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Insert NODE to assembler name hash. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
insert_to_assembler_name_hash (symtab_node node)
|
|
|
|
{
|
|
|
|
gcc_checking_assert (!node->symbol.previous_sharing_asm_name
|
|
|
|
&& !node->symbol.next_sharing_asm_name);
|
|
|
|
if (assembler_name_hash)
|
|
|
|
{
|
|
|
|
void **aslot;
|
|
|
|
tree name = DECL_ASSEMBLER_NAME (node->symbol.decl);
|
|
|
|
|
|
|
|
aslot = htab_find_slot_with_hash (assembler_name_hash, name,
|
|
|
|
decl_assembler_name_hash (name),
|
|
|
|
INSERT);
|
|
|
|
gcc_assert (*aslot != node);
|
|
|
|
node->symbol.next_sharing_asm_name = (symtab_node)*aslot;
|
|
|
|
if (*aslot != NULL)
|
|
|
|
((symtab_node)*aslot)->symbol.previous_sharing_asm_name = node;
|
|
|
|
*aslot = node;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Remove NODE from assembler name hash. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
unlink_from_assembler_name_hash (symtab_node node)
|
|
|
|
{
|
|
|
|
if (assembler_name_hash)
|
|
|
|
{
|
|
|
|
if (node->symbol.next_sharing_asm_name)
|
|
|
|
node->symbol.next_sharing_asm_name->symbol.previous_sharing_asm_name
|
|
|
|
= node->symbol.previous_sharing_asm_name;
|
|
|
|
if (node->symbol.previous_sharing_asm_name)
|
|
|
|
{
|
|
|
|
node->symbol.previous_sharing_asm_name->symbol.next_sharing_asm_name
|
|
|
|
= node->symbol.next_sharing_asm_name;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
tree name = DECL_ASSEMBLER_NAME (node->symbol.decl);
|
|
|
|
void **slot;
|
|
|
|
slot = htab_find_slot_with_hash (assembler_name_hash, name,
|
|
|
|
decl_assembler_name_hash (name),
|
|
|
|
NO_INSERT);
|
|
|
|
gcc_assert (*slot == node);
|
|
|
|
if (!node->symbol.next_sharing_asm_name)
|
|
|
|
htab_clear_slot (assembler_name_hash, slot);
|
|
|
|
else
|
|
|
|
*slot = node->symbol.next_sharing_asm_name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
cgraph.h (symtab_node_base): Add next and previous pointers.
* cgraph.h (symtab_node_base): Add next and previous pointers.
(cgraph_node): Remove next and preivous pointers.
(varpool_node): Likewise; remove next/previous GTY marker;
it is not type safe.
(symtab_node_def): Update GTY marker
(x_cgraph_nodes, cgraph_nodes): Remove.
(symtab_nodes): New function.
(cgraph_order): Rename to ...
(symtab_order): ... this one.
(symtab_register_node, symtab_unregister_node, symtab_remove_node):
Declare.
(x_varpool_nodes, varpool_nodes): Remove.
(FOR_EACH_STATIC_VARIABLE): Update.
(symtab_function_p, symtab_variable_p): New function.
(FOR_EACH_VARIABLE): Update.
(varpool_first_variable, varpool_next_variable): New functions.
(FOR_EACH_VARIABLE): Update.
(cgraph_first_defined_function): Update.
(cgraph_next_defined_function, cgraph_next_defined_function): Update.
(FOR_EACH_DEFINED_FUNCTION, FOR_EACH_FUNCTION): Update.
(cgraph_first_function, cgraph_next_function): New.
(FOR_EACH_FUNCTION): Update.
(cgraph_first_function_with_gimple_body,
cgraph_next_function_with_gimple_body): Update.
* symtab.c: New file.
* cgraph.c: Update copyright dates.
(x_cgraph_nodes, cgraph_order): Remove.
(NEXT_FREE_NODE): Update.
(SET_NEXT_FREE_NODE): New.
(cgraph_create_node_1): Remove common code.
(cgraph_create_node); Remove common code; call symtab_register_node.
(cgraph_remove_node): Remove common code; call symtab_unregister-node.
(cgraph_add_asm_node); update.
(cgraph_clone_node): Register new node.
* cgraphunit.c (process_function_and_variable_attributes): Update.
(cgraph_analyze_functions): Update.
(cgraph_analyze_functions): Update.
(cgraph_output_in_order): Update.
* lto-cgraph.c (input_node, input_varpool_node, input_cgraph_1): Update.
* ipa-inline.c (recursive_inlining); update.
* lto-streamer-in.c (lto_input_toplevel_asms); Update.
* ipa.c (cgraph_remove_unreachable_nodes): Update.
* Makefile.in: Add symtab.o
* varpool.c (x_varpool_nodes): Remove
(varpool_node): Remove common code; call symtab_register_node.
(varpool_remove_node); Remove common code; call symtab_unregister_node.
From-SVN: r186496
2012-04-16 16:34:22 +02:00
|
|
|
/* Add node into symbol table. This function is not used directly, but via
|
|
|
|
cgraph/varpool node creation routines. */
|
|
|
|
|
|
|
|
void
|
|
|
|
symtab_register_node (symtab_node node)
|
|
|
|
{
|
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
2012-04-17 12:53:22 +02:00
|
|
|
struct symtab_node_base key;
|
|
|
|
symtab_node *slot;
|
|
|
|
|
cgraph.h (symtab_node_base): Add next and previous pointers.
* cgraph.h (symtab_node_base): Add next and previous pointers.
(cgraph_node): Remove next and preivous pointers.
(varpool_node): Likewise; remove next/previous GTY marker;
it is not type safe.
(symtab_node_def): Update GTY marker
(x_cgraph_nodes, cgraph_nodes): Remove.
(symtab_nodes): New function.
(cgraph_order): Rename to ...
(symtab_order): ... this one.
(symtab_register_node, symtab_unregister_node, symtab_remove_node):
Declare.
(x_varpool_nodes, varpool_nodes): Remove.
(FOR_EACH_STATIC_VARIABLE): Update.
(symtab_function_p, symtab_variable_p): New function.
(FOR_EACH_VARIABLE): Update.
(varpool_first_variable, varpool_next_variable): New functions.
(FOR_EACH_VARIABLE): Update.
(cgraph_first_defined_function): Update.
(cgraph_next_defined_function, cgraph_next_defined_function): Update.
(FOR_EACH_DEFINED_FUNCTION, FOR_EACH_FUNCTION): Update.
(cgraph_first_function, cgraph_next_function): New.
(FOR_EACH_FUNCTION): Update.
(cgraph_first_function_with_gimple_body,
cgraph_next_function_with_gimple_body): Update.
* symtab.c: New file.
* cgraph.c: Update copyright dates.
(x_cgraph_nodes, cgraph_order): Remove.
(NEXT_FREE_NODE): Update.
(SET_NEXT_FREE_NODE): New.
(cgraph_create_node_1): Remove common code.
(cgraph_create_node); Remove common code; call symtab_register_node.
(cgraph_remove_node): Remove common code; call symtab_unregister-node.
(cgraph_add_asm_node); update.
(cgraph_clone_node): Register new node.
* cgraphunit.c (process_function_and_variable_attributes): Update.
(cgraph_analyze_functions): Update.
(cgraph_analyze_functions): Update.
(cgraph_output_in_order): Update.
* lto-cgraph.c (input_node, input_varpool_node, input_cgraph_1): Update.
* ipa-inline.c (recursive_inlining); update.
* lto-streamer-in.c (lto_input_toplevel_asms); Update.
* ipa.c (cgraph_remove_unreachable_nodes): Update.
* Makefile.in: Add symtab.o
* varpool.c (x_varpool_nodes): Remove
(varpool_node): Remove common code; call symtab_register_node.
(varpool_remove_node); Remove common code; call symtab_unregister_node.
From-SVN: r186496
2012-04-16 16:34:22 +02:00
|
|
|
node->symbol.next = symtab_nodes;
|
|
|
|
node->symbol.previous = NULL;
|
|
|
|
if (symtab_nodes)
|
|
|
|
symtab_nodes->symbol.previous = node;
|
|
|
|
symtab_nodes = node;
|
|
|
|
|
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
2012-04-17 12:53:22 +02:00
|
|
|
if (!symtab_hash)
|
|
|
|
symtab_hash = htab_create_ggc (10, hash_node, eq_node, NULL);
|
|
|
|
key.decl = node->symbol.decl;
|
|
|
|
slot = (symtab_node *) htab_find_slot (symtab_hash, &key, INSERT);
|
|
|
|
if (*slot == NULL)
|
|
|
|
*slot = node;
|
|
|
|
|
|
|
|
insert_to_assembler_name_hash (node);
|
|
|
|
|
cgraph.h (symtab_node_base): Add next and previous pointers.
* cgraph.h (symtab_node_base): Add next and previous pointers.
(cgraph_node): Remove next and preivous pointers.
(varpool_node): Likewise; remove next/previous GTY marker;
it is not type safe.
(symtab_node_def): Update GTY marker
(x_cgraph_nodes, cgraph_nodes): Remove.
(symtab_nodes): New function.
(cgraph_order): Rename to ...
(symtab_order): ... this one.
(symtab_register_node, symtab_unregister_node, symtab_remove_node):
Declare.
(x_varpool_nodes, varpool_nodes): Remove.
(FOR_EACH_STATIC_VARIABLE): Update.
(symtab_function_p, symtab_variable_p): New function.
(FOR_EACH_VARIABLE): Update.
(varpool_first_variable, varpool_next_variable): New functions.
(FOR_EACH_VARIABLE): Update.
(cgraph_first_defined_function): Update.
(cgraph_next_defined_function, cgraph_next_defined_function): Update.
(FOR_EACH_DEFINED_FUNCTION, FOR_EACH_FUNCTION): Update.
(cgraph_first_function, cgraph_next_function): New.
(FOR_EACH_FUNCTION): Update.
(cgraph_first_function_with_gimple_body,
cgraph_next_function_with_gimple_body): Update.
* symtab.c: New file.
* cgraph.c: Update copyright dates.
(x_cgraph_nodes, cgraph_order): Remove.
(NEXT_FREE_NODE): Update.
(SET_NEXT_FREE_NODE): New.
(cgraph_create_node_1): Remove common code.
(cgraph_create_node); Remove common code; call symtab_register_node.
(cgraph_remove_node): Remove common code; call symtab_unregister-node.
(cgraph_add_asm_node); update.
(cgraph_clone_node): Register new node.
* cgraphunit.c (process_function_and_variable_attributes): Update.
(cgraph_analyze_functions): Update.
(cgraph_analyze_functions): Update.
(cgraph_output_in_order): Update.
* lto-cgraph.c (input_node, input_varpool_node, input_cgraph_1): Update.
* ipa-inline.c (recursive_inlining); update.
* lto-streamer-in.c (lto_input_toplevel_asms); Update.
* ipa.c (cgraph_remove_unreachable_nodes): Update.
* Makefile.in: Add symtab.o
* varpool.c (x_varpool_nodes): Remove
(varpool_node): Remove common code; call symtab_register_node.
(varpool_remove_node); Remove common code; call symtab_unregister_node.
From-SVN: r186496
2012-04-16 16:34:22 +02:00
|
|
|
node->symbol.order = symtab_order++;
|
|
|
|
|
|
|
|
ipa_empty_ref_list (&node->symbol.ref_list);
|
|
|
|
}
|
|
|
|
|
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
2012-04-17 12:53:22 +02:00
|
|
|
/* 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_base key;
|
|
|
|
symtab_node *slot;
|
|
|
|
|
|
|
|
if (!symtab_hash)
|
|
|
|
symtab_hash = htab_create_ggc (10, hash_node, eq_node, NULL);
|
|
|
|
key.decl = node->symbol.decl;
|
|
|
|
slot = (symtab_node *) htab_find_slot (symtab_hash, &key, INSERT);
|
|
|
|
*slot = node;
|
|
|
|
}
|
|
|
|
|
cgraph.h (symtab_node_base): Add next and previous pointers.
* cgraph.h (symtab_node_base): Add next and previous pointers.
(cgraph_node): Remove next and preivous pointers.
(varpool_node): Likewise; remove next/previous GTY marker;
it is not type safe.
(symtab_node_def): Update GTY marker
(x_cgraph_nodes, cgraph_nodes): Remove.
(symtab_nodes): New function.
(cgraph_order): Rename to ...
(symtab_order): ... this one.
(symtab_register_node, symtab_unregister_node, symtab_remove_node):
Declare.
(x_varpool_nodes, varpool_nodes): Remove.
(FOR_EACH_STATIC_VARIABLE): Update.
(symtab_function_p, symtab_variable_p): New function.
(FOR_EACH_VARIABLE): Update.
(varpool_first_variable, varpool_next_variable): New functions.
(FOR_EACH_VARIABLE): Update.
(cgraph_first_defined_function): Update.
(cgraph_next_defined_function, cgraph_next_defined_function): Update.
(FOR_EACH_DEFINED_FUNCTION, FOR_EACH_FUNCTION): Update.
(cgraph_first_function, cgraph_next_function): New.
(FOR_EACH_FUNCTION): Update.
(cgraph_first_function_with_gimple_body,
cgraph_next_function_with_gimple_body): Update.
* symtab.c: New file.
* cgraph.c: Update copyright dates.
(x_cgraph_nodes, cgraph_order): Remove.
(NEXT_FREE_NODE): Update.
(SET_NEXT_FREE_NODE): New.
(cgraph_create_node_1): Remove common code.
(cgraph_create_node); Remove common code; call symtab_register_node.
(cgraph_remove_node): Remove common code; call symtab_unregister-node.
(cgraph_add_asm_node); update.
(cgraph_clone_node): Register new node.
* cgraphunit.c (process_function_and_variable_attributes): Update.
(cgraph_analyze_functions): Update.
(cgraph_analyze_functions): Update.
(cgraph_output_in_order): Update.
* lto-cgraph.c (input_node, input_varpool_node, input_cgraph_1): Update.
* ipa-inline.c (recursive_inlining); update.
* lto-streamer-in.c (lto_input_toplevel_asms); Update.
* ipa.c (cgraph_remove_unreachable_nodes): Update.
* Makefile.in: Add symtab.o
* varpool.c (x_varpool_nodes): Remove
(varpool_node): Remove common code; call symtab_register_node.
(varpool_remove_node); Remove common code; call symtab_unregister_node.
From-SVN: r186496
2012-04-16 16:34:22 +02:00
|
|
|
/* Remove node from symbol table. This function is not used directly, but via
|
|
|
|
cgraph/varpool node removal routines. */
|
|
|
|
|
|
|
|
void
|
|
|
|
symtab_unregister_node (symtab_node node)
|
|
|
|
{
|
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
2012-04-17 12:53:22 +02:00
|
|
|
void **slot;
|
cgraph.h (symtab_node_base): Add next and previous pointers.
* cgraph.h (symtab_node_base): Add next and previous pointers.
(cgraph_node): Remove next and preivous pointers.
(varpool_node): Likewise; remove next/previous GTY marker;
it is not type safe.
(symtab_node_def): Update GTY marker
(x_cgraph_nodes, cgraph_nodes): Remove.
(symtab_nodes): New function.
(cgraph_order): Rename to ...
(symtab_order): ... this one.
(symtab_register_node, symtab_unregister_node, symtab_remove_node):
Declare.
(x_varpool_nodes, varpool_nodes): Remove.
(FOR_EACH_STATIC_VARIABLE): Update.
(symtab_function_p, symtab_variable_p): New function.
(FOR_EACH_VARIABLE): Update.
(varpool_first_variable, varpool_next_variable): New functions.
(FOR_EACH_VARIABLE): Update.
(cgraph_first_defined_function): Update.
(cgraph_next_defined_function, cgraph_next_defined_function): Update.
(FOR_EACH_DEFINED_FUNCTION, FOR_EACH_FUNCTION): Update.
(cgraph_first_function, cgraph_next_function): New.
(FOR_EACH_FUNCTION): Update.
(cgraph_first_function_with_gimple_body,
cgraph_next_function_with_gimple_body): Update.
* symtab.c: New file.
* cgraph.c: Update copyright dates.
(x_cgraph_nodes, cgraph_order): Remove.
(NEXT_FREE_NODE): Update.
(SET_NEXT_FREE_NODE): New.
(cgraph_create_node_1): Remove common code.
(cgraph_create_node); Remove common code; call symtab_register_node.
(cgraph_remove_node): Remove common code; call symtab_unregister-node.
(cgraph_add_asm_node); update.
(cgraph_clone_node): Register new node.
* cgraphunit.c (process_function_and_variable_attributes): Update.
(cgraph_analyze_functions): Update.
(cgraph_analyze_functions): Update.
(cgraph_output_in_order): Update.
* lto-cgraph.c (input_node, input_varpool_node, input_cgraph_1): Update.
* ipa-inline.c (recursive_inlining); update.
* lto-streamer-in.c (lto_input_toplevel_asms); Update.
* ipa.c (cgraph_remove_unreachable_nodes): Update.
* Makefile.in: Add symtab.o
* varpool.c (x_varpool_nodes): Remove
(varpool_node): Remove common code; call symtab_register_node.
(varpool_remove_node); Remove common code; call symtab_unregister_node.
From-SVN: r186496
2012-04-16 16:34:22 +02:00
|
|
|
ipa_remove_all_references (&node->symbol.ref_list);
|
|
|
|
ipa_remove_all_refering (&node->symbol.ref_list);
|
|
|
|
|
|
|
|
if (node->symbol.same_comdat_group)
|
|
|
|
{
|
|
|
|
symtab_node prev;
|
|
|
|
for (prev = node->symbol.same_comdat_group;
|
|
|
|
prev->symbol.same_comdat_group != node;
|
|
|
|
prev = prev->symbol.same_comdat_group)
|
|
|
|
;
|
|
|
|
if (node->symbol.same_comdat_group == prev)
|
|
|
|
prev->symbol.same_comdat_group = NULL;
|
|
|
|
else
|
|
|
|
prev->symbol.same_comdat_group = node->symbol.same_comdat_group;
|
|
|
|
node->symbol.same_comdat_group = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (node->symbol.previous)
|
|
|
|
node->symbol.previous->symbol.next = node->symbol.next;
|
|
|
|
else
|
|
|
|
symtab_nodes = node->symbol.next;
|
|
|
|
if (node->symbol.next)
|
|
|
|
node->symbol.next->symbol.previous = node->symbol.previous;
|
|
|
|
node->symbol.next = NULL;
|
|
|
|
node->symbol.previous = NULL;
|
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
2012-04-17 12:53:22 +02:00
|
|
|
|
|
|
|
slot = htab_find_slot (symtab_hash, node, NO_INSERT);
|
|
|
|
if (*slot == node)
|
|
|
|
{
|
|
|
|
symtab_node replacement_node = NULL;
|
|
|
|
if (symtab_function_p (node))
|
|
|
|
replacement_node = (symtab_node)cgraph_find_replacement_node (cgraph (node));
|
|
|
|
if (!replacement_node)
|
|
|
|
htab_clear_slot (symtab_hash, slot);
|
|
|
|
else
|
|
|
|
*slot = replacement_node;
|
|
|
|
}
|
|
|
|
unlink_from_assembler_name_hash (node);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 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_base key;
|
|
|
|
|
|
|
|
gcc_checking_assert (TREE_CODE (decl) == FUNCTION_DECL
|
|
|
|
|| (TREE_CODE (decl) == VAR_DECL
|
|
|
|
&& (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
|
|
|
|
|| in_lto_p)));
|
|
|
|
|
|
|
|
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;
|
cgraph.h (symtab_node_base): Add next and previous pointers.
* cgraph.h (symtab_node_base): Add next and previous pointers.
(cgraph_node): Remove next and preivous pointers.
(varpool_node): Likewise; remove next/previous GTY marker;
it is not type safe.
(symtab_node_def): Update GTY marker
(x_cgraph_nodes, cgraph_nodes): Remove.
(symtab_nodes): New function.
(cgraph_order): Rename to ...
(symtab_order): ... this one.
(symtab_register_node, symtab_unregister_node, symtab_remove_node):
Declare.
(x_varpool_nodes, varpool_nodes): Remove.
(FOR_EACH_STATIC_VARIABLE): Update.
(symtab_function_p, symtab_variable_p): New function.
(FOR_EACH_VARIABLE): Update.
(varpool_first_variable, varpool_next_variable): New functions.
(FOR_EACH_VARIABLE): Update.
(cgraph_first_defined_function): Update.
(cgraph_next_defined_function, cgraph_next_defined_function): Update.
(FOR_EACH_DEFINED_FUNCTION, FOR_EACH_FUNCTION): Update.
(cgraph_first_function, cgraph_next_function): New.
(FOR_EACH_FUNCTION): Update.
(cgraph_first_function_with_gimple_body,
cgraph_next_function_with_gimple_body): Update.
* symtab.c: New file.
* cgraph.c: Update copyright dates.
(x_cgraph_nodes, cgraph_order): Remove.
(NEXT_FREE_NODE): Update.
(SET_NEXT_FREE_NODE): New.
(cgraph_create_node_1): Remove common code.
(cgraph_create_node); Remove common code; call symtab_register_node.
(cgraph_remove_node): Remove common code; call symtab_unregister-node.
(cgraph_add_asm_node); update.
(cgraph_clone_node): Register new node.
* cgraphunit.c (process_function_and_variable_attributes): Update.
(cgraph_analyze_functions): Update.
(cgraph_analyze_functions): Update.
(cgraph_output_in_order): Update.
* lto-cgraph.c (input_node, input_varpool_node, input_cgraph_1): Update.
* ipa-inline.c (recursive_inlining); update.
* lto-streamer-in.c (lto_input_toplevel_asms); Update.
* ipa.c (cgraph_remove_unreachable_nodes): Update.
* Makefile.in: Add symtab.o
* varpool.c (x_varpool_nodes): Remove
(varpool_node): Remove common code; call symtab_register_node.
(varpool_remove_node); Remove common code; call symtab_unregister_node.
From-SVN: r186496
2012-04-16 16:34:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Remove symtab NODE from the symbol table. */
|
|
|
|
|
|
|
|
void
|
|
|
|
symtab_remove_node (symtab_node node)
|
|
|
|
{
|
|
|
|
if (symtab_function_p (node))
|
|
|
|
cgraph_remove_node (cgraph (node));
|
|
|
|
else if (symtab_variable_p (node))
|
|
|
|
varpool_remove_node (varpool (node));
|
|
|
|
}
|
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
2012-04-17 12:53:22 +02:00
|
|
|
|
|
|
|
/* Return the cgraph node that has ASMNAME for its DECL_ASSEMBLER_NAME.
|
|
|
|
Return NULL if there's no such node. */
|
|
|
|
|
|
|
|
symtab_node
|
|
|
|
symtab_node_for_asm (const_tree asmname)
|
|
|
|
{
|
|
|
|
symtab_node node;
|
|
|
|
void **slot;
|
|
|
|
|
|
|
|
if (!assembler_name_hash)
|
|
|
|
{
|
|
|
|
assembler_name_hash =
|
|
|
|
htab_create_ggc (10, hash_node_by_assembler_name, eq_assembler_name,
|
|
|
|
NULL);
|
|
|
|
FOR_EACH_SYMBOL (node)
|
|
|
|
insert_to_assembler_name_hash (node);
|
|
|
|
}
|
|
|
|
|
|
|
|
slot = htab_find_slot_with_hash (assembler_name_hash, asmname,
|
|
|
|
decl_assembler_name_hash (asmname),
|
|
|
|
NO_INSERT);
|
|
|
|
|
|
|
|
if (slot)
|
|
|
|
{
|
|
|
|
node = (symtab_node) *slot;
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set the DECL_ASSEMBLER_NAME and update symtab hashtables. */
|
|
|
|
|
|
|
|
void
|
|
|
|
change_decl_assembler_name (tree decl, tree name)
|
|
|
|
{
|
|
|
|
symtab_node node = NULL;
|
|
|
|
|
|
|
|
/* We can have user ASM names on things, like global register variables, that
|
|
|
|
are not in the symbol table. */
|
|
|
|
if ((TREE_CODE (decl) == VAR_DECL
|
|
|
|
&& (TREE_STATIC (decl) || DECL_EXTERNAL (decl)))
|
|
|
|
|| TREE_CODE (decl) == FUNCTION_DECL)
|
|
|
|
node = symtab_get_node (decl);
|
|
|
|
if (!DECL_ASSEMBLER_NAME_SET_P (decl))
|
|
|
|
{
|
|
|
|
SET_DECL_ASSEMBLER_NAME (decl, name);
|
|
|
|
if (node)
|
|
|
|
insert_to_assembler_name_hash (node);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (name == DECL_ASSEMBLER_NAME (decl))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (node)
|
|
|
|
unlink_from_assembler_name_hash (node);
|
|
|
|
if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))
|
|
|
|
&& DECL_RTL_SET_P (decl))
|
|
|
|
warning (0, "%D renamed after being referenced in assembly", decl);
|
|
|
|
|
|
|
|
SET_DECL_ASSEMBLER_NAME (decl, name);
|
|
|
|
if (node)
|
|
|
|
insert_to_assembler_name_hash (node);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#include "gt-symtab.h"
|