aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2010-10-26 20:34:03 +0200
committerJan Hubicka <hubicka@gcc.gnu.org>2010-10-26 18:34:03 +0000
commit892ae21cc72abd2c3b954a621b303fc2f37adc2a (patch)
tree39f363028e131d86bf27f53db160c2cb47409c98 /gcc
parent0e0f02ff9237738aabcb7466953d62641b9ab1d5 (diff)
downloadgcc-892ae21cc72abd2c3b954a621b303fc2f37adc2a.zip
gcc-892ae21cc72abd2c3b954a621b303fc2f37adc2a.tar.gz
gcc-892ae21cc72abd2c3b954a621b303fc2f37adc2a.tar.bz2
ipa.c (cgraph_externally_visible_p, [...]): Use info provided by linker plugin.
* ipa.c (cgraph_externally_visible_p, varpool_externally_visible_p): Use info provided by linker plugin. From-SVN: r165978
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/ipa.c19
2 files changed, 24 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 5454f67..6fa3e6a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2010-10-26 Jan Hubicka <jh@suse.cz>
+
+ * ipa.c (cgraph_externally_visible_p, varpool_externally_visible_p):
+ Use info provided by linker plugin.
+
2010-10-26 Jason Merrill <jason@redhat.com>
* varasm.c (constructor_static_from_elts_p): Don't require a
diff --git a/gcc/ipa.c b/gcc/ipa.c
index 2eb43b8..c318b65 100644
--- a/gcc/ipa.c
+++ b/gcc/ipa.c
@@ -603,6 +603,7 @@ ipa_discover_readonly_nonaddressable_vars (void)
static bool
cgraph_externally_visible_p (struct cgraph_node *node, bool whole_program, bool aliased)
{
+ struct cgraph_node *alias;
if (!node->local.finalized)
return false;
if (!DECL_COMDAT (node->decl)
@@ -622,6 +623,18 @@ cgraph_externally_visible_p (struct cgraph_node *node, bool whole_program, bool
if (lookup_attribute ("externally_visible", DECL_ATTRIBUTES (node->decl)))
return true;
+ /* See if we have linker information about symbol not being used or
+ if we need to make guess based on the declaration.
+
+ 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. */
+ for (alias = node->same_body; alias; alias = alias->next)
+ if (alias->resolution != LDPR_PREVAILING_DEF_IRONLY)
+ break;
+ if (!alias && node->resolution == LDPR_PREVAILING_DEF_IRONLY)
+ return false;
+
/* When doing link time optimizations, hidden symbols become local. */
if (in_lto_p
&& (DECL_VISIBILITY (node->decl) == VISIBILITY_HIDDEN
@@ -665,6 +678,7 @@ cgraph_externally_visible_p (struct cgraph_node *node, bool whole_program, bool
static bool
varpool_externally_visible_p (struct varpool_node *vnode, bool aliased)
{
+ struct varpool_node *alias;
if (!DECL_COMDAT (vnode->decl) && !TREE_PUBLIC (vnode->decl))
return false;
@@ -691,6 +705,11 @@ varpool_externally_visible_p (struct varpool_node *vnode, bool aliased)
This is needed for i.e. references from asm statements. */
if (varpool_used_from_object_file_p (vnode))
return true;
+ for (alias = vnode->extra_name; alias; alias = alias->next)
+ if (alias->resolution != LDPR_PREVAILING_DEF_IRONLY)
+ break;
+ if (!alias && vnode->resolution == LDPR_PREVAILING_DEF_IRONLY)
+ return false;
/* When doing link time optimizations, hidden symbols become local. */
if (in_lto_p