[flang] [llvm] [Flang] Adding lowering for the allocation and deallocation of coarrays (PR #182110)
Jean-Didier PAILLEUX via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 4 07:14:49 PST 2026
JDPailleux wrote:
Hi Jean, Thanks for your review.
Here few answer from your first comment :
> 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
Information on cobounds can be retrieved using the procedures provided by PRIF (e.g., `prif_lcobound_no_dim`, etc.). Except for intrinsics about cobounds stuff, I don't see any point in storing this type of information.
> 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.
I have a patch (dependent on this PR) pending that includes the LCOBOUND, UCBOUND, and COSHAPE intrinsics, which expect to have a variable with an attribute on the corank (I think I gave it the name ‘fir.corank’). Would this be sufficient to validate at the FIR/HLFIR level that a variable passed as an argument is a coarray?
> 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.
That could be a solution to consider, yes. However, the Fortran runtime is in C/C++ and what PRIF offers is in Fortran (non-interoperable), which will cause problems when trying to match the two together (perhaps I misunderstood/misread what you meant)?
https://github.com/llvm/llvm-project/pull/182110
More information about the llvm-commits
mailing list