@@ -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 *
12071211static 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
0 commit comments