diff options
author | hubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-10-26 18:34:03 +0000 |
---|---|---|
committer | hubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-10-26 18:34:03 +0000 |
commit | 7a1230f71b9ab10ae34001766ec5d20e9d5e2bc6 (patch) | |
tree | 39f363028e131d86bf27f53db160c2cb47409c98 /gcc/ipa.c | |
parent | 73834184cbf71b93df7eb27e02aa176e07d480f3 (diff) | |
download | gcc-7a1230f71b9ab10ae34001766ec5d20e9d5e2bc6.tar.gz |
* ipa.c (cgraph_externally_visible_p, varpool_externally_visible_p):
Use info provided by linker plugin.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@165978 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ipa.c')
-rw-r--r-- | gcc/ipa.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/gcc/ipa.c b/gcc/ipa.c index 2eb43b85596..c318b65fd92 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 |