Commit ca2b1311 by Jakub Jelinek Committed by Jakub Jelinek

gimplify.c (omp_is_private): Don't return true if decl is not already private on…

gimplify.c (omp_is_private): Don't return true if decl is not already private on #pragma omp for or #pragma...

	* gimplify.c (omp_is_private): Don't return true if decl
	is not already private on #pragma omp for or #pragma omp parallel for.

	* gcc.dg/gomp/pr27388-3.c: Adjust dg-final.

	* testsuite/libgomp.c/loop-10.c: New test.
	* libgomp.c/loop-3.c (main): Add lastprivate clause.
	* libgomp.c++/loop-6.C (main): Likewise.

From-SVN: r137199
parent b357f682
2008-06-27 Jakub Jelinek <jakub@redhat.com> 2008-06-27 Jakub Jelinek <jakub@redhat.com>
* gimplify.c (omp_is_private): Don't return true if decl
is not already private on #pragma omp for or #pragma omp parallel for.
PR debug/36617 PR debug/36617
* tree-cfg.c (struct move_stmt_d): Replace block field with * tree-cfg.c (struct move_stmt_d): Replace block field with
orig_block and new_block fields. orig_block and new_block fields.
......
...@@ -5060,15 +5060,16 @@ omp_is_private (struct gimplify_omp_ctx *ctx, tree decl) ...@@ -5060,15 +5060,16 @@ omp_is_private (struct gimplify_omp_ctx *ctx, tree decl)
error ("iteration variable %qs should not be reduction", error ("iteration variable %qs should not be reduction",
IDENTIFIER_POINTER (DECL_NAME (decl))); IDENTIFIER_POINTER (DECL_NAME (decl)));
} }
return true; return (ctx == gimplify_omp_ctxp
|| (ctx->region_type == ORT_COMBINED_PARALLEL
&& gimplify_omp_ctxp->outer_context == ctx));
} }
if (ctx->region_type != ORT_WORKSHARE) if (ctx->region_type != ORT_WORKSHARE)
return false; return false;
else if (ctx->outer_context) else if (ctx->outer_context)
return omp_is_private (ctx->outer_context, decl); return omp_is_private (ctx->outer_context, decl);
else return false;
return !is_global_var (decl);
} }
/* Return true if DECL is private within a parallel region /* Return true if DECL is private within a parallel region
......
2008-06-27 Jakub Jelinek <jakub@redhat.com>
* gcc.dg/gomp/pr27388-3.c: Adjust dg-final.
2008-06-27 Richard Guenther <rguenther@suse.de> 2008-06-27 Richard Guenther <rguenther@suse.de>
PR tree-optimization/36400 PR tree-optimization/36400
......
...@@ -19,5 +19,5 @@ foo (void) ...@@ -19,5 +19,5 @@ foo (void)
} }
} }
/* { dg-final { scan-tree-dump-times "omp for\[^\\n\]*private" 0 "omplower" } } */ /* { dg-final { scan-tree-dump-times "omp for\[^\\n\]*private" 2 "omplower" } } */
/* { dg-final { cleanup-tree-dump "omplower" } } */ /* { dg-final { cleanup-tree-dump "omplower" } } */
2008-06-27 Jakub Jelinek <jakub@redhat.com> 2008-06-27 Jakub Jelinek <jakub@redhat.com>
* testsuite/libgomp.c/loop-10.c: New test.
* libgomp.c/loop-3.c (main): Add lastprivate clause.
* libgomp.c++/loop-6.C (main): Likewise.
PR debug/36617 PR debug/36617
* testsuite/libgomp.c/debug-1.c: New test. * testsuite/libgomp.c/debug-1.c: New test.
......
...@@ -8,10 +8,11 @@ static int test(void) ...@@ -8,10 +8,11 @@ static int test(void)
return ++count > 0; return ++count > 0;
} }
int i;
int main() int main()
{ {
int i; #pragma omp for lastprivate (i)
#pragma omp for
for (i = 0; i < 10; ++i) for (i = 0; i < 10; ++i)
{ {
if (test()) if (test())
......
extern void abort (void);
int i = 8;
int main (void)
{
int j = 7, k = 0;
#pragma omp for
for (i = 0; i < 10; i++)
;
#pragma omp for
for (j = 0; j < 10; j++)
;
/* OpenMP 3.0 newly guarantees that the original list items can't
be shared with the privatized omp for iterators, even when
the original list items are already private. */
if (i != 8 || j != 7)
abort ();
#pragma omp parallel private (i) reduction (+:k)
{
i = 6;
#pragma omp for
for (i = 0; i < 10; i++)
;
k = (i != 6);
}
if (k)
abort ();
return 0;
}
...@@ -8,10 +8,11 @@ static int test(void) ...@@ -8,10 +8,11 @@ static int test(void)
return ++count > 0; return ++count > 0;
} }
int i;
int main() int main()
{ {
int i; #pragma omp for lastprivate (i)
#pragma omp for
for (i = 0; i < 10; ++i) for (i = 0; i < 10; ++i)
{ {
if (test()) if (test())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment