[flang-commits] [flang] edcf65d - [flang][OpenMP] Allow loop iteration variables in DSA clauses (#86194)
via flang-commits
flang-commits at lists.llvm.org
Mon Mar 25 04:48:14 PDT 2024
Author: Leandro Lupori
Date: 2024-03-25T08:48:11-03:00
New Revision: edcf65d40c4160db0a888e801560a671b10179d2
URL: https://github.com/llvm/llvm-project/commit/edcf65d40c4160db0a888e801560a671b10179d2
DIFF: https://github.com/llvm/llvm-project/commit/edcf65d40c4160db0a888e801560a671b10179d2.diff
LOG: [flang][OpenMP] Allow loop iteration variables in DSA clauses (#86194)
Iteration variables of non-associated loops may be listed in DSA
clauses.
Fixes https://github.com/llvm/llvm-project/issues/78938
Added:
flang/test/Semantics/OpenMP/do20.f90
Modified:
flang/lib/Semantics/resolve-directives.cpp
Removed:
################################################################################
diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp
index 6d58013b87d298..27af192f606be9 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -1649,6 +1649,15 @@ void OmpAttributeVisitor::ResolveSeqLoopIndexInParallelOrTaskConstruct(
break;
}
}
+ // If this symbol already has a data-sharing attribute then there is nothing
+ // to do here.
+ if (const Symbol * symbol{iv.symbol}) {
+ for (auto symMap : targetIt->objectWithDSA) {
+ if (symMap.first->name() == symbol->name()) {
+ return;
+ }
+ }
+ }
// If this symbol is already Private or Firstprivate in the enclosing
// OpenMP parallel or task then there is nothing to do here.
if (auto *symbol{targetIt->scope.FindSymbol(iv.source)}) {
diff --git a/flang/test/Semantics/OpenMP/do20.f90 b/flang/test/Semantics/OpenMP/do20.f90
new file mode 100644
index 00000000000000..915d01e69edd74
--- /dev/null
+++ b/flang/test/Semantics/OpenMP/do20.f90
@@ -0,0 +1,18 @@
+! RUN: %python %S/../test_symbols.py %s %flang_fc1 -fopenmp
+
+! OpenMP 5.2 5.1.1
+! Iteration variables of non-associated loops may be listed in DSA clauses.
+
+!DEF: /shared_iv (Subroutine)Subprogram
+subroutine shared_iv
+ !DEF: /shared_iv/i ObjectEntity INTEGER(4)
+ integer i
+
+ !$omp parallel shared(i)
+ !$omp single
+ !REF: /shared_iv/i
+ do i = 0, 1
+ end do
+ !$omp end single
+ !$omp end parallel
+end subroutine
More information about the flang-commits
mailing list