[flang-commits] [flang] [Flang][OpenMP] Skip default privatization of implied do indices (PR #89915)
Kiran Chandramohan via flang-commits
flang-commits at lists.llvm.org
Wed Apr 24 04:57:56 PDT 2024
https://github.com/kiranchandramohan created https://github.com/llvm/llvm-project/pull/89915
These indices are mapped to SSA values or registers and hence need not be privatized.
Fixes #87216
>From b972f9788e9237a8ce66f31a3fae87b7de24d99b Mon Sep 17 00:00:00 2001
From: Kiran Chandramohan <kiran.chandramohan at arm.com>
Date: Wed, 24 Apr 2024 11:51:17 +0000
Subject: [PATCH] [Flang][OpenMP] Skip default privatization of implied do
indices
These indices are mapped to SSA values or registers and hence
need not be privatized.
Fixes #87216
---
flang/lib/Lower/OpenMP/DataSharingProcessor.cpp | 1 +
.../Lower/OpenMP/default-clause-implied-do-fix.f90 | 11 +++++++++++
2 files changed, 12 insertions(+)
create mode 100644 flang/test/Lower/OpenMP/default-clause-implied-do-fix.f90
diff --git a/flang/lib/Lower/OpenMP/DataSharingProcessor.cpp b/flang/lib/Lower/OpenMP/DataSharingProcessor.cpp
index 8bb2f83282b556..96be40a7132059 100644
--- a/flang/lib/Lower/OpenMP/DataSharingProcessor.cpp
+++ b/flang/lib/Lower/OpenMP/DataSharingProcessor.cpp
@@ -332,6 +332,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