[flang-commits] [flang] [flang][openmp] Support importing module declare target globals (PR #213930)

Sergio Afonso via flang-commits flang-commits at lists.llvm.org
Tue Aug 25 05:25:47 PDT 2026


================
@@ -8093,3 +8096,54 @@ void Fortran::lower::materializeOpenMPDeclareMappers(
 // Walk scopes and materialize omp.declare_reduction ops for user-defined
 // operator reductions imported from modules (deleted: replaced by lazy,
 // clause-driven materialization).
+
+// Visitor used to mark declare target globals from imported modules.
+struct ModuleDeclareTargetVisitor {
+  Fortran::lower::AbstractConverter &converter;
+  semantics::SemanticsContext &semaCtx;
+
+  explicit ModuleDeclareTargetVisitor(
+      Fortran::lower::AbstractConverter &converter,
+      semantics::SemanticsContext &ctx)
+      : converter(converter), semaCtx(ctx) {}
+
+  template <typename T>
+  bool Pre(const T &) {
+    return true;
+  }
+  template <typename T>
+  void Post(const T &) {}
+
+  void Post(const parser::OmpDeclareTargetDirective &directive) {
----------------
skatrak wrote:

Nit: This is mostly a copy-paste of `genOMP()` for `parser::OmpDeclareTargetDirective()` except for the missing `eval`. I'd suggest refactoring both to call a single implementation.

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


More information about the flang-commits mailing list