aboutsummaryrefslogtreecommitdiff
path: root/gcc/ipa-visibility.c
diff options
context:
space:
mode:
authorJan Hubicka <hubicka@ucw.cz>2014-06-13 00:23:55 +0200
committerJan Hubicka <hubicka@gcc.gnu.org>2014-06-12 22:23:55 +0000
commit24e49ea0b11e0ccfb2c18b7d79c5cb46f36f8db8 (patch)
tree614d47109aba7fe36bcb27ee602307278455a372 /gcc/ipa-visibility.c
parent6ad386b725dfac340e0d337d4c20e603929c7f9a (diff)
downloadgcc-24e49ea0b11e0ccfb2c18b7d79c5cb46f36f8db8.zip
gcc-24e49ea0b11e0ccfb2c18b7d79c5cb46f36f8db8.tar.gz
gcc-24e49ea0b11e0ccfb2c18b7d79c5cb46f36f8db8.tar.bz2
symtab.c (symtab_node::reset_section): New method.
* symtab.c (symtab_node::reset_section): New method. * cgraph.c (cgraph_node_cannot_be_local_p_1): Accept non-local for localization. * cgraph.h (reset_section): Declare. * ipa-inline-analysis.c (do_estimate_growth): Check for comdat groups; do not consider comdat locals. * cgraphclones.c (set_new_clone_decl_and_node_flags): Get section for new symbol. * ipa-visiblity.c (cgraph_externally_visible_p): Cleanup. (update_visibility_by_resolution_info): Consider UNDEF; fix checking; reset sections of symbols dragged out of the comdats. (function_and_variable_visibility): Reset sections of localized symbols. From-SVN: r211600
Diffstat (limited to 'gcc/ipa-visibility.c')
-rw-r--r--gcc/ipa-visibility.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/gcc/ipa-visibility.c b/gcc/ipa-visibility.c
index 4e0fd9e..97f9a00 100644
--- a/gcc/ipa-visibility.c
+++ b/gcc/ipa-visibility.c
@@ -236,7 +236,7 @@ cgraph_externally_visible_p (struct cgraph_node *node,
return true;
if (node->resolution == LDPR_PREVAILING_DEF_IRONLY)
return false;
- /* When doing LTO or whole program, we can bring COMDAT functoins static.
+ /* When doing LTO or whole program, we can bring COMDAT functions static.
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) */
@@ -295,8 +295,6 @@ varpool_externally_visible_p (varpool_node *vnode)
Even if the linker clams the symbol is unused, never bring internal
symbols that are declared by user as used or externally visible.
This is needed for i.e. references from asm statements. */
- if (symtab_used_from_object_file_p (vnode))
- return true;
if (vnode->resolution == LDPR_PREVAILING_DEF_IRONLY)
return false;
@@ -386,7 +384,8 @@ update_visibility_by_resolution_info (symtab_node * node)
if (!node->externally_visible
|| (!DECL_WEAK (node->decl) && !DECL_ONE_ONLY (node->decl))
- || node->resolution == LDPR_UNKNOWN)
+ || node->resolution == LDPR_UNKNOWN
+ || node->resolution == LDPR_UNDEF)
return;
define = (node->resolution == LDPR_PREVAILING_DEF_IRONLY
@@ -397,7 +396,7 @@ update_visibility_by_resolution_info (symtab_node * node)
if (node->same_comdat_group)
for (symtab_node *next = node->same_comdat_group;
next != node; next = next->same_comdat_group)
- gcc_assert (!node->externally_visible
+ gcc_assert (!next->externally_visible
|| define == (next->resolution == LDPR_PREVAILING_DEF_IRONLY
|| next->resolution == LDPR_PREVAILING_DEF
|| next->resolution == LDPR_PREVAILING_DEF_IRONLY_EXP));
@@ -411,11 +410,15 @@ update_visibility_by_resolution_info (symtab_node * node)
if (next->externally_visible
&& !define)
DECL_EXTERNAL (next->decl) = true;
+ if (!next->alias)
+ next->reset_section ();
}
node->set_comdat_group (NULL);
DECL_WEAK (node->decl) = false;
if (!define)
DECL_EXTERNAL (node->decl) = true;
+ if (!node->alias)
+ node->reset_section ();
symtab_dissolve_same_comdat_group_list (node);
}
@@ -476,7 +479,7 @@ function_and_variable_visibility (bool whole_program)
symtab_dissolve_same_comdat_group_list (node);
}
gcc_assert ((!DECL_WEAK (node->decl)
- && !DECL_COMDAT (node->decl))
+ && !DECL_COMDAT (node->decl))
|| TREE_PUBLIC (node->decl)
|| node->weakref
|| DECL_EXTERNAL (node->decl));
@@ -494,6 +497,7 @@ function_and_variable_visibility (bool whole_program)
&& node->definition && !node->weakref
&& !DECL_EXTERNAL (node->decl))
{
+ bool reset = TREE_PUBLIC (node->decl);
gcc_assert (whole_program || in_lto_p
|| !TREE_PUBLIC (node->decl));
node->unique_name = ((node->resolution == LDPR_PREVAILING_DEF_IRONLY
@@ -512,9 +516,9 @@ function_and_variable_visibility (bool whole_program)
next = next->same_comdat_group)
{
next->set_comdat_group (NULL);
- if (!next->alias)
- next->set_section (NULL);
symtab_make_decl_local (next->decl);
+ if (!node->alias)
+ node->reset_section ();
next->unique_name = ((next->resolution == LDPR_PREVAILING_DEF_IRONLY
|| next->unique_name
|| next->resolution == LDPR_PREVAILING_DEF_IRONLY_EXP)
@@ -528,9 +532,9 @@ function_and_variable_visibility (bool whole_program)
}
if (TREE_PUBLIC (node->decl))
node->set_comdat_group (NULL);
- if (DECL_COMDAT (node->decl) && !node->alias)
- node->set_section (NULL);
symtab_make_decl_local (node->decl);
+ if (reset && !node->alias)
+ node->reset_section ();
}
if (node->thunk.thunk_p
@@ -632,6 +636,7 @@ function_and_variable_visibility (bool whole_program)
if (!vnode->externally_visible
&& !vnode->weakref)
{
+ bool reset = TREE_PUBLIC (vnode->decl);
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)
@@ -647,9 +652,9 @@ function_and_variable_visibility (bool whole_program)
next = next->same_comdat_group)
{
next->set_comdat_group (NULL);
- if (!next->alias)
- next->set_section (NULL);
symtab_make_decl_local (next->decl);
+ if (!next->alias)
+ next->reset_section ();
next->unique_name = ((next->resolution == LDPR_PREVAILING_DEF_IRONLY
|| next->unique_name
|| next->resolution == LDPR_PREVAILING_DEF_IRONLY_EXP)
@@ -659,9 +664,9 @@ function_and_variable_visibility (bool whole_program)
}
if (TREE_PUBLIC (vnode->decl))
vnode->set_comdat_group (NULL);
- if (DECL_COMDAT (vnode->decl) && !vnode->alias)
- vnode->set_section (NULL);
symtab_make_decl_local (vnode->decl);
+ if (reset && !vnode->alias)
+ vnode->reset_section ();
vnode->resolution = LDPR_PREVAILING_DEF_IRONLY;
}
update_visibility_by_resolution_info (vnode);