[flang-commits] [flang] [flang][openmp] initialize allocatable components of firstprivate copies (PR #121808)
via flang-commits
flang-commits at lists.llvm.org
Tue Jan 7 01:04:08 PST 2025
jeanPerier wrote:
> I assumed the later copy would also handle the initialization of allocatable components. It's good to know that is not the case.
Right, the copy is made with an hlfir.assign, which lowers to a `Assign` runtime call currently because of the allocatable components. FortranAssign requires the descriptor to be properly initialized because it must preserve the LHS component allocations if they match the RHS component allocations (it needs to read the LHS component descriptor before doing anything with them, so they must be set to a valid state).
If `AssignTemporary` was used instead, your assumption would be correct because the LHS would be initialized before calling LHS.
Since the `create` code is not specific to OpenMP, I'd rather be safe and do the initialization explicitly here to cover all future usage of this helper, although a solution for OpenMP firstprivate could also have been to change the `hlfir.assign` in the copy region to an `hlfir.assign temporary_lhs`.
https://github.com/llvm/llvm-project/pull/121808
More information about the flang-commits
mailing list