This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[committed] Fix OpenMP ICE with VLA in nested parallel regions (PR middle-end/39154)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 11 Feb 2009 23:01:27 +0100
- Subject: [committed] Fix OpenMP ICE with VLA in nested parallel regions (PR middle-end/39154)
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
The following testcase ICEs with --enable-checking and segfaults at runtime
with --enable-checking=release. The problem is that if an outer parallel
region mentions a VLA in its clauses but the VLA is only referenced in inner
parallel region, we add early the pointer replacement var for it, but
without GOVD_SEEN and nothing afterwards sets the GOVD_SEEN bit on it.
Which means it is removed from the outer parallel clauses and thus
uninitialized.
Fixed thusly, bootstrapped/regtested on x86_64-linux, committed to trunk.
2009-02-11 Jakub Jelinek <jakub@redhat.com>
PR middle-end/39154
* gimplify.c (omp_notice_variable): If adding GOVD_SEEN
bit to variable length decl's flags, add it also to its
pointer replacement variable.
* testsuite/libgomp.c/pr39154.c: New test.
--- gcc/gimplify.c.jj 2009-02-11 19:32:53.000000000 +0100
+++ gcc/gimplify.c 2009-02-11 21:34:42.000000000 +0100
@@ -5308,6 +5308,20 @@ omp_notice_variable (struct gimplify_omp
goto do_outer;
}
+ if ((n->value & (GOVD_SEEN | GOVD_LOCAL)) == 0
+ && (flags & (GOVD_SEEN | GOVD_LOCAL)) == GOVD_SEEN
+ && DECL_SIZE (decl)
+ && TREE_CODE (DECL_SIZE (decl)) != INTEGER_CST)
+ {
+ splay_tree_node n2;
+ tree t = DECL_VALUE_EXPR (decl);
+ gcc_assert (TREE_CODE (t) == INDIRECT_REF);
+ t = TREE_OPERAND (t, 0);
+ gcc_assert (DECL_P (t));
+ n2 = splay_tree_lookup (ctx->variables, (splay_tree_key) t);
+ n2->value |= GOVD_SEEN;
+ }
+
shared = ((flags | n->value) & GOVD_SHARED) != 0;
ret = lang_hooks.decls.omp_disregard_value_expr (decl, shared);
--- libgomp/testsuite/libgomp.c/pr39154.c.jj 2009-02-11 21:08:25.000000000 +0100
+++ libgomp/testsuite/libgomp.c/pr39154.c 2009-02-11 21:36:01.000000000 +0100
@@ -0,0 +1,105 @@
+/* PR middle-end/39154 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -std=gnu99" } */
+
+extern void abort (void);
+
+int n = 20;
+
+int
+main (void)
+{
+ int a[n], b[n][n];
+
+#pragma omp parallel for
+ for (int i = 0; i < n; i++)
+ {
+ a[i] = i + 1;
+#pragma omp parallel for
+ for (int j = 0; j < n; j++)
+ b[i][j] = a[i];
+ }
+
+ for (int i = 0; i < n; i++)
+ {
+ for (int j = 0; j < n; j++)
+ if (b[i][j] != i + 1)
+ abort ();
+ if (a[i] != i + 1)
+ abort ();
+ }
+
+#pragma omp parallel for shared (n, a, b)
+ for (int i = 0; i < n; i++)
+ {
+ a[i] = i + 3;
+#pragma omp parallel for
+ for (int j = 0; j < n; j++)
+ b[i][j] = a[i];
+ }
+
+ for (int i = 0; i < n; i++)
+ {
+ for (int j = 0; j < n; j++)
+ if (b[i][j] != i + 3)
+ abort ();
+ if (a[i] != i + 3)
+ abort ();
+ }
+
+#pragma omp parallel for
+ for (int i = 0; i < n; i++)
+ {
+ a[i] = i + 5;
+#pragma omp parallel for shared (n, a, b)
+ for (int j = 0; j < n; j++)
+ b[i][j] = a[i];
+ }
+
+ for (int i = 0; i < n; i++)
+ {
+ for (int j = 0; j < n; j++)
+ if (b[i][j] != i + 5)
+ abort ();
+ if (a[i] != i + 5)
+ abort ();
+ }
+
+#pragma omp parallel for shared (n, a, b)
+ for (int i = 0; i < n; i++)
+ {
+ a[i] = i + 7;
+#pragma omp parallel for shared (n, a, b)
+ for (int j = 0; j < n; j++)
+ b[i][j] = a[i];
+ }
+
+ for (int i = 0; i < n; i++)
+ {
+ for (int j = 0; j < n; j++)
+ if (b[i][j] != i + 7)
+ abort ();
+ if (a[i] != i + 7)
+ abort ();
+ }
+
+#pragma omp parallel for private (a, b)
+ for (int i = 0; i < n; i++)
+ {
+ a[i] = i + 1;
+#pragma omp parallel for
+ for (int j = 0; j < n; j++)
+ b[i][j] = a[i];
+ }
+
+#pragma omp parallel for private (a, b)
+ for (int i = 0; i < n; i++)
+ {
+ a[i] = i + 1;
+#pragma omp parallel for private (b)
+ for (int j = 0; j < n; j++)
+ b[i][j] = a[i];
+ }
+
+ return 0;
+}
Jakub