[flang-commits] [flang] 5c969af - [Flang][OpenMP] Skip default privatization of implied do indices (#89915)
via flang-commits
flang-commits at lists.llvm.org
Fri Apr 26 03:21:38 PDT 2024
Author: Kiran Chandramohan
Date: 2024-04-26T11:21:34+01:00
New Revision: 5c969af66ac1ea58425101772ad099698f49a20d
URL: https://github.com/llvm/llvm-project/commit/5c969af66ac1ea58425101772ad099698f49a20d
DIFF: https://github.com/llvm/llvm-project/commit/5c969af66ac1ea58425101772ad099698f49a20d.diff
LOG: [Flang][OpenMP] Skip default privatization of implied do indices (#89915)
The scope of these indices is limited to the implied-do and is mapped to
SSA values or registers and hence need not be privatized.
Fixes #87216
Added:
flang/test/Lower/OpenMP/default-clause-implied-do-fix.f90
Modified:
flang/lib/Lower/OpenMP/DataSharingProcessor.cpp
Removed:
################################################################################
diff --git a/flang/lib/Lower/OpenMP/DataSharingProcessor.cpp b/flang/lib/Lower/OpenMP/DataSharingProcessor.cpp
index b419686e8ce467..d94c32375c0dc3 100644
--- a/flang/lib/Lower/OpenMP/DataSharingProcessor.cpp
+++ b/flang/lib/Lower/OpenMP/DataSharingProcessor.cpp
@@ -339,6 +339,7 @@ void DataSharingProcessor::defaultPrivatize(
if (!Fortran::semantics::IsProcedure(*sym) &&
!sym->GetUltimate().has<Fortran::semantics::DerivedTypeDetails>() &&
!sym->GetUltimate().has<Fortran::semantics::NamelistDetails>() &&
+ !Fortran::semantics::IsImpliedDoIndex(sym->GetUltimate()) &&
!symbolsInNestedRegions.contains(sym) &&
!symbolsInParentRegions.contains(sym) &&
!privatizedSymbols.contains(sym))
diff --git a/flang/test/Lower/OpenMP/default-clause-implied-do-fix.f90 b/flang/test/Lower/OpenMP/default-clause-implied-do-fix.f90
new file mode 100644
index 00000000000000..25579272a6e0bc
--- /dev/null
+++ b/flang/test/Lower/OpenMP/default-clause-implied-do-fix.f90
@@ -0,0 +1,11 @@
+!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
+
+!CHECK: @_QPsb
+subroutine sb(a)
+ integer :: a(:)
+!CHECK: omp.parallel
+ !$omp parallel default(private)
+!CHECK: hlfir.elemental
+ if (any(a/=(/(100,i=1,5)/))) print *, "OK"
+ !$omp end parallel
+end subroutine
More information about the flang-commits
mailing list