2016-09-09 Cesar Philippidis <cesar@codesourcery.com>
PR fortran/74600
gcc/
* tree-nested.c (convert_nonlocal_reference_stmt): Create a private
clause for the CHAIN stack frame.
(convert_local_reference_stmt): Create a private clause for the
FRAME stack frame.
(convert_gimple_call): Look for OMP_CLAUSE_PRIVATE when scanning for
FRAME and CHAIN data clauses.
libgomp/
* testsuite/libgomp.oacc-fortran/pr74600.f90: New test.
@@ -1433,10 +1433,15 @@ convert_nonlocal_reference_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p,
{
tree c, decl;
decl = get_chain_decl (info);
- c = build_omp_clause (gimple_location (stmt), OMP_CLAUSE_MAP);
+ if (is_gimple_omp_oacc (stmt))
+ c = build_omp_clause (gimple_location (stmt), OMP_CLAUSE_PRIVATE);
+ else
+ {
+ c = build_omp_clause (gimple_location (stmt), OMP_CLAUSE_MAP);
+ OMP_CLAUSE_SET_MAP_KIND (c, GOMP_MAP_TOFROM);
+ OMP_CLAUSE_SIZE (c) = DECL_SIZE_UNIT (decl);
+ }
OMP_CLAUSE_DECL (c) = decl;
- OMP_CLAUSE_SET_MAP_KIND (c, GOMP_MAP_TO);
- OMP_CLAUSE_SIZE (c) = DECL_SIZE_UNIT (decl);
OMP_CLAUSE_CHAIN (c) = gimple_omp_target_clauses (stmt);
gimple_omp_target_set_clauses (as_a <gomp_target *> (stmt), c);
}
@@ -2064,10 +2069,15 @@ convert_local_reference_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p,
{
tree c;
(void) get_frame_type (info);
- c = build_omp_clause (gimple_location (stmt), OMP_CLAUSE_MAP);
+ if (is_gimple_omp_oacc (stmt))
+ c = build_omp_clause (gimple_location (stmt), OMP_CLAUSE_PRIVATE);
+ else
+ {
+ c = build_omp_clause (gimple_location (stmt), OMP_CLAUSE_MAP);
+ OMP_CLAUSE_SET_MAP_KIND (c, GOMP_MAP_TOFROM);
+ OMP_CLAUSE_SIZE (c) = DECL_SIZE_UNIT (info->frame_decl);
+ }
OMP_CLAUSE_DECL (c) = info->frame_decl;
- OMP_CLAUSE_SET_MAP_KIND (c, GOMP_MAP_TOFROM);
- OMP_CLAUSE_SIZE (c) = DECL_SIZE_UNIT (info->frame_decl);
OMP_CLAUSE_CHAIN (c) = gimple_omp_target_clauses (stmt);
gimple_omp_target_set_clauses (as_a <gomp_target *> (stmt), c);
}
@@ -2538,9 +2548,10 @@ convert_gimple_call (gimple_stmt_iterator *gsi, bool *handled_ops_p,
for (c = gimple_omp_target_clauses (stmt);
c;
c = OMP_CLAUSE_CHAIN (c))
- if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
- && OMP_CLAUSE_DECL (c) == decl)
- break;
+ if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
+ || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_PRIVATE)
+ && OMP_CLAUSE_DECL (c) == decl)
+ break;
if (c == NULL)
{
c = build_omp_clause (gimple_location (stmt), OMP_CLAUSE_MAP);
new file mode 100644
@@ -0,0 +1,37 @@
+program test
+ implicit none
+
+ integer :: i
+ integer :: a, b
+
+ a = 1
+ b = 2
+
+ !$acc parallel copy (a)
+ call foo (a, b)
+ !$acc end parallel
+
+ if (a .ne. 2) call abort
+
+ b = 10
+
+ call bar
+
+ if (a .ne. 10) call abort
+
+contains
+ subroutine foo (aa, bb)
+ implicit none
+ integer :: aa, bb
+ !$acc routine
+
+ aa = bb
+ end subroutine foo
+
+ subroutine bar
+ implicit none
+ !$acc parallel copy (a)
+ call foo (a, b)
+ !$acc end parallel
+ end subroutine bar
+end program test