[flang-commits] [flang] [llvm] [mlir] [Flang][OpenMP] Fix Flang crash and incorrect ordering with OpenMP detached task (PR #194840)
Jack Styles via flang-commits
flang-commits at lists.llvm.org
Fri May 1 09:02:05 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});
----------------
Stylie777 wrote:
Should the symbol be marked as OmpShared here? The spec for `task detach` states the following
```
If a detach clause is present on a task construct a new event allow-completion-event is created. The allow-completion-event is connected to the completion of the associated task region. The original event-handle will be updated to represent the allow-completion-event event before the task data environment is created. The event-handle will be considered as if it was specified on a firstprivate clause. The use of a variable in a detach clause expression of a task construct causes an implicit reference to the variable in all enclosing constructs.
```
If this is the case, should the symbol be marked as `OmpFirstPrivate` not `OmpShared`?
https://github.com/llvm/llvm-project/pull/194840
More information about the flang-commits
mailing list