If privitized symbol needs to be made public, it is renamed. That is not possible for symbols referenced from assembly. Thus we forbid privatization of those symbols.
gcc/ChangeLog: * cgraph.h (cgraph_node::only_called_directly_or_aliased_p): Consider referenced_from_asm. * ipa-visibility.cc (non_local_p): Likewise. (cgraph_externally_visible_p): Likewise. (varpool_node::externally_visible_p): Likewise. --- gcc/cgraph.h | 1 + gcc/ipa-visibility.cc | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/gcc/cgraph.h b/gcc/cgraph.h index 53b8e1d0e37..069392cf131 100644 --- a/gcc/cgraph.h +++ b/gcc/cgraph.h @@ -3213,6 +3213,7 @@ cgraph_node::only_called_directly_or_aliased_p (void) && !DECL_STATIC_CONSTRUCTOR (decl) && !DECL_STATIC_DESTRUCTOR (decl) && !used_from_object_file_p () + && !referenced_from_asm && !externally_visible); } diff --git a/gcc/ipa-visibility.cc b/gcc/ipa-visibility.cc index 8097a03e240..70bdaf4ce34 100644 --- a/gcc/ipa-visibility.cc +++ b/gcc/ipa-visibility.cc @@ -100,6 +100,7 @@ non_local_p (struct cgraph_node *node, void *data ATTRIBUTE_UNUSED) && !DECL_EXTERNAL (node->decl) && !lookup_attribute ("noipa", DECL_ATTRIBUTES (node->decl)) && !node->externally_visible + && !node->referenced_from_asm && !node->used_from_other_partition && !node->in_other_partition && node->get_availability () >= AVAIL_AVAILABLE @@ -198,6 +199,8 @@ cgraph_externally_visible_p (struct cgraph_node *node, if (!TREE_PUBLIC (node->decl) || DECL_EXTERNAL (node->decl)) return false; + if (node->referenced_from_asm) + return true; /* Do not try to localize built-in functions yet. One of problems is that we end up mangling their asm for WHOPR that makes it impossible to call them @@ -269,6 +272,8 @@ varpool_node::externally_visible_p (void) if (!TREE_PUBLIC (decl)) return false; + if (referenced_from_asm) + return true; /* If linker counts on us, we must preserve the function. */ if (used_from_object_file_p ()) -- 2.50.0