svn merge -r 217483:217500 svn+ssh://gcc.gnu.org/svn/gcc/trunk
[official-gcc.git] / gcc / varpool.c
bloba697490d9cad53ec95c98795fc3b44b588b342d6
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"
52 #include "context.h"
53 #include "omp-low.h"
55 const char * const tls_model_names[]={"none", "tls-emulated", "tls-real",
56 "tls-global-dynamic", "tls-local-dynamic",
57 "tls-initial-exec", "tls-local-exec"};
59 /* List of hooks triggered on varpool_node events. */
60 struct varpool_node_hook_list {
61 varpool_node_hook hook;
62 void *data;
63 struct varpool_node_hook_list *next;
66 /* Register HOOK to be called with DATA on each removed node. */
67 varpool_node_hook_list *
68 symbol_table::add_varpool_removal_hook (varpool_node_hook hook, void *data)
70 varpool_node_hook_list *entry;
71 varpool_node_hook_list **ptr = &m_first_varpool_removal_hook;
73 entry = (varpool_node_hook_list *) xmalloc (sizeof (*entry));
74 entry->hook = hook;
75 entry->data = data;
76 entry->next = NULL;
77 while (*ptr)
78 ptr = &(*ptr)->next;
79 *ptr = entry;
80 return entry;
83 /* Remove ENTRY from the list of hooks called on removing nodes. */
84 void
85 symbol_table::remove_varpool_removal_hook (varpool_node_hook_list *entry)
87 varpool_node_hook_list **ptr = &m_first_varpool_removal_hook;
89 while (*ptr != entry)
90 ptr = &(*ptr)->next;
91 *ptr = entry->next;
92 free (entry);
95 /* Call all node removal hooks. */
96 void
97 symbol_table::call_varpool_removal_hooks (varpool_node *node)
99 varpool_node_hook_list *entry = m_first_varpool_removal_hook;
100 while (entry)
102 entry->hook (node, entry->data);
103 entry = entry->next;
107 /* Register HOOK to be called with DATA on each inserted node. */
108 varpool_node_hook_list *
109 symbol_table::add_varpool_insertion_hook (varpool_node_hook hook, void *data)
111 varpool_node_hook_list *entry;
112 varpool_node_hook_list **ptr = &m_first_varpool_insertion_hook;
114 entry = (varpool_node_hook_list *) xmalloc (sizeof (*entry));
115 entry->hook = hook;
116 entry->data = data;
117 entry->next = NULL;
118 while (*ptr)
119 ptr = &(*ptr)->next;
120 *ptr = entry;
121 return entry;
124 /* Remove ENTRY from the list of hooks called on inserted nodes. */
125 void
126 symbol_table::remove_varpool_insertion_hook (varpool_node_hook_list *entry)
128 varpool_node_hook_list **ptr = &m_first_varpool_insertion_hook;
130 while (*ptr != entry)
131 ptr = &(*ptr)->next;
132 *ptr = entry->next;
133 free (entry);
136 /* Call all node insertion hooks. */
137 void
138 symbol_table::call_varpool_insertion_hooks (varpool_node *node)
140 varpool_node_hook_list *entry = m_first_varpool_insertion_hook;
141 while (entry)
143 entry->hook (node, entry->data);
144 entry = entry->next;
148 /* Allocate new callgraph node and insert it into basic data structures. */
150 varpool_node *
151 varpool_node::create_empty (void)
153 varpool_node *node = ggc_cleared_alloc<varpool_node> ();
154 node->type = SYMTAB_VARIABLE;
155 return node;
158 /* Return varpool node assigned to DECL. Create new one when needed. */
159 varpool_node *
160 varpool_node::get_create (tree decl)
162 varpool_node *node = varpool_node::get (decl);
163 gcc_checking_assert (TREE_CODE (decl) == VAR_DECL);
164 if (node)
165 return node;
167 node = varpool_node::create_empty ();
168 node->decl = decl;
170 if ((flag_openacc || flag_openmp)
171 && lookup_attribute ("omp declare target", DECL_ATTRIBUTES (decl)))
173 node->offloadable = 1;
174 g->have_offload = true;
175 if (!in_lto_p)
176 vec_safe_push (offload_vars, decl);
179 node->register_symbol ();
180 return node;
183 /* Remove variable from symbol table. */
185 void
186 varpool_node::remove (void)
188 symtab->call_varpool_removal_hooks (this);
189 unregister ();
191 /* When streaming we can have multiple nodes associated with decl. */
192 if (symtab->state == LTO_STREAMING)
194 /* Keep constructor when it may be used for folding. We remove
195 references to external variables before final compilation. */
196 else if (DECL_INITIAL (decl) && DECL_INITIAL (decl) != error_mark_node
197 && !ctor_useable_for_folding_p ())
198 remove_initializer ();
199 ggc_free (this);
202 /* Remove node initializer when it is no longer needed. */
203 void
204 varpool_node::remove_initializer (void)
206 if (DECL_INITIAL (decl)
207 && !DECL_IN_CONSTANT_POOL (decl)
208 /* Keep vtables for BINFO folding. */
209 && !DECL_VIRTUAL_P (decl)
210 /* FIXME: http://gcc.gnu.org/PR55395 */
211 && debug_info_level == DINFO_LEVEL_NONE
212 /* When doing declaration merging we have duplicate
213 entries for given decl. Do not attempt to remove
214 the boides, or we will end up remiving
215 wrong one. */
216 && symtab->state != LTO_STREAMING)
217 DECL_INITIAL (decl) = error_mark_node;
220 /* Dump given varpool node to F. */
221 void
222 varpool_node::dump (FILE *f)
224 dump_base (f);
225 fprintf (f, " Availability: %s\n",
226 symtab->function_flags_ready
227 ? cgraph_availability_names[get_availability ()]
228 : "not-ready");
229 fprintf (f, " Varpool flags:");
230 if (DECL_INITIAL (decl))
231 fprintf (f, " initialized");
232 if (output)
233 fprintf (f, " output");
234 if (used_by_single_function)
235 fprintf (f, " used-by-single-function");
236 if (need_bounds_init)
237 fprintf (f, " need-bounds-init");
238 if (TREE_READONLY (decl))
239 fprintf (f, " read-only");
240 if (ctor_useable_for_folding_p ())
241 fprintf (f, " const-value-known");
242 if (writeonly)
243 fprintf (f, " write-only");
244 if (tls_model)
245 fprintf (f, " %s", tls_model_names [tls_model]);
246 fprintf (f, "\n");
250 /* Dump given varpool node to stderr. */
251 void varpool_node::debug (void)
253 varpool_node::dump (stderr);
256 /* Dump the variable pool to F. */
257 void
258 varpool_node::dump_varpool (FILE *f)
260 varpool_node *node;
262 fprintf (f, "variable pool:\n\n");
263 FOR_EACH_VARIABLE (node)
264 node->dump (f);
267 /* Dump the variable pool to stderr. */
269 DEBUG_FUNCTION void
270 varpool_node::debug_varpool (void)
272 dump_varpool (stderr);
275 /* Given an assembler name, lookup node. */
276 varpool_node *
277 varpool_node::get_for_asmname (tree asmname)
279 if (symtab_node *node = symtab_node::get_for_asmname (asmname))
280 return dyn_cast <varpool_node *> (node);
281 else
282 return NULL;
285 /* When doing LTO, read variable's constructor from disk if
286 it is not already present. */
288 tree
289 varpool_node::get_constructor (void)
291 lto_file_decl_data *file_data;
292 const char *data, *name;
293 size_t len;
295 if (DECL_INITIAL (decl) != error_mark_node
296 || !in_lto_p)
297 return DECL_INITIAL (decl);
299 timevar_push (TV_IPA_LTO_CTORS_IN);
301 file_data = lto_file_data;
302 name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
304 /* We may have renamed the declaration, e.g., a static function. */
305 name = lto_get_decl_name_mapping (file_data, name);
307 data = lto_get_section_data (file_data, LTO_section_function_body,
308 name, &len);
309 if (!data)
310 fatal_error ("%s: section %s is missing",
311 file_data->file_name,
312 name);
314 lto_input_variable_constructor (file_data, this, data);
315 lto_stats.num_function_bodies++;
316 lto_free_section_data (file_data, LTO_section_function_body, name,
317 data, len);
318 lto_free_function_in_decl_state_for_node (this);
319 timevar_pop (TV_IPA_LTO_CTORS_IN);
320 return DECL_INITIAL (decl);
323 /* Return true if variable has constructor that can be used for folding. */
325 bool
326 varpool_node::ctor_useable_for_folding_p (void)
328 varpool_node *real_node = this;
330 if (real_node->alias && real_node->definition)
331 real_node = ultimate_alias_target ();
333 if (TREE_CODE (decl) == CONST_DECL
334 || DECL_IN_CONSTANT_POOL (decl))
335 return true;
336 if (TREE_THIS_VOLATILE (decl))
337 return false;
339 /* If we do not have a constructor, we can't use it. */
340 if (DECL_INITIAL (real_node->decl) == error_mark_node
341 && !real_node->lto_file_data)
342 return false;
344 /* Avoid attempts to load constructors that was not streamed. */
345 if (flag_ltrans && DECL_INITIAL (real_node->decl) == error_mark_node
346 && real_node->body_removed)
347 return false;
349 /* Vtables are defined by their types and must match no matter of interposition
350 rules. */
351 if (DECL_VIRTUAL_P (decl))
353 /* The C++ front end creates VAR_DECLs for vtables of typeinfo
354 classes not defined in the current TU so that it can refer
355 to them from typeinfo objects. Avoid returning NULL_TREE. */
356 return DECL_INITIAL (real_node->decl) != NULL;
359 /* Alias of readonly variable is also readonly, since the variable is stored
360 in readonly memory. We also accept readonly aliases of non-readonly
361 locations assuming that user knows what he is asking for. */
362 if (!TREE_READONLY (decl) && !TREE_READONLY (real_node->decl))
363 return false;
365 /* Variables declared 'const' without an initializer
366 have zero as the initializer if they may not be
367 overridden at link or run time.
369 It is actually requirement for C++ compiler to optimize const variables
370 consistently. As a GNU extension, do not enfore this rule for user defined
371 weak variables, so we support interposition on:
372 static const int dummy = 0;
373 extern const int foo __attribute__((__weak__, __alias__("dummy")));
375 if ((!DECL_INITIAL (real_node->decl)
376 || (DECL_WEAK (decl) && !DECL_COMDAT (decl)))
377 && (DECL_EXTERNAL (decl) || decl_replaceable_p (decl)))
378 return false;
380 /* Variables declared `const' with an initializer are considered
381 to not be overwritable with different initializer by default.
383 ??? Previously we behaved so for scalar variables but not for array
384 accesses. */
385 return true;
388 /* If DECLARATION is constant variable and its initial value is known
389 (so we can do constant folding), return its constructor (DECL_INITIAL).
390 This may be an expression or NULL when DECL is initialized to 0.
391 Return ERROR_MARK_NODE otherwise.
393 In LTO this may actually trigger reading the constructor from disk.
394 For this reason varpool_ctor_useable_for_folding_p should be used when
395 the actual constructor value is not needed. */
397 tree
398 ctor_for_folding (tree decl)
400 varpool_node *node, *real_node;
401 tree real_decl;
403 if (TREE_CODE (decl) != VAR_DECL
404 && TREE_CODE (decl) != CONST_DECL)
405 return error_mark_node;
407 /* Static constant bounds are created to be
408 used instead of constants and therefore
409 do not let folding it. */
410 if (POINTER_BOUNDS_P (decl))
411 return error_mark_node;
413 if (TREE_CODE (decl) == CONST_DECL
414 || DECL_IN_CONSTANT_POOL (decl))
415 return DECL_INITIAL (decl);
417 if (TREE_THIS_VOLATILE (decl))
418 return error_mark_node;
420 /* Do not care about automatic variables. Those are never initialized
421 anyway, because gimplifier exapnds the code. */
422 if (!TREE_STATIC (decl) && !DECL_EXTERNAL (decl))
424 gcc_assert (!TREE_PUBLIC (decl));
425 return error_mark_node;
428 gcc_assert (TREE_CODE (decl) == VAR_DECL);
430 real_node = node = varpool_node::get (decl);
431 if (node)
433 real_node = node->ultimate_alias_target ();
434 real_decl = real_node->decl;
436 else
437 real_decl = decl;
439 /* See if we are dealing with alias.
440 In most cases alias is just alternative symbol pointing to a given
441 constructor. This allows us to use interposition rules of DECL
442 constructor of REAL_NODE. However weakrefs are special by being just
443 alternative name of their target (if defined). */
444 if (decl != real_decl)
446 gcc_assert (!DECL_INITIAL (decl)
447 || (node->alias && node->get_alias_target () == real_node)
448 || DECL_INITIAL (decl) == error_mark_node);
449 if (node->weakref)
451 node = node->get_alias_target ();
452 decl = node->decl;
456 if ((!DECL_VIRTUAL_P (real_decl)
457 || DECL_INITIAL (real_decl) == error_mark_node
458 || !DECL_INITIAL (real_decl))
459 && (!node || !node->ctor_useable_for_folding_p ()))
460 return error_mark_node;
462 /* OK, we can return constructor. See if we need to fetch it from disk
463 in LTO mode. */
464 if (DECL_INITIAL (real_decl) != error_mark_node
465 || !in_lto_p)
466 return DECL_INITIAL (real_decl);
467 return real_node->get_constructor ();
470 /* Add the variable DECL to the varpool.
471 Unlike finalize_decl function is intended to be used
472 by middle end and allows insertion of new variable at arbitrary point
473 of compilation. */
474 void
475 varpool_node::add (tree decl)
477 varpool_node *node;
478 varpool_node::finalize_decl (decl);
479 node = varpool_node::get_create (decl);
480 symtab->call_varpool_insertion_hooks (node);
481 if (node->externally_visible_p ())
482 node->externally_visible = true;
483 if (lookup_attribute ("no_reorder", DECL_ATTRIBUTES (decl)))
484 node->no_reorder = 1;
487 /* Return variable availability. See cgraph.h for description of individual
488 return values. */
489 enum availability
490 varpool_node::get_availability (void)
492 if (!definition)
493 return AVAIL_NOT_AVAILABLE;
494 if (!TREE_PUBLIC (decl))
495 return AVAIL_AVAILABLE;
496 if (DECL_IN_CONSTANT_POOL (decl)
497 || DECL_VIRTUAL_P (decl))
498 return AVAIL_AVAILABLE;
499 if (alias && weakref)
501 enum availability avail;
503 ultimate_alias_target (&avail)->get_availability ();
504 return avail;
506 /* If the variable can be overwritten, return OVERWRITABLE. Takes
507 care of at least one notable extension - the COMDAT variables
508 used to share template instantiations in C++. */
509 if (decl_replaceable_p (decl)
510 || DECL_EXTERNAL (decl))
511 return AVAIL_INTERPOSABLE;
512 return AVAIL_AVAILABLE;
515 void
516 varpool_node::analyze (void)
518 /* When reading back varpool at LTO time, we re-construct the queue in order
519 to have "needed" list right by inserting all needed nodes into varpool.
520 We however don't want to re-analyze already analyzed nodes. */
521 if (!analyzed)
523 gcc_assert (!in_lto_p || symtab->function_flags_ready);
524 /* Compute the alignment early so function body expanders are
525 already informed about increased alignment. */
526 align_variable (decl, 0);
528 if (alias)
529 resolve_alias (varpool_node::get (alias_target));
530 else if (DECL_INITIAL (decl))
531 record_references_in_initializer (decl, analyzed);
532 analyzed = true;
535 /* Assemble thunks and aliases associated to varpool node. */
537 void
538 varpool_node::assemble_aliases (void)
540 ipa_ref *ref;
542 FOR_EACH_ALIAS (this, ref)
544 varpool_node *alias = dyn_cast <varpool_node *> (ref->referring);
545 do_assemble_alias (alias->decl,
546 DECL_ASSEMBLER_NAME (decl));
547 alias->assemble_aliases ();
551 /* Output one variable, if necessary. Return whether we output it. */
553 bool
554 varpool_node::assemble_decl (void)
556 /* Aliases are outout when their target is produced or by
557 output_weakrefs. */
558 if (alias)
559 return false;
561 /* Constant pool is output from RTL land when the reference
562 survive till this level. */
563 if (DECL_IN_CONSTANT_POOL (decl) && TREE_ASM_WRITTEN (decl))
564 return false;
566 /* Decls with VALUE_EXPR should not be in the varpool at all. They
567 are not real variables, but just info for debugging and codegen.
568 Unfortunately at the moment emutls is not updating varpool correctly
569 after turning real vars into value_expr vars. */
570 if (DECL_HAS_VALUE_EXPR_P (decl)
571 && !targetm.have_tls)
572 return false;
574 /* Hard register vars do not need to be output. */
575 if (DECL_HARD_REGISTER (decl))
576 return false;
578 gcc_checking_assert (!TREE_ASM_WRITTEN (decl)
579 && TREE_CODE (decl) == VAR_DECL
580 && !DECL_HAS_VALUE_EXPR_P (decl));
582 if (!in_other_partition
583 && !DECL_EXTERNAL (decl))
585 get_constructor ();
586 assemble_variable (decl, 0, 1, 0);
587 gcc_assert (TREE_ASM_WRITTEN (decl));
588 gcc_assert (definition);
589 assemble_aliases ();
590 return true;
593 return false;
596 /* Add NODE to queue starting at FIRST.
597 The queue is linked via AUX pointers and terminated by pointer to 1. */
599 static void
600 enqueue_node (varpool_node *node, varpool_node **first)
602 if (node->aux)
603 return;
604 gcc_checking_assert (*first);
605 node->aux = *first;
606 *first = node;
609 /* Optimization of function bodies might've rendered some variables as
610 unnecessary so we want to avoid these from being compiled. Re-do
611 reachability starting from variables that are either externally visible
612 or was referred from the asm output routines. */
614 void
615 symbol_table::remove_unreferenced_decls (void)
617 varpool_node *next, *node;
618 varpool_node *first = (varpool_node *)(void *)1;
619 int i;
620 ipa_ref *ref = NULL;
621 hash_set<varpool_node *> referenced;
623 if (seen_error ())
624 return;
626 if (dump_file)
627 fprintf (dump_file, "Trivially needed variables:");
628 FOR_EACH_DEFINED_VARIABLE (node)
630 if (node->analyzed
631 && (!node->can_remove_if_no_refs_p ()
632 /* We just expanded all function bodies. See if any of
633 them needed the variable. */
634 || DECL_RTL_SET_P (node->decl)))
636 enqueue_node (node, &first);
637 if (dump_file)
638 fprintf (dump_file, " %s", node->asm_name ());
641 while (first != (varpool_node *)(void *)1)
643 node = first;
644 first = (varpool_node *)first->aux;
646 if (node->same_comdat_group)
648 symtab_node *next;
649 for (next = node->same_comdat_group;
650 next != node;
651 next = next->same_comdat_group)
653 varpool_node *vnext = dyn_cast <varpool_node *> (next);
654 if (vnext && vnext->analyzed && !next->comdat_local_p ())
655 enqueue_node (vnext, &first);
658 for (i = 0; node->iterate_reference (i, ref); i++)
660 varpool_node *vnode = dyn_cast <varpool_node *> (ref->referred);
661 if (vnode
662 && !vnode->in_other_partition
663 && (!DECL_EXTERNAL (ref->referred->decl)
664 || vnode->alias)
665 && vnode->analyzed)
666 enqueue_node (vnode, &first);
667 else
668 referenced.add (node);
671 if (dump_file)
672 fprintf (dump_file, "\nRemoving variables:");
673 for (node = first_defined_variable (); node; node = next)
675 next = next_defined_variable (node);
676 if (!node->aux && !node->no_reorder)
678 if (dump_file)
679 fprintf (dump_file, " %s", node->asm_name ());
680 if (referenced.contains(node))
681 node->remove_initializer ();
682 else
683 node->remove ();
687 if (dump_file)
688 fprintf (dump_file, "\n");
691 /* For variables in named sections make sure get_variable_section
692 is called before we switch to those sections. Then section
693 conflicts between read-only and read-only requiring relocations
694 sections can be resolved. */
695 void
696 varpool_node::finalize_named_section_flags (void)
698 if (!TREE_ASM_WRITTEN (decl)
699 && !alias
700 && !in_other_partition
701 && !DECL_EXTERNAL (decl)
702 && TREE_CODE (decl) == VAR_DECL
703 && !DECL_HAS_VALUE_EXPR_P (decl)
704 && get_section ())
705 get_variable_section (decl, false);
708 /* Output all variables enqueued to be assembled. */
709 bool
710 symbol_table::output_variables (void)
712 bool changed = false;
713 varpool_node *node;
715 if (seen_error ())
716 return false;
718 remove_unreferenced_decls ();
720 timevar_push (TV_VAROUT);
722 FOR_EACH_VARIABLE (node)
723 if (!node->definition)
724 assemble_undefined_decl (node->decl);
725 FOR_EACH_DEFINED_VARIABLE (node)
727 /* Handled in output_in_order. */
728 if (node->no_reorder)
729 continue;
731 node->finalize_named_section_flags ();
734 FOR_EACH_DEFINED_VARIABLE (node)
736 /* Handled in output_in_order. */
737 if (node->no_reorder)
738 continue;
739 if (node->assemble_decl ())
740 changed = true;
742 timevar_pop (TV_VAROUT);
743 return changed;
746 /* Create a new global variable of type TYPE. */
747 tree
748 add_new_static_var (tree type)
750 tree new_decl;
751 varpool_node *new_node;
753 new_decl = create_tmp_var_raw (type, NULL);
754 DECL_NAME (new_decl) = create_tmp_var_name (NULL);
755 TREE_READONLY (new_decl) = 0;
756 TREE_STATIC (new_decl) = 1;
757 TREE_USED (new_decl) = 1;
758 DECL_CONTEXT (new_decl) = NULL_TREE;
759 DECL_ABSTRACT_P (new_decl) = false;
760 lang_hooks.dup_lang_specific_decl (new_decl);
761 new_node = varpool_node::get_create (new_decl);
762 varpool_node::finalize_decl (new_decl);
764 return new_node->decl;
767 /* Attempt to mark ALIAS as an alias to DECL. Return TRUE if successful.
768 Extra name aliases are output whenever DECL is output. */
770 varpool_node *
771 varpool_node::create_alias (tree alias, tree decl)
773 varpool_node *alias_node;
775 gcc_assert (TREE_CODE (decl) == VAR_DECL);
776 gcc_assert (TREE_CODE (alias) == VAR_DECL);
777 alias_node = varpool_node::get_create (alias);
778 alias_node->alias = true;
779 alias_node->definition = true;
780 alias_node->alias_target = decl;
781 if (lookup_attribute ("weakref", DECL_ATTRIBUTES (alias)) != NULL)
782 alias_node->weakref = true;
783 return alias_node;
786 /* Attempt to mark ALIAS as an alias to DECL. Return TRUE if successful.
787 Extra name aliases are output whenever DECL is output. */
789 varpool_node *
790 varpool_node::create_extra_name_alias (tree alias, tree decl)
792 varpool_node *alias_node;
794 #ifndef ASM_OUTPUT_DEF
795 /* If aliases aren't supported by the assembler, fail. */
796 return NULL;
797 #endif
798 alias_node = varpool_node::create_alias (alias, decl);
799 alias_node->cpp_implicit_alias = true;
801 /* Extra name alias mechanizm creates aliases really late
802 via DECL_ASSEMBLER_NAME mechanizm.
803 This is unfortunate because they are not going through the
804 standard channels. Ensure they get output. */
805 if (symtab->cpp_implicit_aliases_done)
806 alias_node->resolve_alias (varpool_node::get_create (decl));
807 return alias_node;
810 /* Call calback on varpool symbol and aliases associated to varpool symbol.
811 When INCLUDE_OVERWRITABLE is false, overwritable aliases and thunks are
812 skipped. */
814 bool
815 varpool_node::call_for_node_and_aliases (bool (*callback) (varpool_node *,
816 void *),
817 void *data,
818 bool include_overwritable)
820 ipa_ref *ref;
822 if (callback (this, data))
823 return true;
825 FOR_EACH_ALIAS (this, ref)
827 varpool_node *alias = dyn_cast <varpool_node *> (ref->referring);
828 if (include_overwritable
829 || alias->get_availability () > AVAIL_INTERPOSABLE)
830 if (alias->call_for_node_and_aliases (callback, data,
831 include_overwritable))
832 return true;
834 return false;