aboutsummaryrefslogtreecommitdiff
path: root/gcc/lto
diff options
context:
space:
mode:
authorJan Hubicka <hubicka@ucw.cz>2015-12-08 21:46:42 +0100
committerJan Hubicka <hubicka@gcc.gnu.org>2015-12-08 20:46:42 +0000
commit41c60c6c75356bfe5e4ce11184b4bf62a6a86132 (patch)
tree070b72d4a6f7fcdb30376fb1606827653d3cd7a8 /gcc/lto
parent21fc3950f686e37785b377d44d0054b75e8e203f (diff)
downloadgcc-41c60c6c75356bfe5e4ce11184b4bf62a6a86132.zip
gcc-41c60c6c75356bfe5e4ce11184b4bf62a6a86132.tar.gz
gcc-41c60c6c75356bfe5e4ce11184b4bf62a6a86132.tar.bz2
re PR lto/61886 (LTO breaks fread with _FORTIFY_SOURCE=2)
PR ipa/61886 * lto-partition.c (add_symbol_to_partition_1): Transparent aliases are not part of the definition. (contained_in_symbol): Likewise. (promote_symbol): When promoting a symbol also promote all transparent aliases. (rename_statics): Weakref needs unique name, too. From-SVN: r231425
Diffstat (limited to 'gcc/lto')
-rw-r--r--gcc/lto/ChangeLog10
-rw-r--r--gcc/lto/lto-partition.c42
2 files changed, 47 insertions, 5 deletions
diff --git a/gcc/lto/ChangeLog b/gcc/lto/ChangeLog
index bdbc866..5fba06a 100644
--- a/gcc/lto/ChangeLog
+++ b/gcc/lto/ChangeLog
@@ -1,3 +1,13 @@
+2015-12-08 Jan Hubicka <hubicka@ucw.cz>
+
+ PR ipa/61886
+ * lto-partition.c (add_symbol_to_partition_1): Transparent aliases
+ are not part of the definition.
+ (contained_in_symbol): Likewise.
+ (promote_symbol): When promoting a symbol also promote all transparent
+ aliases.
+ (rename_statics): Weakref needs unique name, too.
+
2015-12-07 Jan Hubicka <hubicka@ucw.cz>
PR ipa/61886
diff --git a/gcc/lto/lto-partition.c b/gcc/lto/lto-partition.c
index ac1b618..8d58647 100644
--- a/gcc/lto/lto-partition.c
+++ b/gcc/lto/lto-partition.c
@@ -177,8 +177,20 @@ add_symbol_to_partition_1 (ltrans_partition part, symtab_node *node)
/* Add all aliases associated with the symbol. */
FOR_EACH_ALIAS (node, ref)
- if (!node->weakref)
+ if (!ref->referring->transparent_alias)
add_symbol_to_partition_1 (part, ref->referring);
+ else
+ {
+ struct ipa_ref *ref2;
+ /* We do not need to add transparent aliases if they are not used.
+ However we must add aliases of transparent aliases if they exist. */
+ FOR_EACH_ALIAS (ref->referring, ref2)
+ {
+ /* Nested transparent aliases are not permitted. */
+ gcc_checking_assert (!ref2->referring->transparent_alias);
+ add_symbol_to_partition_1 (part, ref2->referring);
+ }
+ }
/* Ensure that SAME_COMDAT_GROUP lists all allways added in a group. */
if (node->same_comdat_group)
@@ -199,8 +211,10 @@ add_symbol_to_partition_1 (ltrans_partition part, symtab_node *node)
static symtab_node *
contained_in_symbol (symtab_node *node)
{
- /* Weakrefs are never contained in anything. */
- if (node->weakref)
+ /* There is no need to consider transparent aliases to be part of the
+ definition: they are only useful insite the partition they are output
+ and thus we will always see an explicit reference to it. */
+ if (node->transparent_alias)
return node;
if (cgraph_node *cnode = dyn_cast <cgraph_node *> (node))
{
@@ -967,6 +981,23 @@ promote_symbol (symtab_node *node)
TREE_PUBLIC (node->decl) = 1;
DECL_VISIBILITY (node->decl) = VISIBILITY_HIDDEN;
DECL_VISIBILITY_SPECIFIED (node->decl) = true;
+ ipa_ref *ref;
+
+ /* Promoting a symbol also promotes all trasparent aliases with exception
+ of weakref where the visibility flags are always wrong and set to
+ !PUBLIC. */
+ for (unsigned i = 0; node->iterate_direct_aliases (i, ref); i++)
+ {
+ struct symtab_node *alias = ref->referring;
+ if (alias->transparent_alias && !alias->weakref)
+ {
+ TREE_PUBLIC (alias->decl) = 1;
+ DECL_VISIBILITY (alias->decl) = VISIBILITY_HIDDEN;
+ DECL_VISIBILITY_SPECIFIED (alias->decl) = true;
+ }
+ gcc_assert (!alias->weakref || TREE_PUBLIC (alias->decl));
+ }
+
if (symtab->dump_file)
fprintf (symtab->dump_file,
"Promoting as hidden: %s\n", node->name ());
@@ -974,7 +1005,8 @@ promote_symbol (symtab_node *node)
/* Return true if NODE needs named section even if it won't land in the partition
symbol table.
- FIXME: we should really not use named sections for inline clones and master clones. */
+ FIXME: we should really not use named sections for inline clones and master
+ clones. */
static bool
may_need_named_section_p (lto_symtab_encoder_t encoder, symtab_node *node)
@@ -1004,7 +1036,7 @@ rename_statics (lto_symtab_encoder_t encoder, symtab_node *node)
tree name = DECL_ASSEMBLER_NAME (decl);
/* See if this is static symbol. */
- if ((node->externally_visible
+ if (((node->externally_visible && !node->weakref)
/* FIXME: externally_visible is somewhat illogically not set for
external symbols (i.e. those not defined). Remove this test
once this is fixed. */