]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR lto/54709 (r191713 breaks Firefox build)
authorRichard Guenther <rguenther@suse.de>
Thu, 27 Sep 2012 09:11:18 +0000 (09:11 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 27 Sep 2012 09:11:18 +0000 (09:11 +0000)
2012-09-27  Richard Guenther  <rguenther@suse.de>

PR lto/54709
* lto-symtab.c (resolution_guessed_p): Remove.
(set_resolution_guessed): Likewise.
(lto_symtab_register_decl): Remove assert.
(lto_symtab_resolve_symbols): Do not alter symbol resolutions
and return the prevailing symbol, checking for multiple prevailing
symbols here.
(lto_symtab_merge_decls_1): Use the result from
lto_symtab_resolve_symbols.  Do not alter symbol resolutions.

* gcc.dg/lto/pr54709_0.c: New testcase.
* gcc.dg/lto/pr54709_1.c: Likewise.

From-SVN: r191798

gcc/ChangeLog
gcc/lto-symtab.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/lto/pr54709_0.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/lto/pr54709_1.c [new file with mode: 0644]

index 3fb0b0130a22b79f92cab17a3fced2fd5fe78764..cb66af6b446d7f3a60ee384870c744492785bdb6 100644 (file)
@@ -1,3 +1,15 @@
+2012-09-27  Richard Guenther  <rguenther@suse.de>
+
+       PR lto/54709
+       * lto-symtab.c (resolution_guessed_p): Remove.
+       (set_resolution_guessed): Likewise.
+       (lto_symtab_register_decl): Remove assert.
+       (lto_symtab_resolve_symbols): Do not alter symbol resolutions
+       and return the prevailing symbol, checking for multiple prevailing
+       symbols here.
+       (lto_symtab_merge_decls_1): Use the result from
+       lto_symtab_resolve_symbols.  Do not alter symbol resolutions.
+
 2012-09-26  Steve Ellcey  <sellcey@mips.com>
 
        PR web/54711
index a8a46575ba522ecae3d0107d3e63534e03652d46..cd8ca67b0c0a549c614f545c5b11a3a1a946d05d 100644 (file)
@@ -32,21 +32,6 @@ along with GCC; see the file COPYING3.  If not see
 /* Vector to keep track of external variables we've seen so far.  */
 VEC(tree,gc) *lto_global_var_decls;
 
-/* Return true if the resolution was guessed and not obtained from
-   the file.  */
-static inline bool
-resolution_guessed_p (symtab_node node)
-{
-  return node->symbol.aux != NULL;
-}
-
-/* Set guessed flag for NODE.  */
-static inline void
-set_resolution_guessed (symtab_node node, bool value)
-{
-  node->symbol.aux = (void *)(size_t)value;
-}
-
 /* Registers DECL with the LTO symbol table as having resolution RESOLUTION
    and read from FILE_DATA. */
 
@@ -78,7 +63,6 @@ lto_symtab_register_decl (tree decl,
     {
       node->symbol.resolution = resolution;
       gcc_assert (node->symbol.lto_file_data == file_data);
-      gcc_assert (!resolution_guessed_p (node));
     }
 }
 
@@ -303,7 +287,7 @@ lto_symtab_resolve_can_prevail_p (symtab_node e)
 /* Resolve the symbol with the candidates in the chain *SLOT and store
    their resolutions.  */
 
-static void
+static symtab_node
 lto_symtab_resolve_symbols (symtab_node first)
 {
   symtab_node e;
@@ -315,27 +299,33 @@ lto_symtab_resolve_symbols (symtab_node first)
        && (e->symbol.resolution == LDPR_PREVAILING_DEF_IRONLY
            || e->symbol.resolution == LDPR_PREVAILING_DEF_IRONLY_EXP
            || e->symbol.resolution == LDPR_PREVAILING_DEF))
-      prevailing = e;
+      {
+       prevailing = e;
+       break;
+      }
 
   /* If the chain is already resolved there is nothing else to do.  */
   if (prevailing)
-    return;
+    {
+      /* Assert it's the only one.  */
+      for (e = prevailing->symbol.next_sharing_asm_name; e; e = e->symbol.next_sharing_asm_name)
+       if (symtab_real_symbol_p (e)
+           && (e->symbol.resolution == LDPR_PREVAILING_DEF_IRONLY
+               || e->symbol.resolution == LDPR_PREVAILING_DEF_IRONLY_EXP
+               || e->symbol.resolution == LDPR_PREVAILING_DEF))
+         fatal_error ("multiple prevailing defs for %qE",
+                      DECL_NAME (prevailing->symbol.decl));
+      return prevailing;
+    }
 
   /* Find the single non-replaceable prevailing symbol and
      diagnose ODR violations.  */
   for (e = first; e; e = e->symbol.next_sharing_asm_name)
     {
       if (!lto_symtab_resolve_can_prevail_p (e))
-       {
-         e->symbol.resolution = LDPR_RESOLVED_IR;
-          set_resolution_guessed (e, true);
-         continue;
-       }
+       continue;
 
-      /* Set a default resolution - the final prevailing one will get
-         adjusted later.  */
-      e->symbol.resolution = LDPR_PREEMPTED_IR;
-      set_resolution_guessed (e, true);
+      /* If we have a non-replaceable definition it prevails.  */
       if (!lto_symtab_resolve_replaceable_p (e))
        {
          if (prevailing)
@@ -349,12 +339,12 @@ lto_symtab_resolve_symbols (symtab_node first)
        }
     }
   if (prevailing)
-    goto found;
+    return prevailing;
 
   /* Do a second round choosing one from the replaceable prevailing decls.  */
   for (e = first; e; e = e->symbol.next_sharing_asm_name)
     {
-      if (e->symbol.resolution != LDPR_PREEMPTED_IR
+      if (!lto_symtab_resolve_can_prevail_p (e)
          || !symtab_real_symbol_p (e))
        continue;
 
@@ -386,25 +376,7 @@ lto_symtab_resolve_symbols (symtab_node first)
        prevailing = e;
     }
 
-  if (!prevailing)
-    return;
-
-found:
-  /* If current lto files represent the whole program,
-    it is correct to use LDPR_PREVALING_DEF_IRONLY.
-    If current lto files are part of whole program, internal
-    resolver doesn't know if it is LDPR_PREVAILING_DEF
-    or LDPR_PREVAILING_DEF_IRONLY.  Use IRONLY conforms to
-    using -fwhole-program.  Otherwise, it doesn't
-    matter using either LDPR_PREVAILING_DEF or
-    LDPR_PREVAILING_DEF_IRONLY
-    
-    FIXME: above workaround due to gold plugin makes some
-    variables IRONLY, which are indeed PREVAILING_DEF in
-    resolution file.  These variables still need manual
-    externally_visible attribute.  */
-    prevailing->symbol.resolution = LDPR_PREVAILING_DEF_IRONLY;
-    set_resolution_guessed (prevailing, true);
+  return prevailing;
 }
 
 /* Merge all decls in the symbol table chain to the prevailing decl and
@@ -478,27 +450,7 @@ lto_symtab_merge_decls_1 (symtab_node first)
 
   /* Compute the symbol resolutions.  This is a no-op when using the
      linker plugin and resolution was decided by the linker.  */
-  lto_symtab_resolve_symbols (first);
-
-  /* Find the prevailing decl.  */
-  for (prevailing = first;
-       prevailing
-       && (!symtab_real_symbol_p (prevailing)
-          || (prevailing->symbol.resolution != LDPR_PREVAILING_DEF_IRONLY
-              && prevailing->symbol.resolution != LDPR_PREVAILING_DEF_IRONLY_EXP
-              && prevailing->symbol.resolution != LDPR_PREVAILING_DEF));
-       prevailing = prevailing->symbol.next_sharing_asm_name)
-    ;
-
-  /* Assert it's the only one.  */
-  if (prevailing)
-    for (e = prevailing->symbol.next_sharing_asm_name; e; e = e->symbol.next_sharing_asm_name)
-      if (symtab_real_symbol_p (e)
-         && (e->symbol.resolution == LDPR_PREVAILING_DEF_IRONLY
-             || e->symbol.resolution == LDPR_PREVAILING_DEF_IRONLY_EXP
-             || e->symbol.resolution == LDPR_PREVAILING_DEF))
-       fatal_error ("multiple prevailing defs for %qE",
-                    DECL_NAME (prevailing->symbol.decl));
+  prevailing = lto_symtab_resolve_symbols (first);
 
   /* If there's not a prevailing symbol yet it's an external reference.
      Happens a lot during ltrans.  Choose the first symbol with a
@@ -574,21 +526,6 @@ lto_symtab_merge_decls_1 (symtab_node first)
       for (e = prevailing; e; e = e->symbol.next_sharing_asm_name)
        dump_symtab_node (cgraph_dump_file, e);
     }
-
-  /* Store resolution decision into the callgraph.  
-     In LTRANS don't overwrite information we stored into callgraph at
-     WPA stage.
-
-     Do not bother to store guessed decisions.  Generic code knows how
-     to handle UNKNOWN relocation well.
-
-     The problem with storing guessed decision is whether to use
-     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 (resolution_guessed_p (prevailing))
-    prevailing->symbol.resolution = LDPR_UNKNOWN;
-  return;
 }
 
 /* Resolve and merge all symbol table chains to a prevailing decl.  */
index 7eaa05d834cf7f11bc4278da5da6c9376a7b5499..ac9e619db75c8fc9817dfc294c79b8e1c7379580 100644 (file)
@@ -1,3 +1,9 @@
+2012-09-27  Richard Guenther  <rguenther@suse.de>
+
+       PR lto/54709
+       * gcc.dg/lto/pr54709_0.c: New testcase.
+       * gcc.dg/lto/pr54709_1.c: Likewise.
+
 2012-09-26  Janis Johnson  <janisjo@codesourcery.com>
 
        * gcc.target/arm/div64-unwinding.c: XFAIL for GNU/Linux.
diff --git a/gcc/testsuite/gcc.dg/lto/pr54709_0.c b/gcc/testsuite/gcc.dg/lto/pr54709_0.c
new file mode 100644 (file)
index 0000000..7e38bd4
--- /dev/null
@@ -0,0 +1,9 @@
+/* { dg-lto-do link } */
+/* { dg-require-visibility "hidden" } */
+/* { dg-extra-ld-options { -shared } } */
+/* { dg-lto-options { { -fPIC -fvisibility=hidden -flto } } } */
+
+void foo (void *p, void *q, unsigned s)
+{
+  __builtin_memcpy (p, q, s);
+}
diff --git a/gcc/testsuite/gcc.dg/lto/pr54709_1.c b/gcc/testsuite/gcc.dg/lto/pr54709_1.c
new file mode 100644 (file)
index 0000000..59c137d
--- /dev/null
@@ -0,0 +1,5 @@
+void * memcpy (void *, void *, long);
+void bar (void *p, void *q, unsigned s)
+{
+  memcpy (p, q, s);
+}