llvm-project
1872f06d - [flang][HLFIR] Add SeparateAllocatableAssign pass (#197814)

Commit
72 days ago
[flang][HLFIR] Add SeparateAllocatableAssign pass (#197814) Example: ```fortran !$acc kernels B = A ! A, B allocatable !$acc end kernels ``` In this code, `B = A` lowers to `hlfir.assign ... realloc`, which becomes a `_FortranAAssign` runtime call inside the compute region — the allocation can't be separated from the copy, and it crashes when `B` is unallocated. Fix: add `SeparateAllocatableAssign`, which splits the realloc assign into an explicit conditional [re-]allocation followed by a plain `hlfir.assign`, exposing the allocation as plain FIR. For variable RHS it skips aliasing cases (`a = a(:n)`) by loading the LHS `fir.box` and querying `fir::AliasAnalysis` on the data. For `hlfir.expr` RHS it leaves ordering to bufferization, and fixes `ElementalAssignBufferization` to stop fusing an elemental across a deallocation.
Author
Parents
Loading