[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 Sep 1 04:04:12 PDT 2026
================
@@ -1852,6 +1855,31 @@ markDeclareTarget(mlir::Operation *op, lower::AbstractConverter &converter,
/*implicit=*/false);
}
+// Take a declare target directive, and mark the globals and functions
+// named in its clauses.
+static void markDeclareTargetWithDirective(
+ lower::AbstractConverter &converter, semantics::SemanticsContext &semaCtx,
+ std::optional<common::reference_wrapper<lower::pft::Evaluation>> eval,
+ const parser::OmpDeclareTargetDirective &declareTargetConstruct) {
+ mlir::omp::DeclareTargetOperands clauseOps;
+ llvm::SmallVector<DeclareTargetCaptureInfo> symbolAndClause;
+ mlir::ModuleOp mod = converter.getFirOpBuilder().getModule();
+ getDeclareTargetInfo(converter, semaCtx, eval, declareTargetConstruct,
+ clauseOps, symbolAndClause);
+
+ for (const DeclareTargetCaptureInfo &symClause : symbolAndClause) {
+ mlir::Operation *op =
+ mod.lookupSymbol(converter.mangleName(symClause.symbol));
+
+ // Do nothing if op is not found.
----------------
skatrak wrote:
Nit: This comment doesn't really add anything.
Perhaps it would be good to identify here the two cases that cause this situation and why it's ok to skip those missing ops, rather than documenting it in the callers (mainly because there it isn't clear what we mean by skipping those symbols).
If you feel like those comments are better suited where they currently are, then feel free to leave them there.
https://github.com/llvm/llvm-project/pull/213930
More information about the flang-commits
mailing list