re PR middle-end/27388 (omp_is_private issues)

PR middle-end/27388
	* gimplify.c (omp_is_private): If var is shared in some outer context,
	return false instead of true.  Stop searching on parallel context
	boundary.

	* gcc.dg/gomp/pr27388-1.c: New test.
	* gcc.dg/gomp/pr27388-2.c: New test.
	* gcc.dg/gomp/pr27388-3.c: New test.

From-SVN: r113514
This commit is contained in:
Jakub Jelinek 2006-05-04 08:34:06 +02:00 committed by Jakub Jelinek
parent 76c5e6e079
commit f6a5ffbfbf
6 changed files with 104 additions and 6 deletions

View File

@ -1,3 +1,10 @@
2006-05-04 Jakub Jelinek <jakub@redhat.com>
PR middle-end/27388
* gimplify.c (omp_is_private): If var is shared in some outer context,
return false instead of true. Stop searching on parallel context
boundary.
2006-05-03 Alexandre Oliva <aoliva@redhat.com>
PR java/8260

View File

@ -4443,17 +4443,22 @@ omp_is_private (struct gimplify_omp_ctx *ctx, tree decl)
if (n->value & GOVD_SHARED)
{
if (ctx == gimplify_omp_ctxp)
error ("iteration variable %qs should be private",
IDENTIFIER_POINTER (DECL_NAME (decl)));
n->value = GOVD_PRIVATE;
{
error ("iteration variable %qs should be private",
IDENTIFIER_POINTER (DECL_NAME (decl)));
n->value = GOVD_PRIVATE;
return true;
}
else
return false;
}
return true;
}
if (ctx->outer_context)
return omp_is_private (ctx->outer_context, decl);
else if (ctx->is_parallel)
if (ctx->is_parallel)
return false;
else if (ctx->outer_context)
return omp_is_private (ctx->outer_context, decl);
else
return !is_global_var (decl);
}

View File

@ -1,5 +1,10 @@
2006-05-04 Jakub Jelinek <jakub@redhat.com>
PR middle-end/27388
* gcc.dg/gomp/pr27388-1.c: New test.
* gcc.dg/gomp/pr27388-2.c: New test.
* gcc.dg/gomp/pr27388-3.c: New test.
PR c++/27359
* g++.dg/gomp/pr27359.C: New test.

View File

@ -0,0 +1,23 @@
/* PR middle-end/27388 */
/* { dg-do compile } */
/* { dg-options "-fopenmp -fdump-tree-omplower" } */
int n, o;
void
foo (void)
{
#pragma omp parallel firstprivate (n)
{
int i;
#pragma omp parallel for firstprivate (n)
for (i = 0; i < 10; i++)
++n;
#pragma omp atomic
o += n;
}
}
/* { dg-final { scan-tree-dump-times "shared\\\(i\\\)" 0 "omplower" } } */
/* { dg-final { scan-tree-dump-times "private\\\(i\\\)" 1 "omplower" } } */
/* { dg-final { cleanup-tree-dump "omplower" } } */

View File

@ -0,0 +1,35 @@
/* PR middle-end/27388 */
/* { dg-do compile } */
/* { dg-options "-fopenmp -fdump-tree-omplower" } */
extern void baz (int);
void
foo (void)
{
int i;
#pragma omp parallel for shared (i)
for (i = 0; i < 2; i++)
baz (i);
}
void
bar (void)
{
int j = 0;
#pragma omp parallel shared (j)
{
j++;
#pragma omp for
for (j = 0; j < 2; j++)
baz (j);
}
}
/* { dg-final { scan-tree-dump-times "shared\\\(i\\\)\[^\\n\]*private\\\(i\\\)" 0 "omplower" } } */
/* { dg-final { scan-tree-dump-times "private\\\(i\\\)\[^\\n\]*shared\\\(i\\\)" 0 "omplower" } } */
/* { dg-final { scan-tree-dump-times "omp for\[^\\n\]*private\\\(i\\\)" 1 "omplower" } } */
/* { dg-final { scan-tree-dump-times "shared\\\(j\\\)\[^\\n\]*private\\\(j\\\)" 0 "omplower" } } */
/* { dg-final { scan-tree-dump-times "private\\\(j\\\)\[^\\n\]*shared\\\(j\\\)" 0 "omplower" } } */
/* { dg-final { scan-tree-dump-times "omp for\[^\\n\]*private\\\(j\\\)" 1 "omplower" } } */
/* { dg-final { cleanup-tree-dump "omplower" } } */

View File

@ -0,0 +1,23 @@
/* PR middle-end/27388 */
/* { dg-do compile } */
/* { dg-options "-fopenmp -fdump-tree-omplower" } */
extern void bar (int);
void
foo (void)
{
int i = 0, j = 0;
#pragma omp parallel firstprivate (i) private (j)
{
#pragma omp for
for (i = 0; i < 2; i++)
bar (i);
#pragma omp for
for (j = 0; j < 2; j++)
bar (j);
}
}
/* { dg-final { scan-tree-dump-times "omp for\[^\\n\]*private" 0 "omplower" } } */
/* { dg-final { cleanup-tree-dump "omplower" } } */