[flang-commits] [flang] [flang] Fixed regression in copy-in/copy-out (PR #161259)
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Mon Nov 10 11:55:13 PST 2025
================
@@ -1619,28 +1608,25 @@ bool MayNeedCopy(const ActualArgument *actual,
if (!check.HaveArrayOrAssumedRankArgs()) {
return false;
}
- if (check.HaveContiguityDifferences()) {
- return true;
- }
- if (check.HavePolymorphicDifferences()) {
- return true;
+ if (maybeContigActual) {
+ // We know whether actual arg is contiguous or not
+ bool isContiguousActual{maybeContigActual.value()};
+ bool actualArgNeedsCopy{
+ (!isContiguousActual || check.HavePolymorphicDifferences()) &&
+ check.DummyNeedsContiguity()};
+ return actualArgNeedsCopy;
+ } else {
+ // We don't know whether actual arg is contiguous or not
+ return check.DummyNeedsContiguity();
}
} else { // Implicit interface
- if (ExtractCoarrayRef(*actual)) {
- // Coindexed actual args may need copy-in and copy-out with implicit
- // interface
- return true;
- }
- if (!IsSimplyContiguous(*actual, fc)) {
- // Copy-in: actual arguments that are variables are copy-in when
- // non-contiguous.
- // Copy-out: vector subscripts could refer to duplicate elements, can't
- // copy out.
- return !(forCopyOut && HasVectorSubscript(*actual));
+ if (maybeContigActual) {
+ // If known contiguous, don't copy in/out.
+ // If known non-contiguous, copy in/out.
+ return !(maybeContigActual.value());
----------------
klausler wrote:
`!*maybeContigActual`
https://github.com/llvm/llvm-project/pull/161259
More information about the flang-commits
mailing list