[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:36 PST 2026


https://github.com/jeanPerier commented:

Thanks for all the work here. I have a few inline comments, but before going deeper, my main question is: what is the plan with coarray representation in the IR and at runtime?

This patch is using the CFI descriptor as is, which may be OK, but I think we need to agree with the direction first.

How will the cobounds be tracked in the different stages (lowering/IR/runtime) if needed. For instance, how will cobound inquiry works with the current patch:

```
 real, allocatable :: co[:, :]
 integer :: n
 n = 100
 allocate(co[n,*])
 print *, ucobound(co)
end
```

Also, the idea so far was to carry all the Fortran level information about variables into fir/hlfir declare. I think it may be worth extending them to carry the cobounds or at least the information that the variable is a coarray (at least debug info will need this). The FIR type system could also probably be updated to reflect that, although it is also OK to not do it if there is not foreseen need for it.

Regarding allocation/deallocation, there are some language specific effects in allocations (initialization/finalization/assignment in case of sourced allocation). So I wonder if it would not be best to call the PRIF runtime via the Fortran runtime to deal with the allocation/deallocation and leave the Fortran runtime in charge of the rest. But for that the Fortran runtime needs to know it is dealing with coarrays. I am not saying this is the best option, I am just saying it should be considered.

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


More information about the llvm-commits mailing list