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

via flang-commits flang-commits at lists.llvm.org
Tue Jun 9 00:14:13 PDT 2026


================
@@ -408,6 +408,30 @@ static void PutOpenMPDeclarativeDirectives(llvm::raw_ostream &os,
         decls->printClauseSet(os, dtgt, symbol.name());
         os << "\n";
       }
+      // Re-emit `!$omp groupprivate` (and any recorded device_type) so a TU
+      // that `use`s this module recovers the directive from the .mod file.
+      // Common-block names must be wrapped in slashes when reparsed.
+      if (symbol.test(Symbol::Flag::OmpGroupPrivate)) {
+        os << "!$omp groupprivate(";
+        if (symbol.detailsIf<CommonBlockDetails>())
+          os << '/' << symbol.name() << '/';
+        else
+          os << symbol.name();
+        os << ")";
+        if (auto deviceType{decls->ompGroupprivateDeviceType()}) {
+          switch (*deviceType) {
+          case common::OmpDeviceType::Any:
+            break;
+          case common::OmpDeviceType::Host:
+            os << " device_type(host)";
+            break;
+          case common::OmpDeviceType::Nohost:
+            os << " device_type(nohost)";
+            break;
+          }
----------------
skc7 wrote:

Gave `printClauseSet` an optional `deviceType` override so `groupprivate` and `declare_target` each pass their own value. Updated the patch.

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


More information about the flang-commits mailing list