[flang-commits] [flang] [flang][OpenMP] Implement copyin for pointers and allocatables. (PR #107425)
David Truby via flang-commits
flang-commits at lists.llvm.org
Fri Sep 6 02:33:37 PDT 2024
================
@@ -619,9 +620,28 @@ bool ClauseProcessor::processCopyin() const {
checkAndCopyHostAssociateVar(&*mem, &insPt);
break;
}
- if (semantics::IsAllocatableOrObjectPointer(&sym->GetUltimate()))
- TODO(converter.getCurrentLocation(),
- "pointer or allocatable variables in Copyin clause");
+ if (semantics::IsAllocatable(sym->GetUltimate())) {
+ // copyin should copy the association of the allocatable
+
+ fir::FirOpBuilder &builder = converter.getFirOpBuilder();
+ const Fortran::semantics::Symbol &hsym = sym->GetUltimate();
+
+ Fortran::lower::SymbolBox hsb =
+ converter.lookupOneLevelUpSymbol(hsym);
+ assert(hsb && "Host symbol box not found");
+
+ Fortran::lower::SymbolBox sb = converter.shallowLookupSymbol(*sym);
+ assert(sb && "Host-associated symbol box not found");
+ assert(hsb.getAddr() != sb.getAddr() &&
+ "Host and associated symbol boxes are the same");
+
+ mlir::Location loc = converter.genLocation(sym->name());
+ mlir::OpBuilder::InsertionGuard ipGuard{builder};
+ builder.setInsertionPointAfter(sb.getAddr().getDefiningOp());
+ builder.create<hlfir::AssignOp>(loc, hsb.getAddr(), sb.getAddr(),
+ true, false, false);
+ }
----------------
DavidTruby wrote:
You're right, it's sufficient to just remove the TODO with your patch. Thanks!
https://github.com/llvm/llvm-project/pull/107425
More information about the flang-commits
mailing list