Skip to content

[flang][DRAFT-DEV][DO NOT REVIEW] Copy-in/Copy-out determination #151426

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 49 commits into
base: main
Choose a base branch
from

Conversation

eugeneepshteyn
Copy link
Contributor

When creating ProcedureRef, determine copy-in/copy-out needs

DEVELOPMENT PR NOT FOR REVIEW.

Copy link

github-actions bot commented Aug 1, 2025

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff HEAD~1 HEAD --extensions h,cpp -- flang/include/flang/Evaluate/call.h flang/include/flang/Evaluate/characteristics.h flang/include/flang/Evaluate/check-expression.h flang/include/flang/Evaluate/tools.h flang/include/flang/Lower/CallInterface.h flang/lib/Evaluate/call.cpp flang/lib/Evaluate/check-expression.cpp flang/lib/Evaluate/tools.cpp flang/lib/Lower/ConvertCall.cpp flang/lib/Semantics/expression.cpp
View the diff from clang-format here.
diff --git a/flang/lib/Evaluate/call.cpp b/flang/lib/Evaluate/call.cpp
index e79a314c8..29f2f3d41 100644
--- a/flang/lib/Evaluate/call.cpp
+++ b/flang/lib/Evaluate/call.cpp
@@ -260,8 +260,8 @@ static void DetermineCopyInOutArgument(
     // Actual argument expressions that aren’t variables are copy-in, but
     // not copy-out.
     actual.SetMayNeedCopyIn();
-  } else if (bool actualIsArray{actual.Rank() > 0}; actualIsArray &&
-             !IsSimplyContiguous(actual, sc.foldingContext())) {
+  } else if (bool actualIsArray{actual.Rank() > 0};
+      actualIsArray && !IsSimplyContiguous(actual, sc.foldingContext())) {
     // Actual arguments that are variables are copy-in when non-contiguous.
     // They are copy-out when don't have vector subscripts
     actual.SetMayNeedCopyIn();
@@ -331,8 +331,7 @@ static void DetermineCopyInOutArgument(
   bool dummyIsAssumedSize{dummyObj->type.attrs().test(
       characteristics::TypeAndShape::Attr::AssumedSize)};
   bool dummyNeedsContiguity{dummyIsExplicitShape || dummyIsAssumedSize ||
-      dummyObj->attrs.test(
-          characteristics::DummyDataObject::Attr::Contiguous)};
+      dummyObj->attrs.test(characteristics::DummyDataObject::Attr::Contiguous)};
   if (!actualTreatAsContiguous && dummyNeedsContiguity) {
     setCopyIn();
     // Cannot do copy-out for vector subscripts: there could be repeated
diff --git a/flang/lib/Lower/ConvertCall.cpp b/flang/lib/Lower/ConvertCall.cpp
index 610dd6315..1d92a6340 100644
--- a/flang/lib/Lower/ConvertCall.cpp
+++ b/flang/lib/Lower/ConvertCall.cpp
@@ -1257,10 +1257,9 @@ static PreparedDummyArgument preparePresentUserCallActualArgument(
   // 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.
-  bool mustDoCopyIn =
-      actual.isArray() && arg.mustBeMadeContiguous() &&
-      (passingPolymorphicToNonPolymorphic ||
-       !isSimplyContiguous(*arg.entity, foldingContext));
+  bool mustDoCopyIn = actual.isArray() && arg.mustBeMadeContiguous() &&
+                      (passingPolymorphicToNonPolymorphic ||
+                       !isSimplyContiguous(*arg.entity, foldingContext));
   bool mustDoCopyOut = mustDoCopyIn && arg.mayBeModifiedByCall();
   bool newMustDoCopyIn = false;
   bool newMustDoCopyOut = false;
@@ -1268,15 +1267,15 @@ static PreparedDummyArgument preparePresentUserCallActualArgument(
     newMustDoCopyIn = arg.entity->GetMayNeedCopyIn();
     newMustDoCopyOut = arg.entity->GetMayNeedCopyOut();
 #if 1
-    llvm::dbgs() << "copyinout: CALLER " <<
-        "copy-in: old=" << mustDoCopyIn << ", new=" << newMustDoCopyIn <<
-        "| copy-out: old=" << mustDoCopyOut << ", new=" << newMustDoCopyOut <<
-        "\n";
+    llvm::dbgs() << "copyinout: CALLER " << "copy-in: old=" << mustDoCopyIn
+                 << ", new=" << newMustDoCopyIn
+                 << "| copy-out: old=" << mustDoCopyOut
+                 << ", new=" << newMustDoCopyOut << "\n";
 #endif
   } else {
 #if 1
-    llvm::dbgs() << "copyinout: CALLEE " <<
-        "copy-in=" << mustDoCopyIn << ", copy-out=" << mustDoCopyOut << "\n";
+    llvm::dbgs() << "copyinout: CALLEE " << "copy-in=" << mustDoCopyIn
+                 << ", copy-out=" << mustDoCopyOut << "\n";
 #endif
   }
   mustDoCopyIn = newMustDoCopyIn;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant