@@ -124,41 +124,39 @@ possible_inline_candidate_p (symtab_node *node)
return lookup_attribute ("always_inline", DECL_ATTRIBUTES (node->decl));
}
-/* Process references. */
+/* Mark references from SNODE as (members of) REACHABLE and add them to the
+ queue starting at FIRST. */
static void
-process_references (symtab_node *snode,
- symtab_node **first,
- hash_set<symtab_node *> *reachable)
+mark_references (symtab_node *snode, symtab_node **first,
+ hash_set<symtab_node *> *reachable)
{
- int i;
struct ipa_ref *ref = NULL;
- for (i = 0; snode->iterate_reference (i, ref); i++)
+ for (int i = 0; snode->iterate_reference (i, ref); i++)
{
symtab_node *node = ref->referred;
symtab_node *body = node->ultimate_alias_target ();
- if (node->definition && !node->in_other_partition
- && ((!DECL_EXTERNAL (node->decl) || node->alias)
- || (possible_inline_candidate_p (node)
- /* We use variable constructors during late compilation for
- constant folding. Keep references alive so partitioning
- knows about potential references. */
- || (VAR_P (node->decl)
- && (flag_wpa
- || flag_incremental_link
- == INCREMENTAL_LINK_LTO)
- && dyn_cast <varpool_node *> (node)
- ->ctor_useable_for_folding_p ()))))
+ if (node->definition
+ && !node->in_other_partition
+ && (!DECL_EXTERNAL (node->decl)
+ || node->alias
+ || possible_inline_candidate_p (node)
+ /* We use variable constructors during late compilation for
+ constant folding, but vtables are handled separately. */
+ || (VAR_P (node->decl)
+ && !DECL_VIRTUAL_P (node->decl)
+ && dyn_cast <varpool_node *> (node)
+ ->ctor_useable_for_folding_p ())))
{
- /* Be sure that we will not optimize out alias target
- body. */
+ /* Be sure that we will not optimize out alias target body. */
if (DECL_EXTERNAL (node->decl)
&& node->alias
&& symtab->state < IPA_SSA_AFTER_INLINING)
reachable->add (body);
reachable->add (node);
}
+
enqueue_node (node, first, reachable);
}
}
@@ -409,8 +407,9 @@ symbol_table::remove_unreachable_nodes (FILE *file)
&& !reachable.add (next))
enqueue_node (next, &first, &reachable);
}
+
/* Mark references as reachable. */
- process_references (node, &first, &reachable);
+ mark_references (node, &first, &reachable);
}
if (cgraph_node *cnode = dyn_cast <cgraph_node *> (node))