Skip to content

Commit 5c969af

Browse files
[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
1 parent f1112eb commit 5c969af

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

flang/lib/Lower/OpenMP/DataSharingProcessor.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ void DataSharingProcessor::defaultPrivatize(
339339
if (!Fortran::semantics::IsProcedure(*sym) &&
340340
!sym->GetUltimate().has<Fortran::semantics::DerivedTypeDetails>() &&
341341
!sym->GetUltimate().has<Fortran::semantics::NamelistDetails>() &&
342+
!Fortran::semantics::IsImpliedDoIndex(sym->GetUltimate()) &&
342343
!symbolsInNestedRegions.contains(sym) &&
343344
!symbolsInParentRegions.contains(sym) &&
344345
!privatizedSymbols.contains(sym))
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
2+
3+
!CHECK: @_QPsb
4+
subroutine sb(a)
5+
integer :: a(:)
6+
!CHECK: omp.parallel
7+
!$omp parallel default(private)
8+
!CHECK: hlfir.elemental
9+
if (any(a/=(/(100,i=1,5)/))) print *, "OK"
10+
!$omp end parallel
11+
end subroutine

0 commit comments

Comments
 (0)