]>
git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/symtab.c
2 Copyright (C) 2012 Free Software Foundation, Inc.
3 Contributed by Jan Hubicka
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
23 #include "coretypes.h"
26 #include "tree-inline.h"
30 /* Linked list of symbol table nodes. */
31 symtab_node symtab_nodes
;
33 /* The order index of the next symtab node to be created. This is
34 used so that we can sort the cgraph nodes in order by when we saw
35 them, to support -fno-toplevel-reorder. */
38 /* Add node into symbol table. This function is not used directly, but via
39 cgraph/varpool node creation routines. */
42 symtab_register_node (symtab_node node
)
44 node
->symbol
.next
= symtab_nodes
;
45 node
->symbol
.previous
= NULL
;
47 symtab_nodes
->symbol
.previous
= node
;
50 node
->symbol
.order
= symtab_order
++;
52 ipa_empty_ref_list (&node
->symbol
.ref_list
);
55 /* Remove node from symbol table. This function is not used directly, but via
56 cgraph/varpool node removal routines. */
59 symtab_unregister_node (symtab_node node
)
61 ipa_remove_all_references (&node
->symbol
.ref_list
);
62 ipa_remove_all_refering (&node
->symbol
.ref_list
);
64 if (node
->symbol
.same_comdat_group
)
67 for (prev
= node
->symbol
.same_comdat_group
;
68 prev
->symbol
.same_comdat_group
!= node
;
69 prev
= prev
->symbol
.same_comdat_group
)
71 if (node
->symbol
.same_comdat_group
== prev
)
72 prev
->symbol
.same_comdat_group
= NULL
;
74 prev
->symbol
.same_comdat_group
= node
->symbol
.same_comdat_group
;
75 node
->symbol
.same_comdat_group
= NULL
;
78 if (node
->symbol
.previous
)
79 node
->symbol
.previous
->symbol
.next
= node
->symbol
.next
;
81 symtab_nodes
= node
->symbol
.next
;
82 if (node
->symbol
.next
)
83 node
->symbol
.next
->symbol
.previous
= node
->symbol
.previous
;
84 node
->symbol
.next
= NULL
;
85 node
->symbol
.previous
= NULL
;
88 /* Remove symtab NODE from the symbol table. */
91 symtab_remove_node (symtab_node node
)
93 if (symtab_function_p (node
))
94 cgraph_remove_node (cgraph (node
));
95 else if (symtab_variable_p (node
))
96 varpool_remove_node (varpool (node
));