[flang-commits] [flang] b1161b2 - [Flang][OpenMP] Fix semantics check for nested DISTRIBUTE (#91592)
via flang-commits
flang-commits at lists.llvm.org
Fri May 17 06:31:21 PDT 2024
Author: Sergio Afonso
Date: 2024-05-17T14:31:16+01:00
New Revision: b1161b2a40d89d4146f6b81fda073a37479edf0f
URL: https://github.com/llvm/llvm-project/commit/b1161b2a40d89d4146f6b81fda073a37479edf0f
DIFF: https://github.com/llvm/llvm-project/commit/b1161b2a40d89d4146f6b81fda073a37479edf0f.diff
LOG: [Flang][OpenMP] Fix semantics check for nested DISTRIBUTE (#91592)
Composite OpenMP constructs where DISTRIBUTE is the first leaf
construct, as well as standalone DISTRIBUTE constructs, are allowed
inside of TEAMS regions.
Before this patch, nesting a DISTRIBUTE construct inside of a combined
TARGET TEAMS construct was disallowed, which it shouldn't be. Now both
TEAMS and TARGET TEAMS constructs can be immediate parents of DISTRIBUTE
constructs.
Added:
Modified:
flang/lib/Semantics/check-omp-structure.cpp
flang/test/Semantics/OpenMP/nested-distribute.f90
Removed:
################################################################################
diff --git a/flang/lib/Semantics/check-omp-structure.cpp b/flang/lib/Semantics/check-omp-structure.cpp
index 2493eb3ed3676..e9637b7bb591f 100644
--- a/flang/lib/Semantics/check-omp-structure.cpp
+++ b/flang/lib/Semantics/check-omp-structure.cpp
@@ -280,7 +280,8 @@ void OmpStructureChecker::HasInvalidDistributeNesting(
violation = true;
} else {
// `distribute` region has to be strictly nested inside `teams`
- if (!llvm::omp::topTeamsSet.test(GetContextParent().directive)) {
+ if (!OmpDirectiveSet{llvm::omp::OMPD_teams, llvm::omp::OMPD_target_teams}
+ .test(GetContextParent().directive)) {
violation = true;
}
}
diff --git a/flang/test/Semantics/OpenMP/nested-distribute.f90 b/flang/test/Semantics/OpenMP/nested-distribute.f90
index 5103790392897..ba8c3bf04b337 100644
--- a/flang/test/Semantics/OpenMP/nested-distribute.f90
+++ b/flang/test/Semantics/OpenMP/nested-distribute.f90
@@ -74,6 +74,13 @@ program main
!$omp end distribute
!$omp end teams
+ !$omp target teams
+ !$omp distribute
+ do i = 1, 10
+ end do
+ !$omp end distribute
+ !$omp end target teams
+
!$omp teams
!ERROR: Only `DISTRIBUTE` or `PARALLEL` regions are allowed to be strictly nested inside `TEAMS` region.
!$omp task
More information about the flang-commits
mailing list