Mercurial > hg > CbC > CbC_gcc
comparison gcc/varpool.c @ 55:77e2b8dfacca gcc-4.4.5
update it from 4.4.3 to 4.5.0
author | ryoma <e075725@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 12 Feb 2010 23:39:51 +0900 |
parents | a06113de4d67 |
children | b7f97abdc517 |
comparison
equal
deleted
inserted
replaced
52:c156f1bd5cd9 | 55:77e2b8dfacca |
---|---|
28 #include "langhooks.h" | 28 #include "langhooks.h" |
29 #include "diagnostic.h" | 29 #include "diagnostic.h" |
30 #include "hashtab.h" | 30 #include "hashtab.h" |
31 #include "ggc.h" | 31 #include "ggc.h" |
32 #include "timevar.h" | 32 #include "timevar.h" |
33 #include "debug.h" | 33 #include "debug.h" |
34 #include "target.h" | 34 #include "target.h" |
35 #include "output.h" | 35 #include "output.h" |
36 #include "gimple.h" | 36 #include "gimple.h" |
37 #include "tree-flow.h" | 37 #include "tree-flow.h" |
38 #include "flags.h" | |
38 | 39 |
39 /* This file contains basic routines manipulating variable pool. | 40 /* This file contains basic routines manipulating variable pool. |
40 | 41 |
41 Varpool acts as interface in between the front-end and middle-end | 42 Varpool acts as interface in between the front-end and middle-end |
42 and drives the decision process on what variables and when are | 43 and drives the decision process on what variables and when are |
54 Linked via node->next pointer. */ | 55 Linked via node->next pointer. */ |
55 struct varpool_node *varpool_nodes; | 56 struct varpool_node *varpool_nodes; |
56 | 57 |
57 /* Queue of cgraph nodes scheduled to be lowered and output. | 58 /* Queue of cgraph nodes scheduled to be lowered and output. |
58 The queue is maintained via mark_needed_node, linked via node->next_needed | 59 The queue is maintained via mark_needed_node, linked via node->next_needed |
59 pointer. | 60 pointer. |
60 | 61 |
61 LAST_NEEDED_NODE points to the end of queue, so it can be | 62 LAST_NEEDED_NODE points to the end of queue, so it can be |
62 maintained in forward order. GTY is needed to make it friendly to | 63 maintained in forward order. GTY is needed to make it friendly to |
63 PCH. | 64 PCH. |
64 | 65 |
65 During compilation we construct the queue of needed variables | 66 During compilation we construct the queue of needed variables |
66 twice: first time it is during cgraph construction, second time it is at the | 67 twice: first time it is during cgraph construction, second time it is at the |
67 end of compilation in VARPOOL_REMOVE_UNREFERENCED_DECLS so we can avoid | 68 end of compilation in VARPOOL_REMOVE_UNREFERENCED_DECLS so we can avoid |
68 optimized out variables being output. | 69 optimized out variables being output. |
69 | 70 |
70 Each variable is thus first analyzed and then later possibly output. | 71 Each variable is thus first analyzed and then later possibly output. |
71 FIRST_UNANALYZED_NODE points to first node in queue that was not analyzed | 72 FIRST_UNANALYZED_NODE points to first node in queue that was not analyzed |
72 yet and is moved via VARPOOL_ANALYZE_PENDING_DECLS. */ | 73 yet and is moved via VARPOOL_ANALYZE_PENDING_DECLS. */ |
73 | 74 |
74 struct varpool_node *varpool_nodes_queue; | 75 struct varpool_node *varpool_nodes_queue; |
75 static GTY(()) struct varpool_node *varpool_last_needed_node; | 76 static GTY(()) struct varpool_node *varpool_last_needed_node; |
76 static GTY(()) struct varpool_node *varpool_first_unanalyzed_node; | 77 static GTY(()) struct varpool_node *varpool_first_unanalyzed_node; |
77 | 78 |
78 /* Lists all assembled variables to be sent to debugger output later on. */ | 79 /* Lists all assembled variables to be sent to debugger output later on. */ |
79 static GTY(()) struct varpool_node *varpool_assembled_nodes_queue; | 80 static GTY(()) struct varpool_node *varpool_assembled_nodes_queue; |
80 | 81 |
81 /* Return name of the node used in debug output. */ | 82 /* Return name of the node used in debug output. */ |
82 static const char * | 83 const char * |
83 varpool_node_name (struct varpool_node *node) | 84 varpool_node_name (struct varpool_node *node) |
84 { | 85 { |
85 return lang_hooks.decl_printable_name (node->decl, 2); | 86 return lang_hooks.decl_printable_name (node->decl, 2); |
86 } | 87 } |
87 | 88 |
162 fprintf (f, "variable pool:\n\n"); | 163 fprintf (f, "variable pool:\n\n"); |
163 for (node = varpool_nodes; node; node = node->next) | 164 for (node = varpool_nodes; node; node = node->next) |
164 dump_varpool_node (f, node); | 165 dump_varpool_node (f, node); |
165 } | 166 } |
166 | 167 |
168 /* Dump the variable pool to stderr. */ | |
169 | |
170 void | |
171 debug_varpool (void) | |
172 { | |
173 dump_varpool (stderr); | |
174 } | |
175 | |
167 /* Given an assembler name, lookup node. */ | 176 /* Given an assembler name, lookup node. */ |
168 struct varpool_node * | 177 struct varpool_node * |
169 varpool_node_for_asm (tree asmname) | 178 varpool_node_for_asm (tree asmname) |
170 { | 179 { |
171 struct varpool_node *node; | 180 struct varpool_node *node; |
218 configury */ | 227 configury */ |
219 bool | 228 bool |
220 decide_is_variable_needed (struct varpool_node *node, tree decl) | 229 decide_is_variable_needed (struct varpool_node *node, tree decl) |
221 { | 230 { |
222 /* If the user told us it is used, then it must be so. */ | 231 /* If the user told us it is used, then it must be so. */ |
223 if (node->externally_visible || node->force_output) | 232 if ((node->externally_visible && !DECL_COMDAT (decl)) |
233 || node->force_output) | |
224 return true; | 234 return true; |
225 | 235 |
226 /* ??? If the assembler name is set by hand, it is possible to assemble | 236 /* ??? If the assembler name is set by hand, it is possible to assemble |
227 the name later after finalizing the function and the fact is noticed | 237 the name later after finalizing the function and the fact is noticed |
228 in assemble_name then. This is arguably a bug. */ | 238 in assemble_name then. This is arguably a bug. */ |
229 if (DECL_ASSEMBLER_NAME_SET_P (decl) | 239 if (DECL_ASSEMBLER_NAME_SET_P (decl) |
230 && TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))) | 240 && TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))) |
231 return true; | 241 return true; |
232 | 242 |
233 /* If we decided it was needed before, but at the time we didn't have | |
234 the definition available, then it's still needed. */ | |
235 if (node->needed) | |
236 return true; | |
237 | |
238 /* Externally visible variables must be output. The exception is | 243 /* Externally visible variables must be output. The exception is |
239 COMDAT variables that must be output only when they are needed. */ | 244 COMDAT variables that must be output only when they are needed. */ |
240 if (TREE_PUBLIC (decl) && !flag_whole_program && !DECL_COMDAT (decl) | 245 if (TREE_PUBLIC (decl) |
246 && !flag_whole_program | |
247 && !flag_lto | |
248 && !flag_whopr | |
249 && !DECL_COMDAT (decl) | |
241 && !DECL_EXTERNAL (decl)) | 250 && !DECL_EXTERNAL (decl)) |
242 return true; | 251 return true; |
243 | 252 |
244 /* When emulating tls, we actually see references to the control | 253 /* When emulating tls, we actually see references to the control |
245 variable, rather than the user-level variable. */ | 254 variable, rather than the user-level variable. */ |
268 visible. */ | 277 visible. */ |
269 void | 278 void |
270 varpool_finalize_decl (tree decl) | 279 varpool_finalize_decl (tree decl) |
271 { | 280 { |
272 struct varpool_node *node = varpool_node (decl); | 281 struct varpool_node *node = varpool_node (decl); |
282 | |
283 /* FIXME: We don't really stream varpool datastructure and instead rebuild it | |
284 by varpool_finalize_decl. This is not quite correct since this way we can't | |
285 attach any info to varpool. Eventually we will want to stream varpool nodes | |
286 and the flags. | |
287 | |
288 For the moment just prevent analysis of varpool nodes to happen again, so | |
289 we will re-try to compute "address_taken" flag of varpool that breaks | |
290 in presence of clones. */ | |
291 if (in_lto_p) | |
292 node->analyzed = true; | |
273 | 293 |
274 /* The first declaration of a variable that comes through this function | 294 /* The first declaration of a variable that comes through this function |
275 decides whether it is global (in C, has external linkage) | 295 decides whether it is global (in C, has external linkage) |
276 or local (in C, has internal linkage). So do nothing more | 296 or local (in C, has internal linkage). So do nothing more |
277 if this function has already run. */ | 297 if this function has already run. */ |
323 timevar_push (TV_CGRAPH); | 343 timevar_push (TV_CGRAPH); |
324 | 344 |
325 while (varpool_first_unanalyzed_node) | 345 while (varpool_first_unanalyzed_node) |
326 { | 346 { |
327 tree decl = varpool_first_unanalyzed_node->decl; | 347 tree decl = varpool_first_unanalyzed_node->decl; |
348 bool analyzed = varpool_first_unanalyzed_node->analyzed; | |
328 | 349 |
329 varpool_first_unanalyzed_node->analyzed = true; | 350 varpool_first_unanalyzed_node->analyzed = true; |
330 | 351 |
331 varpool_first_unanalyzed_node = varpool_first_unanalyzed_node->next_needed; | 352 varpool_first_unanalyzed_node = varpool_first_unanalyzed_node->next_needed; |
332 | 353 |
333 /* Compute the alignment early so function body expanders are | 354 /* When reading back varpool at LTO time, we re-construct the queue in order |
334 already informed about increased alignment. */ | 355 to have "needed" list right by inserting all needed nodes into varpool. |
335 align_variable (decl, 0); | 356 We however don't want to re-analyze already analyzed nodes. */ |
336 | 357 if (!analyzed) |
358 { | |
359 gcc_assert (!in_lto_p); | |
360 /* Compute the alignment early so function body expanders are | |
361 already informed about increased alignment. */ | |
362 align_variable (decl, 0); | |
363 } | |
337 if (DECL_INITIAL (decl)) | 364 if (DECL_INITIAL (decl)) |
338 record_references_in_initializer (decl); | 365 record_references_in_initializer (decl, analyzed); |
339 changed = true; | 366 changed = true; |
340 } | 367 } |
341 timevar_pop (TV_CGRAPH); | 368 timevar_pop (TV_CGRAPH); |
342 return changed; | 369 return changed; |
343 } | 370 } |