[flang] [llvm] [Flang] Adding lowering for the allocation and deallocation of coarrays (PR #182110)

via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 3 06:36:38 PST 2026


================
@@ -478,6 +481,29 @@ class AllocateStmtHelper {
                             !box.isPointer();
     unsigned allocatorIdx = Fortran::lower::getAllocatorIdx(alloc.getSymbol());
 
+    const Fortran::lower::SomeExpr *expr =
+        Fortran::semantics::GetExpr(alloc.getAllocObj());
+    std::optional<Fortran::evaluate::DataRef> dataRef =
+        !expr ? std::nullopt : Fortran::evaluate::ExtractDataRef(expr);
+    bool isCoarrayAllocate = alloc.hasCoarraySpec();
+
+    if (isCoarrayAllocate) {
----------------
jeanPerier wrote:

Also, given only the allocation part is different, I would advise placing it below next to the cuda/normal allocation to ensure the rest of the descriptor set-up is and remains the same.

```
if (alloc.hasCoarraySpec()) {
  stat = Fortran::lower::genAllocateCoarray(
          converter, loc, alloc.getSymbol(), box.getAddr(),
          alloc.getCoarraySpec(), errorManager.errMsgAddr);
} else if (isCudaAllocate) {
     stat =
          genCudaAllocate(builder, loc, box, errorManager, alloc.getSymbol());
} else {
      stat = genRuntimeAllocate(builder, loc, box, errorManager);
      setPinnedToFalse();
}
```


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


More information about the llvm-commits mailing list