]> gcc.gnu.org Git - gcc.git/commitdiff
backport: re PR middle-end/89002 (ICE in scan_omp_1_op, at omp-low.c:3166)
authorJakub Jelinek <jakub@redhat.com>
Fri, 30 Aug 2019 11:33:12 +0000 (13:33 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 30 Aug 2019 11:33:12 +0000 (13:33 +0200)
Backported from mainline
2019-01-28  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/89002
* gimplify.c (gimplify_omp_for): When adding OMP_CLAUSE_*_GIMPLE_SEQ
for lastprivate/linear IV, push gimplify context around gimplify_assign
and, if it needed any temporaries, pop it into a gimple bind around the
sequence.

* testsuite/libgomp.c/pr89002.c: New test.

From-SVN: r275093

gcc/ChangeLog
gcc/gimplify.c
libgomp/ChangeLog
libgomp/testsuite/libgomp.c/pr89002.c [new file with mode: 0644]

index f2299b35b0aa0f6b46dc1cd0d25d8beb2f92a6f6..a3bc11114a5733c7127798d529665861c5d65cc3 100644 (file)
@@ -1,6 +1,14 @@
 2019-08-30  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2019-01-28  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/89002
+       * gimplify.c (gimplify_omp_for): When adding OMP_CLAUSE_*_GIMPLE_SEQ
+       for lastprivate/linear IV, push gimplify context around gimplify_assign
+       and, if it needed any temporaries, pop it into a gimple bind around the
+       sequence.
+
        2019-01-27  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/87214
index 818f0abd2f921d38da6451b34531c8e7ae56007e..ce90e7b77bae30740809e2d8d07ee187390a221d 100644 (file)
@@ -10103,8 +10103,17 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p)
                  seq = &OMP_CLAUSE_LASTPRIVATE_GIMPLE_SEQ (c);
                else
                  seq = &OMP_CLAUSE_LINEAR_GIMPLE_SEQ (c);
+               push_gimplify_context ();
                gimplify_assign (decl, t, seq);
-           }
+               gimple *bind = NULL;
+               if (gimplify_ctxp->temps)
+                 {
+                   bind = gimple_build_bind (NULL_TREE, *seq, NULL_TREE);
+                   *seq = NULL;
+                   gimplify_seq_add_stmt (seq, bind);
+                 }
+               pop_gimplify_context (bind);
+             }
        }
     }
 
index 24d1d0a719f818a46810dfcb0621b432838fffa7..946ac0e99f7328f5ed76f2d74e2f2d6ff0fdd47b 100644 (file)
@@ -1,3 +1,11 @@
+2019-08-30  Jakub Jelinek  <jakub@redhat.com>
+
+       Backported from mainline
+       2019-01-28  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/89002
+       * testsuite/libgomp.c/pr89002.c: New test.
+
 2018-12-06  Release Manager
 
        * GCC 7.4.0 released.
diff --git a/libgomp/testsuite/libgomp.c/pr89002.c b/libgomp/testsuite/libgomp.c/pr89002.c
new file mode 100644 (file)
index 0000000..6d1b164
--- /dev/null
@@ -0,0 +1,43 @@
+/* PR middle-end/89002 */
+
+extern void abort (void);
+
+int
+foo (int x)
+{
+  int a;
+  int *p = &a;
+
+#pragma omp taskloop lastprivate (a)
+  for (a = 0; a < x; ++a)
+    ;
+  return *p;
+}
+
+int
+bar (int x)
+{
+  int a;
+  int *p = &a;
+
+#pragma omp parallel
+#pragma omp single
+#pragma omp taskloop lastprivate (a)
+  for (a = 0; a < x; ++a)
+    ;
+  return *p;
+}
+
+int
+main ()
+{
+#pragma omp parallel
+#pragma omp single
+  {
+    if (foo (4) != 4)
+      abort ();
+  }
+  if (bar (6) != 6)
+    abort ();
+  return 0;
+}
This page took 0.084365 seconds and 5 git commands to generate.