Fix a bug that broke -freorder-functions
[official-gcc.git] / gcc / varpool.c
blobd223779a5c195e877688d6e36f4d30798249f47a
1 /* Callgraph handling code.
2 Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2010, 2011
3 Free Software Foundation, Inc.
4 Contributed by Jan Hubicka
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
11 version.
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
22 #include "config.h"
23 #include "system.h"
24 #include "coretypes.h"
25 #include "tm.h"
26 #include "tree.h"
27 #include "cgraph.h"
28 #include "langhooks.h"
29 #include "diagnostic-core.h"
30 #include "hashtab.h"
31 #include "ggc.h"
32 #include "timevar.h"
33 #include "debug.h"
34 #include "target.h"
35 #include "output.h"
36 #include "gimple.h"
37 #include "tree-flow.h"
38 #include "flags.h"
40 /* This file contains basic routines manipulating variable pool.
42 Varpool acts as interface in between the front-end and middle-end
43 and drives the decision process on what variables and when are
44 going to be compiled.
46 The varpool nodes are allocated lazily for declarations
47 either by frontend or at callgraph construction time.
48 All variables supposed to be output into final file needs to be
49 explicitly marked by frontend via VARPOOL_FINALIZE_DECL function. */
51 /* Hash table used to convert declarations into nodes. */
52 static GTY((param_is (struct varpool_node))) htab_t varpool_hash;
54 /* The linked list of cgraph varpool nodes.
55 Linked via node->next pointer. */
56 struct varpool_node *varpool_nodes;
58 /* Queue of cgraph nodes scheduled to be lowered and output.
59 The queue is maintained via mark_needed_node, linked via node->next_needed
60 pointer.
62 LAST_NEEDED_NODE points to the end of queue, so it can be
63 maintained in forward order. GTY is needed to make it friendly to
64 PCH.
66 During compilation we construct the queue of needed variables
67 twice: first time it is during cgraph construction, second time it is at the
68 end of compilation in VARPOOL_REMOVE_UNREFERENCED_DECLS so we can avoid
69 optimized out variables being output.
71 Each variable is thus first analyzed and then later possibly output.
72 FIRST_UNANALYZED_NODE points to first node in queue that was not analyzed
73 yet and is moved via VARPOOL_ANALYZE_PENDING_DECLS. */
75 struct varpool_node *varpool_nodes_queue;
76 static GTY(()) struct varpool_node *varpool_last_needed_node;
77 static GTY(()) struct varpool_node *varpool_first_unanalyzed_node;
79 /* Lists all assembled variables to be sent to debugger output later on. */
80 static GTY(()) struct varpool_node *varpool_assembled_nodes_queue;
82 /* Return name of the node used in debug output. */
83 const char *
84 varpool_node_name (struct varpool_node *node)
86 return lang_hooks.decl_printable_name (node->decl, 2);
89 /* Returns a hash code for P. */
90 static hashval_t
91 hash_varpool_node (const void *p)
93 const struct varpool_node *n = (const struct varpool_node *) p;
94 return (hashval_t) DECL_UID (n->decl);
97 /* Returns nonzero if P1 and P2 are equal. */
98 static int
99 eq_varpool_node (const void *p1, const void *p2)
101 const struct varpool_node *n1 =
102 (const struct varpool_node *) p1;
103 const struct varpool_node *n2 =
104 (const struct varpool_node *) p2;
105 return DECL_UID (n1->decl) == DECL_UID (n2->decl);
108 /* Return varpool node assigned to DECL without creating new one. */
109 struct varpool_node *
110 varpool_get_node (const_tree decl)
112 struct varpool_node key, **slot;
114 gcc_assert (TREE_CODE (decl) == VAR_DECL
115 && (TREE_STATIC (decl) || DECL_EXTERNAL (decl)));
117 if (!varpool_hash)
118 return NULL;
119 key.decl = CONST_CAST2 (tree, const_tree, decl);
120 slot = (struct varpool_node **)
121 htab_find_slot (varpool_hash, &key, NO_INSERT);
122 if (!slot)
123 return NULL;
124 return *slot;
127 /* Return varpool node assigned to DECL. Create new one when needed. */
128 struct varpool_node *
129 varpool_node (tree decl)
131 struct varpool_node key, *node, **slot;
133 gcc_assert (TREE_CODE (decl) == VAR_DECL
134 && (TREE_STATIC (decl) || DECL_EXTERNAL (decl) || in_lto_p));
136 if (!varpool_hash)
137 varpool_hash = htab_create_ggc (10, hash_varpool_node,
138 eq_varpool_node, NULL);
139 key.decl = decl;
140 slot = (struct varpool_node **)
141 htab_find_slot (varpool_hash, &key, INSERT);
142 if (*slot)
143 return *slot;
144 node = ggc_alloc_cleared_varpool_node ();
145 node->decl = decl;
146 node->order = cgraph_order++;
147 node->next = varpool_nodes;
148 ipa_empty_ref_list (&node->ref_list);
149 if (varpool_nodes)
150 varpool_nodes->prev = node;
151 varpool_nodes = node;
152 *slot = node;
153 return node;
156 /* Remove node from the varpool. */
157 void
158 varpool_remove_node (struct varpool_node *node)
160 void **slot;
161 slot = htab_find_slot (varpool_hash, node, NO_INSERT);
162 gcc_assert (*slot == node);
163 htab_clear_slot (varpool_hash, slot);
164 gcc_assert (!varpool_assembled_nodes_queue);
165 if (node->next)
166 node->next->prev = node->prev;
167 if (node->prev)
168 node->prev->next = node->next;
169 else
171 gcc_assert (varpool_nodes == node);
172 varpool_nodes = node->next;
174 if (varpool_first_unanalyzed_node == node)
175 varpool_first_unanalyzed_node = node->next_needed;
176 if (node->next_needed)
177 node->next_needed->prev_needed = node->prev_needed;
178 else if (node->prev_needed)
180 gcc_assert (varpool_last_needed_node);
181 varpool_last_needed_node = node->prev_needed;
183 if (node->prev_needed)
184 node->prev_needed->next_needed = node->next_needed;
185 else if (node->next_needed)
187 gcc_assert (varpool_nodes_queue == node);
188 varpool_nodes_queue = node->next_needed;
190 if (node->same_comdat_group)
192 struct varpool_node *prev;
193 for (prev = node->same_comdat_group;
194 prev->same_comdat_group != node;
195 prev = prev->same_comdat_group)
197 if (node->same_comdat_group == prev)
198 prev->same_comdat_group = NULL;
199 else
200 prev->same_comdat_group = node->same_comdat_group;
201 node->same_comdat_group = NULL;
203 ipa_remove_all_references (&node->ref_list);
204 ipa_remove_all_refering (&node->ref_list);
205 ggc_free (node);
208 /* Dump given cgraph node. */
209 void
210 dump_varpool_node (FILE *f, struct varpool_node *node)
212 fprintf (f, "%s:", varpool_node_name (node));
213 fprintf (f, " availability:%s",
214 cgraph_function_flags_ready
215 ? cgraph_availability_names[cgraph_variable_initializer_availability (node)]
216 : "not-ready");
217 if (DECL_ASSEMBLER_NAME_SET_P (node->decl))
218 fprintf (f, " (asm: %s)", IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (node->decl)));
219 if (DECL_INITIAL (node->decl))
220 fprintf (f, " initialized");
221 if (TREE_ASM_WRITTEN (node->decl))
222 fprintf (f, " (asm written)");
223 if (node->needed)
224 fprintf (f, " needed");
225 if (node->analyzed)
226 fprintf (f, " analyzed");
227 if (node->finalized)
228 fprintf (f, " finalized");
229 if (node->output)
230 fprintf (f, " output");
231 if (node->externally_visible)
232 fprintf (f, " externally_visible");
233 if (node->resolution != LDPR_UNKNOWN)
234 fprintf (f, " %s",
235 ld_plugin_symbol_resolution_names[(int)node->resolution]);
236 if (node->in_other_partition)
237 fprintf (f, " in_other_partition");
238 else if (node->used_from_other_partition)
239 fprintf (f, " used_from_other_partition");
240 fprintf (f, "\n");
241 fprintf (f, " References: ");
242 ipa_dump_references (f, &node->ref_list);
243 fprintf (f, " Refering this var: ");
244 ipa_dump_refering (f, &node->ref_list);
247 /* Dump the variable pool. */
248 void
249 dump_varpool (FILE *f)
251 struct varpool_node *node;
253 fprintf (f, "variable pool:\n\n");
254 for (node = varpool_nodes; node; node = node->next)
255 dump_varpool_node (f, node);
258 /* Dump the variable pool to stderr. */
260 DEBUG_FUNCTION void
261 debug_varpool (void)
263 dump_varpool (stderr);
266 /* Given an assembler name, lookup node. */
267 struct varpool_node *
268 varpool_node_for_asm (tree asmname)
270 struct varpool_node *node;
272 for (node = varpool_nodes; node ; node = node->next)
273 if (decl_assembler_name_equal (node->decl, asmname))
274 return node;
276 return NULL;
279 /* Helper function for finalization code - add node into lists so it will
280 be analyzed and compiled. */
281 static void
282 varpool_enqueue_needed_node (struct varpool_node *node)
284 if (varpool_last_needed_node)
286 varpool_last_needed_node->next_needed = node;
287 node->prev_needed = varpool_last_needed_node;
289 varpool_last_needed_node = node;
290 node->next_needed = NULL;
291 if (!varpool_nodes_queue)
292 varpool_nodes_queue = node;
293 if (!varpool_first_unanalyzed_node)
294 varpool_first_unanalyzed_node = node;
295 notice_global_symbol (node->decl);
298 /* Notify finalize_compilation_unit that given node is reachable
299 or needed. */
300 void
301 varpool_mark_needed_node (struct varpool_node *node)
303 if (!node->needed && node->finalized
304 && !TREE_ASM_WRITTEN (node->decl))
305 varpool_enqueue_needed_node (node);
306 node->needed = 1;
309 /* Reset the queue of needed nodes. */
310 void
311 varpool_reset_queue (void)
313 varpool_last_needed_node = NULL;
314 varpool_nodes_queue = NULL;
315 varpool_first_unanalyzed_node = NULL;
318 /* Determine if variable DECL is needed. That is, visible to something
319 either outside this translation unit, something magic in the system
320 configury */
321 bool
322 decide_is_variable_needed (struct varpool_node *node, tree decl)
324 /* If the user told us it is used, then it must be so. */
325 if (node->force_output)
326 return true;
328 gcc_assert (!DECL_EXTERNAL (decl));
330 /* Externally visible variables must be output. The exception is
331 COMDAT variables that must be output only when they are needed. */
332 if (TREE_PUBLIC (decl)
333 && !DECL_COMDAT (decl)
334 && !DECL_EXTERNAL (decl))
335 return true;
337 /* When not reordering top level variables, we have to assume that
338 we are going to keep everything. */
339 if (!flag_toplevel_reorder)
340 return true;
341 return false;
344 /* Return if DECL is constant and its initial value is known (so we can do
345 constant folding using DECL_INITIAL (decl)). */
347 bool
348 const_value_known_p (tree decl)
350 if (TREE_CODE (decl) != VAR_DECL
351 &&TREE_CODE (decl) != CONST_DECL)
352 return false;
354 if (TREE_CODE (decl) == CONST_DECL
355 || DECL_IN_CONSTANT_POOL (decl))
356 return true;
358 gcc_assert (TREE_CODE (decl) == VAR_DECL);
360 if (!TREE_READONLY (decl) || TREE_THIS_VOLATILE (decl))
361 return false;
363 /* Gimplifier takes away constructors of local vars */
364 if (!TREE_STATIC (decl) && !DECL_EXTERNAL (decl))
365 return DECL_INITIAL (decl) != NULL;
367 gcc_assert (TREE_STATIC (decl) || DECL_EXTERNAL (decl));
369 /* Variables declared 'const' without an initializer
370 have zero as the initializer if they may not be
371 overridden at link or run time. */
372 if (!DECL_INITIAL (decl)
373 && (DECL_EXTERNAL (decl)
374 || decl_replaceable_p (decl)))
375 return false;
377 /* Variables declared `const' with an initializer are considered
378 to not be overwritable with different initializer by default.
380 ??? Previously we behaved so for scalar variables but not for array
381 accesses. */
382 return true;
385 /* Mark DECL as finalized. By finalizing the declaration, frontend instruct the
386 middle end to output the variable to asm file, if needed or externally
387 visible. */
388 void
389 varpool_finalize_decl (tree decl)
391 struct varpool_node *node = varpool_node (decl);
393 gcc_assert (TREE_STATIC (decl));
395 /* The first declaration of a variable that comes through this function
396 decides whether it is global (in C, has external linkage)
397 or local (in C, has internal linkage). So do nothing more
398 if this function has already run. */
399 if (node->finalized)
401 if (cgraph_global_info_ready)
402 varpool_assemble_pending_decls ();
403 return;
405 if (node->needed)
406 varpool_enqueue_needed_node (node);
407 node->finalized = true;
408 if (TREE_THIS_VOLATILE (decl) || DECL_PRESERVE_P (decl))
409 node->force_output = true;
411 if (decide_is_variable_needed (node, decl))
412 varpool_mark_needed_node (node);
413 if (cgraph_global_info_ready)
414 varpool_assemble_pending_decls ();
417 /* Return variable availability. See cgraph.h for description of individual
418 return values. */
419 enum availability
420 cgraph_variable_initializer_availability (struct varpool_node *node)
422 gcc_assert (cgraph_function_flags_ready);
423 if (!node->finalized)
424 return AVAIL_NOT_AVAILABLE;
425 if (!TREE_PUBLIC (node->decl))
426 return AVAIL_AVAILABLE;
427 /* If the variable can be overwritten, return OVERWRITABLE. Takes
428 care of at least two notable extensions - the COMDAT variables
429 used to share template instantiations in C++. */
430 if (!decl_replaceable_p (node->decl))
431 return AVAIL_OVERWRITABLE;
432 return AVAIL_AVAILABLE;
435 /* Walk the decls we marked as necessary and see if they reference new
436 variables or functions and add them into the worklists. */
437 bool
438 varpool_analyze_pending_decls (void)
440 bool changed = false;
442 timevar_push (TV_VARPOOL);
443 while (varpool_first_unanalyzed_node)
445 struct varpool_node *node = varpool_first_unanalyzed_node, *next;
446 tree decl = node->decl;
447 bool analyzed = node->analyzed;
449 varpool_first_unanalyzed_node->analyzed = true;
451 varpool_first_unanalyzed_node = varpool_first_unanalyzed_node->next_needed;
453 /* When reading back varpool at LTO time, we re-construct the queue in order
454 to have "needed" list right by inserting all needed nodes into varpool.
455 We however don't want to re-analyze already analyzed nodes. */
456 if (!analyzed)
458 gcc_assert (!in_lto_p || cgraph_function_flags_ready);
459 /* Compute the alignment early so function body expanders are
460 already informed about increased alignment. */
461 align_variable (decl, 0);
463 if (node->alias && node->alias_of)
465 struct varpool_node *tgt = varpool_node (node->alias_of);
466 if (!VEC_length (ipa_ref_t, node->ref_list.references))
467 ipa_record_reference (NULL, node, NULL, tgt, IPA_REF_ALIAS, NULL);
468 /* C++ FE sometimes change linkage flags after producing same body aliases. */
469 if (node->extra_name_alias)
471 DECL_WEAK (node->decl) = DECL_WEAK (node->alias_of);
472 TREE_PUBLIC (node->decl) = TREE_PUBLIC (node->alias_of);
473 DECL_VISIBILITY (node->decl) = DECL_VISIBILITY (node->alias_of);
474 if (TREE_PUBLIC (node->decl))
476 DECL_COMDAT (node->decl) = DECL_COMDAT (node->alias_of);
477 DECL_COMDAT_GROUP (node->decl) = DECL_COMDAT_GROUP (node->alias_of);
478 if (DECL_ONE_ONLY (node->alias_of) && !node->same_comdat_group)
480 node->same_comdat_group = tgt;
481 if (!tgt->same_comdat_group)
482 tgt->same_comdat_group = node;
483 else
485 struct varpool_node *n;
486 for (n = tgt->same_comdat_group;
487 n->same_comdat_group != tgt;
488 n = n->same_comdat_group)
490 n->same_comdat_group = node;
496 else if (DECL_INITIAL (decl))
497 record_references_in_initializer (decl, analyzed);
498 if (node->same_comdat_group)
500 for (next = node->same_comdat_group;
501 next != node;
502 next = next->same_comdat_group)
503 varpool_mark_needed_node (next);
505 changed = true;
507 timevar_pop (TV_VARPOOL);
508 return changed;
511 /* Assemble thunks and aliases asociated to NODE. */
513 static void
514 assemble_aliases (struct varpool_node *node)
516 int i;
517 struct ipa_ref *ref;
518 for (i = 0; ipa_ref_list_refering_iterate (&node->ref_list, i, ref); i++)
519 if (ref->use == IPA_REF_ALIAS)
521 struct varpool_node *alias = ipa_ref_refering_varpool_node (ref);
522 assemble_alias (alias->decl,
523 DECL_ASSEMBLER_NAME (alias->alias_of));
524 assemble_aliases (alias);
528 /* Output one variable, if necessary. Return whether we output it. */
529 bool
530 varpool_assemble_decl (struct varpool_node *node)
532 tree decl = node->decl;
534 if (!TREE_ASM_WRITTEN (decl)
535 && !node->alias
536 && !node->in_other_partition
537 && !DECL_EXTERNAL (decl)
538 && (TREE_CODE (decl) != VAR_DECL || !DECL_HAS_VALUE_EXPR_P (decl)))
540 assemble_variable (decl, 0, 1, 0);
541 if (TREE_ASM_WRITTEN (decl))
543 node->next_needed = varpool_assembled_nodes_queue;
544 node->prev_needed = NULL;
545 if (varpool_assembled_nodes_queue)
546 varpool_assembled_nodes_queue->prev_needed = node;
547 varpool_assembled_nodes_queue = node;
548 node->finalized = 1;
549 assemble_aliases (node);
550 return true;
554 return false;
557 /* Optimization of function bodies might've rendered some variables as
558 unnecessary so we want to avoid these from being compiled.
560 This is done by pruning the queue and keeping only the variables that
561 really appear needed (ie they are either externally visible or referenced
562 by compiled function). Re-doing the reachability analysis on variables
563 brings back the remaining variables referenced by these. */
564 void
565 varpool_remove_unreferenced_decls (void)
567 struct varpool_node *next, *node = varpool_nodes_queue;
569 varpool_reset_queue ();
571 if (seen_error ())
572 return;
574 while (node)
576 next = node->next_needed;
577 node->needed = 0;
579 if (node->analyzed
580 && (!varpool_can_remove_if_no_refs (node)
581 /* We just expanded all function bodies. See if any of
582 them needed the variable. */
583 || DECL_RTL_SET_P (node->decl)))
584 varpool_mark_needed_node (node);
586 node = next;
588 /* Make sure we mark alias targets as used targets. */
589 finish_aliases_1 ();
590 varpool_analyze_pending_decls ();
593 /* For variables in named sections make sure get_variable_section
594 is called before we switch to those sections. Then section
595 conflicts between read-only and read-only requiring relocations
596 sections can be resolved. */
597 void
598 varpool_finalize_named_section_flags (struct varpool_node *node)
600 if (!TREE_ASM_WRITTEN (node->decl)
601 && !node->alias
602 && !node->in_other_partition
603 && !DECL_EXTERNAL (node->decl)
604 && TREE_CODE (node->decl) == VAR_DECL
605 && !DECL_HAS_VALUE_EXPR_P (node->decl)
606 && DECL_SECTION_NAME (node->decl))
607 get_variable_section (node->decl, false);
610 /* Output all variables enqueued to be assembled. */
611 bool
612 varpool_assemble_pending_decls (void)
614 bool changed = false;
615 struct varpool_node *node;
617 if (seen_error ())
618 return false;
620 timevar_push (TV_VAROUT);
621 /* EH might mark decls as needed during expansion. This should be safe since
622 we don't create references to new function, but it should not be used
623 elsewhere. */
624 varpool_analyze_pending_decls ();
626 for (node = varpool_nodes_queue; node; node = node->next_needed)
627 varpool_finalize_named_section_flags (node);
629 while (varpool_nodes_queue)
631 struct varpool_node *node = varpool_nodes_queue;
633 varpool_nodes_queue = varpool_nodes_queue->next_needed;
634 if (varpool_assemble_decl (node))
635 changed = true;
636 else
638 node->prev_needed = NULL;
639 node->next_needed = NULL;
642 /* varpool_nodes_queue is now empty, clear the pointer to the last element
643 in the queue. */
644 varpool_last_needed_node = NULL;
645 timevar_pop (TV_VAROUT);
646 return changed;
649 /* Remove all elements from the queue so we can re-use it for debug output. */
650 void
651 varpool_empty_needed_queue (void)
653 /* EH might mark decls as needed during expansion. This should be safe since
654 we don't create references to new function, but it should not be used
655 elsewhere. */
656 varpool_analyze_pending_decls ();
658 while (varpool_nodes_queue)
660 struct varpool_node *node = varpool_nodes_queue;
661 varpool_nodes_queue = varpool_nodes_queue->next_needed;
662 node->next_needed = NULL;
663 node->prev_needed = NULL;
665 /* varpool_nodes_queue is now empty, clear the pointer to the last element
666 in the queue. */
667 varpool_last_needed_node = NULL;
670 /* Create a new global variable of type TYPE. */
671 tree
672 add_new_static_var (tree type)
674 tree new_decl;
675 struct varpool_node *new_node;
677 new_decl = create_tmp_var (type, NULL);
678 DECL_NAME (new_decl) = create_tmp_var_name (NULL);
679 TREE_READONLY (new_decl) = 0;
680 TREE_STATIC (new_decl) = 1;
681 TREE_USED (new_decl) = 1;
682 DECL_CONTEXT (new_decl) = NULL_TREE;
683 DECL_ABSTRACT (new_decl) = 0;
684 lang_hooks.dup_lang_specific_decl (new_decl);
685 create_var_ann (new_decl);
686 new_node = varpool_node (new_decl);
687 varpool_mark_needed_node (new_node);
688 add_referenced_var (new_decl);
689 varpool_finalize_decl (new_decl);
691 return new_node->decl;
694 /* Attempt to mark ALIAS as an alias to DECL. Return TRUE if successful.
695 Extra name aliases are output whenever DECL is output. */
697 struct varpool_node *
698 varpool_create_variable_alias (tree alias, tree decl)
700 struct varpool_node *alias_node;
702 gcc_assert (TREE_CODE (decl) == VAR_DECL);
703 gcc_assert (TREE_CODE (alias) == VAR_DECL);
704 alias_node = varpool_node (alias);
705 alias_node->alias = 1;
706 alias_node->finalized = 1;
707 alias_node->alias_of = decl;
708 if (decide_is_variable_needed (alias_node, alias)
709 || alias_node->needed)
710 varpool_mark_needed_node (alias_node);
711 return alias_node;
714 /* Attempt to mark ALIAS as an alias to DECL. Return TRUE if successful.
715 Extra name aliases are output whenever DECL is output. */
717 struct varpool_node *
718 varpool_extra_name_alias (tree alias, tree decl)
720 struct varpool_node *alias_node;
722 #ifndef ASM_OUTPUT_DEF
723 /* If aliases aren't supported by the assembler, fail. */
724 return NULL;
725 #endif
726 alias_node = varpool_create_variable_alias (alias, decl);
727 alias_node->extra_name_alias = true;
728 return alias_node;
731 /* Return true when NODE is known to be used from other (non-LTO) object file.
732 Known only when doing LTO via linker plugin. */
734 bool
735 varpool_used_from_object_file_p (struct varpool_node *node)
737 if (!TREE_PUBLIC (node->decl))
738 return false;
739 if (resolution_used_from_other_file_p (node->resolution))
740 return true;
741 return false;
744 /* Call calback on NODE and aliases asociated to NODE.
745 When INCLUDE_OVERWRITABLE is false, overwritable aliases and thunks are
746 skipped. */
748 bool
749 varpool_for_node_and_aliases (struct varpool_node *node,
750 bool (*callback) (struct varpool_node *, void *),
751 void *data,
752 bool include_overwritable)
754 int i;
755 struct ipa_ref *ref;
757 if (callback (node, data))
758 return true;
759 for (i = 0; ipa_ref_list_refering_iterate (&node->ref_list, i, ref); i++)
760 if (ref->use == IPA_REF_ALIAS)
762 struct varpool_node *alias = ipa_ref_refering_varpool_node (ref);
763 if (include_overwritable
764 || cgraph_variable_initializer_availability (alias) > AVAIL_OVERWRITABLE)
765 if (varpool_for_node_and_aliases (alias, callback, data,
766 include_overwritable))
767 return true;
769 return false;
771 #include "gt-varpool.h"