Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
131 commits
Select commit Hold shift + click to select a range
54c0158
[flang][DRAFT] Copy-in/Copy-out determination
eugeneepshteyn Jul 30, 2025
808fb20
Call DetermineCopyInOut() from lowering
eugeneepshteyn Jul 30, 2025
28bc5bd
clang-format
eugeneepshteyn Jul 30, 2025
f44b945
DetermineCopyInOut() is now called from ProcedureRef constructor
eugeneepshteyn Jul 30, 2025
ffd6563
clang-format
eugeneepshteyn Jul 30, 2025
fb3a93c
Minor tweak
eugeneepshteyn Jul 31, 2025
6e052f4
Merge branch 'llvm:main' into copy-inout-dev
eugeneepshteyn Jul 31, 2025
b914f79
Merge branch 'llvm:main' into copy-inout-dev
eugeneepshteyn Jul 31, 2025
527b2d7
DetermineCopyInOut() is now called at ProcedureRef instantiation
eugeneepshteyn Jul 31, 2025
9c1755b
Very rough beginnings of argument handling in DetermineCopyInOut()
eugeneepshteyn Aug 1, 2025
3198e90
More args handing in DetermineCopyInOut()
eugeneepshteyn Aug 1, 2025
0378a5f
clang-format
eugeneepshteyn Aug 3, 2025
5d5418a
clang-format
eugeneepshteyn Aug 3, 2025
2cce4bb
clang-format
eugeneepshteyn Aug 3, 2025
f6f64ca
Merge branch 'llvm:main' into copy-inout-dev
eugeneepshteyn Aug 3, 2025
4a6d402
Merge branch 'llvm:main' into copy-inout-dev
eugeneepshteyn Aug 6, 2025
698b865
Merge branch 'llvm:main' into copy-inout-dev
eugeneepshteyn Aug 6, 2025
de06d25
Initial implementation of DetermineCopyInOutArgument() for implicit
eugeneepshteyn Aug 7, 2025
cf42b12
Removed empty line
eugeneepshteyn Aug 7, 2025
9373b90
clang-format
eugeneepshteyn Aug 7, 2025
889f7c1
Merge branch 'llvm:main' into copy-inout-dev
eugeneepshteyn Aug 7, 2025
905c315
Merge branch 'llvm:main' into copy-inout-review
eugeneepshteyn Aug 7, 2025
d9452c3
Merge branch 'llvm:main' into copy-inout-dev
eugeneepshteyn Aug 7, 2025
fab0c75
Merge branch 'copy-inout-dev' into copy-inout-review
eugeneepshteyn Aug 7, 2025
9e47176
Merge branch 'llvm:main' into copy-inout-dev
eugeneepshteyn Aug 8, 2025
12ca5a8
Braces!
eugeneepshteyn Aug 8, 2025
3126a8c
Merge branch 'llvm:main' into copy-inout-dev
eugeneepshteyn Aug 10, 2025
c2fc2e9
Merge branch 'llvm:main' into copy-inout-dev
eugeneepshteyn Aug 11, 2025
902894c
Merge branch 'llvm:main' into copy-inout-dev
eugeneepshteyn Aug 12, 2025
c3ef243
Merge branch 'llvm:main' into copy-inout-dev
eugeneepshteyn Aug 12, 2025
143f7bd
clang-format
eugeneepshteyn Aug 8, 2025
6d0935c
Renamed copy-in/copy-out getter/setter functions
eugeneepshteyn Aug 11, 2025
15db3f8
Contiguity check
eugeneepshteyn Aug 12, 2025
58764a6
clang-format
eugeneepshteyn Aug 12, 2025
eb27031
Continue filling out DetermineCopyInOutArgument(). Implemented IsExpl…
eugeneepshteyn Aug 12, 2025
3ec01ad
clang-format
eugeneepshteyn Aug 12, 2025
889d514
In DetermineCopyInOutArgument(), handle INTENT(IN) and INTENT(OUT)
eugeneepshteyn Aug 12, 2025
040572f
Merge branch 'llvm:main' into copy-inout-dev
eugeneepshteyn Aug 12, 2025
04daa83
Merge branch 'llvm:main' into copy-inout-dev
eugeneepshteyn Aug 13, 2025
5136de2
Merge branch 'llvm:main' into copy-inout-dev
eugeneepshteyn Aug 13, 2025
7e448f0
Merge branch 'llvm:main' into copy-inout-dev
eugeneepshteyn Aug 14, 2025
546af8f
Merge branch 'llvm:main' into copy-inout-dev
eugeneepshteyn Aug 14, 2025
068216f
Support polymorphic-to-non-polymorphic case. Initial hookup into lowe…
eugeneepshteyn Aug 13, 2025
3f36c9f
clang-format
eugeneepshteyn Aug 13, 2025
070ffd1
array check
eugeneepshteyn Aug 14, 2025
5062266
array check
eugeneepshteyn Aug 14, 2025
312cf25
Changed IsExplicitShape() and restructured the checks
eugeneepshteyn Aug 14, 2025
bc2e17a
Redid the integration to basically the old code but debug output with…
eugeneepshteyn Aug 15, 2025
d026f49
Tweaks and debug output
eugeneepshteyn Aug 15, 2025
55b8e0e
Switched to the new code. 5 failed tests left
eugeneepshteyn Aug 15, 2025
a781512
Merge branch 'llvm:main' into copy-inout-dev
eugeneepshteyn Aug 15, 2025
384bc2e
Merge branch 'llvm:main' into copy-inout-dev
eugeneepshteyn Aug 18, 2025
b3fd99a
Merge branch 'llvm:main' into copy-inout-dev
eugeneepshteyn Aug 18, 2025
258fc64
Fixed one issue with assumed rank arrays
eugeneepshteyn Aug 15, 2025
a197190
clang-format
eugeneepshteyn Aug 15, 2025
30d36b0
Expaned IsAssumedShape() checks and moved them to Fortran::evaluate n…
eugeneepshteyn Aug 15, 2025
47f2656
clang-format
eugeneepshteyn Aug 15, 2025
aa65a3e
Passes LIT tests
eugeneepshteyn Aug 18, 2025
d285ded
Clean up in lowering to switch to the new checks
eugeneepshteyn Aug 18, 2025
413eafd
Ignore rank support
eugeneepshteyn Aug 18, 2025
4590955
Polymorphic dummy with ignore rank
eugeneepshteyn Aug 18, 2025
d026e0d
clang-format (upstream)
eugeneepshteyn Aug 18, 2025
0289de2
clang-format (upstream)
eugeneepshteyn Aug 18, 2025
2464dd3
clang-format (started using upstream)
eugeneepshteyn Aug 18, 2025
f76c9e3
Added LIT test
eugeneepshteyn Aug 18, 2025
b12d2c8
Implement copy-in/copy-out determination in Fortran::evaluate::MayNee…
eugeneepshteyn Aug 18, 2025
24c2040
clang-format
eugeneepshteyn Aug 18, 2025
a760320
Removed the old way to integrate copy-in/copy-out check
eugeneepshteyn Aug 18, 2025
6868af8
Merge branch 'llvm:main' into copy-inout-dev
eugeneepshteyn Aug 18, 2025
e69fa22
Merge branch 'llvm:main' into copy-inout-review
eugeneepshteyn Aug 18, 2025
1bd1822
Merge branch 'copy-inout-dev' into copy-inout-review
eugeneepshteyn Aug 18, 2025
f752112
Merge branch 'llvm:main' into copy-inout-dev
eugeneepshteyn Aug 19, 2025
7aa458c
Fixed the issue with user defined assignment
eugeneepshteyn Aug 19, 2025
d1a8d7c
clang-format
eugeneepshteyn Aug 19, 2025
57fd73e
Tweaked MayNeedCopyInOut() API
eugeneepshteyn Aug 19, 2025
b7dab28
Simplified IsAssumedRank() and IsAssumedShape()
eugeneepshteyn Aug 19, 2025
0239c1d
Moved IsAssumedRank() and IsAssumedShape() to namespace Fortran::sema…
eugeneepshteyn Aug 19, 2025
95f0aac
Merge branch 'llvm:main' into copy-inout-dev
eugeneepshteyn Aug 19, 2025
02ee2b7
Merge branch 'llvm:main' into copy-inout-review
eugeneepshteyn Aug 19, 2025
4938d03
Merge branch 'copy-inout-dev' into copy-inout-review
eugeneepshteyn Aug 19, 2025
0faca16
clang-format
eugeneepshteyn Aug 19, 2025
6f828b3
Merge branch 'copy-inout-dev' into copy-inout-review
eugeneepshteyn Aug 19, 2025
450a5d7
WIP: new API MayNeedCopy()
eugeneepshteyn Aug 20, 2025
0be16a4
clang-format
eugeneepshteyn Aug 20, 2025
68722d6
Merge branch 'llvm:main' into copy-inout-dev
eugeneepshteyn Aug 20, 2025
dd9560a
Continue implementation of new MayNeedCopy()
eugeneepshteyn Aug 20, 2025
a8c4dcf
Assumed type check for contiguity
eugeneepshteyn Aug 20, 2025
be85c20
Better void* standing for old implementation
eugeneepshteyn Aug 20, 2025
36a3049
clang-format
eugeneepshteyn Aug 20, 2025
69d7ca0
Tweaks to MayNeedCopyIn() to bring it closer to the old implementation
eugeneepshteyn Aug 20, 2025
f6bb3df
Removed the old implementation (MayNeedCopyInOut) and switched to the…
eugeneepshteyn Aug 20, 2025
fce3da4
Simplified MayNeedCopyOut()
eugeneepshteyn Aug 21, 2025
e36a534
Enhanced flang/test/Lower/force-temp.f90 to cover more cases
eugeneepshteyn Aug 21, 2025
6c5a1e2
Merge branch 'llvm:main' into copy-inout-dev
eugeneepshteyn Aug 21, 2025
11c27fb
Merge branch 'llvm:main' into copy-inout-review
eugeneepshteyn Aug 21, 2025
73e9db7
WIP: new API MayNeedCopy()
eugeneepshteyn Aug 20, 2025
4ab82fd
Merge branch 'copy-inout-dev' into copy-inout-review
eugeneepshteyn Aug 21, 2025
3baa7da
Fixed bad merge
eugeneepshteyn Aug 21, 2025
0050af6
Merge branch 'llvm:main' into copy-inout-dev
eugeneepshteyn Aug 21, 2025
3e281e4
Yet another refactoring and logic update: use common class CopyInOutE…
eugeneepshteyn Aug 22, 2025
bd61c2a
Merge branch 'llvm:main' into copy-inout-dev
eugeneepshteyn Aug 22, 2025
335a463
Merge branch 'llvm:main' into copy-inout-dev
eugeneepshteyn Aug 22, 2025
b8e78b1
clang-format
eugeneepshteyn Aug 22, 2025
9be6a3e
Merge branch 'llvm:main' into copy-inout-dev
eugeneepshteyn Aug 22, 2025
36993cd
Merge branch 'llvm:main' into copy-inout-dev
eugeneepshteyn Aug 22, 2025
629b67d
debugging (checking the old code again)
eugeneepshteyn Aug 22, 2025
6138cc8
Fixed build issue with the old code
eugeneepshteyn Aug 22, 2025
02eec4c
Different copy-in/copy-out flag configuration
eugeneepshteyn Aug 22, 2025
f5be38b
Merge branch 'llvm:main' into copy-inout-dev
eugeneepshteyn Aug 25, 2025
5ddac27
Removed the old code
eugeneepshteyn Aug 25, 2025
b5ff581
updated comment
eugeneepshteyn Aug 25, 2025
6284e57
Merge branch 'llvm:main' into copy-inout-dev
eugeneepshteyn Aug 25, 2025
def4089
Merge branch 'llvm:main' into copy-inout-review
eugeneepshteyn Aug 25, 2025
09e507a
Merge branch 'copy-inout-dev' into copy-inout-review
eugeneepshteyn Aug 25, 2025
e54a8d2
Code review feedback
eugeneepshteyn Aug 25, 2025
d22d27c
clang-format
eugeneepshteyn Aug 25, 2025
84ce8ad
Merge branch 'llvm:main' into copy-inout-dev
eugeneepshteyn Aug 25, 2025
45eaddc
force-temp.f90: add test for INTENT(OUT) dummy argument
eugeneepshteyn Aug 25, 2025
fc28315
MayNeedCopy() simplification
eugeneepshteyn Aug 25, 2025
c7a740c
Further simplification of MayNeedCopy()
eugeneepshteyn Aug 25, 2025
0d9302e
Removed the old code
eugeneepshteyn Aug 25, 2025
3bb10d5
Merge branch 'llvm:main' into copy-inout-dev
eugeneepshteyn Aug 26, 2025
395e4ca
Merge branch 'llvm:main' into copy-inout-review
eugeneepshteyn Aug 26, 2025
b7c35c9
Merge branch 'copy-inout-dev' into copy-inout-review
eugeneepshteyn Aug 26, 2025
d22d76f
Removed DummyDataObject::IsArray() (no longer used)
eugeneepshteyn Aug 26, 2025
991df0e
Merge branch 'copy-inout-dev' into copy-inout-review
eugeneepshteyn Aug 26, 2025
99aaa2b
Merge branch 'llvm:main' into copy-inout-dev
eugeneepshteyn Aug 26, 2025
3c64f13
Code review feedback
eugeneepshteyn Aug 26, 2025
0c5dc79
Merge branch 'llvm:main' into copy-inout-dev
eugeneepshteyn Aug 26, 2025
d79c588
Merge branch 'llvm:main' into copy-inout-review
eugeneepshteyn Aug 26, 2025
8f768ca
Merge branch 'copy-inout-dev' into copy-inout-review
eugeneepshteyn Aug 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions flang/include/flang/Evaluate/call.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ using SymbolRef = common::Reference<const Symbol>;

class ActualArgument {
public:
ENUM_CLASS(Attr, PassedObject, PercentVal, PercentRef);
ENUM_CLASS(Attr, PassedObject, PercentVal, PercentRef, CopyIn, CopyOut);
using Attrs = common::EnumSet<Attr, Attr_enumSize>;

// Dummy arguments that are TYPE(*) can be forwarded as actual arguments.
Expand Down Expand Up @@ -131,7 +131,6 @@ class ActualArgument {
return *this;
}

bool Matches(const characteristics::DummyArgument &) const;
common::Intent dummyIntent() const { return dummyIntent_; }
ActualArgument &set_dummyIntent(common::Intent intent) {
dummyIntent_ = intent;
Expand Down Expand Up @@ -161,6 +160,20 @@ class ActualArgument {
return *this;
}

// This actual argument may need copy-in before the procedure call
bool mayNeedCopyIn() const { return attrs_.test(Attr::CopyIn); };
ActualArgument &set_mayNeedCopyIn() {
attrs_ = attrs_ + Attr::CopyIn;
return *this;
}

// This actual argument may need copy-out after the procedure call
bool mayNeedCopyOut() const { return attrs_.test(Attr::CopyOut); };
ActualArgument &set_mayNeedCopyOut() {
attrs_ = attrs_ + Attr::CopyOut;
return *this;
}

private:
// Subtlety: There is a distinction that must be maintained here between an
// actual argument expression that is a variable and one that is not,
Expand Down Expand Up @@ -272,6 +285,8 @@ class ProcedureRef {
bool operator==(const ProcedureRef &) const;
llvm::raw_ostream &AsFortran(llvm::raw_ostream &) const;

void DetermineCopyInOut();

protected:
ProcedureDesignator proc_;
ActualArguments arguments_;
Expand Down
3 changes: 3 additions & 0 deletions flang/include/flang/Lower/CallInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,9 @@ class CallerInterface : public CallInterface<CallerInterface> {
CallerInterface(const Fortran::evaluate::ProcedureRef &p,
Fortran::lower::AbstractConverter &c)
: CallInterface{c}, procRef{p} {
// Ensure that procRef gathers necessary information to determine the
// need for copy-in and copy-out
const_cast<Fortran::evaluate::ProcedureRef &>(procRef).DetermineCopyInOut();
declare();
mapPassedEntities();
actualInputs.resize(getNumFIRArguments());
Expand Down
16 changes: 16 additions & 0 deletions flang/lib/Evaluate/call.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "flang/Evaluate/check-expression.h"
#include "flang/Evaluate/expression.h"
#include "flang/Evaluate/tools.h"
#include "flang/Semantics/semantics.h"
#include "flang/Semantics/symbol.h"
#include "flang/Support/Fortran.h"

Expand Down Expand Up @@ -247,4 +248,19 @@ ProcedureRef::~ProcedureRef() {}

void ProcedureRef::Deleter(ProcedureRef *p) { delete p; }

void ProcedureRef::DetermineCopyInOut() {
if (!proc().GetSymbol()) {
return;
}
// Get folding context of the call site owner
FoldingContext &fc{proc_.GetSymbol()->owner().context().foldingContext()};
auto procInfo{characteristics::Procedure::Characterize(
proc(), fc, /*emitError=*/false)};
if (!procInfo) {
return;
}
// TODO: at this point have dummy arguments as procInfo->dummyArguments
// and have actual arguments via arguments_
}

} // namespace Fortran::evaluate