re PR lto/47247 (Linker plugin specification makes it difficult to handle COMDATs)
authorJan Hubicka <jh@suse.cz>
Sun, 2 Oct 2011 10:41:24 +0000 (12:41 +0200)
committerJan Hubicka <hubicka@gcc.gnu.org>
Sun, 2 Oct 2011 10:41:24 +0000 (10:41 +0000)
PR lto/47247
* lto-plugin.c (get_symbols_v2): New variable.
(write_resolution): Use V2 API when available.
(onload): Handle LDPT_GET_SYMBOLS_V2.

* lto-symtab.c (lto_symtab_resolve_symbols): Do not resolve
when resolution is already availbale from plugin.
(lto_symtab_merge_decls_1): Handle LDPR_PREVAILING_DEF_IRONLY_EXP.
* cgraph.c (ld_plugin_symbol_resolution): Add prevailing_def_ironly_exp.
* lto-cgraph.c (LDPR_NUM_KNOWN): Update.
* ipa.c (varpool_externally_visible_p): IRONLY variables are never
externally visible.
* varasm.c (resolution_to_local_definition_p): Add
LDPR_PREVAILING_DEF_IRONLY_EXP.
(resolution_local_p): Likewise.

* common.c (lto_resolution_str): Add new resolution.
* common.h (lto_resolution_str): Likewise.

From-SVN: r179424

gcc/ChangeLog
gcc/cgraph.c
gcc/ipa.c
gcc/lto-cgraph.c
gcc/lto-symtab.c
gcc/lto/ChangeLog
gcc/lto/common.c
gcc/lto/common.h
gcc/varasm.c
lto-plugin/ChangeLog
lto-plugin/lto-plugin.c

index c6c8322e0aa6a2b7fa4e11f81e0c8525b93535a9..5373a31e291f65f41fea0bd325305e557baf659a 100644 (file)
@@ -1,3 +1,17 @@
+2011-10-02  Jan Hubicka  <jh@suse.cz>
+
+       PR lto/47247
+       * lto-symtab.c (lto_symtab_resolve_symbols): Do not resolve
+       when resolution is already availbale from plugin.
+       (lto_symtab_merge_decls_1): Handle LDPR_PREVAILING_DEF_IRONLY_EXP.
+       * cgraph.c (ld_plugin_symbol_resolution): Add prevailing_def_ironly_exp.
+       * lto-cgraph.c (LDPR_NUM_KNOWN): Update.
+       * ipa.c (varpool_externally_visible_p): IRONLY variables are never
+       externally visible.
+       * varasm.c (resolution_to_local_definition_p): Add
+       LDPR_PREVAILING_DEF_IRONLY_EXP.
+       (resolution_local_p): Likewise.
+
 2011-10-01  David S. Miller  <davem@davemloft.net>
 
        * config/sparc/sparc.opt (VIS3): New option.
index 14e7a3b0f0818e0729b475a9e99a322dc188c411..84d6bd5198ab1e77fb9aa4b18c5ccb9a5cdb1e9b 100644 (file)
@@ -110,7 +110,8 @@ const char * const ld_plugin_symbol_resolution_names[]=
   "preempted_ir",
   "resolved_ir",
   "resolved_exec",
-  "resolved_dyn"
+  "resolved_dyn",
+  "prevailing_def_ironly_exp"
 };
 
 static void cgraph_node_remove_callers (struct cgraph_node *node);
index 9d54811e5c9e8eef6c2b11fde45a0eca31ef82f2..a8c4a358e04a48ea01ef040f0aa3f38d97910419 100644 (file)
--- a/gcc/ipa.c
+++ b/gcc/ipa.c
@@ -685,6 +685,8 @@ 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;
+  if (vnode->resolution == LDPR_PREVAILING_DEF_IRONLY)
+    return false;
 
   /* As a special case, the COMDAT virutal tables can be unshared.
      In LTO mode turn vtables into static variables.  The variable is readonly,
index 0f1a8c5ff27b7b015f7160f5177413c51c3a772b..9254b8f90140b47aabef92ffec9522166d19fa69 100644 (file)
@@ -52,7 +52,7 @@ static void output_cgraph_opt_summary (cgraph_node_set set);
 static void input_cgraph_opt_summary (VEC (cgraph_node_ptr, heap) * nodes);
 
 /* Number of LDPR values known to GCC.  */
-#define LDPR_NUM_KNOWN (LDPR_RESOLVED_DYN + 1)
+#define LDPR_NUM_KNOWN (LDPR_PREVAILING_DEF_IRONLY_EXP + 1)
 
 /* Cgraph streaming is organized as set of record whose type
    is indicated by a tag.  */
index 3a7c783f770efb3da8aa9facfd9c4ffe3b70f9fb..68c6231760e7d0be7f8ef1f69ef383253fe7b060 100644 (file)
@@ -441,12 +441,14 @@ lto_symtab_resolve_symbols (void **slot)
        e->node = cgraph_get_node (e->decl);
       else if (TREE_CODE (e->decl) == VAR_DECL)
        e->vnode = varpool_get_node (e->decl);
+      if (e->resolution == LDPR_PREVAILING_DEF_IRONLY
+         || e->resolution == LDPR_PREVAILING_DEF_IRONLY_EXP
+         || e->resolution == LDPR_PREVAILING_DEF)
+       prevailing = e;
     }
 
-  e = (lto_symtab_entry_t) *slot;
-
   /* If the chain is already resolved there is nothing else to do.  */
-  if (e->resolution != LDPR_UNKNOWN)
+  if (prevailing)
     return;
 
   /* Find the single non-replaceable prevailing symbol and
@@ -586,6 +588,7 @@ lto_symtab_merge_decls_1 (void **slot, void *data ATTRIBUTE_UNUSED)
   for (prevailing = (lto_symtab_entry_t) *slot;
        prevailing
        && prevailing->resolution != LDPR_PREVAILING_DEF_IRONLY
+       && prevailing->resolution != LDPR_PREVAILING_DEF_IRONLY_EXP
        && prevailing->resolution != LDPR_PREVAILING_DEF;
        prevailing = prevailing->next)
     ;
@@ -595,6 +598,7 @@ lto_symtab_merge_decls_1 (void **slot, void *data ATTRIBUTE_UNUSED)
     for (e = prevailing->next; e; e = e->next)
       {
        if (e->resolution == LDPR_PREVAILING_DEF_IRONLY
+           || e->resolution == LDPR_PREVAILING_DEF_IRONLY_EXP
            || e->resolution == LDPR_PREVAILING_DEF)
          fatal_error ("multiple prevailing defs for %qE",
                       DECL_NAME (prevailing->decl));
@@ -685,9 +689,9 @@ lto_symtab_merge_decls_1 (void **slot, void *data ATTRIBUTE_UNUSED)
      to handle UNKNOWN relocation well.
 
      The problem with storing guessed decision is whether to use
-     PREVAILING_DEF or PREVAILING_DEF_IRONLY.  First one would disable
-     some whole program optimizations, while ther second would imply
-     to many whole program assumptions.  */
+     PREVAILING_DEF, PREVAILING_DEF_IRONLY, PREVAILING_DEF_IRONLY_EXP.
+     First one would disable some whole program optimizations, while
+     ther second would imply to many whole program assumptions.  */
   if (prevailing->node && !flag_ltrans && !prevailing->guessed)
     prevailing->node->resolution = prevailing->resolution;
   else if (prevailing->vnode && !flag_ltrans && !prevailing->guessed)
index 6ca8f5b7b1def9b05d3ab88282890023aa271c03..d3d7ffd484ef09f8ddbda8e3bfd95a2fe0069667 100644 (file)
@@ -1,3 +1,9 @@
+2011-10-02  Jan Hubicka  <jh@suse.cz>
+
+       PR lto/47247
+       * common.c (lto_resolution_str): Add new resolution.
+       * common.h (lto_resolution_str): Likewise.
+
 2011-09-30  H.J. Lu  <hongjiu.lu@intel.com>
            Andi Kleen  <ak@linux.intel.com>
 
index b54ec491e1215924bbdd8ac81bc84678e6141e7a..a23fdbb8434bb1e62455864c14e39ee6f2ade1a8 100644 (file)
@@ -31,7 +31,7 @@ const char *lto_visibility_str[4] __attribute__ ((visibility ("hidden"))) =
  "INTERNAL", "HIDDEN"
 };
 
-const char *lto_resolution_str[9] __attribute__ ((visibility ("hidden"))) =
+const char *lto_resolution_str[10] __attribute__ ((visibility ("hidden"))) =
 {
   "UNKNOWN",
   "UNDEF",
@@ -41,6 +41,7 @@ const char *lto_resolution_str[9] __attribute__ ((visibility ("hidden"))) =
   "PREEMPTED_IR",
   "RESOLVED_IR",
   "RESOLVED_EXEC",
-  "RESOLVED_DYN"
+  "RESOLVED_DYN",
+  "PREVAILING_DEF_IRONLY_EXP",
 };
 
index e82184795ba75efb29357b300c32f7bce3b098a0..6f9a6928916ce673e454a1295303c05baa1877f8 100644 (file)
@@ -20,7 +20,7 @@ along with GCC; see the file COPYING3.  If not see
 
 
 
-static const char *lto_resolution_str[9] =
+static const char *lto_resolution_str[10] =
 {
   "UNKNOWN",
   "UNDEF",
@@ -30,5 +30,6 @@ static const char *lto_resolution_str[9] =
   "PREEMPTED_IR",
   "RESOLVED_IR",
   "RESOLVED_EXEC",
-  "RESOLVED_DYN"
+  "RESOLVED_DYN",
+  "PREVAILING_DEF_IRONLY_EXP",
 };
index 9eb7295d68fe6e12c63b4a0b54806213ba974621..9b4dfad5cbb35dc162f315ee9954b48e37fb957e 100644 (file)
@@ -6683,6 +6683,7 @@ static bool
 resolution_to_local_definition_p (enum ld_plugin_symbol_resolution resolution)
 {
   return (resolution == LDPR_PREVAILING_DEF
+         || resolution == LDPR_PREVAILING_DEF_IRONLY_EXP
          || resolution == LDPR_PREVAILING_DEF_IRONLY);
 }
 
@@ -6694,6 +6695,7 @@ resolution_local_p (enum ld_plugin_symbol_resolution resolution)
 {
   return (resolution == LDPR_PREVAILING_DEF
          || resolution == LDPR_PREVAILING_DEF_IRONLY
+         || resolution == LDPR_PREVAILING_DEF_IRONLY_EXP
          || resolution == LDPR_PREEMPTED_REG
          || resolution == LDPR_PREEMPTED_IR
          || resolution == LDPR_RESOLVED_IR
index 7b0f3bc8b274a7bcabf41bf9d0fbf1b761493e77..bf149e4b880d971e223b9093597c6f24d72ffa1b 100644 (file)
@@ -1,3 +1,10 @@
+2011-10-02  Jan Hubicka  <jh@suse.cz>
+
+       PR lto/47247
+       * lto-plugin.c (get_symbols_v2): New variable.
+       (write_resolution): Use V2 API when available.
+       (onload): Handle LDPT_GET_SYMBOLS_V2.
+
 2011-09-30  H.J. Lu  <hongjiu.lu@intel.com>
            Andi Kleen  <ak@linux.intel.com>
 
index 9323bd201ed30486c7b68538045fc240450ddb8f..d7a78136827866038d69e9cb154dec7202d87ee3 100644 (file)
@@ -130,7 +130,7 @@ enum symbol_style
 static char *arguments_file_name;
 static ld_plugin_register_claim_file register_claim_file;
 static ld_plugin_register_all_symbols_read register_all_symbols_read;
-static ld_plugin_get_symbols get_symbols;
+static ld_plugin_get_symbols get_symbols, get_symbols_v2;
 static ld_plugin_register_cleanup register_cleanup;
 static ld_plugin_add_input_file add_input_file;
 static ld_plugin_add_input_library add_input_library;
@@ -443,7 +443,12 @@ write_resolution (void)
       struct plugin_symtab *symtab = &info->symtab;
       struct ld_plugin_symbol *syms = symtab->syms;
 
-      get_symbols (info->handle, symtab->nsyms, syms);
+      /* Version 2 of API supports IRONLY_EXP resolution that is
+         accepted by GCC-4.7 and newer.  */
+      if (get_symbols_v2)
+        get_symbols_v2 (info->handle, symtab->nsyms, syms);
+      else
+        get_symbols (info->handle, symtab->nsyms, syms);
 
       finish_conflict_resolution (symtab, &info->conflicts);
 
@@ -988,6 +993,9 @@ onload (struct ld_plugin_tv *tv)
        case LDPT_REGISTER_ALL_SYMBOLS_READ_HOOK:
          register_all_symbols_read = p->tv_u.tv_register_all_symbols_read;
          break;
+       case LDPT_GET_SYMBOLS_V2:
+         get_symbols_v2 = p->tv_u.tv_get_symbols;
+         break;
        case LDPT_GET_SYMBOLS:
          get_symbols = p->tv_u.tv_get_symbols;
          break;