]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix can_be_discarded_p wrt partitioned functions.
authorJan Hubicka <hubicka@ucw.cz>
Sat, 6 Nov 2021 22:36:08 +0000 (23:36 +0100)
committerJan Hubicka <hubicka@ucw.cz>
Sat, 6 Nov 2021 22:36:08 +0000 (23:36 +0100)
gcc/ChangeLog:

* cgraph.h (cgraph_node::can_be_discarded_p): Do not
return true on functions from other partition.

gcc/lto/ChangeLog:

PR ipa/103070
PR ipa/103058
* lto-partition.c (must_not_rename): Update comment.
(promote_symbol): Set resolution to LDPR_PREVAILING_DEF_IRONLY.

gcc/cgraph.h
gcc/lto/lto-partition.c

index 4cdb3738b4de0c3dbaaa0059fe0c1e4ff345ce2d..0a1f7c8960eb8fd77967d7fad5bf80c8a6026788 100644 (file)
@@ -404,7 +404,8 @@ public:
   inline bool
   can_be_discarded_p (void)
   {
-    return (DECL_EXTERNAL (decl)
+    return ((DECL_EXTERNAL (decl)
+            && !in_other_partition)
            || ((get_comdat_group ()
                 || DECL_COMMON (decl)
                 || (DECL_SECTION_NAME (decl) && DECL_WEAK (decl)))
index 15761ac9eb50f0a2ae0a90c9b63a80f5d2dd404d..bee402181596a5e2bbd4594a87b9453fe9b7effc 100644 (file)
@@ -852,7 +852,9 @@ must_not_rename (symtab_node *node, const char *name)
   /* Avoid mangling of already mangled clones. 
      ???  should have a flag whether a symbol has a 'private' name already,
      since we produce some symbols like that i.e. for global constructors
-     that are not really clones.  */
+     that are not really clones.
+     ???  it is what unique_name means.  We only need to set it when doing
+     private symbols.  */
   if (node->unique_name)
     {
       if (dump_file)
@@ -995,6 +997,10 @@ promote_symbol (symtab_node *node)
      defined by the non-LTO part.  */
   privatize_symbol_name (node);
   TREE_PUBLIC (node->decl) = 1;
+  /* After privatization the node should not conflict with any other symbol,
+     so it is prevailing.  This is important to keep binds_to_current_def_p
+     to work across partitions.  */
+  node->resolution = LDPR_PREVAILING_DEF_IRONLY;
   DECL_VISIBILITY (node->decl) = VISIBILITY_HIDDEN;
   DECL_VISIBILITY_SPECIFIED (node->decl) = true;
   if (dump_file)