diff options
Diffstat (limited to 'gcc/ipa-visibility.c')
-rw-r--r-- | gcc/ipa-visibility.c | 46 |
1 files changed, 33 insertions, 13 deletions
diff --git a/gcc/ipa-visibility.c b/gcc/ipa-visibility.c index d128ca85f1c..41ed4db6745 100644 --- a/gcc/ipa-visibility.c +++ b/gcc/ipa-visibility.c @@ -217,13 +217,13 @@ cgraph_externally_visible_p (struct cgraph_node *node, This improves code quality and we know we will duplicate them at most twice (in the case that we are not using plugin and link with object file implementing same COMDAT) */ - if ((in_lto_p || whole_program) + if (((in_lto_p || whole_program) && !flag_incremental_link) && DECL_COMDAT (node->decl) && comdat_can_be_unshared_p (node)) return false; /* When doing link time optimizations, hidden symbols become local. */ - if (in_lto_p + if ((in_lto_p && !flag_incremental_link) && (DECL_VISIBILITY (node->decl) == VISIBILITY_HIDDEN || DECL_VISIBILITY (node->decl) == VISIBILITY_INTERNAL) /* Be sure that node is defined in IR file, not in other object @@ -293,13 +293,13 @@ varpool_node::externally_visible_p (void) so this does not enable more optimization, but referring static var is faster for dynamic linking. Also this match logic hidding vtables from LTO symbol tables. */ - if ((in_lto_p || flag_whole_program) + if (((in_lto_p || flag_whole_program) && !flag_incremental_link) && DECL_COMDAT (decl) && comdat_can_be_unshared_p (this)) return false; /* When doing link time optimizations, hidden symbols become local. */ - if (in_lto_p + if (in_lto_p && !flag_incremental_link && (DECL_VISIBILITY (decl) == VISIBILITY_HIDDEN || DECL_VISIBILITY (decl) == VISIBILITY_INTERNAL) /* Be sure that node is defined in IR file, not in other object @@ -405,17 +405,36 @@ update_visibility_by_resolution_info (symtab_node * node) for (symtab_node *next = node->same_comdat_group; next != node; next = next->same_comdat_group) { - next->set_comdat_group (NULL); - DECL_WEAK (next->decl) = false; + /* During incremental linking we need to keep symbol weak for future + linking. We can still drop definition if we know non-LTO world + prevails. */ + if (!flag_incremental_link) + { + DECL_WEAK (next->decl) = false; + next->set_comdat_group (NULL); + } if (next->externally_visible && !define) - DECL_EXTERNAL (next->decl) = true; + { + DECL_EXTERNAL (next->decl) = true; + next->set_comdat_group (NULL); + } } - node->set_comdat_group (NULL); - DECL_WEAK (node->decl) = false; + + /* During incremental linking we need to keep symbol weak for future + linking. We can still drop definition if we know non-LTO world prevails. */ + if (!flag_incremental_link) + { + DECL_WEAK (node->decl) = false; + node->set_comdat_group (NULL); + node->dissolve_same_comdat_group_list (); + } if (!define) - DECL_EXTERNAL (node->decl) = true; - node->dissolve_same_comdat_group_list (); + { + DECL_EXTERNAL (node->decl) = true; + node->set_comdat_group (NULL); + node->dissolve_same_comdat_group_list (); + } } /* Decide on visibility of all symbols. */ @@ -639,8 +658,9 @@ function_and_variable_visibility (bool whole_program) { gcc_assert (in_lto_p || whole_program || !TREE_PUBLIC (vnode->decl)); vnode->unique_name = ((vnode->resolution == LDPR_PREVAILING_DEF_IRONLY - || vnode->resolution == LDPR_PREVAILING_DEF_IRONLY_EXP) - && TREE_PUBLIC (vnode->decl)); + || vnode->resolution + == LDPR_PREVAILING_DEF_IRONLY_EXP) + && TREE_PUBLIC (vnode->decl)); if (vnode->same_comdat_group && TREE_PUBLIC (vnode->decl)) { symtab_node *next = vnode; |