public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed] Fix OpenMP VLA implicit determination in task (PR middle-end/80809)
@ 2017-05-22 19:06 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2017-05-22 19:06 UTC (permalink / raw)
  To: gcc-patches

Hi!

If a VLA is shared e.g. on parallel or task construct, we firstprivatize
a pointer pointing to it, and add a private VLA variable that will have a
DECL_VALUE_EXPR for debug info purposes.  But, standardwise, the VLA is
still shared on the parallel/task, it is just implementation detail what we
are doing with it.  So, for the purpose of implicit data sharing
determination we want to treat it still as shared and only when emitting or
changing the clause we want to emit private with OMP_CLAUSE_PRIVATE_DEBUG.

The following patch does that, bootstrapped/regtested on x86_64-linux and
i686-linux, committed to trunk, queued for release branches.

2017-05-22  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/80809
	* gimplify.c (omp_add_variable): For GOVD_DEBUG_PRIVATE use
	GOVD_SHARED rather than GOVD_PRIVATE with it.
	(gimplify_adjust_omp_clauses_1, gimplify_adjust_omp_clauses): Expect
	GOVD_SHARED rather than GOVD_PRIVATE with GOVD_DEBUG_PRIVATE.

	* testsuite/libgomp.c/pr80809-1.c: New test.

--- gcc/gimplify.c.jj	2017-05-22 10:50:07.000000000 +0200
+++ gcc/gimplify.c	2017-05-22 13:07:00.520162436 +0200
@@ -6693,7 +6693,7 @@ omp_add_variable (struct gimplify_omp_ct
 	 of PRIVATE.  The sharing would take place via the pointer variable
 	 which we remapped above.  */
       if (flags & GOVD_SHARED)
-	flags = GOVD_PRIVATE | GOVD_DEBUG_PRIVATE
+	flags = GOVD_SHARED | GOVD_DEBUG_PRIVATE
 		| (flags & (GOVD_SEEN | GOVD_EXPLICIT));
 
       /* We're going to make use of the TYPE_SIZE_UNIT at least in the
@@ -8616,7 +8616,7 @@ gimplify_adjust_omp_clauses_1 (splay_tre
     return 0;
   if (flags & GOVD_DEBUG_PRIVATE)
     {
-      gcc_assert ((flags & GOVD_DATA_SHARE_CLASS) == GOVD_PRIVATE);
+      gcc_assert ((flags & GOVD_DATA_SHARE_CLASS) == GOVD_SHARED);
       private_debug = true;
     }
   else if (flags & GOVD_MAP)
@@ -8878,7 +8878,7 @@ gimplify_adjust_omp_clauses (gimple_seq
 		{
 		  gcc_assert ((n->value & GOVD_DEBUG_PRIVATE) == 0
 			      || ((n->value & GOVD_DATA_SHARE_CLASS)
-				  == GOVD_PRIVATE));
+				  == GOVD_SHARED));
 		  OMP_CLAUSE_SET_CODE (c, OMP_CLAUSE_PRIVATE);
 		  OMP_CLAUSE_PRIVATE_DEBUG (c) = 1;
 		}
--- libgomp/testsuite/libgomp.c/pr80809-1.c.jj	2017-05-22 12:52:11.445135718 +0200
+++ libgomp/testsuite/libgomp.c/pr80809-1.c	2017-05-22 12:51:10.000000000 +0200
@@ -0,0 +1,29 @@
+/* PR middle-end/80809 */
+/* { dg-do run } */
+
+__attribute__((noinline, noclone)) void
+foo (int x)
+{
+  int i, j, v[x], *w[16];
+  for (i = 0; i < x; i++)
+    v[i] = i;
+#pragma omp parallel
+#pragma omp single
+  for (i = 0; i < 16; i++)
+  /* Make sure v is implicitly determined shared in task, because it
+     is shared on the parallel.  */
+#pragma omp task private (j)
+    w[i] = v;
+  for (i = 0; i < 16; i++)
+    if (w[i] != v)
+      __builtin_abort ();
+}
+
+int
+main ()
+{
+  foo (4);
+  foo (27);
+  foo (196);
+  return 0;
+}

	Jakub

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-05-22 19:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-22 19:06 [committed] Fix OpenMP VLA implicit determination in task (PR middle-end/80809) Jakub Jelinek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).