[flang-commits] [flang] [flang][mlir] Add flang to mlir lowering for groupprivate (PR #180934)

Sergio Afonso via flang-commits flang-commits at lists.llvm.org
Mon Jun 8 08:25:26 PDT 2026


================
@@ -2181,6 +2181,34 @@ bool OmpAttributeVisitor::Pre(const parser::OmpGroupprivateDirective &x) {
       ResolveOmpObject(*object, Symbol::Flag::OmpGroupPrivate);
     }
   }
+
+  // OpenMP 6.0 allows an optional device_type clause on groupprivate. Record it
+  // on each listed object's ultimate symbol so lowering and .mod emission can
+  // read it. An absent clause means the spec default (any).
+  std::optional<common::OmpDeviceType> device;
+  if (auto *devClause{
+          parser::omp::FindClause(x.v, llvm::omp::Clause::OMPC_device_type)}) {
+    device = parser::UnwrapRef<common::OmpDeviceType>(*devClause);
+  }
+
+  if (device) {
----------------
skatrak wrote:

Nit: I think this would be a bit simpler. Feel free to ignore if you disagree:
```c++
if (auto *devClause{
        parser::omp::FindClause(x.v, llvm::omp::Clause::OMPC_device_type)}) {
  common::OmpDeviceType device{parser::UnwrapRef<common::OmpDeviceType>(*devClause)};
  for (const parser::OmpArgument &arg : x.v.Arguments().v) { ... }
}
```

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


More information about the flang-commits mailing list