diff options
Diffstat (limited to 'gcc/ipa.c')
-rw-r--r-- | gcc/ipa.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/gcc/ipa.c b/gcc/ipa.c index 8c0ca86d59d..9670a9c7941 100644 --- a/gcc/ipa.c +++ b/gcc/ipa.c @@ -238,7 +238,12 @@ cgraph_remove_unreachable_nodes (bool before_inlining_p, FILE *file) #endif varpool_reset_queue (); for (node = cgraph_nodes; node; node = node->next) - if (!cgraph_can_remove_if_no_direct_calls_and_refs_p (node) + if ((!cgraph_can_remove_if_no_direct_calls_and_refs_p (node) + /* Keep around virtual functions for possible devirtualization. */ + || (!before_inlining_p + && !node->global.inlined_to + && DECL_VIRTUAL_P (node->decl) + && (DECL_COMDAT (node->decl) || DECL_EXTERNAL (node->decl)))) && ((!DECL_EXTERNAL (node->decl)) || before_inlining_p)) { @@ -565,7 +570,6 @@ ipa_discover_readonly_nonaddressable_vars (void) if (dump_file) fprintf (dump_file, " %s (read-only)", varpool_node_name (vnode)); TREE_READONLY (vnode->decl) = 1; - vnode->const_value_known |= varpool_decide_const_value_known (vnode); } } if (dump_file) @@ -617,7 +621,7 @@ cgraph_externally_visible_p (struct cgraph_node *node, bool whole_program, bool return true; } } - if (node->local.used_from_object_file) + if (cgraph_used_from_object_file_p (node)) return true; if (DECL_PRESERVE_P (node->decl)) return true; @@ -734,6 +738,7 @@ function_and_variable_visibility (bool whole_program) struct cgraph_node *alias; gcc_assert (whole_program || in_lto_p || !TREE_PUBLIC (node->decl)); cgraph_make_decl_local (node->decl); + node->resolution = LDPR_PREVAILING_DEF_IRONLY; for (alias = node->same_body; alias; alias = alias->next) cgraph_make_decl_local (alias->decl); if (node->same_comdat_group) @@ -772,9 +777,6 @@ function_and_variable_visibility (bool whole_program) || ! (ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (TREE_TYPE (vnode->decl)))))) DECL_COMMON (vnode->decl) = 0; - /* Even extern variables might have initializers known. - See, for example testsuite/g++.dg/opt/static3.C */ - vnode->const_value_known |= varpool_decide_const_value_known (vnode); } for (vnode = varpool_nodes_queue; vnode; vnode = vnode->next_needed) { @@ -797,7 +799,7 @@ function_and_variable_visibility (bool whole_program) In this case we do not sed used_from_object_file. */ || !vnode->finalized)) || DECL_PRESERVE_P (vnode->decl) - || vnode->used_from_object_file + || varpool_used_from_object_file_p (vnode) || pointer_set_contains (aliased_vnodes, vnode) || lookup_attribute ("externally_visible", DECL_ATTRIBUTES (vnode->decl)))) @@ -808,8 +810,8 @@ function_and_variable_visibility (bool whole_program) { gcc_assert (in_lto_p || whole_program || !TREE_PUBLIC (vnode->decl)); cgraph_make_decl_local (vnode->decl); + vnode->resolution = LDPR_PREVAILING_DEF_IRONLY; } - vnode->const_value_known |= varpool_decide_const_value_known (vnode); gcc_assert (TREE_STATIC (vnode->decl)); } pointer_set_destroy (aliased_nodes); |