]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR lto/60404 (wrong code by LTO on x86_64-linux-gnu)
authorJakub Jelinek <jakub@redhat.com>
Wed, 5 Mar 2014 08:46:31 +0000 (09:46 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 5 Mar 2014 08:46:31 +0000 (09:46 +0100)
PR lto/60404
* cfgexpand.c (expand_used_vars): Do not assume all SSA_NAMEs
of PARM/RESULT_DECLs must be coalesced with optimize && in_lto_p.
* tree-ssa-coalesce.c (coalesce_ssa_name): Use MUST_COALESCE_COST - 1
cost for in_lto_p.

* gcc.dg/lto/pr60404_0.c: New test.
* gcc.dg/lto/pr60404_1.c: New file.
* gcc.dg/lto/pr60404_2.c: New file.

From-SVN: r208340

gcc/ChangeLog
gcc/cfgexpand.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/lto/pr60404_0.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/lto/pr60404_1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/lto/pr60404_2.c [new file with mode: 0644]
gcc/tree-ssa-coalesce.c

index 1c15a1eba54c9b9569efd0cb22116fa93a1908dc..2ef225e192b5d1aa9bc3117aa0313444c7a080eb 100644 (file)
@@ -1,3 +1,11 @@
+2014-03-05  Jakub Jelinek  <jakub@redhat.com>
+
+       PR lto/60404
+       * cfgexpand.c (expand_used_vars): Do not assume all SSA_NAMEs
+       of PARM/RESULT_DECLs must be coalesced with optimize && in_lto_p.
+       * tree-ssa-coalesce.c (coalesce_ssa_name): Use MUST_COALESCE_COST - 1
+       cost for in_lto_p.
+
 2014-03-04  Heiher  <r@hev.cc>
 
        * config/mips/mips-cpus.def (loongson3a): Mark as a MIPS64r2 processor.
index 5c23b72ee7dbb15f5aa6ad6921ee6f8bd063d943..dd163a5f8c5e76e1adea1f211cfc9198f500e95f 100644 (file)
@@ -1652,10 +1652,12 @@ expand_used_vars (void)
         debug info, there is no need to do so if optimization is disabled
         because all the SSA_NAMEs based on these DECLs have been coalesced
         into a single partition, which is thus assigned the canonical RTL
-        location of the DECLs.  */
+        location of the DECLs.  If in_lto_p, we can't rely on optimize,
+        a function could be compiled with -O1 -flto first and only the
+        link performed at -O0.  */
       if (TREE_CODE (SSA_NAME_VAR (var)) == VAR_DECL)
        expand_one_var (var, true, true);
-      else if (DECL_IGNORED_P (SSA_NAME_VAR (var)) || optimize)
+      else if (DECL_IGNORED_P (SSA_NAME_VAR (var)) || optimize || in_lto_p)
        {
          /* This is a PARM_DECL or RESULT_DECL.  For those partitions that
             contain the default def (representing the parm or result itself)
index f9fa2b9deef1041924c6af618c49b12c25b819ba..e9258f3da830fa0497be867d1728a0113b10b4c0 100644 (file)
@@ -1,3 +1,10 @@
+2014-03-05  Jakub Jelinek  <jakub@redhat.com>
+
+       PR lto/60404
+       * gcc.dg/lto/pr60404_0.c: New test.
+       * gcc.dg/lto/pr60404_1.c: New file.
+       * gcc.dg/lto/pr60404_2.c: New file.
+
 2014-03-04  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
        * gcc.dg/vmx/extract-vsx.c: Replace "vector long" with "vector
diff --git a/gcc/testsuite/gcc.dg/lto/pr60404_0.c b/gcc/testsuite/gcc.dg/lto/pr60404_0.c
new file mode 100644 (file)
index 0000000..a22216d
--- /dev/null
@@ -0,0 +1,15 @@
+/* { dg-lto-do run } */
+/* { dg-lto-options { { -O1 -flto } } } */
+/* { dg-extra-ld-options { -O0 } } */
+
+extern void fn2 (int);
+int a[1], b;
+
+int
+main ()
+{
+  fn2 (0);
+  if (b != 0 || a[b] != 0)
+    __builtin_abort ();
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/lto/pr60404_1.c b/gcc/testsuite/gcc.dg/lto/pr60404_1.c
new file mode 100644 (file)
index 0000000..8c12598
--- /dev/null
@@ -0,0 +1,4 @@
+void
+fn1 (int p)
+{
+}
diff --git a/gcc/testsuite/gcc.dg/lto/pr60404_2.c b/gcc/testsuite/gcc.dg/lto/pr60404_2.c
new file mode 100644 (file)
index 0000000..e1db024
--- /dev/null
@@ -0,0 +1,9 @@
+extern int b;
+extern void fn1 (int);
+
+void
+fn2 (int p)
+{
+  b = p++;
+  fn1 (p);
+}
index 86276b361a61742e5b5cbeb0cb58d4f80c905203..9a1ac67bf7767cb359eae702b0fefc27cde2666d 100644 (file)
@@ -1289,9 +1289,12 @@ coalesce_ssa_name (void)
                     _require_ that all the names originating from it be
                     coalesced, because there must be a single partition
                     containing all the names so that it can be assigned
-                    the canonical RTL location of the DECL safely.  */
+                    the canonical RTL location of the DECL safely.
+                    If in_lto_p, a function could have been compiled
+                    originally with optimizations and only the link
+                    performed at -O0, so we can't actually require it.  */
                  const int cost
-                   = TREE_CODE (SSA_NAME_VAR (a)) == VAR_DECL
+                   = (TREE_CODE (SSA_NAME_VAR (a)) == VAR_DECL || in_lto_p)
                      ? MUST_COALESCE_COST - 1 : MUST_COALESCE_COST;
                  add_coalesce (cl, SSA_NAME_VERSION (a),
                                SSA_NAME_VERSION (*slot), cost);