annotate gcc/varpool.c @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 1830386684a0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 /* Callgraph handling code.
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
2 Copyright (C) 2003-2020 Free Software Foundation, Inc.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 Contributed by Jan Hubicka
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 This file is part of GCC.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 GCC is free software; you can redistribute it and/or modify it under
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 the terms of the GNU General Public License as published by the Free
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 Software Foundation; either version 3, or (at your option) any later
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 version.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 for more details.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 along with GCC; see the file COPYING3. If not see
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 <http://www.gnu.org/licenses/>. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 #include "config.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 #include "system.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 #include "coretypes.h"
111
kono
parents: 67
diff changeset
24 #include "backend.h"
kono
parents: 67
diff changeset
25 #include "target.h"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 #include "tree.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 #include "gimple.h"
111
kono
parents: 67
diff changeset
28 #include "timevar.h"
kono
parents: 67
diff changeset
29 #include "cgraph.h"
kono
parents: 67
diff changeset
30 #include "lto-streamer.h"
kono
parents: 67
diff changeset
31 #include "varasm.h"
kono
parents: 67
diff changeset
32 #include "debug.h"
kono
parents: 67
diff changeset
33 #include "output.h"
kono
parents: 67
diff changeset
34 #include "omp-offload.h"
kono
parents: 67
diff changeset
35 #include "context.h"
kono
parents: 67
diff changeset
36 #include "stringpool.h"
kono
parents: 67
diff changeset
37 #include "attribs.h"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
38
111
kono
parents: 67
diff changeset
39 const char * const tls_model_names[]={"none", "emulated",
kono
parents: 67
diff changeset
40 "global-dynamic", "local-dynamic",
kono
parents: 67
diff changeset
41 "initial-exec", "local-exec"};
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
42
111
kono
parents: 67
diff changeset
43 /* List of hooks triggered on varpool_node events. */
kono
parents: 67
diff changeset
44 struct varpool_node_hook_list {
kono
parents: 67
diff changeset
45 varpool_node_hook hook;
kono
parents: 67
diff changeset
46 void *data;
kono
parents: 67
diff changeset
47 struct varpool_node_hook_list *next;
kono
parents: 67
diff changeset
48 };
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
49
111
kono
parents: 67
diff changeset
50 /* Register HOOK to be called with DATA on each removed node. */
kono
parents: 67
diff changeset
51 varpool_node_hook_list *
kono
parents: 67
diff changeset
52 symbol_table::add_varpool_removal_hook (varpool_node_hook hook, void *data)
kono
parents: 67
diff changeset
53 {
kono
parents: 67
diff changeset
54 varpool_node_hook_list *entry;
kono
parents: 67
diff changeset
55 varpool_node_hook_list **ptr = &m_first_varpool_removal_hook;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
56
111
kono
parents: 67
diff changeset
57 entry = (varpool_node_hook_list *) xmalloc (sizeof (*entry));
kono
parents: 67
diff changeset
58 entry->hook = hook;
kono
parents: 67
diff changeset
59 entry->data = data;
kono
parents: 67
diff changeset
60 entry->next = NULL;
kono
parents: 67
diff changeset
61 while (*ptr)
kono
parents: 67
diff changeset
62 ptr = &(*ptr)->next;
kono
parents: 67
diff changeset
63 *ptr = entry;
kono
parents: 67
diff changeset
64 return entry;
kono
parents: 67
diff changeset
65 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
66
111
kono
parents: 67
diff changeset
67 /* Remove ENTRY from the list of hooks called on removing nodes. */
kono
parents: 67
diff changeset
68 void
kono
parents: 67
diff changeset
69 symbol_table::remove_varpool_removal_hook (varpool_node_hook_list *entry)
kono
parents: 67
diff changeset
70 {
kono
parents: 67
diff changeset
71 varpool_node_hook_list **ptr = &m_first_varpool_removal_hook;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
72
111
kono
parents: 67
diff changeset
73 while (*ptr != entry)
kono
parents: 67
diff changeset
74 ptr = &(*ptr)->next;
kono
parents: 67
diff changeset
75 *ptr = entry->next;
kono
parents: 67
diff changeset
76 free (entry);
kono
parents: 67
diff changeset
77 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
78
111
kono
parents: 67
diff changeset
79 /* Call all node removal hooks. */
kono
parents: 67
diff changeset
80 void
kono
parents: 67
diff changeset
81 symbol_table::call_varpool_removal_hooks (varpool_node *node)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
82 {
111
kono
parents: 67
diff changeset
83 varpool_node_hook_list *entry = m_first_varpool_removal_hook;
kono
parents: 67
diff changeset
84 while (entry)
kono
parents: 67
diff changeset
85 {
kono
parents: 67
diff changeset
86 entry->hook (node, entry->data);
kono
parents: 67
diff changeset
87 entry = entry->next;
kono
parents: 67
diff changeset
88 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
89 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
90
111
kono
parents: 67
diff changeset
91 /* Register HOOK to be called with DATA on each inserted node. */
kono
parents: 67
diff changeset
92 varpool_node_hook_list *
kono
parents: 67
diff changeset
93 symbol_table::add_varpool_insertion_hook (varpool_node_hook hook, void *data)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
94 {
111
kono
parents: 67
diff changeset
95 varpool_node_hook_list *entry;
kono
parents: 67
diff changeset
96 varpool_node_hook_list **ptr = &m_first_varpool_insertion_hook;
kono
parents: 67
diff changeset
97
kono
parents: 67
diff changeset
98 entry = (varpool_node_hook_list *) xmalloc (sizeof (*entry));
kono
parents: 67
diff changeset
99 entry->hook = hook;
kono
parents: 67
diff changeset
100 entry->data = data;
kono
parents: 67
diff changeset
101 entry->next = NULL;
kono
parents: 67
diff changeset
102 while (*ptr)
kono
parents: 67
diff changeset
103 ptr = &(*ptr)->next;
kono
parents: 67
diff changeset
104 *ptr = entry;
kono
parents: 67
diff changeset
105 return entry;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
106 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
107
111
kono
parents: 67
diff changeset
108 /* Remove ENTRY from the list of hooks called on inserted nodes. */
kono
parents: 67
diff changeset
109 void
kono
parents: 67
diff changeset
110 symbol_table::remove_varpool_insertion_hook (varpool_node_hook_list *entry)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
111 {
111
kono
parents: 67
diff changeset
112 varpool_node_hook_list **ptr = &m_first_varpool_insertion_hook;
kono
parents: 67
diff changeset
113
kono
parents: 67
diff changeset
114 while (*ptr != entry)
kono
parents: 67
diff changeset
115 ptr = &(*ptr)->next;
kono
parents: 67
diff changeset
116 *ptr = entry->next;
kono
parents: 67
diff changeset
117 free (entry);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
118 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
119
111
kono
parents: 67
diff changeset
120 /* Call all node insertion hooks. */
kono
parents: 67
diff changeset
121 void
kono
parents: 67
diff changeset
122 symbol_table::call_varpool_insertion_hooks (varpool_node *node)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
123 {
111
kono
parents: 67
diff changeset
124 varpool_node_hook_list *entry = m_first_varpool_insertion_hook;
kono
parents: 67
diff changeset
125 while (entry)
kono
parents: 67
diff changeset
126 {
kono
parents: 67
diff changeset
127 entry->hook (node, entry->data);
kono
parents: 67
diff changeset
128 entry = entry->next;
kono
parents: 67
diff changeset
129 }
kono
parents: 67
diff changeset
130 }
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
131
111
kono
parents: 67
diff changeset
132 /* Allocate new callgraph node and insert it into basic data structures. */
kono
parents: 67
diff changeset
133
kono
parents: 67
diff changeset
134 varpool_node *
kono
parents: 67
diff changeset
135 varpool_node::create_empty (void)
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
136 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
137 return new (ggc_alloc<varpool_node> ()) varpool_node ();
111
kono
parents: 67
diff changeset
138 }
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
139
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
140 /* Return varpool node assigned to DECL. Create new one when needed. */
111
kono
parents: 67
diff changeset
141 varpool_node *
kono
parents: 67
diff changeset
142 varpool_node::get_create (tree decl)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
143 {
111
kono
parents: 67
diff changeset
144 varpool_node *node = varpool_node::get (decl);
kono
parents: 67
diff changeset
145 gcc_checking_assert (VAR_P (decl));
kono
parents: 67
diff changeset
146 if (node)
kono
parents: 67
diff changeset
147 return node;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
148
111
kono
parents: 67
diff changeset
149 node = varpool_node::create_empty ();
kono
parents: 67
diff changeset
150 node->decl = decl;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
151
111
kono
parents: 67
diff changeset
152 if ((flag_openacc || flag_openmp)
kono
parents: 67
diff changeset
153 && lookup_attribute ("omp declare target", DECL_ATTRIBUTES (decl)))
kono
parents: 67
diff changeset
154 {
kono
parents: 67
diff changeset
155 node->offloadable = 1;
kono
parents: 67
diff changeset
156 if (ENABLE_OFFLOADING && !DECL_EXTERNAL (decl))
kono
parents: 67
diff changeset
157 {
kono
parents: 67
diff changeset
158 g->have_offload = true;
kono
parents: 67
diff changeset
159 if (!in_lto_p)
kono
parents: 67
diff changeset
160 vec_safe_push (offload_vars, decl);
kono
parents: 67
diff changeset
161 }
kono
parents: 67
diff changeset
162 }
kono
parents: 67
diff changeset
163
kono
parents: 67
diff changeset
164 node->register_symbol ();
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
165 return node;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
166 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
167
111
kono
parents: 67
diff changeset
168 /* Remove variable from symbol table. */
kono
parents: 67
diff changeset
169
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
170 void
111
kono
parents: 67
diff changeset
171 varpool_node::remove (void)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
172 {
111
kono
parents: 67
diff changeset
173 symtab->call_varpool_removal_hooks (this);
kono
parents: 67
diff changeset
174 if (lto_file_data)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
175 {
111
kono
parents: 67
diff changeset
176 lto_free_function_in_decl_state_for_node (this);
kono
parents: 67
diff changeset
177 lto_file_data = NULL;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
178 }
111
kono
parents: 67
diff changeset
179
kono
parents: 67
diff changeset
180 /* When streaming we can have multiple nodes associated with decl. */
kono
parents: 67
diff changeset
181 if (symtab->state == LTO_STREAMING)
kono
parents: 67
diff changeset
182 ;
kono
parents: 67
diff changeset
183 /* Keep constructor when it may be used for folding. We remove
kono
parents: 67
diff changeset
184 references to external variables before final compilation. */
kono
parents: 67
diff changeset
185 else if (DECL_INITIAL (decl) && DECL_INITIAL (decl) != error_mark_node
kono
parents: 67
diff changeset
186 && !ctor_useable_for_folding_p ())
kono
parents: 67
diff changeset
187 remove_initializer ();
kono
parents: 67
diff changeset
188
kono
parents: 67
diff changeset
189 unregister ();
kono
parents: 67
diff changeset
190 ggc_free (this);
kono
parents: 67
diff changeset
191 }
kono
parents: 67
diff changeset
192
kono
parents: 67
diff changeset
193 /* Remove node initializer when it is no longer needed. */
kono
parents: 67
diff changeset
194 void
kono
parents: 67
diff changeset
195 varpool_node::remove_initializer (void)
kono
parents: 67
diff changeset
196 {
kono
parents: 67
diff changeset
197 if (DECL_INITIAL (decl)
kono
parents: 67
diff changeset
198 && !DECL_IN_CONSTANT_POOL (decl)
kono
parents: 67
diff changeset
199 /* Keep vtables for BINFO folding. */
kono
parents: 67
diff changeset
200 && !DECL_VIRTUAL_P (decl)
kono
parents: 67
diff changeset
201 /* FIXME: http://gcc.gnu.org/PR55395 */
kono
parents: 67
diff changeset
202 && debug_info_level == DINFO_LEVEL_NONE
kono
parents: 67
diff changeset
203 /* When doing declaration merging we have duplicate
kono
parents: 67
diff changeset
204 entries for given decl. Do not attempt to remove
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
205 the bodies, or we will end up removing
111
kono
parents: 67
diff changeset
206 wrong one. */
kono
parents: 67
diff changeset
207 && symtab->state != LTO_STREAMING)
kono
parents: 67
diff changeset
208 DECL_INITIAL (decl) = error_mark_node;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
209 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
210
111
kono
parents: 67
diff changeset
211 /* Dump given varpool node to F. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
212 void
111
kono
parents: 67
diff changeset
213 varpool_node::dump (FILE *f)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
214 {
111
kono
parents: 67
diff changeset
215 dump_base (f);
kono
parents: 67
diff changeset
216 fprintf (f, " Availability: %s\n",
kono
parents: 67
diff changeset
217 symtab->function_flags_ready
kono
parents: 67
diff changeset
218 ? cgraph_availability_names[get_availability ()]
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
219 : "not-ready");
111
kono
parents: 67
diff changeset
220 fprintf (f, " Varpool flags:");
kono
parents: 67
diff changeset
221 if (DECL_INITIAL (decl))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
222 fprintf (f, " initialized");
111
kono
parents: 67
diff changeset
223 if (output)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
224 fprintf (f, " output");
111
kono
parents: 67
diff changeset
225 if (used_by_single_function)
kono
parents: 67
diff changeset
226 fprintf (f, " used-by-single-function");
kono
parents: 67
diff changeset
227 if (TREE_READONLY (decl))
kono
parents: 67
diff changeset
228 fprintf (f, " read-only");
kono
parents: 67
diff changeset
229 if (ctor_useable_for_folding_p ())
kono
parents: 67
diff changeset
230 fprintf (f, " const-value-known");
kono
parents: 67
diff changeset
231 if (writeonly)
kono
parents: 67
diff changeset
232 fprintf (f, " write-only");
kono
parents: 67
diff changeset
233 if (tls_model)
kono
parents: 67
diff changeset
234 fprintf (f, " tls-%s", tls_model_names [tls_model]);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
235 fprintf (f, "\n");
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
236 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
237
111
kono
parents: 67
diff changeset
238
kono
parents: 67
diff changeset
239 /* Dump given varpool node to stderr. */
kono
parents: 67
diff changeset
240 void varpool_node::debug (void)
kono
parents: 67
diff changeset
241 {
kono
parents: 67
diff changeset
242 varpool_node::dump (stderr);
kono
parents: 67
diff changeset
243 }
kono
parents: 67
diff changeset
244
kono
parents: 67
diff changeset
245 /* Dump the variable pool to F. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
246 void
111
kono
parents: 67
diff changeset
247 varpool_node::dump_varpool (FILE *f)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
248 {
111
kono
parents: 67
diff changeset
249 varpool_node *node;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
250
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
251 fprintf (f, "variable pool:\n\n");
111
kono
parents: 67
diff changeset
252 FOR_EACH_VARIABLE (node)
kono
parents: 67
diff changeset
253 node->dump (f);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
254 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
255
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
256 /* Dump the variable pool to stderr. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
257
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
258 DEBUG_FUNCTION void
111
kono
parents: 67
diff changeset
259 varpool_node::debug_varpool (void)
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
260 {
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
261 dump_varpool (stderr);
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
262 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
263
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
264 /* Given an assembler name, lookup node. */
111
kono
parents: 67
diff changeset
265 varpool_node *
kono
parents: 67
diff changeset
266 varpool_node::get_for_asmname (tree asmname)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
267 {
111
kono
parents: 67
diff changeset
268 if (symtab_node *node = symtab_node::get_for_asmname (asmname))
kono
parents: 67
diff changeset
269 return dyn_cast <varpool_node *> (node);
kono
parents: 67
diff changeset
270 else
kono
parents: 67
diff changeset
271 return NULL;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
272 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
273
111
kono
parents: 67
diff changeset
274 /* When doing LTO, read variable's constructor from disk if
kono
parents: 67
diff changeset
275 it is not already present. */
kono
parents: 67
diff changeset
276
kono
parents: 67
diff changeset
277 tree
kono
parents: 67
diff changeset
278 varpool_node::get_constructor (void)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
279 {
111
kono
parents: 67
diff changeset
280 lto_file_decl_data *file_data;
kono
parents: 67
diff changeset
281 const char *data, *name;
kono
parents: 67
diff changeset
282 size_t len;
kono
parents: 67
diff changeset
283
kono
parents: 67
diff changeset
284 if (DECL_INITIAL (decl) != error_mark_node
kono
parents: 67
diff changeset
285 || !in_lto_p
kono
parents: 67
diff changeset
286 || !lto_file_data)
kono
parents: 67
diff changeset
287 return DECL_INITIAL (decl);
kono
parents: 67
diff changeset
288
kono
parents: 67
diff changeset
289 timevar_push (TV_IPA_LTO_CTORS_IN);
kono
parents: 67
diff changeset
290
kono
parents: 67
diff changeset
291 file_data = lto_file_data;
kono
parents: 67
diff changeset
292 name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
kono
parents: 67
diff changeset
293
kono
parents: 67
diff changeset
294 /* We may have renamed the declaration, e.g., a static function. */
kono
parents: 67
diff changeset
295 name = lto_get_decl_name_mapping (file_data, name);
kono
parents: 67
diff changeset
296 struct lto_in_decl_state *decl_state
kono
parents: 67
diff changeset
297 = lto_get_function_in_decl_state (file_data, decl);
kono
parents: 67
diff changeset
298
kono
parents: 67
diff changeset
299 data = lto_get_section_data (file_data, LTO_section_function_body,
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
300 name, order - file_data->order_base,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
301 &len, decl_state->compressed);
111
kono
parents: 67
diff changeset
302 if (!data)
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
303 fatal_error (input_location, "%s: section %s.%d is missing",
111
kono
parents: 67
diff changeset
304 file_data->file_name,
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
305 name, order - file_data->order_base);
111
kono
parents: 67
diff changeset
306
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
307 if (!quiet_flag)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
308 fprintf (stderr, " in:%s", IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
111
kono
parents: 67
diff changeset
309 lto_input_variable_constructor (file_data, this, data);
kono
parents: 67
diff changeset
310 gcc_assert (DECL_INITIAL (decl) != error_mark_node);
kono
parents: 67
diff changeset
311 lto_stats.num_function_bodies++;
kono
parents: 67
diff changeset
312 lto_free_section_data (file_data, LTO_section_function_body, name,
kono
parents: 67
diff changeset
313 data, len, decl_state->compressed);
kono
parents: 67
diff changeset
314 lto_free_function_in_decl_state_for_node (this);
kono
parents: 67
diff changeset
315 timevar_pop (TV_IPA_LTO_CTORS_IN);
kono
parents: 67
diff changeset
316 return DECL_INITIAL (decl);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
317 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
318
111
kono
parents: 67
diff changeset
319 /* Return true if variable has constructor that can be used for folding. */
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
320
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
321 bool
111
kono
parents: 67
diff changeset
322 varpool_node::ctor_useable_for_folding_p (void)
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
323 {
111
kono
parents: 67
diff changeset
324 varpool_node *real_node = this;
kono
parents: 67
diff changeset
325
kono
parents: 67
diff changeset
326 if (real_node->alias && real_node->definition)
kono
parents: 67
diff changeset
327 real_node = ultimate_alias_target ();
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
328
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
329 if (TREE_CODE (decl) == CONST_DECL
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
330 || DECL_IN_CONSTANT_POOL (decl))
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
331 return true;
111
kono
parents: 67
diff changeset
332 if (TREE_THIS_VOLATILE (decl))
kono
parents: 67
diff changeset
333 return false;
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
334
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
335 /* Avoid attempts to load constructors that was not streamed. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
336 if (in_lto_p && DECL_INITIAL (real_node->decl) == error_mark_node
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
337 && real_node->body_removed)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
338 return false;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
339
111
kono
parents: 67
diff changeset
340 /* If we do not have a constructor, we can't use it. */
kono
parents: 67
diff changeset
341 if (DECL_INITIAL (real_node->decl) == error_mark_node
kono
parents: 67
diff changeset
342 && !real_node->lto_file_data)
kono
parents: 67
diff changeset
343 return false;
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
344
111
kono
parents: 67
diff changeset
345 /* Vtables are defined by their types and must match no matter of interposition
kono
parents: 67
diff changeset
346 rules. */
kono
parents: 67
diff changeset
347 if (DECL_VIRTUAL_P (decl))
kono
parents: 67
diff changeset
348 {
kono
parents: 67
diff changeset
349 /* The C++ front end creates VAR_DECLs for vtables of typeinfo
kono
parents: 67
diff changeset
350 classes not defined in the current TU so that it can refer
kono
parents: 67
diff changeset
351 to them from typeinfo objects. Avoid returning NULL_TREE. */
kono
parents: 67
diff changeset
352 return DECL_INITIAL (real_node->decl) != NULL;
kono
parents: 67
diff changeset
353 }
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
354
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
355 /* An alias of a read-only variable is also read-only, since the variable
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
356 is stored in read-only memory. We also accept read-only aliases of
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
357 non-read-only locations assuming that the user knows what he is asking
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
358 for. */
111
kono
parents: 67
diff changeset
359 if (!TREE_READONLY (decl) && !TREE_READONLY (real_node->decl))
kono
parents: 67
diff changeset
360 return false;
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
361
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
362 /* Variables declared 'const' without an initializer
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
363 have zero as the initializer if they may not be
111
kono
parents: 67
diff changeset
364 overridden at link or run time.
kono
parents: 67
diff changeset
365
kono
parents: 67
diff changeset
366 It is actually requirement for C++ compiler to optimize const variables
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
367 consistently. As a GNU extension, do not enforce this rule for user defined
111
kono
parents: 67
diff changeset
368 weak variables, so we support interposition on:
kono
parents: 67
diff changeset
369 static const int dummy = 0;
kono
parents: 67
diff changeset
370 extern const int foo __attribute__((__weak__, __alias__("dummy")));
kono
parents: 67
diff changeset
371 */
kono
parents: 67
diff changeset
372 if ((!DECL_INITIAL (real_node->decl)
kono
parents: 67
diff changeset
373 || (DECL_WEAK (decl) && !DECL_COMDAT (decl)))
kono
parents: 67
diff changeset
374 && (DECL_EXTERNAL (decl) || decl_replaceable_p (decl)))
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
375 return false;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
376
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
377 /* Variables declared `const' with an initializer are considered
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
378 to not be overwritable with different initializer by default.
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
379
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
380 ??? Previously we behaved so for scalar variables but not for array
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
381 accesses. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
382 return true;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
383 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
384
111
kono
parents: 67
diff changeset
385 /* If DECLARATION is constant variable and its initial value is known
kono
parents: 67
diff changeset
386 (so we can do constant folding), return its constructor (DECL_INITIAL).
kono
parents: 67
diff changeset
387 This may be an expression or NULL when DECL is initialized to 0.
kono
parents: 67
diff changeset
388 Return ERROR_MARK_NODE otherwise.
kono
parents: 67
diff changeset
389
kono
parents: 67
diff changeset
390 In LTO this may actually trigger reading the constructor from disk.
kono
parents: 67
diff changeset
391 For this reason varpool_ctor_useable_for_folding_p should be used when
kono
parents: 67
diff changeset
392 the actual constructor value is not needed. */
kono
parents: 67
diff changeset
393
kono
parents: 67
diff changeset
394 tree
kono
parents: 67
diff changeset
395 ctor_for_folding (tree decl)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
396 {
111
kono
parents: 67
diff changeset
397 varpool_node *node, *real_node;
kono
parents: 67
diff changeset
398 tree real_decl;
kono
parents: 67
diff changeset
399
kono
parents: 67
diff changeset
400 if (!VAR_P (decl) && TREE_CODE (decl) != CONST_DECL)
kono
parents: 67
diff changeset
401 return error_mark_node;
kono
parents: 67
diff changeset
402
kono
parents: 67
diff changeset
403 if (TREE_CODE (decl) == CONST_DECL
kono
parents: 67
diff changeset
404 || DECL_IN_CONSTANT_POOL (decl))
kono
parents: 67
diff changeset
405 return DECL_INITIAL (decl);
kono
parents: 67
diff changeset
406
kono
parents: 67
diff changeset
407 if (TREE_THIS_VOLATILE (decl))
kono
parents: 67
diff changeset
408 return error_mark_node;
kono
parents: 67
diff changeset
409
kono
parents: 67
diff changeset
410 /* Do not care about automatic variables. Those are never initialized
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
411 anyway, because gimplifier expands the code. */
111
kono
parents: 67
diff changeset
412 if (!TREE_STATIC (decl) && !DECL_EXTERNAL (decl))
kono
parents: 67
diff changeset
413 {
kono
parents: 67
diff changeset
414 gcc_assert (!TREE_PUBLIC (decl));
kono
parents: 67
diff changeset
415 return error_mark_node;
kono
parents: 67
diff changeset
416 }
kono
parents: 67
diff changeset
417
kono
parents: 67
diff changeset
418 gcc_assert (VAR_P (decl));
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
419
111
kono
parents: 67
diff changeset
420 real_node = node = varpool_node::get (decl);
kono
parents: 67
diff changeset
421 if (node)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
422 {
111
kono
parents: 67
diff changeset
423 real_node = node->ultimate_alias_target ();
kono
parents: 67
diff changeset
424 real_decl = real_node->decl;
kono
parents: 67
diff changeset
425 }
kono
parents: 67
diff changeset
426 else
kono
parents: 67
diff changeset
427 real_decl = decl;
kono
parents: 67
diff changeset
428
kono
parents: 67
diff changeset
429 /* See if we are dealing with alias.
kono
parents: 67
diff changeset
430 In most cases alias is just alternative symbol pointing to a given
kono
parents: 67
diff changeset
431 constructor. This allows us to use interposition rules of DECL
kono
parents: 67
diff changeset
432 constructor of REAL_NODE. However weakrefs are special by being just
kono
parents: 67
diff changeset
433 alternative name of their target (if defined). */
kono
parents: 67
diff changeset
434 if (decl != real_decl)
kono
parents: 67
diff changeset
435 {
kono
parents: 67
diff changeset
436 gcc_assert (!DECL_INITIAL (decl)
kono
parents: 67
diff changeset
437 || (node->alias && node->get_alias_target () == real_node)
kono
parents: 67
diff changeset
438 || DECL_INITIAL (decl) == error_mark_node);
kono
parents: 67
diff changeset
439 while (node->transparent_alias && node->analyzed)
kono
parents: 67
diff changeset
440 {
kono
parents: 67
diff changeset
441 node = node->get_alias_target ();
kono
parents: 67
diff changeset
442 decl = node->decl;
kono
parents: 67
diff changeset
443 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
444 }
111
kono
parents: 67
diff changeset
445
kono
parents: 67
diff changeset
446 if ((!DECL_VIRTUAL_P (real_decl)
kono
parents: 67
diff changeset
447 || DECL_INITIAL (real_decl) == error_mark_node
kono
parents: 67
diff changeset
448 || !DECL_INITIAL (real_decl))
kono
parents: 67
diff changeset
449 && (!node || !node->ctor_useable_for_folding_p ()))
kono
parents: 67
diff changeset
450 return error_mark_node;
kono
parents: 67
diff changeset
451
kono
parents: 67
diff changeset
452 /* OK, we can return constructor. See if we need to fetch it from disk
kono
parents: 67
diff changeset
453 in LTO mode. */
kono
parents: 67
diff changeset
454 if (DECL_INITIAL (real_decl) != error_mark_node
kono
parents: 67
diff changeset
455 || !in_lto_p)
kono
parents: 67
diff changeset
456 return DECL_INITIAL (real_decl);
kono
parents: 67
diff changeset
457 return real_node->get_constructor ();
kono
parents: 67
diff changeset
458 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
459
111
kono
parents: 67
diff changeset
460 /* Add the variable DECL to the varpool.
kono
parents: 67
diff changeset
461 Unlike finalize_decl function is intended to be used
kono
parents: 67
diff changeset
462 by middle end and allows insertion of new variable at arbitrary point
kono
parents: 67
diff changeset
463 of compilation. */
kono
parents: 67
diff changeset
464 void
kono
parents: 67
diff changeset
465 varpool_node::add (tree decl)
kono
parents: 67
diff changeset
466 {
kono
parents: 67
diff changeset
467 varpool_node *node;
kono
parents: 67
diff changeset
468 varpool_node::finalize_decl (decl);
kono
parents: 67
diff changeset
469 node = varpool_node::get_create (decl);
kono
parents: 67
diff changeset
470 symtab->call_varpool_insertion_hooks (node);
kono
parents: 67
diff changeset
471 if (node->externally_visible_p ())
kono
parents: 67
diff changeset
472 node->externally_visible = true;
kono
parents: 67
diff changeset
473 if (lookup_attribute ("no_reorder", DECL_ATTRIBUTES (decl)))
kono
parents: 67
diff changeset
474 node->no_reorder = 1;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
475 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
476
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
477 /* Return variable availability. See cgraph.h for description of individual
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
478 return values. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
479 enum availability
111
kono
parents: 67
diff changeset
480 varpool_node::get_availability (symtab_node *ref)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
481 {
111
kono
parents: 67
diff changeset
482 if (!definition)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
483 return AVAIL_NOT_AVAILABLE;
111
kono
parents: 67
diff changeset
484 if (!TREE_PUBLIC (decl))
kono
parents: 67
diff changeset
485 return AVAIL_AVAILABLE;
kono
parents: 67
diff changeset
486 if (DECL_IN_CONSTANT_POOL (decl)
kono
parents: 67
diff changeset
487 || DECL_VIRTUAL_P (decl))
kono
parents: 67
diff changeset
488 return AVAIL_AVAILABLE;
kono
parents: 67
diff changeset
489 if (transparent_alias && definition)
kono
parents: 67
diff changeset
490 {
kono
parents: 67
diff changeset
491 enum availability avail;
kono
parents: 67
diff changeset
492
kono
parents: 67
diff changeset
493 ultimate_alias_target (&avail, ref);
kono
parents: 67
diff changeset
494 return avail;
kono
parents: 67
diff changeset
495 }
kono
parents: 67
diff changeset
496 /* If this is a reference from symbol itself and there are no aliases, we
kono
parents: 67
diff changeset
497 may be sure that the symbol was not interposed by something else because
kono
parents: 67
diff changeset
498 the symbol itself would be unreachable otherwise. */
kono
parents: 67
diff changeset
499 if ((this == ref && !has_aliases_p ())
kono
parents: 67
diff changeset
500 || (ref && get_comdat_group ()
kono
parents: 67
diff changeset
501 && get_comdat_group () == ref->get_comdat_group ()))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
502 return AVAIL_AVAILABLE;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
503 /* If the variable can be overwritten, return OVERWRITABLE. Takes
111
kono
parents: 67
diff changeset
504 care of at least one notable extension - the COMDAT variables
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
505 used to share template instantiations in C++. */
111
kono
parents: 67
diff changeset
506 if (decl_replaceable_p (decl)
kono
parents: 67
diff changeset
507 || DECL_EXTERNAL (decl))
kono
parents: 67
diff changeset
508 return AVAIL_INTERPOSABLE;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
509 return AVAIL_AVAILABLE;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
510 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
511
111
kono
parents: 67
diff changeset
512 void
kono
parents: 67
diff changeset
513 varpool_node::analyze (void)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
514 {
111
kono
parents: 67
diff changeset
515 /* When reading back varpool at LTO time, we re-construct the queue in order
kono
parents: 67
diff changeset
516 to have "needed" list right by inserting all needed nodes into varpool.
kono
parents: 67
diff changeset
517 We however don't want to re-analyze already analyzed nodes. */
kono
parents: 67
diff changeset
518 if (!analyzed)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
519 {
111
kono
parents: 67
diff changeset
520 gcc_assert (!in_lto_p || symtab->function_flags_ready);
kono
parents: 67
diff changeset
521 /* Compute the alignment early so function body expanders are
kono
parents: 67
diff changeset
522 already informed about increased alignment. */
kono
parents: 67
diff changeset
523 align_variable (decl, 0);
kono
parents: 67
diff changeset
524 }
kono
parents: 67
diff changeset
525 if (alias)
kono
parents: 67
diff changeset
526 resolve_alias (varpool_node::get (alias_target));
kono
parents: 67
diff changeset
527 else if (DECL_INITIAL (decl))
kono
parents: 67
diff changeset
528 record_references_in_initializer (decl, analyzed);
kono
parents: 67
diff changeset
529 analyzed = true;
kono
parents: 67
diff changeset
530 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
531
111
kono
parents: 67
diff changeset
532 /* Assemble thunks and aliases associated to varpool node. */
kono
parents: 67
diff changeset
533
kono
parents: 67
diff changeset
534 void
kono
parents: 67
diff changeset
535 varpool_node::assemble_aliases (void)
kono
parents: 67
diff changeset
536 {
kono
parents: 67
diff changeset
537 ipa_ref *ref;
kono
parents: 67
diff changeset
538
kono
parents: 67
diff changeset
539 FOR_EACH_ALIAS (this, ref)
kono
parents: 67
diff changeset
540 {
kono
parents: 67
diff changeset
541 varpool_node *alias = dyn_cast <varpool_node *> (ref->referring);
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
542 if (alias->symver)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
543 do_assemble_symver (alias->decl,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
544 DECL_ASSEMBLER_NAME (decl));
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
545 else if (!alias->transparent_alias)
111
kono
parents: 67
diff changeset
546 do_assemble_alias (alias->decl,
kono
parents: 67
diff changeset
547 DECL_ASSEMBLER_NAME (decl));
kono
parents: 67
diff changeset
548 alias->assemble_aliases ();
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
549 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
550 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
551
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
552 /* Output one variable, if necessary. Return whether we output it. */
111
kono
parents: 67
diff changeset
553
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
554 bool
111
kono
parents: 67
diff changeset
555 varpool_node::assemble_decl (void)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
556 {
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
557 /* Aliases are output when their target is produced or by
111
kono
parents: 67
diff changeset
558 output_weakrefs. */
kono
parents: 67
diff changeset
559 if (alias)
kono
parents: 67
diff changeset
560 return false;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
561
111
kono
parents: 67
diff changeset
562 /* Constant pool is output from RTL land when the reference
kono
parents: 67
diff changeset
563 survive till this level. */
kono
parents: 67
diff changeset
564 if (DECL_IN_CONSTANT_POOL (decl) && TREE_ASM_WRITTEN (decl))
kono
parents: 67
diff changeset
565 return false;
kono
parents: 67
diff changeset
566
kono
parents: 67
diff changeset
567 /* Decls with VALUE_EXPR should not be in the varpool at all. They
kono
parents: 67
diff changeset
568 are not real variables, but just info for debugging and codegen.
kono
parents: 67
diff changeset
569 Unfortunately at the moment emutls is not updating varpool correctly
kono
parents: 67
diff changeset
570 after turning real vars into value_expr vars. */
kono
parents: 67
diff changeset
571 if (DECL_HAS_VALUE_EXPR_P (decl)
kono
parents: 67
diff changeset
572 && !targetm.have_tls)
kono
parents: 67
diff changeset
573 return false;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
574
111
kono
parents: 67
diff changeset
575 /* Hard register vars do not need to be output. */
kono
parents: 67
diff changeset
576 if (DECL_HARD_REGISTER (decl))
kono
parents: 67
diff changeset
577 return false;
kono
parents: 67
diff changeset
578
kono
parents: 67
diff changeset
579 gcc_checking_assert (!TREE_ASM_WRITTEN (decl)
kono
parents: 67
diff changeset
580 && VAR_P (decl)
kono
parents: 67
diff changeset
581 && !DECL_HAS_VALUE_EXPR_P (decl));
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
582
111
kono
parents: 67
diff changeset
583 if (!in_other_partition
kono
parents: 67
diff changeset
584 && !DECL_EXTERNAL (decl))
kono
parents: 67
diff changeset
585 {
kono
parents: 67
diff changeset
586 get_constructor ();
kono
parents: 67
diff changeset
587 assemble_variable (decl, 0, 1, 0);
kono
parents: 67
diff changeset
588 gcc_assert (TREE_ASM_WRITTEN (decl));
kono
parents: 67
diff changeset
589 gcc_assert (definition);
kono
parents: 67
diff changeset
590 assemble_aliases ();
kono
parents: 67
diff changeset
591 /* After the parser has generated debugging information, augment
kono
parents: 67
diff changeset
592 this information with any new location/etc information that may
kono
parents: 67
diff changeset
593 have become available after the compilation proper. */
kono
parents: 67
diff changeset
594 debug_hooks->late_global_decl (decl);
kono
parents: 67
diff changeset
595 return true;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
596 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
597
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
598 return false;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
599 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
600
111
kono
parents: 67
diff changeset
601 /* Add NODE to queue starting at FIRST.
kono
parents: 67
diff changeset
602 The queue is linked via AUX pointers and terminated by pointer to 1. */
kono
parents: 67
diff changeset
603
kono
parents: 67
diff changeset
604 static void
kono
parents: 67
diff changeset
605 enqueue_node (varpool_node *node, varpool_node **first)
kono
parents: 67
diff changeset
606 {
kono
parents: 67
diff changeset
607 if (node->aux)
kono
parents: 67
diff changeset
608 return;
kono
parents: 67
diff changeset
609 gcc_checking_assert (*first);
kono
parents: 67
diff changeset
610 node->aux = *first;
kono
parents: 67
diff changeset
611 *first = node;
kono
parents: 67
diff changeset
612 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
613
111
kono
parents: 67
diff changeset
614 /* Optimization of function bodies might've rendered some variables as
kono
parents: 67
diff changeset
615 unnecessary so we want to avoid these from being compiled. Re-do
kono
parents: 67
diff changeset
616 reachability starting from variables that are either externally visible
kono
parents: 67
diff changeset
617 or was referred from the asm output routines. */
kono
parents: 67
diff changeset
618
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
619 void
111
kono
parents: 67
diff changeset
620 symbol_table::remove_unreferenced_decls (void)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
621 {
111
kono
parents: 67
diff changeset
622 varpool_node *next, *node;
kono
parents: 67
diff changeset
623 varpool_node *first = (varpool_node *)(void *)1;
kono
parents: 67
diff changeset
624 int i;
kono
parents: 67
diff changeset
625 ipa_ref *ref = NULL;
kono
parents: 67
diff changeset
626 hash_set<varpool_node *> referenced;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
627
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
628 if (seen_error ())
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
629 return;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
630
111
kono
parents: 67
diff changeset
631 if (dump_file)
kono
parents: 67
diff changeset
632 fprintf (dump_file, "Trivially needed variables:");
kono
parents: 67
diff changeset
633 FOR_EACH_DEFINED_VARIABLE (node)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
634 {
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
635 if (node->analyzed
111
kono
parents: 67
diff changeset
636 && (!node->can_remove_if_no_refs_p ()
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
637 /* We just expanded all function bodies. See if any of
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
638 them needed the variable. */
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
639 || DECL_RTL_SET_P (node->decl)))
111
kono
parents: 67
diff changeset
640 {
kono
parents: 67
diff changeset
641 enqueue_node (node, &first);
kono
parents: 67
diff changeset
642 if (dump_file)
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
643 fprintf (dump_file, " %s", node->dump_asm_name ());
111
kono
parents: 67
diff changeset
644 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
645 }
111
kono
parents: 67
diff changeset
646 while (first != (varpool_node *)(void *)1)
kono
parents: 67
diff changeset
647 {
kono
parents: 67
diff changeset
648 node = first;
kono
parents: 67
diff changeset
649 first = (varpool_node *)first->aux;
kono
parents: 67
diff changeset
650
kono
parents: 67
diff changeset
651 if (node->same_comdat_group)
kono
parents: 67
diff changeset
652 {
kono
parents: 67
diff changeset
653 symtab_node *next;
kono
parents: 67
diff changeset
654 for (next = node->same_comdat_group;
kono
parents: 67
diff changeset
655 next != node;
kono
parents: 67
diff changeset
656 next = next->same_comdat_group)
kono
parents: 67
diff changeset
657 {
kono
parents: 67
diff changeset
658 varpool_node *vnext = dyn_cast <varpool_node *> (next);
kono
parents: 67
diff changeset
659 if (vnext && vnext->analyzed && !next->comdat_local_p ())
kono
parents: 67
diff changeset
660 enqueue_node (vnext, &first);
kono
parents: 67
diff changeset
661 }
kono
parents: 67
diff changeset
662 }
kono
parents: 67
diff changeset
663 for (i = 0; node->iterate_reference (i, ref); i++)
kono
parents: 67
diff changeset
664 {
kono
parents: 67
diff changeset
665 varpool_node *vnode = dyn_cast <varpool_node *> (ref->referred);
kono
parents: 67
diff changeset
666 if (vnode
kono
parents: 67
diff changeset
667 && !vnode->in_other_partition
kono
parents: 67
diff changeset
668 && (!DECL_EXTERNAL (ref->referred->decl)
kono
parents: 67
diff changeset
669 || vnode->alias)
kono
parents: 67
diff changeset
670 && vnode->analyzed)
kono
parents: 67
diff changeset
671 enqueue_node (vnode, &first);
kono
parents: 67
diff changeset
672 else
kono
parents: 67
diff changeset
673 {
kono
parents: 67
diff changeset
674 referenced.add (vnode);
kono
parents: 67
diff changeset
675 while (vnode && vnode->alias && vnode->definition)
kono
parents: 67
diff changeset
676 {
kono
parents: 67
diff changeset
677 vnode = vnode->get_alias_target ();
kono
parents: 67
diff changeset
678 referenced.add (vnode);
kono
parents: 67
diff changeset
679 }
kono
parents: 67
diff changeset
680 }
kono
parents: 67
diff changeset
681 }
kono
parents: 67
diff changeset
682 }
kono
parents: 67
diff changeset
683 if (dump_file)
kono
parents: 67
diff changeset
684 fprintf (dump_file, "\nRemoving variables:");
kono
parents: 67
diff changeset
685 for (node = first_defined_variable (); node; node = next)
kono
parents: 67
diff changeset
686 {
kono
parents: 67
diff changeset
687 next = next_defined_variable (node);
kono
parents: 67
diff changeset
688 if (!node->aux && !node->no_reorder)
kono
parents: 67
diff changeset
689 {
kono
parents: 67
diff changeset
690 if (dump_file)
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
691 fprintf (dump_file, " %s", node->dump_asm_name ());
111
kono
parents: 67
diff changeset
692 if (referenced.contains(node))
kono
parents: 67
diff changeset
693 node->remove_initializer ();
kono
parents: 67
diff changeset
694 else
kono
parents: 67
diff changeset
695 node->remove ();
kono
parents: 67
diff changeset
696 }
kono
parents: 67
diff changeset
697 }
kono
parents: 67
diff changeset
698
kono
parents: 67
diff changeset
699 if (dump_file)
kono
parents: 67
diff changeset
700 fprintf (dump_file, "\n");
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
701 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
702
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
703 /* For variables in named sections make sure get_variable_section
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
704 is called before we switch to those sections. Then section
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
705 conflicts between read-only and read-only requiring relocations
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
706 sections can be resolved. */
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
707 void
111
kono
parents: 67
diff changeset
708 varpool_node::finalize_named_section_flags (void)
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
709 {
111
kono
parents: 67
diff changeset
710 if (!TREE_ASM_WRITTEN (decl)
kono
parents: 67
diff changeset
711 && !alias
kono
parents: 67
diff changeset
712 && !in_other_partition
kono
parents: 67
diff changeset
713 && !DECL_EXTERNAL (decl)
kono
parents: 67
diff changeset
714 && VAR_P (decl)
kono
parents: 67
diff changeset
715 && !DECL_HAS_VALUE_EXPR_P (decl)
kono
parents: 67
diff changeset
716 && get_section ())
kono
parents: 67
diff changeset
717 get_variable_section (decl, false);
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
718 }
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
719
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
720 /* Output all variables enqueued to be assembled. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
721 bool
111
kono
parents: 67
diff changeset
722 symbol_table::output_variables (void)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
723 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
724 bool changed = false;
111
kono
parents: 67
diff changeset
725 varpool_node *node;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
726
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
727 if (seen_error ())
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
728 return false;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
729
111
kono
parents: 67
diff changeset
730 remove_unreferenced_decls ();
kono
parents: 67
diff changeset
731
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
732 timevar_push (TV_VAROUT);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
733
111
kono
parents: 67
diff changeset
734 FOR_EACH_DEFINED_VARIABLE (node)
kono
parents: 67
diff changeset
735 {
kono
parents: 67
diff changeset
736 /* Handled in output_in_order. */
kono
parents: 67
diff changeset
737 if (node->no_reorder)
kono
parents: 67
diff changeset
738 continue;
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
739
111
kono
parents: 67
diff changeset
740 node->finalize_named_section_flags ();
kono
parents: 67
diff changeset
741 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
742
111
kono
parents: 67
diff changeset
743 /* There is a similar loop in output_in_order. Please keep them in sync. */
kono
parents: 67
diff changeset
744 FOR_EACH_VARIABLE (node)
kono
parents: 67
diff changeset
745 {
kono
parents: 67
diff changeset
746 /* Handled in output_in_order. */
kono
parents: 67
diff changeset
747 if (node->no_reorder)
kono
parents: 67
diff changeset
748 continue;
kono
parents: 67
diff changeset
749 if (DECL_HARD_REGISTER (node->decl)
kono
parents: 67
diff changeset
750 || DECL_HAS_VALUE_EXPR_P (node->decl))
kono
parents: 67
diff changeset
751 continue;
kono
parents: 67
diff changeset
752 if (node->definition)
kono
parents: 67
diff changeset
753 changed |= node->assemble_decl ();
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
754 else
111
kono
parents: 67
diff changeset
755 assemble_undefined_decl (node->decl);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
756 }
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
757 timevar_pop (TV_VAROUT);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
758 return changed;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
759 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
760
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
761 /* Attempt to mark ALIAS as an alias to DECL. Return TRUE if successful.
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
762 Extra name aliases are output whenever DECL is output. */
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
763
111
kono
parents: 67
diff changeset
764 varpool_node *
kono
parents: 67
diff changeset
765 varpool_node::create_alias (tree alias, tree decl)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
766 {
111
kono
parents: 67
diff changeset
767 varpool_node *alias_node;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
768
111
kono
parents: 67
diff changeset
769 gcc_assert (VAR_P (decl));
kono
parents: 67
diff changeset
770 gcc_assert (VAR_P (alias));
kono
parents: 67
diff changeset
771 alias_node = varpool_node::get_create (alias);
kono
parents: 67
diff changeset
772 alias_node->alias = true;
kono
parents: 67
diff changeset
773 alias_node->definition = true;
kono
parents: 67
diff changeset
774 alias_node->alias_target = decl;
kono
parents: 67
diff changeset
775 if (lookup_attribute ("weakref", DECL_ATTRIBUTES (alias)) != NULL)
kono
parents: 67
diff changeset
776 alias_node->weakref = alias_node->transparent_alias = true;
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
777 return alias_node;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
778 }
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
779
111
kono
parents: 67
diff changeset
780 /* Attempt to mark ALIAS as an alias to DECL. Return TRUE if successful.
kono
parents: 67
diff changeset
781 Extra name aliases are output whenever DECL is output. */
kono
parents: 67
diff changeset
782
kono
parents: 67
diff changeset
783 varpool_node *
kono
parents: 67
diff changeset
784 varpool_node::create_extra_name_alias (tree alias, tree decl)
kono
parents: 67
diff changeset
785 {
kono
parents: 67
diff changeset
786 varpool_node *alias_node;
kono
parents: 67
diff changeset
787
kono
parents: 67
diff changeset
788 /* If aliases aren't supported by the assembler, fail. */
kono
parents: 67
diff changeset
789 if (!TARGET_SUPPORTS_ALIASES)
kono
parents: 67
diff changeset
790 return NULL;
kono
parents: 67
diff changeset
791
kono
parents: 67
diff changeset
792 alias_node = varpool_node::create_alias (alias, decl);
kono
parents: 67
diff changeset
793 alias_node->cpp_implicit_alias = true;
kono
parents: 67
diff changeset
794
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
795 /* Extra name alias mechanism creates aliases really late
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
796 via DECL_ASSEMBLER_NAME mechanism.
111
kono
parents: 67
diff changeset
797 This is unfortunate because they are not going through the
kono
parents: 67
diff changeset
798 standard channels. Ensure they get output. */
kono
parents: 67
diff changeset
799 if (symtab->cpp_implicit_aliases_done)
kono
parents: 67
diff changeset
800 alias_node->resolve_alias (varpool_node::get_create (decl));
kono
parents: 67
diff changeset
801 return alias_node;
kono
parents: 67
diff changeset
802 }
kono
parents: 67
diff changeset
803
kono
parents: 67
diff changeset
804 /* Worker for call_for_symbol_and_aliases. */
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
805
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
806 bool
111
kono
parents: 67
diff changeset
807 varpool_node::call_for_symbol_and_aliases_1 (bool (*callback) (varpool_node *,
kono
parents: 67
diff changeset
808 void *),
kono
parents: 67
diff changeset
809 void *data,
kono
parents: 67
diff changeset
810 bool include_overwritable)
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
811 {
111
kono
parents: 67
diff changeset
812 ipa_ref *ref;
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
813
111
kono
parents: 67
diff changeset
814 FOR_EACH_ALIAS (this, ref)
kono
parents: 67
diff changeset
815 {
kono
parents: 67
diff changeset
816 varpool_node *alias = dyn_cast <varpool_node *> (ref->referring);
kono
parents: 67
diff changeset
817 if (include_overwritable
kono
parents: 67
diff changeset
818 || alias->get_availability () > AVAIL_INTERPOSABLE)
kono
parents: 67
diff changeset
819 if (alias->call_for_symbol_and_aliases (callback, data,
kono
parents: 67
diff changeset
820 include_overwritable))
kono
parents: 67
diff changeset
821 return true;
kono
parents: 67
diff changeset
822 }
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
823 return false;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
824 }