[flang-commits] [flang] [flang] Fixed repacking for TARGET and INTENT(OUT) (PR #131972)
Slava Zakharin via flang-commits
flang-commits at lists.llvm.org
Wed Mar 19 08:12:44 PDT 2025
================
@@ -346,6 +347,8 @@ The copy creation is also restricted for `ASYNCHRONOUS` and `VOLATILE` arguments
It does not make sense to generate the new operations for `CONTIGUOUS` arguments and for arguments with statically known element size that exceeds the `max-element-size` threshold.
+The `fir.pack_array`'s copy-in action cannot be skipped for `INTENT(OUT)` dummy argument of a derived type that requires finalization on entry to the subprogram, as long as the finalization subroutines may access the value of the dummy argument. In this case `fir.pack_array` operation cannot have `no_copy` attribute, so that it creates a contiguous temporary matching the value of the original array, and then the temporary is finalized before execution of the subprogram's body begins.
----------------
vzakhari wrote:
This would be problematic, because we insert the finalization after `hlfir.declare`.
I thought about this case, and I think it might be profitable to repack before the finalization, because the finalization will walk the whole array and may benefit from the derived type elements being in the data cache (dependng on the size of the derived type).
https://github.com/llvm/llvm-project/pull/131972
More information about the flang-commits
mailing list