OSDN Git Service

* ipa.c (cgraph_externally_visible_p, varpool_externally_visible_p):
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 26 Oct 2010 18:34:03 +0000 (18:34 +0000)
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 26 Oct 2010 18:34:03 +0000 (18:34 +0000)
Use info provided by linker plugin.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@165978 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/ipa.c

index 5454f67..6fa3e6a 100644 (file)
@@ -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
index 2eb43b8..c318b65 100644 (file)
--- 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