[clang] acaa026 - [clang][OpenMP] Use leaf constructs in `mapLoopConstruct` (#97446)

via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 3 05:57:35 PDT 2024


Author: Krzysztof Parzyszek
Date: 2024-07-03T07:57:31-05:00
New Revision: acaa0262a98fe8ecc525bdbdc2692d803e50976a

URL: https://github.com/llvm/llvm-project/commit/acaa0262a98fe8ecc525bdbdc2692d803e50976a
DIFF: https://github.com/llvm/llvm-project/commit/acaa0262a98fe8ecc525bdbdc2692d803e50976a.diff

LOG: [clang][OpenMP] Use leaf constructs in `mapLoopConstruct` (#97446)

This removes mentions of specific combined directives.

Also, add a quote from the OpenMP spec to explain the code dealing with
the `bind` clause.

Added: 
    

Modified: 
    clang/lib/Sema/SemaOpenMP.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 86666f064f35d..5fde4f67b4fd9 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -6270,16 +6270,21 @@ bool SemaOpenMP::mapLoopConstruct(
     if (BindKind == OMPC_BIND_unknown) {
       // Setting the enclosing teams or parallel construct for the loop
       // directive without bind clause.
+      // [5.0:129:25-28] If the bind clause is not present on the construct and
+      // the loop construct is closely nested inside a teams or parallel
+      // construct, the binding region is the corresponding teams or parallel
+      // region. If none of those conditions hold, the binding region is not
+      // defined.
       BindKind = OMPC_BIND_thread; // Default bind(thread) if binding is unknown
+      ArrayRef<OpenMPDirectiveKind> ParentLeafs =
+          getLeafConstructsOrSelf(ParentDirective);
 
       if (ParentDirective == OMPD_unknown) {
         Diag(DSAStack->getDefaultDSALocation(),
              diag::err_omp_bind_required_on_loop);
-      } else if (ParentDirective == OMPD_parallel ||
-                 ParentDirective == OMPD_target_parallel) {
+      } else if (ParentLeafs.back() == OMPD_parallel) {
         BindKind = OMPC_BIND_parallel;
-      } else if (ParentDirective == OMPD_teams ||
-                 ParentDirective == OMPD_target_teams) {
+      } else if (ParentLeafs.back() == OMPD_teams) {
         BindKind = OMPC_BIND_teams;
       }
     } else {


        


More information about the cfe-commits mailing list