From d665f8dde6f4d6c68635cbef972ef7ce085a359b Mon Sep 17 00:00:00 2001 From: Jan Hubicka Date: Wed, 5 Feb 2014 00:26:36 +0100 Subject: [PATCH] ipa.c (function_and_variable_visibility): Decompose DECL_ONE_ONLY groups when we know they are controlled by LTO. * ipa.c (function_and_variable_visibility): Decompose DECL_ONE_ONLY groups when we know they are controlled by LTO. * varasm.c (default_binds_local_p_1): If object is in other partition, it will be resolved locally. * lto-partition.c (get_symbol_class): Only unforced DECL_ONE_ONLY needs duplicating, not generic COMDAT. From-SVN: r207489 --- gcc/ChangeLog | 7 +++++++ gcc/ipa.c | 30 ++++++++++++++++++++++++++++++ gcc/lto/ChangeLog | 5 +++++ gcc/lto/lto-partition.c | 8 +++++--- gcc/varasm.c | 4 ++-- 5 files changed, 49 insertions(+), 5 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1d7a8fd5d07c..8d2e39444cce 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2014-02-04 Jan Hubicka + + * ipa.c (function_and_variable_visibility): Decompose DECL_ONE_ONLY + groups when we know they are controlled by LTO. + * varasm.c (default_binds_local_p_1): If object is in other partition, + it will be resolved locally. + 2014-02-04 Bernd Edlinger * gcc/config/host-linux.c (linux_gt_pch_use_address): Don't diff --git a/gcc/ipa.c b/gcc/ipa.c index a7e4d764786a..be75cba2dfa3 100644 --- a/gcc/ipa.c +++ b/gcc/ipa.c @@ -1002,6 +1002,36 @@ function_and_variable_visibility (bool whole_program) if (DECL_EXTERNAL (decl_node->decl)) DECL_EXTERNAL (node->decl) = 1; } + + /* If whole comdat group is used only within LTO code, we can dissolve it, + we handle the unification ourselves. + We keep COMDAT and weak so visibility out of DSO does not change. + Later we may bring the symbols static if they are not exported. */ + if (DECL_ONE_ONLY (node->decl) + && (node->resolution == LDPR_PREVAILING_DEF_IRONLY + || node->resolution == LDPR_PREVAILING_DEF_IRONLY_EXP)) + { + symtab_node *next = node; + + if (node->same_comdat_group) + for (next = node->same_comdat_group; + next != node; + next = next->same_comdat_group) + if (next->externally_visible + && (next->resolution != LDPR_PREVAILING_DEF_IRONLY + && next->resolution != LDPR_PREVAILING_DEF_IRONLY_EXP)) + break; + if (node == next) + { + if (node->same_comdat_group) + for (next = node->same_comdat_group; + next != node; + next = next->same_comdat_group) + DECL_COMDAT_GROUP (next->decl) = NULL; + DECL_COMDAT_GROUP (node->decl) = NULL; + symtab_dissolve_same_comdat_group_list (node); + } + } } FOR_EACH_DEFINED_FUNCTION (node) { diff --git a/gcc/lto/ChangeLog b/gcc/lto/ChangeLog index 437e97e99f82..0f9e6882b5fb 100644 --- a/gcc/lto/ChangeLog +++ b/gcc/lto/ChangeLog @@ -1,3 +1,8 @@ +2014-02-04 Jan Hubicka + + * lto-partition.c (get_symbol_class): Only unforced DECL_ONE_ONLY + needs duplicating, not generic COMDAT. + 2014-02-04 Richard Biener PR lto/59723 diff --git a/gcc/lto/lto-partition.c b/gcc/lto/lto-partition.c index 6b2d488ed090..da76b10511f0 100644 --- a/gcc/lto/lto-partition.c +++ b/gcc/lto/lto-partition.c @@ -94,10 +94,12 @@ get_symbol_class (symtab_node *node) else if (!cgraph (node)->definition) return SYMBOL_EXTERNAL; - /* Comdats are duplicated to every use unless they are keyed. - Those do not need duplication. */ - if (DECL_COMDAT (node->decl) + /* Linker discardable symbols are duplicated to every use unless they are + keyed. + Keyed symbols or those. */ + if (DECL_ONE_ONLY (node->decl) && !node->force_output + && !node->forced_by_abi && !symtab_used_from_object_file_p (node)) return SYMBOL_DUPLICATE; diff --git a/gcc/varasm.c b/gcc/varasm.c index d46f0084458b..295c27d9d8dc 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -6739,7 +6739,7 @@ default_binds_local_p_1 (const_tree exp, int shlib) && (TREE_STATIC (exp) || DECL_EXTERNAL (exp))) { varpool_node *vnode = varpool_get_node (exp); - if (vnode && resolution_local_p (vnode->resolution)) + if (vnode && (resolution_local_p (vnode->resolution) || vnode->in_other_partition)) resolved_locally = true; if (vnode && resolution_to_local_definition_p (vnode->resolution)) @@ -6749,7 +6749,7 @@ default_binds_local_p_1 (const_tree exp, int shlib) { struct cgraph_node *node = cgraph_get_node (exp); if (node - && resolution_local_p (node->resolution)) + && (resolution_local_p (node->resolution) || node->in_other_partition)) resolved_locally = true; if (node && resolution_to_local_definition_p (node->resolution)) -- 2.47.2