[Mlir-commits] [flang] [llvm] [mlir] [Flang][OpenMP] Fix Flang crash and incorrect ordering with OpenMP detached task (PR #194840)

Urvi Rav llvmlistbot at llvm.org
Mon May 4 00:19:13 PDT 2026


================
@@ -766,6 +766,17 @@ class OmpAttributeVisitor : DirectiveAttributeVisitor<llvm::omp::Directive> {
         *parser::omp::GetOmpObjectList(x), Symbol::Flag::OmpLastPrivate);
     return false;
   }
+  bool Pre(const parser::OmpClause::Detach &x) {
+    // OpenMP 5.0: Variables in detach clause have predetermined shared
+    // data-sharing attribute
+    if (const auto *name{parser::Unwrap<parser::Name>(x.v.v)}) {
+      if (auto *symbol{name->symbol})
+        SetSymbolDSA(*symbol,
+            Symbol::Flags{
+                Symbol::Flag::OmpShared, Symbol::Flag::OmpPreDetermined});
----------------
ravurvi20 wrote:

The spec’s “as if firstprivate” describes how the event handle is treated when the task data environment is created, rather than how the original symbol should be classified. In this case, we are still working with the enclosing-scope symbol referenced by `detach`, so keeping it as `OmpShared` seems more appropriate.

Using `OmpFirstPrivate` would make sense if we were modeling a separate task-local copy of the event handle, which is not the case here.


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


More information about the Mlir-commits mailing list