This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[committed] Fix OpenMP default(none) handling of module array/derived type parameters from other TUs (PR fortran/88463)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org, fortran at gcc dot gnu dot org
- Date: Wed, 12 Dec 2018 23:52:49 +0100
- Subject: [committed] Fix OpenMP default(none) handling of module array/derived type parameters from other TUs (PR fortran/88463)
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
The following patch makes array or derived type module parameters from other
TUs predetermined shared, so that they aren't rejected with default(none) or
copied with default(firstprivate). I went through all the spots in the
Fortran FE that set TREE_READONLY, most of them are on PARM_DECLs (this case
is for VAR_DECLs only), the rest are either parameters, or artificial vars
that should be predetermined shared anyway.
Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk,
queued for backporting.
2018-12-12 Jakub Jelinek <jakub@redhat.com>
PR fortran/88463
* trans-openmp.c (gfc_omp_predetermined_sharing): Handle TREE_READONLY
VAR_DECLs with DECL_EXTERNAL like those with TREE_STATIC.
* testsuite/libgomp.fortran/pr88463-1.f90: New test.
* testsuite/libgomp.fortran/pr88463-2.f90: New test.
--- gcc/fortran/trans-openmp.c.jj 2018-12-10 13:34:10.112948095 +0100
+++ gcc/fortran/trans-openmp.c 2018-12-12 21:52:46.956177474 +0100
@@ -149,7 +149,8 @@ gfc_omp_predetermined_sharing (tree decl
variables at all (they can't be redefined), but they can nevertheless appear
in parallel/task regions and for default(none) purposes treat them as shared.
For vtables likely the same handling is desirable. */
- if (VAR_P (decl) && TREE_READONLY (decl) && TREE_STATIC (decl))
+ if (VAR_P (decl) && TREE_READONLY (decl)
+ && (TREE_STATIC (decl) || DECL_EXTERNAL (decl)))
return OMP_CLAUSE_DEFAULT_SHARED;
return OMP_CLAUSE_DEFAULT_UNSPECIFIED;
--- libgomp/testsuite/libgomp.fortran/pr88463-1.f90.jj 2018-12-12 21:57:25.088640143 +0100
+++ libgomp/testsuite/libgomp.fortran/pr88463-1.f90 2018-12-12 21:59:42.699395228 +0100
@@ -0,0 +1,19 @@
+! PR fortran/88463
+! { dg-do compile { target { ! *-*-* } } }
+
+module pr88463_1
+ integer, parameter :: c = 1
+ real, parameter :: d(4) = (/ 2, 3, 4, 5 /)
+end module pr88463_1
+
+program pr88463
+ use pr88463_1
+ use pr88463_2
+ integer :: i
+ real :: j(4)
+ !$omp parallel default(none) private (i, j)
+ i = a + b(1) + b(4) + c + d(1) + d(4)
+ j(1:4) = b(1:4)
+ j(1:4) = d(1:4)
+ !$omp end parallel
+end program pr88463
--- libgomp/testsuite/libgomp.fortran/pr88463-2.f90.jj 2018-12-12 21:57:40.732384942 +0100
+++ libgomp/testsuite/libgomp.fortran/pr88463-2.f90 2018-12-12 22:03:35.559596448 +0100
@@ -0,0 +1,9 @@
+! PR fortran/88463
+! { dg-do link }
+! { dg-options "-fopenmp" }
+! { dg-additional-sources pr88463-1.f90 }
+
+module pr88463_2
+ integer, parameter :: a = 1
+ real, parameter :: b(4) = (/ 2., 3., 4., 5. /)
+end module pr88463_2
Jakub