PR middle-end/49897
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 29 Jul 2011 17:45:42 +0000 (17:45 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 29 Jul 2011 17:45:42 +0000 (17:45 +0000)
PR middle-end/49898
* omp-low.c (use_pointer_for_field): If disallowing copy-in/out
in nested parallel and outer is a gimple_reg, mark it as addressable
and set its bit in task_shared_vars bitmap too.

* testsuite/libgomp.c/pr49897-1.c: New test.
* testsuite/libgomp.c/pr49897-2.c: New test.
* testsuite/libgomp.c/pr49898-1.c: New test.
* testsuite/libgomp.c/pr49898-2.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@176945 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/omp-low.c
libgomp/ChangeLog
libgomp/testsuite/libgomp.c/pr49897-1.c [new file with mode: 0644]
libgomp/testsuite/libgomp.c/pr49897-2.c [new file with mode: 0644]
libgomp/testsuite/libgomp.c/pr49898-1.c [new file with mode: 0644]
libgomp/testsuite/libgomp.c/pr49898-2.c [new file with mode: 0644]

index 738144d..de98034 100644 (file)
@@ -1,3 +1,11 @@
+2011-07-29  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/49897
+       PR middle-end/49898
+       * omp-low.c (use_pointer_for_field): If disallowing copy-in/out
+       in nested parallel and outer is a gimple_reg, mark it as addressable
+       and set its bit in task_shared_vars bitmap too.
+
 2011-07-29  Uros Bizjak  <ubizjak@gmail.com>
 
        * config/i386/predicates.md (tp_or_register_operand): Remove predicate.
index ccd248c..0376d92 100644 (file)
@@ -781,7 +781,7 @@ use_pointer_for_field (tree decl, omp_context *shared_ctx)
                  break;
 
              if (c)
-               return true;
+               goto maybe_mark_addressable_and_ret;
            }
        }
 
@@ -791,7 +791,9 @@ use_pointer_for_field (tree decl, omp_context *shared_ctx)
         returns, the task hasn't necessarily terminated.  */
       if (!TREE_READONLY (decl) && is_task_ctx (shared_ctx))
        {
-         tree outer = maybe_lookup_decl_in_outer_ctx (decl, shared_ctx);
+         tree outer;
+       maybe_mark_addressable_and_ret:
+         outer = maybe_lookup_decl_in_outer_ctx (decl, shared_ctx);
          if (is_gimple_reg (outer))
            {
              /* Taking address of OUTER in lower_send_shared_vars
index 19c88fb..292d58a 100644 (file)
@@ -1,3 +1,12 @@
+2011-07-29  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/49897
+       PR middle-end/49898
+       * testsuite/libgomp.c/pr49897-1.c: New test.
+       * testsuite/libgomp.c/pr49897-2.c: New test.
+       * testsuite/libgomp.c/pr49898-1.c: New test.
+       * testsuite/libgomp.c/pr49898-2.c: New test.
+
 2011-07-28  H.J. Lu  <hongjiu.lu@intel.com>
 
        * testsuite/lib/libgomp.exp (libgomp_init): Add -march=i486
diff --git a/libgomp/testsuite/libgomp.c/pr49897-1.c b/libgomp/testsuite/libgomp.c/pr49897-1.c
new file mode 100644 (file)
index 0000000..d21a262
--- /dev/null
@@ -0,0 +1,31 @@
+/* PR middle-end/49897 */
+/* { dg-do run } */
+
+extern void abort (void);
+
+int
+main ()
+{
+  int i, j, x = 0, y, sum = 0;
+#pragma omp parallel reduction(+:sum)
+  {
+  #pragma omp for firstprivate(x) lastprivate(x, y)
+    for (i = 0; i < 10; i++)
+      {
+       x = i;
+       y = 0;
+      #pragma omp parallel reduction(+:sum)
+       {
+       #pragma omp for firstprivate(y) lastprivate(y)
+         for (j = 0; j < 10; j++)
+           {
+             y = j;
+             sum += y;
+           }
+       }
+      }
+  }
+  if (x != 9 || y != 9 || sum != 450)
+    abort ();
+  return 0;
+}
diff --git a/libgomp/testsuite/libgomp.c/pr49897-2.c b/libgomp/testsuite/libgomp.c/pr49897-2.c
new file mode 100644 (file)
index 0000000..c9ea5ec
--- /dev/null
@@ -0,0 +1,25 @@
+/* PR middle-end/49897 */
+/* { dg-do run } */
+
+extern void abort (void);
+
+int
+main ()
+{
+  int i, j, x = 0, y, sum = 0;
+#pragma omp parallel for reduction(+:sum) firstprivate(x) lastprivate(x, y)
+  for (i = 0; i < 10; i++)
+    {
+      x = i;
+      y = 0;
+    #pragma omp parallel for reduction(+:sum) firstprivate(y) lastprivate(y)
+      for (j = 0; j < 10; j++)
+       {
+         y = j;
+         sum += y;
+       }
+    }
+  if (x != 9 || y != 9 || sum != 450)
+    abort ();
+  return 0;
+}
diff --git a/libgomp/testsuite/libgomp.c/pr49898-1.c b/libgomp/testsuite/libgomp.c/pr49898-1.c
new file mode 100644 (file)
index 0000000..175426d
--- /dev/null
@@ -0,0 +1,26 @@
+/* PR middle-end/49898 */
+/* { dg-do run } */
+
+extern void abort (void);
+
+int
+main ()
+{
+  int i, j, sum = 0;
+#pragma omp parallel
+  {
+  #pragma omp for reduction(+:sum)
+    for (i = 0; i < 10; i++)
+      {
+      #pragma omp parallel
+       {
+       #pragma omp for reduction(+:sum)
+         for (j = 0; j < 10; j++)
+           sum += j;
+       }
+      }
+  }
+  if (sum != 450)
+    abort ();
+  return 0;
+}
diff --git a/libgomp/testsuite/libgomp.c/pr49898-2.c b/libgomp/testsuite/libgomp.c/pr49898-2.c
new file mode 100644 (file)
index 0000000..03ba0f8
--- /dev/null
@@ -0,0 +1,18 @@
+/* PR middle-end/49898 */
+/* { dg-do run } */
+
+extern void abort (void);
+
+int
+main ()
+{
+  int i, j, sum = 0;
+#pragma omp parallel for reduction(+:sum)
+  for (i = 0; i < 10; i++)
+    #pragma omp parallel for reduction(+:sum)
+    for (j = 0; j < 10; j++)
+      sum += j;
+  if (sum != 450)
+    abort ();
+  return 0;
+}