Skip to content

Commit aa65a3e

Browse files
Passes LIT tests
1 parent 47f2656 commit aa65a3e

File tree

3 files changed

+11
-15
lines changed

3 files changed

+11
-15
lines changed

flang/include/flang/Lower/CallInterface.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,6 @@ class CallInterface {
159159
/// PassedEntity is what is provided back to the CallInterface user.
160160
/// It describe how the entity is plugged in the interface
161161
struct PassedEntity {
162-
/// Helps with caller/callee differentiation
163-
static constexpr bool isCaller = std::is_same_v<T, CallerInterface>;
164162
/// Is the dummy argument optional?
165163
bool isOptional() const;
166164
/// Can the argument be modified by the callee?

flang/lib/Lower/ConvertCall.cpp

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,6 +1204,10 @@ static bool isParameterObjectOrSubObject(hlfir::Entity entity) {
12041204
/// fir.box_char...).
12051205
/// This function should only be called with an actual that is present.
12061206
/// The optional aspects must be handled by this function user.
1207+
///
1208+
/// Note: while Fortran::lower::CallerInterface::PassedEntity (the type of arg)
1209+
/// is technically a template type, in the prepare*ActualArgument() calls
1210+
/// it resolves to Fortran::evaluate::ActualArgument *
12071211
static PreparedDummyArgument preparePresentUserCallActualArgument(
12081212
mlir::Location loc, fir::FirOpBuilder &builder,
12091213
const Fortran::lower::PreparedActualArgument &preparedActual,
@@ -1263,21 +1267,14 @@ static PreparedDummyArgument preparePresentUserCallActualArgument(
12631267
bool mustDoCopyOut = mustDoCopyIn && arg.mayBeModifiedByCall();
12641268
bool newMustDoCopyIn = false;
12651269
bool newMustDoCopyOut = false;
1266-
if constexpr (Fortran::lower::CallerInterface::PassedEntity::isCaller) {
1267-
newMustDoCopyIn = arg.entity->GetMayNeedCopyIn();
1268-
newMustDoCopyOut = arg.entity->GetMayNeedCopyOut();
1270+
newMustDoCopyIn = actual.isArray() && arg.entity->GetMayNeedCopyIn();
1271+
newMustDoCopyOut = newMustDoCopyIn && arg.entity->GetMayNeedCopyOut();
12691272
#if 1
1270-
llvm::dbgs() << "copyinout: CALLER " << "copy-in: old=" << mustDoCopyIn
1271-
<< ", new=" << newMustDoCopyIn
1272-
<< "| copy-out: old=" << mustDoCopyOut
1273-
<< ", new=" << newMustDoCopyOut << "\n";
1273+
llvm::dbgs() << "copyinout: CALLER " << "copy-in: old=" << mustDoCopyIn
1274+
<< ", new=" << newMustDoCopyIn
1275+
<< "| copy-out: old=" << mustDoCopyOut
1276+
<< ", new=" << newMustDoCopyOut << "\n";
12741277
#endif
1275-
} else {
1276-
#if 1
1277-
llvm::dbgs() << "copyinout: CALLEE " << "copy-in=" << mustDoCopyIn
1278-
<< ", copy-out=" << mustDoCopyOut << "\n";
1279-
#endif
1280-
}
12811278
mustDoCopyIn = newMustDoCopyIn;
12821279
mustDoCopyOut = newMustDoCopyOut;
12831280

flang/lib/Semantics/expression.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4389,6 +4389,7 @@ MaybeExpr ExpressionAnalyzer::MakeFunctionRef(parser::CharBlock callSite,
43894389
if (chars->functionResult) {
43904390
const auto &result{*chars->functionResult};
43914391
ProcedureRef procRef{std::move(proc), std::move(arguments)};
4392+
procRef.DetermineCopyInOut();
43924393
if (result.IsProcedurePointer()) {
43934394
return Expr<SomeType>{std::move(procRef)};
43944395
} else {

0 commit comments

Comments
 (0)