re PR ipa/60026 (ICE at -O3 on valid code (with the optimize pragma) on x86_64-linux...
authorJakub Jelinek <jakub@redhat.com>
Tue, 4 Feb 2014 13:04:37 +0000 (14:04 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 4 Feb 2014 13:04:37 +0000 (14:04 +0100)
PR ipa/60026
* tree-inline.c (copy_forbidden): Fail for
__attribute__((optimize (0))) functions.

* c-c++-common/torture/pr60026.c: New test.

From-SVN: r207463

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/torture/pr60026.c [new file with mode: 0644]
gcc/tree-inline.c

index 1105fa9de8afb3ba680d998b643f54b498e7b44f..6c6dfd6cd9490928cd08dfe74baccb0002e0de09 100644 (file)
@@ -1,5 +1,9 @@
 2014-02-04  Jakub Jelinek  <jakub@redhat.com>
 
+       PR ipa/60026
+       * tree-inline.c (copy_forbidden): Fail for
+       __attribute__((optimize (0))) functions.
+
        PR other/58712
        * omp-low.c (simd_clone_struct_copy): If from->inbranch
        is set, copy one less argument.
index 31e271dc34f239535d4a287d4547a339a5bd35ae..f23b6c47455395e0080fc2a162ca76593a9df436 100644 (file)
@@ -1,5 +1,8 @@
 2014-02-04  Jakub Jelinek  <jakub@redhat.com>
 
+       PR ipa/60026
+       * c-c++-common/torture/pr60026.c: New test.
+
        PR rtl-optimization/57915
        * gcc.target/i386/pr57915.c: New test.
 
diff --git a/gcc/testsuite/c-c++-common/torture/pr60026.c b/gcc/testsuite/c-c++-common/torture/pr60026.c
new file mode 100644 (file)
index 0000000..1cc5f55
--- /dev/null
@@ -0,0 +1,28 @@
+/* PR ipa/60026 */
+/* { dg-do compile } */
+
+struct S { int f; } a;
+
+__attribute__((optimize (0)))
+struct S foo (int x, struct S y)
+{
+  int b = y.f;
+  return a; 
+}
+
+void
+bar ()
+{
+  while (a.f)
+    {
+      struct S c = {0};
+      foo (0, c);
+    }
+}
+
+int
+main ()
+{
+  bar (); 
+  return 0;
+}
index 439ef4c2933a793e76fe387379a081515441e458..ade78b22a12aceb5bab23e5652cdfafc76ecc0bc 100644 (file)
@@ -3315,6 +3315,18 @@ copy_forbidden (struct function *fun, tree fndecl)
        goto fail;
       }
 
+  tree fs_opts;
+  fs_opts = DECL_FUNCTION_SPECIFIC_OPTIMIZATION (fun->decl);
+  if (fs_opts)
+    {
+      struct cl_optimization *os = TREE_OPTIMIZATION (fs_opts);
+      if (!os->x_optimize)
+       {
+         reason = G_("function %q+F compiled without optimizations");
+         goto fail;
+       }
+    }
+
  fail:
   fun->cannot_be_copied_reason = reason;
   fun->cannot_be_copied_set = true;