@@ -2183,8 +2183,9 @@ static Op createComputeOp(
21832183 mlir::Value ifCond;
21842184 mlir::Value selfCond;
21852185 llvm::SmallVector<mlir::Value> waitOperands, attachEntryOperands,
2186- copyEntryOperands, copyoutEntryOperands, createEntryOperands,
2187- dataClauseOperands, numGangs, numWorkers, vectorLength, async;
2186+ copyEntryOperands, copyinEntryOperands, copyoutEntryOperands,
2187+ createEntryOperands, dataClauseOperands, numGangs, numWorkers,
2188+ vectorLength, async;
21882189 llvm::SmallVector<mlir::Attribute> numGangsDeviceTypes, numWorkersDeviceTypes,
21892190 vectorLengthDeviceTypes, asyncDeviceTypes, asyncOnlyDeviceTypes,
21902191 waitOperandsDeviceTypes, waitOnlyDeviceTypes;
@@ -2321,13 +2322,16 @@ static Op createComputeOp(
23212322 dataClauseOperands.end ());
23222323 } else if (const auto *copyinClause =
23232324 std::get_if<Fortran::parser::AccClause::Copyin>(&clause.u )) {
2325+ auto crtDataStart = dataClauseOperands.size ();
23242326 genDataOperandOperationsWithModifier<mlir::acc::CopyinOp,
23252327 Fortran::parser::AccClause::Copyin>(
23262328 copyinClause, converter, semanticsContext, stmtCtx,
23272329 Fortran::parser::AccDataModifier::Modifier::ReadOnly,
23282330 dataClauseOperands, mlir::acc::DataClause::acc_copyin,
23292331 mlir::acc::DataClause::acc_copyin_readonly, async, asyncDeviceTypes,
23302332 asyncOnlyDeviceTypes);
2333+ copyinEntryOperands.append (dataClauseOperands.begin () + crtDataStart,
2334+ dataClauseOperands.end ());
23312335 } else if (const auto *copyoutClause =
23322336 std::get_if<Fortran::parser::AccClause::Copyout>(
23332337 &clause.u )) {
@@ -2525,6 +2529,8 @@ static Op createComputeOp(
25252529 // Create the exit operations after the region.
25262530 genDataExitOperations<mlir::acc::CopyinOp, mlir::acc::CopyoutOp>(
25272531 builder, copyEntryOperands, /* structured=*/ true );
2532+ genDataExitOperations<mlir::acc::CopyinOp, mlir::acc::DeleteOp>(
2533+ builder, copyinEntryOperands, /* structured=*/ true );
25282534 genDataExitOperations<mlir::acc::CreateOp, mlir::acc::CopyoutOp>(
25292535 builder, copyoutEntryOperands, /* structured=*/ true );
25302536 genDataExitOperations<mlir::acc::AttachOp, mlir::acc::DetachOp>(
@@ -2544,8 +2550,8 @@ static void genACCDataOp(Fortran::lower::AbstractConverter &converter,
25442550 const Fortran::parser::AccClauseList &accClauseList) {
25452551 mlir::Value ifCond;
25462552 llvm::SmallVector<mlir::Value> attachEntryOperands, createEntryOperands,
2547- copyEntryOperands, copyoutEntryOperands, dataClauseOperands, waitOperands ,
2548- async;
2553+ copyEntryOperands, copyinEntryOperands, copyoutEntryOperands ,
2554+ dataClauseOperands, waitOperands, async;
25492555 llvm::SmallVector<mlir::Attribute> asyncDeviceTypes, asyncOnlyDeviceTypes,
25502556 waitOperandsDeviceTypes, waitOnlyDeviceTypes;
25512557 llvm::SmallVector<int32_t > waitOperandsSegments;
@@ -2604,13 +2610,16 @@ static void genACCDataOp(Fortran::lower::AbstractConverter &converter,
26042610 dataClauseOperands.end ());
26052611 } else if (const auto *copyinClause =
26062612 std::get_if<Fortran::parser::AccClause::Copyin>(&clause.u )) {
2613+ auto crtDataStart = dataClauseOperands.size ();
26072614 genDataOperandOperationsWithModifier<mlir::acc::CopyinOp,
26082615 Fortran::parser::AccClause::Copyin>(
26092616 copyinClause, converter, semanticsContext, stmtCtx,
26102617 Fortran::parser::AccDataModifier::Modifier::ReadOnly,
26112618 dataClauseOperands, mlir::acc::DataClause::acc_copyin,
26122619 mlir::acc::DataClause::acc_copyin_readonly, async, asyncDeviceTypes,
26132620 asyncOnlyDeviceTypes);
2621+ copyinEntryOperands.append (dataClauseOperands.begin () + crtDataStart,
2622+ dataClauseOperands.end ());
26142623 } else if (const auto *copyoutClause =
26152624 std::get_if<Fortran::parser::AccClause::Copyout>(
26162625 &clause.u )) {
@@ -2723,6 +2732,8 @@ static void genACCDataOp(Fortran::lower::AbstractConverter &converter,
27232732 // Create the exit operations after the region.
27242733 genDataExitOperations<mlir::acc::CopyinOp, mlir::acc::CopyoutOp>(
27252734 builder, copyEntryOperands, /* structured=*/ true );
2735+ genDataExitOperations<mlir::acc::CopyinOp, mlir::acc::DeleteOp>(
2736+ builder, copyinEntryOperands, /* structured=*/ true );
27262737 genDataExitOperations<mlir::acc::CreateOp, mlir::acc::CopyoutOp>(
27272738 builder, copyoutEntryOperands, /* structured=*/ true );
27282739 genDataExitOperations<mlir::acc::AttachOp, mlir::acc::DetachOp>(
@@ -3691,7 +3702,8 @@ genDeclareInFunction(Fortran::lower::AbstractConverter &converter,
36913702 mlir::Location loc,
36923703 const Fortran::parser::AccClauseList &accClauseList) {
36933704 llvm::SmallVector<mlir::Value> dataClauseOperands, copyEntryOperands,
3694- createEntryOperands, copyoutEntryOperands, deviceResidentEntryOperands;
3705+ copyinEntryOperands, createEntryOperands, copyoutEntryOperands,
3706+ deviceResidentEntryOperands;
36953707 Fortran::lower::StatementContext stmtCtx;
36963708 fir::FirOpBuilder &builder = converter.getFirOpBuilder ();
36973709
@@ -3729,12 +3741,15 @@ genDeclareInFunction(Fortran::lower::AbstractConverter &converter,
37293741 /* structured=*/ true , /* implicit=*/ false );
37303742 } else if (const auto *copyinClause =
37313743 std::get_if<Fortran::parser::AccClause::Copyin>(&clause.u )) {
3744+ auto crtDataStart = dataClauseOperands.size ();
37323745 genDeclareDataOperandOperationsWithModifier<mlir::acc::CopyinOp,
37333746 mlir::acc::DeleteOp>(
37343747 copyinClause, converter, semanticsContext, stmtCtx,
37353748 Fortran::parser::AccDataModifier::Modifier::ReadOnly,
37363749 dataClauseOperands, mlir::acc::DataClause::acc_copyin,
37373750 mlir::acc::DataClause::acc_copyin_readonly);
3751+ copyinEntryOperands.append (dataClauseOperands.begin () + crtDataStart,
3752+ dataClauseOperands.end ());
37383753 } else if (const auto *copyoutClause =
37393754 std::get_if<Fortran::parser::AccClause::Copyout>(
37403755 &clause.u )) {
@@ -3801,12 +3816,14 @@ genDeclareInFunction(Fortran::lower::AbstractConverter &converter,
38013816 }
38023817
38033818 openAccCtx.attachCleanup ([&builder, loc, createEntryOperands,
3804- copyEntryOperands, copyoutEntryOperands,
3805- deviceResidentEntryOperands, declareToken]() {
3819+ copyEntryOperands, copyinEntryOperands,
3820+ copyoutEntryOperands, deviceResidentEntryOperands,
3821+ declareToken]() {
38063822 llvm::SmallVector<mlir::Value> operands;
38073823 operands.append (createEntryOperands);
38083824 operands.append (deviceResidentEntryOperands);
38093825 operands.append (copyEntryOperands);
3826+ operands.append (copyinEntryOperands);
38103827 operands.append (copyoutEntryOperands);
38113828
38123829 mlir::func::FuncOp funcOp = builder.getFunction ();
@@ -3825,6 +3842,8 @@ genDeclareInFunction(Fortran::lower::AbstractConverter &converter,
38253842 builder, deviceResidentEntryOperands, /* structured=*/ true );
38263843 genDataExitOperations<mlir::acc::CopyinOp, mlir::acc::CopyoutOp>(
38273844 builder, copyEntryOperands, /* structured=*/ true );
3845+ genDataExitOperations<mlir::acc::CopyinOp, mlir::acc::DeleteOp>(
3846+ builder, copyinEntryOperands, /* structured=*/ true );
38283847 genDataExitOperations<mlir::acc::CreateOp, mlir::acc::CopyoutOp>(
38293848 builder, copyoutEntryOperands, /* structured=*/ true );
38303849 });
@@ -3848,7 +3867,7 @@ genDeclareInModule(Fortran::lower::AbstractConverter &converter,
38483867 } else if (const auto *copyinClause =
38493868 std::get_if<Fortran::parser::AccClause::Copyin>(&clause.u )) {
38503869 genGlobalCtorsWithModifier<Fortran::parser::AccClause::Copyin,
3851- mlir::acc::CopyinOp, mlir::acc::CopyinOp >(
3870+ mlir::acc::CopyinOp, mlir::acc::DeleteOp >(
38523871 converter, modBuilder, copyinClause,
38533872 Fortran::parser::AccDataModifier::Modifier::ReadOnly,
38543873 mlir::acc::DataClause::acc_copyin,
0 commit comments