Daily bump.
[official-gcc.git] / gcc / varpool.c
blobac7abc1be86b10491844a6b4cfa4cb23ed8738eb
1 /* Callgraph handling code.
2 Copyright (C) 2003-2014 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
10 version.
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
15 for more details.
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/>. */
21 #include "config.h"
22 #include "system.h"
23 #include "coretypes.h"
24 #include "tm.h"
25 #include "tree.h"
26 #include "varasm.h"
27 #include "predict.h"
28 #include "basic-block.h"
29 #include "hash-map.h"
30 #include "is-a.h"
31 #include "plugin-api.h"
32 #include "vec.h"
33 #include "hashtab.h"
34 #include "hash-set.h"
35 #include "machmode.h"
36 #include "hard-reg-set.h"
37 #include "input.h"
38 #include "function.h"
39 #include "ipa-ref.h"
40 #include "cgraph.h"
41 #include "langhooks.h"
42 #include "diagnostic-core.h"
43 #include "timevar.h"
44 #include "debug.h"
45 #include "target.h"
46 #include "output.h"
47 #include "gimple-expr.h"
48 #include "flags.h"
49 #include "tree-ssa-alias.h"
50 #include "gimple.h"
51 #include "lto-streamer.h"
53 const char * const tls_model_names[]={"none", "tls-emulated", "tls-real",
54 "tls-global-dynamic", "tls-local-dynamic",
55 "tls-initial-exec", "tls-local-exec"};
57 /* List of hooks triggered on varpool_node events. */
58 struct varpool_node_hook_list {
59 varpool_node_hook hook;
60 void *data;
61 struct varpool_node_hook_list *next;
64 /* Register HOOK to be called with DATA on each removed node. */
65 varpool_node_hook_list *
66 symbol_table::add_varpool_removal_hook (varpool_node_hook hook, void *data)
68 varpool_node_hook_list *entry;
69 varpool_node_hook_list **ptr = &m_first_varpool_removal_hook;
71 entry = (varpool_node_hook_list *) xmalloc (sizeof (*entry));
72 entry->hook = hook;
73 entry->data = data;
74 entry->next = NULL;
75 while (*ptr)
76 ptr = &(*ptr)->next;
77 *ptr = entry;
78 return entry;
81 /* Remove ENTRY from the list of hooks called on removing nodes. */
82 void
83 symbol_table::remove_varpool_removal_hook (varpool_node_hook_list *entry)
85 varpool_node_hook_list **ptr = &m_first_varpool_removal_hook;
87 while (*ptr != entry)
88 ptr = &(*ptr)->next;
89 *ptr = entry->next;
90 free (entry);
93 /* Call all node removal hooks. */
94 void
95 symbol_table::call_varpool_removal_hooks (varpool_node *node)
97 varpool_node_hook_list *entry = m_first_varpool_removal_hook;
98 while (entry)
100 entry->hook (node, entry->data);
101 entry = entry->next;
105 /* Register HOOK to be called with DATA on each inserted node. */
106 varpool_node_hook_list *
107 symbol_table::add_varpool_insertion_hook (varpool_node_hook hook, void *data)
109 varpool_node_hook_list *entry;
110 varpool_node_hook_list **ptr = &m_first_varpool_insertion_hook;
112 entry = (varpool_node_hook_list *) xmalloc (sizeof (*entry));
113 entry->hook = hook;
114 entry->data = data;
115 entry->next = NULL;
116 while (*ptr)
117 ptr = &(*ptr)->next;
118 *ptr = entry;
119 return entry;
122 /* Remove ENTRY from the list of hooks called on inserted nodes. */
123 void
124 symbol_table::remove_varpool_insertion_hook (varpool_node_hook_list *entry)
126 varpool_node_hook_list **ptr = &m_first_varpool_insertion_hook;
128 while (*ptr != entry)
129 ptr = &(*ptr)->next;
130 *ptr = entry->next;
131 free (entry);
134 /* Call all node insertion hooks. */
135 void
136 symbol_table::call_varpool_insertion_hooks (varpool_node *node)
138 varpool_node_hook_list *entry = m_first_varpool_insertion_hook;
139 while (entry)
141 entry->hook (node, entry->data);
142 entry = entry->next;
146 /* Allocate new callgraph node and insert it into basic data structures. */
148 varpool_node *
149 varpool_node::create_empty (void)
151 varpool_node *node = ggc_cleared_alloc<varpool_node> ();
152 node->type = SYMTAB_VARIABLE;
153 return node;
156 /* Return varpool node assigned to DECL. Create new one when needed. */
157 varpool_node *
158 varpool_node::get_create (tree decl)
160 varpool_node *node = varpool_node::get (decl);
161 gcc_checking_assert (TREE_CODE (decl) == VAR_DECL);
162 if (node)
163 return node;
165 node = varpool_node::create_empty ();
166 node->decl = decl;
167 node->register_symbol ();
168 return node;
171 /* Remove variable from symbol table. */
173 void
174 varpool_node::remove (void)
176 symtab->call_varpool_removal_hooks (this);
177 unregister ();
179 /* When streaming we can have multiple nodes associated with decl. */
180 if (symtab->state == LTO_STREAMING)
182 /* Keep constructor when it may be used for folding. We remove
183 references to external variables before final compilation. */
184 else if (DECL_INITIAL (decl) && DECL_INITIAL (decl) != error_mark_node
185 && !ctor_useable_for_folding_p ())
186 remove_initializer ();
187 ggc_free (this);
190 /* Remove node initializer when it is no longer needed. */
191 void
192 varpool_node::remove_initializer (void)
194 if (DECL_INITIAL (decl)
195 && !DECL_IN_CONSTANT_POOL (decl)
196 /* Keep vtables for BINFO folding. */
197 && !DECL_VIRTUAL_P (decl)
198 /* FIXME: http://gcc.gnu.org/PR55395 */
199 && debug_info_level == DINFO_LEVEL_NONE
200 /* When doing declaration merging we have duplicate
201 entries for given decl. Do not attempt to remove
202 the boides, or we will end up remiving
203 wrong one. */
204 && symtab->state != LTO_STREAMING)
205 DECL_INITIAL (decl) = error_mark_node;
208 /* Dump given varpool node to F. */
209 void
210 varpool_node::dump (FILE *f)
212 dump_base (f);
213 fprintf (f, " Availability: %s\n",
214 symtab->function_flags_ready
215 ? cgraph_availability_names[get_availability ()]
216 : "not-ready");
217 fprintf (f, " Varpool flags:");
218 if (DECL_INITIAL (decl))
219 fprintf (f, " initialized");
220 if (output)
221 fprintf (f, " output");
222 if (used_by_single_function)
223 fprintf (f, " used-by-single-function");
224 if (need_bounds_init)
225 fprintf (f, " need-bounds-init");
226 if (TREE_READONLY (decl))
227 fprintf (f, " read-only");
228 if (ctor_useable_for_folding_p ())
229 fprintf (f, " const-value-known");
230 if (writeonly)
231 fprintf (f, " write-only");
232 if (tls_model)
233 fprintf (f, " %s", tls_model_names [tls_model]);
234 fprintf (f, "\n");
238 /* Dump given varpool node to stderr. */
239 void varpool_node::debug (void)
241 varpool_node::dump (stderr);
244 /* Dump the variable pool to F. */
245 void
246 varpool_node::dump_varpool (FILE *f)
248 varpool_node *node;
250 fprintf (f, "variable pool:\n\n");
251 FOR_EACH_VARIABLE (node)
252 node->dump (f);
255 /* Dump the variable pool to stderr. */
257 DEBUG_FUNCTION void
258 varpool_node::debug_varpool (void)
260 dump_varpool (stderr);
263 /* Given an assembler name, lookup node. */
264 varpool_node *
265 varpool_node::get_for_asmname (tree asmname)
267 if (symtab_node *node = symtab_node::get_for_asmname (asmname))
268 return dyn_cast <varpool_node *> (node);
269 else
270 return NULL;
273 /* When doing LTO, read variable's constructor from disk if
274 it is not already present. */
276 tree
277 varpool_node::get_constructor (void)
279 lto_file_decl_data *file_data;
280 const char *data, *name;
281 size_t len;
283 if (DECL_INITIAL (decl) != error_mark_node
284 || !in_lto_p)
285 return DECL_INITIAL (decl);
287 timevar_push (TV_IPA_LTO_CTORS_IN);
289 file_data = lto_file_data;
290 name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
292 /* We may have renamed the declaration, e.g., a static function. */
293 name = lto_get_decl_name_mapping (file_data, name);
295 data = lto_get_section_data (file_data, LTO_section_function_body,
296 name, &len);
297 if (!data)
298 fatal_error ("%s: section %s is missing",
299 file_data->file_name,
300 name);
302 lto_input_variable_constructor (file_data, this, data);
303 lto_stats.num_function_bodies++;
304 lto_free_section_data (file_data, LTO_section_function_body, name,
305 data, len);
306 lto_free_function_in_decl_state_for_node (this);
307 timevar_pop (TV_IPA_LTO_CTORS_IN);
308 return DECL_INITIAL (decl);
311 /* Return true if variable has constructor that can be used for folding. */
313 bool
314 varpool_node::ctor_useable_for_folding_p (void)
316 varpool_node *real_node = this;
318 if (real_node->alias && real_node->definition)
319 real_node = ultimate_alias_target ();
321 if (TREE_CODE (decl) == CONST_DECL
322 || DECL_IN_CONSTANT_POOL (decl))
323 return true;
324 if (TREE_THIS_VOLATILE (decl))
325 return false;
327 /* If we do not have a constructor, we can't use it. */
328 if (DECL_INITIAL (real_node->decl) == error_mark_node
329 && !real_node->lto_file_data)
330 return false;
332 /* Avoid attempts to load constructors that was not streamed. */
333 if (flag_ltrans && DECL_INITIAL (real_node->decl) == error_mark_node
334 && real_node->body_removed)
335 return false;
337 /* Vtables are defined by their types and must match no matter of interposition
338 rules. */
339 if (DECL_VIRTUAL_P (decl))
341 /* The C++ front end creates VAR_DECLs for vtables of typeinfo
342 classes not defined in the current TU so that it can refer
343 to them from typeinfo objects. Avoid returning NULL_TREE. */
344 return DECL_INITIAL (real_node->decl) != NULL;
347 /* Alias of readonly variable is also readonly, since the variable is stored
348 in readonly memory. We also accept readonly aliases of non-readonly
349 locations assuming that user knows what he is asking for. */
350 if (!TREE_READONLY (decl) && !TREE_READONLY (real_node->decl))
351 return false;
353 /* Variables declared 'const' without an initializer
354 have zero as the initializer if they may not be
355 overridden at link or run time.
357 It is actually requirement for C++ compiler to optimize const variables
358 consistently. As a GNU extension, do not enfore this rule for user defined
359 weak variables, so we support interposition on:
360 static const int dummy = 0;
361 extern const int foo __attribute__((__weak__, __alias__("dummy")));
363 if ((!DECL_INITIAL (real_node->decl)
364 || (DECL_WEAK (decl) && !DECL_COMDAT (decl)))
365 && (DECL_EXTERNAL (decl) || decl_replaceable_p (decl)))
366 return false;
368 /* Variables declared `const' with an initializer are considered
369 to not be overwritable with different initializer by default.
371 ??? Previously we behaved so for scalar variables but not for array
372 accesses. */
373 return true;
376 /* If DECLARATION is constant variable and its initial value is known
377 (so we can do constant folding), return its constructor (DECL_INITIAL).
378 This may be an expression or NULL when DECL is initialized to 0.
379 Return ERROR_MARK_NODE otherwise.
381 In LTO this may actually trigger reading the constructor from disk.
382 For this reason varpool_ctor_useable_for_folding_p should be used when
383 the actual constructor value is not needed. */
385 tree
386 ctor_for_folding (tree decl)
388 varpool_node *node, *real_node;
389 tree real_decl;
391 if (TREE_CODE (decl) != VAR_DECL
392 && TREE_CODE (decl) != CONST_DECL)
393 return error_mark_node;
395 /* Static constant bounds are created to be
396 used instead of constants and therefore
397 do not let folding it. */
398 if (POINTER_BOUNDS_P (decl))
399 return error_mark_node;
401 if (TREE_CODE (decl) == CONST_DECL
402 || DECL_IN_CONSTANT_POOL (decl))
403 return DECL_INITIAL (decl);
405 if (TREE_THIS_VOLATILE (decl))
406 return error_mark_node;
408 /* Do not care about automatic variables. Those are never initialized
409 anyway, because gimplifier exapnds the code. */
410 if (!TREE_STATIC (decl) && !DECL_EXTERNAL (decl))
412 gcc_assert (!TREE_PUBLIC (decl));
413 return error_mark_node;
416 gcc_assert (TREE_CODE (decl) == VAR_DECL);
418 real_node = node = varpool_node::get (decl);
419 if (node)
421 real_node = node->ultimate_alias_target ();
422 real_decl = real_node->decl;
424 else
425 real_decl = decl;
427 /* See if we are dealing with alias.
428 In most cases alias is just alternative symbol pointing to a given
429 constructor. This allows us to use interposition rules of DECL
430 constructor of REAL_NODE. However weakrefs are special by being just
431 alternative name of their target (if defined). */
432 if (decl != real_decl)
434 gcc_assert (!DECL_INITIAL (decl)
435 || (node->alias && node->get_alias_target () == real_node)
436 || DECL_INITIAL (decl) == error_mark_node);
437 if (node->weakref)
439 node = node->get_alias_target ();
440 decl = node->decl;
444 if ((!DECL_VIRTUAL_P (real_decl)
445 || DECL_INITIAL (real_decl) == error_mark_node
446 || !DECL_INITIAL (real_decl))
447 && (!node || !node->ctor_useable_for_folding_p ()))
448 return error_mark_node;
450 /* OK, we can return constructor. See if we need to fetch it from disk
451 in LTO mode. */
452 if (DECL_INITIAL (real_decl) != error_mark_node
453 || !in_lto_p)
454 return DECL_INITIAL (real_decl);
455 return real_node->get_constructor ();
458 /* Add the variable DECL to the varpool.
459 Unlike finalize_decl function is intended to be used
460 by middle end and allows insertion of new variable at arbitrary point
461 of compilation. */
462 void
463 varpool_node::add (tree decl)
465 varpool_node *node;
466 varpool_node::finalize_decl (decl);
467 node = varpool_node::get_create (decl);
468 symtab->call_varpool_insertion_hooks (node);
469 if (node->externally_visible_p ())
470 node->externally_visible = true;
471 if (lookup_attribute ("no_reorder", DECL_ATTRIBUTES (decl)))
472 node->no_reorder = 1;
475 /* Return variable availability. See cgraph.h for description of individual
476 return values. */
477 enum availability
478 varpool_node::get_availability (void)
480 if (!definition)
481 return AVAIL_NOT_AVAILABLE;
482 if (!TREE_PUBLIC (decl))
483 return AVAIL_AVAILABLE;
484 if (DECL_IN_CONSTANT_POOL (decl)
485 || DECL_VIRTUAL_P (decl))
486 return AVAIL_AVAILABLE;
487 if (alias && weakref)
489 enum availability avail;
491 ultimate_alias_target (&avail)->get_availability ();
492 return avail;
494 /* If the variable can be overwritten, return OVERWRITABLE. Takes
495 care of at least one notable extension - the COMDAT variables
496 used to share template instantiations in C++. */
497 if (decl_replaceable_p (decl)
498 || DECL_EXTERNAL (decl))
499 return AVAIL_INTERPOSABLE;
500 return AVAIL_AVAILABLE;
503 void
504 varpool_node::analyze (void)
506 /* When reading back varpool at LTO time, we re-construct the queue in order
507 to have "needed" list right by inserting all needed nodes into varpool.
508 We however don't want to re-analyze already analyzed nodes. */
509 if (!analyzed)
511 gcc_assert (!in_lto_p || symtab->function_flags_ready);
512 /* Compute the alignment early so function body expanders are
513 already informed about increased alignment. */
514 align_variable (decl, 0);
516 if (alias)
517 resolve_alias (varpool_node::get (alias_target));
518 else if (DECL_INITIAL (decl))
519 record_references_in_initializer (decl, analyzed);
520 analyzed = true;
523 /* Assemble thunks and aliases associated to varpool node. */
525 void
526 varpool_node::assemble_aliases (void)
528 ipa_ref *ref;
530 FOR_EACH_ALIAS (this, ref)
532 varpool_node *alias = dyn_cast <varpool_node *> (ref->referring);
533 do_assemble_alias (alias->decl,
534 DECL_ASSEMBLER_NAME (decl));
535 alias->assemble_aliases ();
539 /* Output one variable, if necessary. Return whether we output it. */
541 bool
542 varpool_node::assemble_decl (void)
544 /* Aliases are outout when their target is produced or by
545 output_weakrefs. */
546 if (alias)
547 return false;
549 /* Constant pool is output from RTL land when the reference
550 survive till this level. */
551 if (DECL_IN_CONSTANT_POOL (decl) && TREE_ASM_WRITTEN (decl))
552 return false;
554 /* Decls with VALUE_EXPR should not be in the varpool at all. They
555 are not real variables, but just info for debugging and codegen.
556 Unfortunately at the moment emutls is not updating varpool correctly
557 after turning real vars into value_expr vars. */
558 if (DECL_HAS_VALUE_EXPR_P (decl)
559 && !targetm.have_tls)
560 return false;
562 /* Hard register vars do not need to be output. */
563 if (DECL_HARD_REGISTER (decl))
564 return false;
566 gcc_checking_assert (!TREE_ASM_WRITTEN (decl)
567 && TREE_CODE (decl) == VAR_DECL
568 && !DECL_HAS_VALUE_EXPR_P (decl));
570 if (!in_other_partition
571 && !DECL_EXTERNAL (decl))
573 get_constructor ();
574 assemble_variable (decl, 0, 1, 0);
575 gcc_assert (TREE_ASM_WRITTEN (decl));
576 gcc_assert (definition);
577 assemble_aliases ();
578 return true;
581 return false;
584 /* Add NODE to queue starting at FIRST.
585 The queue is linked via AUX pointers and terminated by pointer to 1. */
587 static void
588 enqueue_node (varpool_node *node, varpool_node **first)
590 if (node->aux)
591 return;
592 gcc_checking_assert (*first);
593 node->aux = *first;
594 *first = node;
597 /* Optimization of function bodies might've rendered some variables as
598 unnecessary so we want to avoid these from being compiled. Re-do
599 reachability starting from variables that are either externally visible
600 or was referred from the asm output routines. */
602 void
603 symbol_table::remove_unreferenced_decls (void)
605 varpool_node *next, *node;
606 varpool_node *first = (varpool_node *)(void *)1;
607 int i;
608 ipa_ref *ref = NULL;
609 hash_set<varpool_node *> referenced;
611 if (seen_error ())
612 return;
614 if (dump_file)
615 fprintf (dump_file, "Trivially needed variables:");
616 FOR_EACH_DEFINED_VARIABLE (node)
618 if (node->analyzed
619 && (!node->can_remove_if_no_refs_p ()
620 /* We just expanded all function bodies. See if any of
621 them needed the variable. */
622 || DECL_RTL_SET_P (node->decl)))
624 enqueue_node (node, &first);
625 if (dump_file)
626 fprintf (dump_file, " %s", node->asm_name ());
629 while (first != (varpool_node *)(void *)1)
631 node = first;
632 first = (varpool_node *)first->aux;
634 if (node->same_comdat_group)
636 symtab_node *next;
637 for (next = node->same_comdat_group;
638 next != node;
639 next = next->same_comdat_group)
641 varpool_node *vnext = dyn_cast <varpool_node *> (next);
642 if (vnext && vnext->analyzed && !next->comdat_local_p ())
643 enqueue_node (vnext, &first);
646 for (i = 0; node->iterate_reference (i, ref); i++)
648 varpool_node *vnode = dyn_cast <varpool_node *> (ref->referred);
649 if (vnode
650 && !vnode->in_other_partition
651 && (!DECL_EXTERNAL (ref->referred->decl)
652 || vnode->alias)
653 && vnode->analyzed)
654 enqueue_node (vnode, &first);
655 else
656 referenced.add (node);
659 if (dump_file)
660 fprintf (dump_file, "\nRemoving variables:");
661 for (node = first_defined_variable (); node; node = next)
663 next = next_defined_variable (node);
664 if (!node->aux && !node->no_reorder)
666 if (dump_file)
667 fprintf (dump_file, " %s", node->asm_name ());
668 if (referenced.contains(node))
669 node->remove_initializer ();
670 else
671 node->remove ();
675 if (dump_file)
676 fprintf (dump_file, "\n");
679 /* For variables in named sections make sure get_variable_section
680 is called before we switch to those sections. Then section
681 conflicts between read-only and read-only requiring relocations
682 sections can be resolved. */
683 void
684 varpool_node::finalize_named_section_flags (void)
686 if (!TREE_ASM_WRITTEN (decl)
687 && !alias
688 && !in_other_partition
689 && !DECL_EXTERNAL (decl)
690 && TREE_CODE (decl) == VAR_DECL
691 && !DECL_HAS_VALUE_EXPR_P (decl)
692 && get_section ())
693 get_variable_section (decl, false);
696 /* Output all variables enqueued to be assembled. */
697 bool
698 symbol_table::output_variables (void)
700 bool changed = false;
701 varpool_node *node;
703 if (seen_error ())
704 return false;
706 remove_unreferenced_decls ();
708 timevar_push (TV_VAROUT);
710 FOR_EACH_VARIABLE (node)
711 if (!node->definition)
712 assemble_undefined_decl (node->decl);
713 FOR_EACH_DEFINED_VARIABLE (node)
715 /* Handled in output_in_order. */
716 if (node->no_reorder)
717 continue;
719 node->finalize_named_section_flags ();
722 FOR_EACH_DEFINED_VARIABLE (node)
724 /* Handled in output_in_order. */
725 if (node->no_reorder)
726 continue;
727 if (node->assemble_decl ())
728 changed = true;
730 timevar_pop (TV_VAROUT);
731 return changed;
734 /* Create a new global variable of type TYPE. */
735 tree
736 add_new_static_var (tree type)
738 tree new_decl;
739 varpool_node *new_node;
741 new_decl = create_tmp_var_raw (type, NULL);
742 DECL_NAME (new_decl) = create_tmp_var_name (NULL);
743 TREE_READONLY (new_decl) = 0;
744 TREE_STATIC (new_decl) = 1;
745 TREE_USED (new_decl) = 1;
746 DECL_CONTEXT (new_decl) = NULL_TREE;
747 DECL_ABSTRACT_P (new_decl) = false;
748 lang_hooks.dup_lang_specific_decl (new_decl);
749 new_node = varpool_node::get_create (new_decl);
750 varpool_node::finalize_decl (new_decl);
752 return new_node->decl;
755 /* Attempt to mark ALIAS as an alias to DECL. Return TRUE if successful.
756 Extra name aliases are output whenever DECL is output. */
758 varpool_node *
759 varpool_node::create_alias (tree alias, tree decl)
761 varpool_node *alias_node;
763 gcc_assert (TREE_CODE (decl) == VAR_DECL);
764 gcc_assert (TREE_CODE (alias) == VAR_DECL);
765 alias_node = varpool_node::get_create (alias);
766 alias_node->alias = true;
767 alias_node->definition = true;
768 alias_node->alias_target = decl;
769 if (lookup_attribute ("weakref", DECL_ATTRIBUTES (alias)) != NULL)
770 alias_node->weakref = true;
771 return alias_node;
774 /* Attempt to mark ALIAS as an alias to DECL. Return TRUE if successful.
775 Extra name aliases are output whenever DECL is output. */
777 varpool_node *
778 varpool_node::create_extra_name_alias (tree alias, tree decl)
780 varpool_node *alias_node;
782 #ifndef ASM_OUTPUT_DEF
783 /* If aliases aren't supported by the assembler, fail. */
784 return NULL;
785 #endif
786 alias_node = varpool_node::create_alias (alias, decl);
787 alias_node->cpp_implicit_alias = true;
789 /* Extra name alias mechanizm creates aliases really late
790 via DECL_ASSEMBLER_NAME mechanizm.
791 This is unfortunate because they are not going through the
792 standard channels. Ensure they get output. */
793 if (symtab->cpp_implicit_aliases_done)
794 alias_node->resolve_alias (varpool_node::get_create (decl));
795 return alias_node;
798 /* Call calback on varpool symbol and aliases associated to varpool symbol.
799 When INCLUDE_OVERWRITABLE is false, overwritable aliases and thunks are
800 skipped. */
802 bool
803 varpool_node::call_for_node_and_aliases (bool (*callback) (varpool_node *,
804 void *),
805 void *data,
806 bool include_overwritable)
808 ipa_ref *ref;
810 if (callback (this, data))
811 return true;
813 FOR_EACH_ALIAS (this, ref)
815 varpool_node *alias = dyn_cast <varpool_node *> (ref->referring);
816 if (include_overwritable
817 || alias->get_availability () > AVAIL_INTERPOSABLE)
818 if (alias->call_for_node_and_aliases (callback, data,
819 include_overwritable))
820 return true;
822 return false;