Hi,
in the testcase I don't really know how to put into testsuite since it needs DSO
there is issue with LTO not merging external declaration with body. This is 
because
logic in symtab_real_symbol_p that really applies only to LTO symbol table 
output
not to the symbol merging.

Bootstrapped/regtested x86_64-linux and tested with Mozilla build.

Honza

        PR lto/54728
        * cgraph.h (symtab_real_symbol_p): Drop code looking for external 
functions.
        * lto-streamer-out.c (output_symbol_p): New function.
        (produce_symtab) Use it.
Index: cgraph.h
===================================================================
*** cgraph.h    (revision 194605)
--- cgraph.h    (working copy)
*************** static inline bool
*** 1357,1363 ****
  symtab_real_symbol_p (symtab_node node)
  {
    struct cgraph_node *cnode;
-   struct ipa_ref *ref;
  
    if (!is_a <cgraph_node> (node))
      return true;
--- 1357,1362 ----
*************** symtab_real_symbol_p (symtab_node node)
*** 1366,1376 ****
      return false;
    if (cnode->abstract_and_needed)
      return false;
-   /* We keep virtual clones in symtab.  */
-   if (!cnode->analyzed
-       || DECL_EXTERNAL (cnode->symbol.decl))
-     return (cnode->callers
-           || ipa_ref_list_referring_iterate (&cnode->symbol.ref_list, 0, 
ref));
    return true;
  }
  #endif  /* GCC_CGRAPH_H  */
--- 1365,1370 ----
Index: lto-streamer-out.c
===================================================================
*** lto-streamer-out.c  (revision 194605)
--- lto-streamer-out.c  (working copy)
*************** write_symbol (struct streamer_tree_cache
*** 1257,1262 ****
--- 1257,1282 ----
    lto_output_data_stream (stream, &slot_num, 4);
  }
  
+ /* Return true if NODE should appear in the plugin symbol table.  */
+ 
+ bool
+ output_symbol_p (symtab_node node)
+ {
+   struct cgraph_node *cnode;
+   struct ipa_ref *ref;
+ 
+   if (!symtab_real_symbol_p (node))
+     return false;
+   /* We keep external functions in symtab for sake of inlining
+      and devirtualization.  We do not want to see them in symbol table as
+      references.  */
+   cnode = dyn_cast <cgraph_node> (node);
+   if (cnode && DECL_EXTERNAL (cnode->symbol.decl))
+     return (cnode->callers
+           || ipa_ref_list_referring_iterate (&cnode->symbol.ref_list, 0, 
ref));
+   return true;
+ }
+ 
  
  /* Write an IL symbol table to OB.
     SET and VSET are cgraph/varpool node sets we are outputting.  */
*************** produce_symtab (struct output_block *ob)
*** 1285,1291 ****
      {
        symtab_node node = lsei_node (lsei);
  
!       if (!symtab_real_symbol_p (node) || DECL_EXTERNAL (node->symbol.decl))
        continue;
        write_symbol (cache, &stream, node->symbol.decl, seen, false);
      }
--- 1305,1311 ----
      {
        symtab_node node = lsei_node (lsei);
  
!       if (!output_symbol_p (node) || DECL_EXTERNAL (node->symbol.decl))
        continue;
        write_symbol (cache, &stream, node->symbol.decl, seen, false);
      }
*************** produce_symtab (struct output_block *ob)
*** 1294,1300 ****
      {
        symtab_node node = lsei_node (lsei);
  
!       if (!symtab_real_symbol_p (node) || !DECL_EXTERNAL (node->symbol.decl))
        continue;
        write_symbol (cache, &stream, node->symbol.decl, seen, false);
      }
--- 1314,1320 ----
      {
        symtab_node node = lsei_node (lsei);
  
!       if (!output_symbol_p (node) || !DECL_EXTERNAL (node->symbol.decl))
        continue;
        write_symbol (cache, &stream, node->symbol.decl, seen, false);
      }

Reply via email to