* gcc.dg/store-motion-fgcse-sm.c (dg-final): Cleanup
[official-gcc.git] / gcc / varpool.c
blob50f2e6e755add8e69ee5886bba7fe8580f60d8e2
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_openmp
171 && lookup_attribute ("omp declare target", DECL_ATTRIBUTES (decl)))
173 node->offloadable = 1;
174 #ifdef ENABLE_OFFLOADING
175 g->have_offload = true;
176 if (!in_lto_p)
177 vec_safe_push (offload_vars, decl);
178 #endif
181 node->register_symbol ();
182 return node;
185 /* Remove variable from symbol table. */
187 void
188 varpool_node::remove (void)
190 symtab->call_varpool_removal_hooks (this);
191 unregister ();
193 /* When streaming we can have multiple nodes associated with decl. */
194 if (symtab->state == LTO_STREAMING)
196 /* Keep constructor when it may be used for folding. We remove
197 references to external variables before final compilation. */
198 else if (DECL_INITIAL (decl) && DECL_INITIAL (decl) != error_mark_node
199 && !ctor_useable_for_folding_p ())
200 remove_initializer ();
201 ggc_free (this);
204 /* Remove node initializer when it is no longer needed. */
205 void
206 varpool_node::remove_initializer (void)
208 if (DECL_INITIAL (decl)
209 && !DECL_IN_CONSTANT_POOL (decl)
210 /* Keep vtables for BINFO folding. */
211 && !DECL_VIRTUAL_P (decl)
212 /* FIXME: http://gcc.gnu.org/PR55395 */
213 && debug_info_level == DINFO_LEVEL_NONE
214 /* When doing declaration merging we have duplicate
215 entries for given decl. Do not attempt to remove
216 the boides, or we will end up remiving
217 wrong one. */
218 && symtab->state != LTO_STREAMING)
219 DECL_INITIAL (decl) = error_mark_node;
222 /* Dump given varpool node to F. */
223 void
224 varpool_node::dump (FILE *f)
226 dump_base (f);
227 fprintf (f, " Availability: %s\n",
228 symtab->function_flags_ready
229 ? cgraph_availability_names[get_availability ()]
230 : "not-ready");
231 fprintf (f, " Varpool flags:");
232 if (DECL_INITIAL (decl))
233 fprintf (f, " initialized");
234 if (output)
235 fprintf (f, " output");
236 if (used_by_single_function)
237 fprintf (f, " used-by-single-function");
238 if (need_bounds_init)
239 fprintf (f, " need-bounds-init");
240 if (TREE_READONLY (decl))
241 fprintf (f, " read-only");
242 if (ctor_useable_for_folding_p ())
243 fprintf (f, " const-value-known");
244 if (writeonly)
245 fprintf (f, " write-only");
246 if (tls_model)
247 fprintf (f, " %s", tls_model_names [tls_model]);
248 fprintf (f, "\n");
252 /* Dump given varpool node to stderr. */
253 void varpool_node::debug (void)
255 varpool_node::dump (stderr);
258 /* Dump the variable pool to F. */
259 void
260 varpool_node::dump_varpool (FILE *f)
262 varpool_node *node;
264 fprintf (f, "variable pool:\n\n");
265 FOR_EACH_VARIABLE (node)
266 node->dump (f);
269 /* Dump the variable pool to stderr. */
271 DEBUG_FUNCTION void
272 varpool_node::debug_varpool (void)
274 dump_varpool (stderr);
277 /* Given an assembler name, lookup node. */
278 varpool_node *
279 varpool_node::get_for_asmname (tree asmname)
281 if (symtab_node *node = symtab_node::get_for_asmname (asmname))
282 return dyn_cast <varpool_node *> (node);
283 else
284 return NULL;
287 /* When doing LTO, read variable's constructor from disk if
288 it is not already present. */
290 tree
291 varpool_node::get_constructor (void)
293 lto_file_decl_data *file_data;
294 const char *data, *name;
295 size_t len;
297 if (DECL_INITIAL (decl) != error_mark_node
298 || !in_lto_p)
299 return DECL_INITIAL (decl);
301 timevar_push (TV_IPA_LTO_CTORS_IN);
303 file_data = lto_file_data;
304 name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
306 /* We may have renamed the declaration, e.g., a static function. */
307 name = lto_get_decl_name_mapping (file_data, name);
309 data = lto_get_section_data (file_data, LTO_section_function_body,
310 name, &len);
311 if (!data)
312 fatal_error ("%s: section %s is missing",
313 file_data->file_name,
314 name);
316 lto_input_variable_constructor (file_data, this, data);
317 lto_stats.num_function_bodies++;
318 lto_free_section_data (file_data, LTO_section_function_body, name,
319 data, len);
320 lto_free_function_in_decl_state_for_node (this);
321 timevar_pop (TV_IPA_LTO_CTORS_IN);
322 return DECL_INITIAL (decl);
325 /* Return true if variable has constructor that can be used for folding. */
327 bool
328 varpool_node::ctor_useable_for_folding_p (void)
330 varpool_node *real_node = this;
332 if (real_node->alias && real_node->definition)
333 real_node = ultimate_alias_target ();
335 if (TREE_CODE (decl) == CONST_DECL
336 || DECL_IN_CONSTANT_POOL (decl))
337 return true;
338 if (TREE_THIS_VOLATILE (decl))
339 return false;
341 /* If we do not have a constructor, we can't use it. */
342 if (DECL_INITIAL (real_node->decl) == error_mark_node
343 && !real_node->lto_file_data)
344 return false;
346 /* Avoid attempts to load constructors that was not streamed. */
347 if (flag_ltrans && DECL_INITIAL (real_node->decl) == error_mark_node
348 && real_node->body_removed)
349 return false;
351 /* Vtables are defined by their types and must match no matter of interposition
352 rules. */
353 if (DECL_VIRTUAL_P (decl))
355 /* The C++ front end creates VAR_DECLs for vtables of typeinfo
356 classes not defined in the current TU so that it can refer
357 to them from typeinfo objects. Avoid returning NULL_TREE. */
358 return DECL_INITIAL (real_node->decl) != NULL;
361 /* Alias of readonly variable is also readonly, since the variable is stored
362 in readonly memory. We also accept readonly aliases of non-readonly
363 locations assuming that user knows what he is asking for. */
364 if (!TREE_READONLY (decl) && !TREE_READONLY (real_node->decl))
365 return false;
367 /* Variables declared 'const' without an initializer
368 have zero as the initializer if they may not be
369 overridden at link or run time.
371 It is actually requirement for C++ compiler to optimize const variables
372 consistently. As a GNU extension, do not enfore this rule for user defined
373 weak variables, so we support interposition on:
374 static const int dummy = 0;
375 extern const int foo __attribute__((__weak__, __alias__("dummy")));
377 if ((!DECL_INITIAL (real_node->decl)
378 || (DECL_WEAK (decl) && !DECL_COMDAT (decl)))
379 && (DECL_EXTERNAL (decl) || decl_replaceable_p (decl)))
380 return false;
382 /* Variables declared `const' with an initializer are considered
383 to not be overwritable with different initializer by default.
385 ??? Previously we behaved so for scalar variables but not for array
386 accesses. */
387 return true;
390 /* If DECLARATION is constant variable and its initial value is known
391 (so we can do constant folding), return its constructor (DECL_INITIAL).
392 This may be an expression or NULL when DECL is initialized to 0.
393 Return ERROR_MARK_NODE otherwise.
395 In LTO this may actually trigger reading the constructor from disk.
396 For this reason varpool_ctor_useable_for_folding_p should be used when
397 the actual constructor value is not needed. */
399 tree
400 ctor_for_folding (tree decl)
402 varpool_node *node, *real_node;
403 tree real_decl;
405 if (TREE_CODE (decl) != VAR_DECL
406 && TREE_CODE (decl) != CONST_DECL)
407 return error_mark_node;
409 /* Static constant bounds are created to be
410 used instead of constants and therefore
411 do not let folding it. */
412 if (POINTER_BOUNDS_P (decl))
413 return error_mark_node;
415 if (TREE_CODE (decl) == CONST_DECL
416 || DECL_IN_CONSTANT_POOL (decl))
417 return DECL_INITIAL (decl);
419 if (TREE_THIS_VOLATILE (decl))
420 return error_mark_node;
422 /* Do not care about automatic variables. Those are never initialized
423 anyway, because gimplifier exapnds the code. */
424 if (!TREE_STATIC (decl) && !DECL_EXTERNAL (decl))
426 gcc_assert (!TREE_PUBLIC (decl));
427 return error_mark_node;
430 gcc_assert (TREE_CODE (decl) == VAR_DECL);
432 real_node = node = varpool_node::get (decl);
433 if (node)
435 real_node = node->ultimate_alias_target ();
436 real_decl = real_node->decl;
438 else
439 real_decl = decl;
441 /* See if we are dealing with alias.
442 In most cases alias is just alternative symbol pointing to a given
443 constructor. This allows us to use interposition rules of DECL
444 constructor of REAL_NODE. However weakrefs are special by being just
445 alternative name of their target (if defined). */
446 if (decl != real_decl)
448 gcc_assert (!DECL_INITIAL (decl)
449 || (node->alias && node->get_alias_target () == real_node)
450 || DECL_INITIAL (decl) == error_mark_node);
451 if (node->weakref)
453 node = node->get_alias_target ();
454 decl = node->decl;
458 if ((!DECL_VIRTUAL_P (real_decl)
459 || DECL_INITIAL (real_decl) == error_mark_node
460 || !DECL_INITIAL (real_decl))
461 && (!node || !node->ctor_useable_for_folding_p ()))
462 return error_mark_node;
464 /* OK, we can return constructor. See if we need to fetch it from disk
465 in LTO mode. */
466 if (DECL_INITIAL (real_decl) != error_mark_node
467 || !in_lto_p)
468 return DECL_INITIAL (real_decl);
469 return real_node->get_constructor ();
472 /* Add the variable DECL to the varpool.
473 Unlike finalize_decl function is intended to be used
474 by middle end and allows insertion of new variable at arbitrary point
475 of compilation. */
476 void
477 varpool_node::add (tree decl)
479 varpool_node *node;
480 varpool_node::finalize_decl (decl);
481 node = varpool_node::get_create (decl);
482 symtab->call_varpool_insertion_hooks (node);
483 if (node->externally_visible_p ())
484 node->externally_visible = true;
485 if (lookup_attribute ("no_reorder", DECL_ATTRIBUTES (decl)))
486 node->no_reorder = 1;
489 /* Return variable availability. See cgraph.h for description of individual
490 return values. */
491 enum availability
492 varpool_node::get_availability (void)
494 if (!definition)
495 return AVAIL_NOT_AVAILABLE;
496 if (!TREE_PUBLIC (decl))
497 return AVAIL_AVAILABLE;
498 if (DECL_IN_CONSTANT_POOL (decl)
499 || DECL_VIRTUAL_P (decl))
500 return AVAIL_AVAILABLE;
501 if (alias && weakref)
503 enum availability avail;
505 ultimate_alias_target (&avail)->get_availability ();
506 return avail;
508 /* If the variable can be overwritten, return OVERWRITABLE. Takes
509 care of at least one notable extension - the COMDAT variables
510 used to share template instantiations in C++. */
511 if (decl_replaceable_p (decl)
512 || DECL_EXTERNAL (decl))
513 return AVAIL_INTERPOSABLE;
514 return AVAIL_AVAILABLE;
517 void
518 varpool_node::analyze (void)
520 /* When reading back varpool at LTO time, we re-construct the queue in order
521 to have "needed" list right by inserting all needed nodes into varpool.
522 We however don't want to re-analyze already analyzed nodes. */
523 if (!analyzed)
525 gcc_assert (!in_lto_p || symtab->function_flags_ready);
526 /* Compute the alignment early so function body expanders are
527 already informed about increased alignment. */
528 align_variable (decl, 0);
530 if (alias)
531 resolve_alias (varpool_node::get (alias_target));
532 else if (DECL_INITIAL (decl))
533 record_references_in_initializer (decl, analyzed);
534 analyzed = true;
537 /* Assemble thunks and aliases associated to varpool node. */
539 void
540 varpool_node::assemble_aliases (void)
542 ipa_ref *ref;
544 FOR_EACH_ALIAS (this, ref)
546 varpool_node *alias = dyn_cast <varpool_node *> (ref->referring);
547 do_assemble_alias (alias->decl,
548 DECL_ASSEMBLER_NAME (decl));
549 alias->assemble_aliases ();
553 /* Output one variable, if necessary. Return whether we output it. */
555 bool
556 varpool_node::assemble_decl (void)
558 /* Aliases are outout when their target is produced or by
559 output_weakrefs. */
560 if (alias)
561 return false;
563 /* Constant pool is output from RTL land when the reference
564 survive till this level. */
565 if (DECL_IN_CONSTANT_POOL (decl) && TREE_ASM_WRITTEN (decl))
566 return false;
568 /* Decls with VALUE_EXPR should not be in the varpool at all. They
569 are not real variables, but just info for debugging and codegen.
570 Unfortunately at the moment emutls is not updating varpool correctly
571 after turning real vars into value_expr vars. */
572 if (DECL_HAS_VALUE_EXPR_P (decl)
573 && !targetm.have_tls)
574 return false;
576 /* Hard register vars do not need to be output. */
577 if (DECL_HARD_REGISTER (decl))
578 return false;
580 gcc_checking_assert (!TREE_ASM_WRITTEN (decl)
581 && TREE_CODE (decl) == VAR_DECL
582 && !DECL_HAS_VALUE_EXPR_P (decl));
584 if (!in_other_partition
585 && !DECL_EXTERNAL (decl))
587 get_constructor ();
588 assemble_variable (decl, 0, 1, 0);
589 gcc_assert (TREE_ASM_WRITTEN (decl));
590 gcc_assert (definition);
591 assemble_aliases ();
592 return true;
595 return false;
598 /* Add NODE to queue starting at FIRST.
599 The queue is linked via AUX pointers and terminated by pointer to 1. */
601 static void
602 enqueue_node (varpool_node *node, varpool_node **first)
604 if (node->aux)
605 return;
606 gcc_checking_assert (*first);
607 node->aux = *first;
608 *first = node;
611 /* Optimization of function bodies might've rendered some variables as
612 unnecessary so we want to avoid these from being compiled. Re-do
613 reachability starting from variables that are either externally visible
614 or was referred from the asm output routines. */
616 void
617 symbol_table::remove_unreferenced_decls (void)
619 varpool_node *next, *node;
620 varpool_node *first = (varpool_node *)(void *)1;
621 int i;
622 ipa_ref *ref = NULL;
623 hash_set<varpool_node *> referenced;
625 if (seen_error ())
626 return;
628 if (dump_file)
629 fprintf (dump_file, "Trivially needed variables:");
630 FOR_EACH_DEFINED_VARIABLE (node)
632 if (node->analyzed
633 && (!node->can_remove_if_no_refs_p ()
634 /* We just expanded all function bodies. See if any of
635 them needed the variable. */
636 || DECL_RTL_SET_P (node->decl)))
638 enqueue_node (node, &first);
639 if (dump_file)
640 fprintf (dump_file, " %s", node->asm_name ());
643 while (first != (varpool_node *)(void *)1)
645 node = first;
646 first = (varpool_node *)first->aux;
648 if (node->same_comdat_group)
650 symtab_node *next;
651 for (next = node->same_comdat_group;
652 next != node;
653 next = next->same_comdat_group)
655 varpool_node *vnext = dyn_cast <varpool_node *> (next);
656 if (vnext && vnext->analyzed && !next->comdat_local_p ())
657 enqueue_node (vnext, &first);
660 for (i = 0; node->iterate_reference (i, ref); i++)
662 varpool_node *vnode = dyn_cast <varpool_node *> (ref->referred);
663 if (vnode
664 && !vnode->in_other_partition
665 && (!DECL_EXTERNAL (ref->referred->decl)
666 || vnode->alias)
667 && vnode->analyzed)
668 enqueue_node (vnode, &first);
669 else
670 referenced.add (node);
673 if (dump_file)
674 fprintf (dump_file, "\nRemoving variables:");
675 for (node = first_defined_variable (); node; node = next)
677 next = next_defined_variable (node);
678 if (!node->aux && !node->no_reorder)
680 if (dump_file)
681 fprintf (dump_file, " %s", node->asm_name ());
682 if (referenced.contains(node))
683 node->remove_initializer ();
684 else
685 node->remove ();
689 if (dump_file)
690 fprintf (dump_file, "\n");
693 /* For variables in named sections make sure get_variable_section
694 is called before we switch to those sections. Then section
695 conflicts between read-only and read-only requiring relocations
696 sections can be resolved. */
697 void
698 varpool_node::finalize_named_section_flags (void)
700 if (!TREE_ASM_WRITTEN (decl)
701 && !alias
702 && !in_other_partition
703 && !DECL_EXTERNAL (decl)
704 && TREE_CODE (decl) == VAR_DECL
705 && !DECL_HAS_VALUE_EXPR_P (decl)
706 && get_section ())
707 get_variable_section (decl, false);
710 /* Output all variables enqueued to be assembled. */
711 bool
712 symbol_table::output_variables (void)
714 bool changed = false;
715 varpool_node *node;
717 if (seen_error ())
718 return false;
720 remove_unreferenced_decls ();
722 timevar_push (TV_VAROUT);
724 FOR_EACH_VARIABLE (node)
725 if (!node->definition)
726 assemble_undefined_decl (node->decl);
727 FOR_EACH_DEFINED_VARIABLE (node)
729 /* Handled in output_in_order. */
730 if (node->no_reorder)
731 continue;
733 node->finalize_named_section_flags ();
736 FOR_EACH_DEFINED_VARIABLE (node)
738 /* Handled in output_in_order. */
739 if (node->no_reorder)
740 continue;
741 if (node->assemble_decl ())
742 changed = true;
744 timevar_pop (TV_VAROUT);
745 return changed;
748 /* Create a new global variable of type TYPE. */
749 tree
750 add_new_static_var (tree type)
752 tree new_decl;
753 varpool_node *new_node;
755 new_decl = create_tmp_var_raw (type, NULL);
756 DECL_NAME (new_decl) = create_tmp_var_name (NULL);
757 TREE_READONLY (new_decl) = 0;
758 TREE_STATIC (new_decl) = 1;
759 TREE_USED (new_decl) = 1;
760 DECL_CONTEXT (new_decl) = NULL_TREE;
761 DECL_ABSTRACT_P (new_decl) = false;
762 lang_hooks.dup_lang_specific_decl (new_decl);
763 new_node = varpool_node::get_create (new_decl);
764 varpool_node::finalize_decl (new_decl);
766 return new_node->decl;
769 /* Attempt to mark ALIAS as an alias to DECL. Return TRUE if successful.
770 Extra name aliases are output whenever DECL is output. */
772 varpool_node *
773 varpool_node::create_alias (tree alias, tree decl)
775 varpool_node *alias_node;
777 gcc_assert (TREE_CODE (decl) == VAR_DECL);
778 gcc_assert (TREE_CODE (alias) == VAR_DECL);
779 alias_node = varpool_node::get_create (alias);
780 alias_node->alias = true;
781 alias_node->definition = true;
782 alias_node->alias_target = decl;
783 if (lookup_attribute ("weakref", DECL_ATTRIBUTES (alias)) != NULL)
784 alias_node->weakref = true;
785 return alias_node;
788 /* Attempt to mark ALIAS as an alias to DECL. Return TRUE if successful.
789 Extra name aliases are output whenever DECL is output. */
791 varpool_node *
792 varpool_node::create_extra_name_alias (tree alias, tree decl)
794 varpool_node *alias_node;
796 #ifndef ASM_OUTPUT_DEF
797 /* If aliases aren't supported by the assembler, fail. */
798 return NULL;
799 #endif
800 alias_node = varpool_node::create_alias (alias, decl);
801 alias_node->cpp_implicit_alias = true;
803 /* Extra name alias mechanizm creates aliases really late
804 via DECL_ASSEMBLER_NAME mechanizm.
805 This is unfortunate because they are not going through the
806 standard channels. Ensure they get output. */
807 if (symtab->cpp_implicit_aliases_done)
808 alias_node->resolve_alias (varpool_node::get_create (decl));
809 return alias_node;
812 /* Call calback on varpool symbol and aliases associated to varpool symbol.
813 When INCLUDE_OVERWRITABLE is false, overwritable aliases and thunks are
814 skipped. */
816 bool
817 varpool_node::call_for_node_and_aliases (bool (*callback) (varpool_node *,
818 void *),
819 void *data,
820 bool include_overwritable)
822 ipa_ref *ref;
824 if (callback (this, data))
825 return true;
827 FOR_EACH_ALIAS (this, ref)
829 varpool_node *alias = dyn_cast <varpool_node *> (ref->referring);
830 if (include_overwritable
831 || alias->get_availability () > AVAIL_INTERPOSABLE)
832 if (alias->call_for_node_and_aliases (callback, data,
833 include_overwritable))
834 return true;
836 return false;