]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR middle-end/30494 (ICE with VLA and openmp)
authorJakub Jelinek <jakub@redhat.com>
Wed, 24 Jan 2007 20:56:45 +0000 (21:56 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 24 Jan 2007 20:56:45 +0000 (21:56 +0100)
PR middle-end/30494
* gimplify.c (omp_add_variable): Don't call omp_notice_variable
on TYPE_SIZE_UNIT for GOVD_LOCAL VLAs.

* gcc.dg/gomp/pr30494.c: New test.
* g++.dg/gomp/pr30494.C: New test.

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

From-SVN: r121132

gcc/ChangeLog
gcc/gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/gomp/pr30494.C [new file with mode: 0644]
gcc/testsuite/gcc.dg/gomp/pr30494.c [new file with mode: 0644]
libgomp/ChangeLog
libgomp/testsuite/libgomp.c/pr30494.c [new file with mode: 0644]

index 252b4192e3d70b1134d819aa7d744a508444d1ba..8d5d41189c3b46996f51c1775cdbeee19b9d2bf7 100644 (file)
@@ -1,5 +1,9 @@
 2007-01-24  Jakub Jelinek  <jakub@redhat.com>
 
+       PR middle-end/30494
+       * gimplify.c (omp_add_variable): Don't call omp_notice_variable
+       on TYPE_SIZE_UNIT for GOVD_LOCAL VLAs.
+
        PR middle-end/30421
        * omp-low.c (lower_omp_for_lastprivate): Add dlist argument.
        If lower_lastprivate_clauses emits some statements, append them
index d14e01e8202b5a043db393fac92fbfc101e1af09..be02fb23cbb3d36007b0ee7df9ecaa444a94b2df 100644 (file)
@@ -4505,8 +4505,11 @@ omp_add_variable (struct gimplify_omp_ctx *ctx, tree decl, unsigned int flags)
       /* We're going to make use of the TYPE_SIZE_UNIT at least in the 
         alloca statement we generate for the variable, so make sure it
         is available.  This isn't automatically needed for the SHARED
-        case, since we won't be allocating local storage then.  */
-      else
+        case, since we won't be allocating local storage then.
+        For local variables TYPE_SIZE_UNIT might not be gimplified yet,
+        in this case omp_notice_variable will be called later
+        on when it is gimplified.  */
+      else if (! (flags & GOVD_LOCAL))
        omp_notice_variable (ctx, TYPE_SIZE_UNIT (TREE_TYPE (decl)), true);
     }
   else if (lang_hooks.decls.omp_privatize_by_reference (decl))
index 2d9fc84346cae633d2de869b5e309a1afca7f9bf..fcb4e7442a6aec773a63946bd4c0ccc8efd93b92 100644 (file)
@@ -1,5 +1,9 @@
 2007-01-24  Jakub Jelinek  <jakub@redhat.com>
 
+       PR middle-end/30494
+       * gcc.dg/gomp/pr30494.c: New test.
+       * g++.dg/gomp/pr30494.C: New test.
+
        PR middle-end/30421
        * gcc.dg/gomp/pr30421.c: New test.
 
diff --git a/gcc/testsuite/g++.dg/gomp/pr30494.C b/gcc/testsuite/g++.dg/gomp/pr30494.C
new file mode 100644 (file)
index 0000000..3f2d120
--- /dev/null
@@ -0,0 +1,30 @@
+// PR middle-end/30494
+// { dg-do compile }
+
+int
+foo (int n)
+{
+  int i;
+#pragma omp for
+  for (i = 0; i < 6; i++)
+    {
+      int v[n], w[n * 3 + i];
+      v[0] = 1;
+      w[0] = 2;
+    }
+  return 0;
+}
+
+int
+bar (int n)
+{
+  int i;
+#pragma parallel omp for
+  for (i = 0; i < 6; i++)
+    {
+      int v[n], w[n * 3 + i];
+      v[0] = 1;
+      w[0] = 2;
+    }
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/gomp/pr30494.c b/gcc/testsuite/gcc.dg/gomp/pr30494.c
new file mode 100644 (file)
index 0000000..6a042ce
--- /dev/null
@@ -0,0 +1,30 @@
+/* PR middle-end/30494 */
+/* { dg-do compile } */
+
+int
+foo (int n)
+{
+  int i;
+#pragma omp for
+  for (i = 0; i < 6; i++)
+    {
+      int v[n], w[n * 3 + i];
+      v[0] = 1;
+      w[0] = 2;
+    }
+  return 0;
+}
+
+int
+bar (int n)
+{
+  int i;
+#pragma parallel omp for
+  for (i = 0; i < 6; i++)
+    {
+      int v[n], w[n * 3 + i];
+      v[0] = 1;
+      w[0] = 2;
+    }
+  return 0;
+}
index 93021993e396345c978e29b41a39c67c014e63a4..e0e21298dfac28f983b267fd3228a62bdd154875 100644 (file)
@@ -1,3 +1,8 @@
+2007-01-24  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/30494
+       * testsuite/libgomp.c/pr30494.c: New test.
+
 2007-01-15  Tom Tromey  <tromey@redhat.com>
 
        * configure: Rebuilt.
diff --git a/libgomp/testsuite/libgomp.c/pr30494.c b/libgomp/testsuite/libgomp.c/pr30494.c
new file mode 100644 (file)
index 0000000..ec6828e
--- /dev/null
@@ -0,0 +1,64 @@
+/* PR middle-end/30494 */
+/* { dg-do run } */
+
+#include <omp.h>
+
+int errors;
+
+int
+check (int m, int i, int *v, int *w)
+{
+  int j;
+  int n = omp_get_thread_num ();
+  for (j = 0; j < m; j++)
+    if (v[j] != j + n)
+      #pragma omp atomic
+       errors += 1;
+  for (j = 0; j < m * 3 + i; j++)
+    if (w[j] != j + 10 + n)
+      #pragma omp atomic
+       errors += 1;
+}
+
+int
+foo (int n, int m)
+{
+  int i;
+#pragma omp for
+  for (i = 0; i < 6; i++)
+    {
+      int v[n], w[n * 3 + i], j;
+      for (j = 0; j < n; j++)
+       v[j] = j + omp_get_thread_num ();
+      for (j = 0; j < n * 3 + i; j++)
+       w[j] = j + 10 + omp_get_thread_num ();
+      check (m, i, v, w);
+    }
+  return 0;
+}
+
+int
+bar (int n, int m)
+{
+  int i;
+#pragma omp parallel for num_threads (4)
+  for (i = 0; i < 6; i++)
+    {
+      int v[n], w[n * 3 + i], j;
+      for (j = 0; j < n; j++)
+       v[j] = j + omp_get_thread_num ();
+      for (j = 0; j < n * 3 + i; j++)
+       w[j] = j + 10 + omp_get_thread_num ();
+      check (m, i, v, w);
+    }
+  return 0;
+}
+
+int
+main (void)
+{
+#pragma omp parallel num_threads (3)
+  foo (128, 128);
+  bar (256, 256);
+  return 0;
+}