[llvm] [Frontend][OpenMP] Allow implicit clauses to fail to apply (PR #100460)

via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 24 13:13:32 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-flang-openmp

Author: Krzysztof Parzyszek (kparzysz)

<details>
<summary>Changes</summary>

The `linear(x)` clause implies `firstprivate(x)` on the compound construct if `x` is not an induction variable. With more construct combinations coming in OpenMP 6.0, the `firstprivate` clause may not be possible to apply, e.g. in "masked simd".
An additional benefit from this change is that it allows treating leaf constructs as combined constructs with a single constituent. Otherwise, a `linear` clause on a `simd` construct could imply a `firstprivate` clause that can't be applied.

---
Full diff: https://github.com/llvm/llvm-project/pull/100460.diff


1 Files Affected:

- (modified) llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h (+8-2) 


``````````diff
diff --git a/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h b/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h
index 349d862135d8c..b93bc594a82bf 100644
--- a/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h
+++ b/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h
@@ -1114,6 +1114,11 @@ bool ConstructDecompositionT<C, H>::applyClause(
 template <typename C, typename H> bool ConstructDecompositionT<C, H>::split() {
   bool success = true;
 
+  auto isImplicit = [this](const ClauseTy *node) {
+    return llvm::any_of(
+        implicit, [node](const ClauseTy &clause) { return &clause == node; });
+  };
+
   for (llvm::omp::Directive leaf :
        llvm::omp::getLeafConstructsOrSelf(construct))
     leafs.push_back(LeafReprInternal{leaf, /*clauses=*/{}});
@@ -1153,9 +1158,10 @@ template <typename C, typename H> bool ConstructDecompositionT<C, H>::split() {
   for (const ClauseTy *node : nodes) {
     if (skip(node))
       continue;
-    success =
-        success &&
+    bool result =
         std::visit([&](auto &&s) { return applyClause(s, node); }, node->u);
+    if (!isImplicit(node))
+      success = success && result;
   }
 
   // Apply "allocate".

``````````

</details>


https://github.com/llvm/llvm-project/pull/100460


More information about the llvm-commits mailing list