[flang-commits] [flang] [flang] Associate named constant actual arguments with their storage (PR #222986)
Eugene Epshteyn via flang-commits
flang-commits at lists.llvm.org
Mon Sep 28 18:32:51 PDT 2026
================
@@ -1392,19 +1392,24 @@ static PreparedDummyArgument preparePresentUserCallActualArgument(
bool mustDoCopyIn{false};
bool mustDoCopyOut{false};
+ // Default to suggesting a copy when the copy analysis does not run, so
+ // that the parameter-object temporary below stays conservative in
+ // contexts that disable the analysis.
+ bool suggestCopyIn{true};
+ bool suggestCopyOut{true};
if (callContext.doCopyIn) {
----------------
eugeneepshteyn wrote:
Reverted back to `false`, but with the new array section support `suggestCopyIn/Out` is always computed.
To answer the original question itself: `doCopyIn` is false only in `convertUserDefinedAssignmentToHLFIR`, which is reached from four places — the `hlfir.region_assign` path and the CUDA device right-hand-side path in `Bridge.cpp`, and the OpenMP declare-reduction initializer and combiner lowering. No extra copies appear in the ordinary defined assignment path, because nothing reaches the parameter branch there: the right-hand side of an assignment is analyzed as an expression rather than as a procedure-reference argument (F2023 15.4.3.4.3 p2), so a named constant arrives folded and is never one of the retained designators, and inside `hlfir.region_assign` the actual arguments are block arguments that `isParameterObjectOrSubObject` cannot look through.
https://github.com/llvm/llvm-project/pull/222986
More information about the flang-commits
mailing list