@@ -3835,7 +3835,7 @@ genDeclareInFunction(Fortran::lower::AbstractConverter &converter,
38353835 const Fortran::parser::AccClauseList &accClauseList) {
38363836 llvm::SmallVector<mlir::Value> dataClauseOperands, copyEntryOperands,
38373837 copyinEntryOperands, createEntryOperands, copyoutEntryOperands,
3838- deviceResidentEntryOperands;
3838+ presentEntryOperands, deviceResidentEntryOperands;
38393839 Fortran::lower::StatementContext stmtCtx;
38403840 fir::FirOpBuilder &builder = converter.getFirOpBuilder ();
38413841
@@ -3866,11 +3866,14 @@ genDeclareInFunction(Fortran::lower::AbstractConverter &converter,
38663866 } else if (const auto *presentClause =
38673867 std::get_if<Fortran::parser::AccClause::Present>(
38683868 &clause.u )) {
3869+ auto crtDataStart = dataClauseOperands.size ();
38693870 genDeclareDataOperandOperations<mlir::acc::PresentOp,
3870- mlir::acc::PresentOp >(
3871+ mlir::acc::DeleteOp >(
38713872 presentClause->v , converter, semanticsContext, stmtCtx,
38723873 dataClauseOperands, mlir::acc::DataClause::acc_present,
38733874 /* structured=*/ true , /* implicit=*/ false );
3875+ presentEntryOperands.append (dataClauseOperands.begin () + crtDataStart,
3876+ dataClauseOperands.end ());
38743877 } else if (const auto *copyinClause =
38753878 std::get_if<Fortran::parser::AccClause::Copyin>(&clause.u )) {
38763879 auto crtDataStart = dataClauseOperands.size ();
@@ -3949,14 +3952,15 @@ genDeclareInFunction(Fortran::lower::AbstractConverter &converter,
39493952
39503953 openAccCtx.attachCleanup ([&builder, loc, createEntryOperands,
39513954 copyEntryOperands, copyinEntryOperands,
3952- copyoutEntryOperands, deviceResidentEntryOperands ,
3953- declareToken]() {
3955+ copyoutEntryOperands, presentEntryOperands ,
3956+ deviceResidentEntryOperands, declareToken]() {
39543957 llvm::SmallVector<mlir::Value> operands;
39553958 operands.append (createEntryOperands);
39563959 operands.append (deviceResidentEntryOperands);
39573960 operands.append (copyEntryOperands);
39583961 operands.append (copyinEntryOperands);
39593962 operands.append (copyoutEntryOperands);
3963+ operands.append (presentEntryOperands);
39603964
39613965 mlir::func::FuncOp funcOp = builder.getFunction ();
39623966 auto ops = funcOp.getOps <mlir::acc::DeclareExitOp>();
@@ -3978,6 +3982,8 @@ genDeclareInFunction(Fortran::lower::AbstractConverter &converter,
39783982 builder, copyinEntryOperands, /* structured=*/ true );
39793983 genDataExitOperations<mlir::acc::CreateOp, mlir::acc::CopyoutOp>(
39803984 builder, copyoutEntryOperands, /* structured=*/ true );
3985+ genDataExitOperations<mlir::acc::PresentOp, mlir::acc::DeleteOp>(
3986+ builder, presentEntryOperands, /* structured=*/ true );
39813987 });
39823988}
39833989
0 commit comments