diff options
author | Jan Hubicka <jh@suse.cz> | 2012-04-16 16:34:22 +0200 |
---|---|---|
committer | Jan Hubicka <hubicka@gcc.gnu.org> | 2012-04-16 14:34:22 +0000 |
commit | 2aae768068b8f9e0b36b593f80a6403dc5063d83 (patch) | |
tree | 5faa94b4b722d5a4697b6faeb99c4c72e121c4ff /gcc/symtab.c | |
parent | 1c4010c6d61d3fa7f5fceeb09ea06a260bc5128c (diff) | |
download | gcc-2aae768068b8f9e0b36b593f80a6403dc5063d83.zip gcc-2aae768068b8f9e0b36b593f80a6403dc5063d83.tar.gz gcc-2aae768068b8f9e0b36b593f80a6403dc5063d83.tar.bz2 |
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
Diffstat (limited to 'gcc/symtab.c')
-rw-r--r-- | gcc/symtab.c | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/gcc/symtab.c b/gcc/symtab.c new file mode 100644 index 0000000..c30f33d --- /dev/null +++ b/gcc/symtab.c @@ -0,0 +1,97 @@ +/* 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" +#include "cgraph.h" + +/* 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; + +/* 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) +{ + node->symbol.next = symtab_nodes; + node->symbol.previous = NULL; + if (symtab_nodes) + symtab_nodes->symbol.previous = node; + symtab_nodes = node; + + node->symbol.order = symtab_order++; + + ipa_empty_ref_list (&node->symbol.ref_list); +} + +/* 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) +{ + 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; +} + +/* 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)); +} |