[flang-commits] [flang] [flang][OpenMP] Implement copyin for pointers and allocatables. (PR #107425)
Leandro Lupori via flang-commits
flang-commits at lists.llvm.org
Thu Sep 5 10:53:16 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);
+ }
----------------
luporl wrote:
The test program works correctly with https://github.com/llvm/llvm-project/pull/106559, if I just remove the TODO:
```
--- a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
+++ b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
@@ -619,9 +619,6 @@ bool ClauseProcessor::processCopyin() const {
checkAndCopyHostAssociateVar(&*mem, &insPt);
break;
}
- if (semantics::IsAllocatableOrObjectPointer(&sym->GetUltimate()))
- TODO(converter.getCurrentLocation(),
- "pointer or allocatable variables in Copyin clause");
assert(sym->has<semantics::HostAssocDetails>() &&
"No host-association found");
checkAndCopyHostAssociateVar(sym);
```
But line https://github.com/llvm/llvm-project/pull/106559/files#diff-0f70165af00b05acb5abeb11198079b793a20acf8f069edd2dbe7b34ac67b328R1262 should be chaged too, to allow `copyin` with unallocated variables.
https://github.com/llvm/llvm-project/pull/107425
More information about the flang-commits
mailing list