[flang-commits] [flang] [flang] Consolidate copy-in/copy-out determination in evaluate framework (PR #151408)

Eugene Epshteyn via flang-commits flang-commits at lists.llvm.org
Tue Aug 19 10:51:25 PDT 2025


================
@@ -1254,13 +1243,12 @@ static PreparedDummyArgument preparePresentUserCallActualArgument(
       passingPolymorphicToNonPolymorphic &&
       (actual.isArray() || mlir::isa<fir::BaseBoxType>(dummyType));
 
-  // The simple contiguity of the actual is "lost" when passing a polymorphic
-  // to a non polymorphic entity because the dummy dynamic type matters for
-  // the contiguity.
-  const bool mustDoCopyInOut =
-      actual.isArray() && arg.mustBeMadeContiguous() &&
-      (passingPolymorphicToNonPolymorphic ||
-       !isSimplyContiguous(*arg.entity, foldingContext));
+  Fortran::evaluate::FoldingContext &foldingContext{
+      callContext.converter.getFoldingContext()};
+  auto [suggestCopyIn, suggestCopyOut] = Fortran::evaluate::MayNeedCopyInOut(
+      *arg.entity, arg.characteristics, foldingContext);
+  bool mustDoCopyIn = actual.isArray() && suggestCopyIn;
+  bool mustDoCopyOut = mustDoCopyIn && suggestCopyOut;
----------------
eugeneepshteyn wrote:

This was done. User defined assignment works now.

https://github.com/llvm/llvm-project/pull/151408


More information about the flang-commits mailing list