@@ -2183,8 +2183,9 @@ static Op createComputeOp(
2183
2183
mlir::Value ifCond;
2184
2184
mlir::Value selfCond;
2185
2185
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;
2188
2189
llvm::SmallVector<mlir::Attribute> numGangsDeviceTypes, numWorkersDeviceTypes,
2189
2190
vectorLengthDeviceTypes, asyncDeviceTypes, asyncOnlyDeviceTypes,
2190
2191
waitOperandsDeviceTypes, waitOnlyDeviceTypes;
@@ -2321,13 +2322,16 @@ static Op createComputeOp(
2321
2322
dataClauseOperands.end ());
2322
2323
} else if (const auto *copyinClause =
2323
2324
std::get_if<Fortran::parser::AccClause::Copyin>(&clause.u )) {
2325
+ auto crtDataStart = dataClauseOperands.size ();
2324
2326
genDataOperandOperationsWithModifier<mlir::acc::CopyinOp,
2325
2327
Fortran::parser::AccClause::Copyin>(
2326
2328
copyinClause, converter, semanticsContext, stmtCtx,
2327
2329
Fortran::parser::AccDataModifier::Modifier::ReadOnly,
2328
2330
dataClauseOperands, mlir::acc::DataClause::acc_copyin,
2329
2331
mlir::acc::DataClause::acc_copyin_readonly, async, asyncDeviceTypes,
2330
2332
asyncOnlyDeviceTypes);
2333
+ copyinEntryOperands.append (dataClauseOperands.begin () + crtDataStart,
2334
+ dataClauseOperands.end ());
2331
2335
} else if (const auto *copyoutClause =
2332
2336
std::get_if<Fortran::parser::AccClause::Copyout>(
2333
2337
&clause.u )) {
@@ -2525,6 +2529,8 @@ static Op createComputeOp(
2525
2529
// Create the exit operations after the region.
2526
2530
genDataExitOperations<mlir::acc::CopyinOp, mlir::acc::CopyoutOp>(
2527
2531
builder, copyEntryOperands, /* structured=*/ true );
2532
+ genDataExitOperations<mlir::acc::CopyinOp, mlir::acc::DeleteOp>(
2533
+ builder, copyinEntryOperands, /* structured=*/ true );
2528
2534
genDataExitOperations<mlir::acc::CreateOp, mlir::acc::CopyoutOp>(
2529
2535
builder, copyoutEntryOperands, /* structured=*/ true );
2530
2536
genDataExitOperations<mlir::acc::AttachOp, mlir::acc::DetachOp>(
@@ -2544,8 +2550,8 @@ static void genACCDataOp(Fortran::lower::AbstractConverter &converter,
2544
2550
const Fortran::parser::AccClauseList &accClauseList) {
2545
2551
mlir::Value ifCond;
2546
2552
llvm::SmallVector<mlir::Value> attachEntryOperands, createEntryOperands,
2547
- copyEntryOperands, copyoutEntryOperands, dataClauseOperands, waitOperands ,
2548
- async;
2553
+ copyEntryOperands, copyinEntryOperands, copyoutEntryOperands ,
2554
+ dataClauseOperands, waitOperands, async;
2549
2555
llvm::SmallVector<mlir::Attribute> asyncDeviceTypes, asyncOnlyDeviceTypes,
2550
2556
waitOperandsDeviceTypes, waitOnlyDeviceTypes;
2551
2557
llvm::SmallVector<int32_t > waitOperandsSegments;
@@ -2604,13 +2610,16 @@ static void genACCDataOp(Fortran::lower::AbstractConverter &converter,
2604
2610
dataClauseOperands.end ());
2605
2611
} else if (const auto *copyinClause =
2606
2612
std::get_if<Fortran::parser::AccClause::Copyin>(&clause.u )) {
2613
+ auto crtDataStart = dataClauseOperands.size ();
2607
2614
genDataOperandOperationsWithModifier<mlir::acc::CopyinOp,
2608
2615
Fortran::parser::AccClause::Copyin>(
2609
2616
copyinClause, converter, semanticsContext, stmtCtx,
2610
2617
Fortran::parser::AccDataModifier::Modifier::ReadOnly,
2611
2618
dataClauseOperands, mlir::acc::DataClause::acc_copyin,
2612
2619
mlir::acc::DataClause::acc_copyin_readonly, async, asyncDeviceTypes,
2613
2620
asyncOnlyDeviceTypes);
2621
+ copyinEntryOperands.append (dataClauseOperands.begin () + crtDataStart,
2622
+ dataClauseOperands.end ());
2614
2623
} else if (const auto *copyoutClause =
2615
2624
std::get_if<Fortran::parser::AccClause::Copyout>(
2616
2625
&clause.u )) {
@@ -2723,6 +2732,8 @@ static void genACCDataOp(Fortran::lower::AbstractConverter &converter,
2723
2732
// Create the exit operations after the region.
2724
2733
genDataExitOperations<mlir::acc::CopyinOp, mlir::acc::CopyoutOp>(
2725
2734
builder, copyEntryOperands, /* structured=*/ true );
2735
+ genDataExitOperations<mlir::acc::CopyinOp, mlir::acc::DeleteOp>(
2736
+ builder, copyinEntryOperands, /* structured=*/ true );
2726
2737
genDataExitOperations<mlir::acc::CreateOp, mlir::acc::CopyoutOp>(
2727
2738
builder, copyoutEntryOperands, /* structured=*/ true );
2728
2739
genDataExitOperations<mlir::acc::AttachOp, mlir::acc::DetachOp>(
@@ -3691,7 +3702,8 @@ genDeclareInFunction(Fortran::lower::AbstractConverter &converter,
3691
3702
mlir::Location loc,
3692
3703
const Fortran::parser::AccClauseList &accClauseList) {
3693
3704
llvm::SmallVector<mlir::Value> dataClauseOperands, copyEntryOperands,
3694
- createEntryOperands, copyoutEntryOperands, deviceResidentEntryOperands;
3705
+ copyinEntryOperands, createEntryOperands, copyoutEntryOperands,
3706
+ deviceResidentEntryOperands;
3695
3707
Fortran::lower::StatementContext stmtCtx;
3696
3708
fir::FirOpBuilder &builder = converter.getFirOpBuilder ();
3697
3709
@@ -3729,12 +3741,15 @@ genDeclareInFunction(Fortran::lower::AbstractConverter &converter,
3729
3741
/* structured=*/ true , /* implicit=*/ false );
3730
3742
} else if (const auto *copyinClause =
3731
3743
std::get_if<Fortran::parser::AccClause::Copyin>(&clause.u )) {
3744
+ auto crtDataStart = dataClauseOperands.size ();
3732
3745
genDeclareDataOperandOperationsWithModifier<mlir::acc::CopyinOp,
3733
3746
mlir::acc::DeleteOp>(
3734
3747
copyinClause, converter, semanticsContext, stmtCtx,
3735
3748
Fortran::parser::AccDataModifier::Modifier::ReadOnly,
3736
3749
dataClauseOperands, mlir::acc::DataClause::acc_copyin,
3737
3750
mlir::acc::DataClause::acc_copyin_readonly);
3751
+ copyinEntryOperands.append (dataClauseOperands.begin () + crtDataStart,
3752
+ dataClauseOperands.end ());
3738
3753
} else if (const auto *copyoutClause =
3739
3754
std::get_if<Fortran::parser::AccClause::Copyout>(
3740
3755
&clause.u )) {
@@ -3801,12 +3816,14 @@ genDeclareInFunction(Fortran::lower::AbstractConverter &converter,
3801
3816
}
3802
3817
3803
3818
openAccCtx.attachCleanup ([&builder, loc, createEntryOperands,
3804
- copyEntryOperands, copyoutEntryOperands,
3805
- deviceResidentEntryOperands, declareToken]() {
3819
+ copyEntryOperands, copyinEntryOperands,
3820
+ copyoutEntryOperands, deviceResidentEntryOperands,
3821
+ declareToken]() {
3806
3822
llvm::SmallVector<mlir::Value> operands;
3807
3823
operands.append (createEntryOperands);
3808
3824
operands.append (deviceResidentEntryOperands);
3809
3825
operands.append (copyEntryOperands);
3826
+ operands.append (copyinEntryOperands);
3810
3827
operands.append (copyoutEntryOperands);
3811
3828
3812
3829
mlir::func::FuncOp funcOp = builder.getFunction ();
@@ -3825,6 +3842,8 @@ genDeclareInFunction(Fortran::lower::AbstractConverter &converter,
3825
3842
builder, deviceResidentEntryOperands, /* structured=*/ true );
3826
3843
genDataExitOperations<mlir::acc::CopyinOp, mlir::acc::CopyoutOp>(
3827
3844
builder, copyEntryOperands, /* structured=*/ true );
3845
+ genDataExitOperations<mlir::acc::CopyinOp, mlir::acc::DeleteOp>(
3846
+ builder, copyinEntryOperands, /* structured=*/ true );
3828
3847
genDataExitOperations<mlir::acc::CreateOp, mlir::acc::CopyoutOp>(
3829
3848
builder, copyoutEntryOperands, /* structured=*/ true );
3830
3849
});
@@ -3848,7 +3867,7 @@ genDeclareInModule(Fortran::lower::AbstractConverter &converter,
3848
3867
} else if (const auto *copyinClause =
3849
3868
std::get_if<Fortran::parser::AccClause::Copyin>(&clause.u )) {
3850
3869
genGlobalCtorsWithModifier<Fortran::parser::AccClause::Copyin,
3851
- mlir::acc::CopyinOp, mlir::acc::CopyinOp >(
3870
+ mlir::acc::CopyinOp, mlir::acc::DeleteOp >(
3852
3871
converter, modBuilder, copyinClause,
3853
3872
Fortran::parser::AccDataModifier::Modifier::ReadOnly,
3854
3873
mlir::acc::DataClause::acc_copyin,
0 commit comments