[flang-commits] [flang] [flang] Changes to map variables in link clause of declare target (PR #83643)
via flang-commits
flang-commits at lists.llvm.org
Fri Mar 1 20:27:31 PST 2024
================
@@ -1120,7 +1120,21 @@ genTargetOp(Fortran::lower::AbstractConverter &converter,
if (auto refType = baseOp.getType().dyn_cast<fir::ReferenceType>())
eleType = refType.getElementType();
- if (fir::isa_trivial(eleType) || fir::isa_char(eleType)) {
+ // If a variable is specified in declare target link and if device
+ // type is nohost, it needs to be mapped tofrom
+ mlir::ModuleOp mod = converter.getFirOpBuilder().getModule();
+ mlir::Operation *op = mod.lookupSymbol(converter.mangleName(sym));
+ auto declareTargetOp =
+ llvm::dyn_cast_if_present<mlir::omp::DeclareTargetInterface>(op);
+ if (declareTargetOp && declareTargetOp.isDeclareTarget()) {
+ if (declareTargetOp.getDeclareTargetCaptureClause() ==
+ mlir::omp::DeclareTargetCaptureClause::link &&
+ declareTargetOp.getDeclareTargetDeviceType() !=
----------------
agozillon wrote:
And as an aside, if it wouldn't be too much of a bother could you add a runtime test to: https://github.com/llvm/llvm-project/tree/main/openmp/libomptarget/test/offloading/fortran not necessary for me signing off, but it would be excellent to track this behavior with a runtime test as well!
https://github.com/llvm/llvm-project/pull/83643
More information about the flang-commits
mailing list