Lines Matching refs:node
90 /* Return true when NODE cannot be local. Worker for cgraph_local_node_p. */
93 non_local_p (struct cgraph_node *node, void *data ATTRIBUTE_UNUSED)
95 return !(node->only_called_directly_or_aliased_p ()
98 && !node->thunk
99 && node->definition
100 && !DECL_EXTERNAL (node->decl)
101 && !lookup_attribute ("noipa", DECL_ATTRIBUTES (node->decl))
102 && !node->externally_visible
103 && !node->used_from_other_partition
104 && !node->in_other_partition
105 && node->get_availability () >= AVAIL_AVAILABLE);
125 comdat_can_be_unshared_p_1 (symtab_node *node)
127 if (!node->externally_visible)
129 if (node->address_can_be_compared_p ())
133 for (unsigned int i = 0; node->iterate_referring (i, ref); i++)
139 if (node->force_output)
144 if (node->forced_by_abi
145 && TREE_PUBLIC (node->decl)
146 && (node->resolution != LDPR_PREVAILING_DEF_IRONLY
151 if (is_a <varpool_node *> (node)
152 && (!TREE_READONLY (node->decl)
153 || TREE_THIS_VOLATILE (node->decl)))
168 comdat_can_be_unshared_p (symtab_node *node)
170 if (!comdat_can_be_unshared_p_1 (node))
172 if (node->same_comdat_group)
179 for (next = node->same_comdat_group;
180 next != node; next = next->same_comdat_group)
187 /* Return true when function NODE should be considered externally visible. */
190 cgraph_externally_visible_p (struct cgraph_node *node,
193 while (node->transparent_alias && node->definition)
194 node = node->get_alias_target ();
195 if (!node->definition)
197 if (!TREE_PUBLIC (node->decl)
198 || DECL_EXTERNAL (node->decl))
206 if (fndecl_built_in_p (node->decl))
210 if (node->used_from_object_file_p ())
212 if (DECL_PRESERVE_P (node->decl))
215 DECL_ATTRIBUTES (node->decl)))
217 if (lookup_attribute ("noipa", DECL_ATTRIBUTES (node->decl)))
221 DECL_ATTRIBUTES (node->decl)))
227 FOR_EACH_ALIAS (node, ref)
231 if (node->resolution == LDPR_PREVAILING_DEF_IRONLY)
238 && DECL_COMDAT (node->decl)
239 && comdat_can_be_unshared_p (node))
244 && (DECL_VISIBILITY (node->decl) == VISIBILITY_HIDDEN
245 || DECL_VISIBILITY (node->decl) == VISIBILITY_INTERNAL)
246 /* Be sure that node is defined in IR file, not in other object
248 && node->definition)
253 if (MAIN_NAME_P (DECL_NAME (node->decl)))
319 /* Be sure that node is defined in IR file, not in other object
338 /* Return true if reference to NODE can be replaced by a local alias.
343 can_replace_by_local_alias (symtab_node *node)
351 while (node->transparent_alias && node->definition && !node->weakref)
352 node = node->get_alias_target ();
353 if (node->weakref)
356 return (node->get_availability () > AVAIL_INTERPOSABLE
357 && !decl_binds_to_current_def_p (node->decl)
358 && !node->can_be_discarded_p ());
361 /* Return true if we can replace reference to NODE by local alias
366 can_replace_by_local_alias_in_vtable (symtab_node *node)
368 if (is_a <varpool_node *> (node)
369 && !DECL_VIRTUAL_P (node->decl))
371 return can_replace_by_local_alias (node);
396 update_visibility_by_resolution_info (symtab_node * node)
400 if (!node->externally_visible
401 || (!DECL_WEAK (node->decl) && !DECL_ONE_ONLY (node->decl))
402 || node->resolution == LDPR_UNKNOWN)
405 define = (node->resolution == LDPR_PREVAILING_DEF_IRONLY
406 || node->resolution == LDPR_PREVAILING_DEF
407 || node->resolution == LDPR_UNDEF
408 || node->resolution == LDPR_PREVAILING_DEF_IRONLY_EXP);
411 if (node->same_comdat_group)
412 for (symtab_node *next = node->same_comdat_group;
413 next != node; next = next->same_comdat_group)
428 if (node->same_comdat_group)
429 for (symtab_node *next = node->same_comdat_group;
430 next != node; next = next->same_comdat_group)
452 DECL_WEAK (node->decl) = false;
453 node->set_comdat_group (NULL);
454 node->dissolve_same_comdat_group_list ();
458 DECL_EXTERNAL (node->decl) = true;
459 node->set_comdat_group (NULL);
460 node->dissolve_same_comdat_group_list ();
467 optimize_weakref (symtab_node *node)
472 gcc_assert (node->weakref);
475 if (!node->analyzed)
477 symtab_node *target = node->get_alias_target ();
495 || IDENTIFIER_TRANSPARENT_ALIAS (DECL_ASSEMBLER_NAME (node->decl)))
503 node->weakref = false;
504 IDENTIFIER_TRANSPARENT_ALIAS (DECL_ASSEMBLER_NAME (node->decl)) = 0;
505 TREE_CHAIN (DECL_ASSEMBLER_NAME (node->decl)) = NULL_TREE;
506 DECL_ATTRIBUTES (node->decl) = remove_attribute ("weakref",
508 (node->decl));
512 node->dump_name (),
519 TREE_PUBLIC (node->decl) = true;
520 node->make_decl_local ();
521 node->forced_by_abi = false;
522 node->resolution = LDPR_PREVAILING_DEF_IRONLY;
523 node->externally_visible = false;
524 gcc_assert (!DECL_WEAK (node->decl));
525 node->transparent_alias = false;
530 (node->decl, DECL_ASSEMBLER_NAME (node->get_alias_target ()->decl));
531 node->transparent_alias = true;
532 node->copy_visibility_from (target);
534 gcc_assert (node->alias);
537 /* NODE is an externally visible definition, which we've discovered is
541 localize_node (bool whole_program, symtab_node *node)
543 gcc_assert (whole_program || in_lto_p || !TREE_PUBLIC (node->decl));
548 if (node->same_comdat_group
549 && (node->resolution == LDPR_PREVAILING_DEF_IRONLY
550 || node->resolution == LDPR_PREVAILING_DEF_IRONLY_EXP))
553 for (next = node->same_comdat_group;
554 next != node; next = next->same_comdat_group)
558 if (node != next)
560 if (!node->transparent_alias)
562 node->resolution = LDPR_PREVAILING_DEF_IRONLY;
563 node->make_decl_local ();
565 node->unique_name |= true;
572 if (node->comdat_local_p ())
575 if (node->same_comdat_group && TREE_PUBLIC (node->decl))
577 for (symtab_node *next = node->same_comdat_group;
578 next != node; next = next->same_comdat_group)
594 node->dissolve_same_comdat_group_list ();
597 node->unique_name
598 |= ((node->resolution == LDPR_PREVAILING_DEF_IRONLY
599 || node->resolution == LDPR_PREVAILING_DEF_IRONLY_EXP)
600 && TREE_PUBLIC (node->decl)
603 if (TREE_PUBLIC (node->decl))
604 node->set_comdat_group (NULL);
605 if (DECL_COMDAT (node->decl) && !node->alias)
606 node->set_section (NULL);
607 if (!node->transparent_alias)
609 node->resolution = LDPR_PREVAILING_DEF_IRONLY;
610 node->make_decl_local ();
619 struct cgraph_node *node;
626 FOR_EACH_DEFINED_FUNCTION (node)
628 if (node->get_availability () != AVAIL_INTERPOSABLE
629 || DECL_EXTERNAL (node->decl)
630 || node->has_aliases_p ()
631 || lookup_attribute ("noipa", DECL_ATTRIBUTES (node->decl)))
636 for (cgraph_edge *e = node->callees; e; e = next_edge)
646 alias = dyn_cast<cgraph_node *> (node->noninterposable_alias ());
647 gcc_assert (alias && alias != node);
661 FOR_EACH_FUNCTION (node)
663 int flags = flags_from_decl_or_type (node->decl);
666 if (node->analyzed
667 && (DECL_STATIC_CONSTRUCTOR (node->decl)
668 || DECL_STATIC_DESTRUCTOR (node->decl))
671 && opt_for_fn (node->decl, optimize))
673 DECL_STATIC_CONSTRUCTOR (node->decl) = 0;
674 DECL_STATIC_DESTRUCTOR (node->decl) = 0;
678 is finished. We may end up marking as node external nodes
680 if (DECL_EXTERNAL (node->decl) || !node->definition)
682 node->force_output = 0;
683 node->forced_by_abi = 0;
690 if (DECL_COMDAT (node->decl) && !TREE_PUBLIC (node->decl))
691 DECL_COMDAT (node->decl) = 0;
699 if (node->same_comdat_group && DECL_EXTERNAL (node->decl) && !in_lto_p)
703 for (symtab_node *n = node->same_comdat_group;
704 n != node;
710 node->dissolve_same_comdat_group_list ();
712 gcc_assert ((!DECL_WEAK (node->decl)
713 && !DECL_COMDAT (node->decl))
714 || TREE_PUBLIC (node->decl)
715 || node->weakref
716 || DECL_EXTERNAL (node->decl));
717 if (cgraph_externally_visible_p (node, whole_program))
719 gcc_assert (!node->inlined_to);
720 node->externally_visible = true;
724 node->externally_visible = false;
725 node->forced_by_abi = false;
727 if (!node->externally_visible
728 && node->definition && !node->weakref
729 && !DECL_EXTERNAL (node->decl))
730 localize_node (whole_program, node);
732 if (node->thunk
733 && TREE_PUBLIC (node->decl))
735 struct cgraph_node *decl_node = node;
743 gcc_checking_assert (DECL_COMDAT (node->decl)
745 gcc_checking_assert (node->in_same_comdat_group_p (decl_node));
746 gcc_checking_assert (node->same_comdat_group);
748 node->forced_by_abi = decl_node->forced_by_abi;
750 DECL_EXTERNAL (node->decl) = 1;
753 update_visibility_by_resolution_info (node);
754 if (node->weakref)
755 optimize_weakref (node);
757 FOR_EACH_DEFINED_FUNCTION (node)
759 if (!node->local)
760 node->local |= node->local_p ();
769 if (node->callers
770 && can_replace_by_local_alias (node))
773 (node->noninterposable_alias ());
775 if (alias && alias != node)
777 while (node->callers)
779 struct cgraph_edge *e = node->callers;
879 FOR_EACH_DEFINED_FUNCTION (node)
880 if (node->local)
881 fprintf (dump_file, " %s", node->dump_name ());
884 FOR_EACH_DEFINED_FUNCTION (node)
885 if (node->externally_visible)
886 fprintf (dump_file, " %s", node->dump_name ());