diff --git a/flang/include/flang/Lower/OpenACC.h b/flang/include/flang/Lower/OpenACC.h index e974f3d6eef11..19d759479abaf 100644 --- a/flang/include/flang/Lower/OpenACC.h +++ b/flang/include/flang/Lower/OpenACC.h @@ -66,11 +66,11 @@ struct Evaluation; } // namespace pft static constexpr llvm::StringRef declarePostAllocSuffix = - "_acc_declare_update_desc_post_alloc"; + "_acc_declare_post_alloc"; static constexpr llvm::StringRef declarePreDeallocSuffix = - "_acc_declare_update_desc_pre_dealloc"; + "_acc_declare_pre_dealloc"; static constexpr llvm::StringRef declarePostDeallocSuffix = - "_acc_declare_update_desc_post_dealloc"; + "_acc_declare_post_dealloc"; static constexpr llvm::StringRef privatizationRecipePrefix = "privatization"; diff --git a/flang/lib/Lower/OpenACC.cpp b/flang/lib/Lower/OpenACC.cpp index bbe749f8c8805..1fbd1b31a8db7 100644 --- a/flang/lib/Lower/OpenACC.cpp +++ b/flang/lib/Lower/OpenACC.cpp @@ -244,17 +244,29 @@ static void createDeclareAllocFuncWithArg(mlir::OpBuilder &modBuilder, if (unwrapFirBox) asFortranDesc << accFirDescriptorPostfix.str(); - // Updating descriptor must occur before the mapping of the data so that - // attached data pointer is not overwritten. - mlir::acc::UpdateDeviceOp updateDeviceOp = - createDataEntryOp( - builder, loc, registerFuncOp.getArgument(0), asFortranDesc, bounds, - /*structured=*/false, /*implicit=*/true, - mlir::acc::DataClause::acc_update_device, descTy, - /*async=*/{}, /*asyncDeviceTypes=*/{}, /*asyncOnlyDeviceTypes=*/{}); - llvm::SmallVector operandSegments{0, 0, 0, 1}; - llvm::SmallVector operands{updateDeviceOp.getResult()}; - createSimpleOp(builder, loc, operands, operandSegments); + // For descriptor, preserve old behavior when unwrapping FIR box: update. + if (unwrapFirBox) { + mlir::acc::UpdateDeviceOp updateDeviceOp = + createDataEntryOp( + builder, loc, registerFuncOp.getArgument(0), asFortranDesc, bounds, + /*structured=*/false, /*implicit=*/true, + mlir::acc::DataClause::acc_update_device, descTy, + /*async=*/{}, /*asyncDeviceTypes=*/{}, /*asyncOnlyDeviceTypes=*/{}); + llvm::SmallVector operandSegments{0, 0, 0, 1}; + llvm::SmallVector operands{updateDeviceOp.getResult()}; + createSimpleOp(builder, loc, operands, + operandSegments); + } else { + // New behavior: start a structured region with declare_enter. + EntryOp descEntryOp = createDataEntryOp( + builder, loc, registerFuncOp.getArgument(0), asFortranDesc, bounds, + /*structured=*/false, /*implicit=*/true, clause, descTy, + /*async=*/{}, /*asyncDeviceTypes=*/{}, /*asyncOnlyDeviceTypes=*/{}); + mlir::acc::DeclareEnterOp::create( + builder, loc, + mlir::acc::DeclareTokenType::get(descEntryOp.getContext()), + mlir::ValueRange(descEntryOp.getAccVar())); + } if (unwrapFirBox) { mlir::Value desc = @@ -299,30 +311,58 @@ static void createDeclareDeallocFuncWithArg( } llvm::SmallVector bounds; - mlir::acc::GetDevicePtrOp entryOp = - createDataEntryOp( - builder, loc, var, asFortran, bounds, - /*structured=*/false, /*implicit=*/false, clause, var.getType(), - /*async=*/{}, /*asyncDeviceTypes=*/{}, /*asyncOnlyDeviceTypes=*/{}); - mlir::acc::DeclareExitOp::create(builder, loc, mlir::Value{}, - mlir::ValueRange(entryOp.getAccVar())); - - if constexpr (std::is_same_v || - std::is_same_v) - ExitOp::create(builder, entryOp.getLoc(), entryOp.getAccVar(), - entryOp.getVar(), entryOp.getVarType(), entryOp.getBounds(), - entryOp.getAsyncOperands(), - entryOp.getAsyncOperandsDeviceTypeAttr(), - entryOp.getAsyncOnlyAttr(), entryOp.getDataClause(), - /*structured=*/false, /*implicit=*/false, - builder.getStringAttr(*entryOp.getName())); - else - ExitOp::create(builder, entryOp.getLoc(), entryOp.getAccVar(), - entryOp.getBounds(), entryOp.getAsyncOperands(), - entryOp.getAsyncOperandsDeviceTypeAttr(), - entryOp.getAsyncOnlyAttr(), entryOp.getDataClause(), - /*structured=*/false, /*implicit=*/false, - builder.getStringAttr(*entryOp.getName())); + if (unwrapFirBox) { + // Unwrap: delete device payload using getdeviceptr + declare_exit + ExitOp + mlir::acc::GetDevicePtrOp entryOp = + createDataEntryOp( + builder, loc, var, asFortran, bounds, + /*structured=*/false, /*implicit=*/false, clause, var.getType(), + /*async=*/{}, /*asyncDeviceTypes=*/{}, /*asyncOnlyDeviceTypes=*/{}); + mlir::acc::DeclareExitOp::create(builder, loc, mlir::Value{}, + mlir::ValueRange(entryOp.getAccVar())); + + if constexpr (std::is_same_v || + std::is_same_v) + ExitOp::create(builder, entryOp.getLoc(), entryOp.getAccVar(), + entryOp.getVar(), entryOp.getVarType(), + entryOp.getBounds(), entryOp.getAsyncOperands(), + entryOp.getAsyncOperandsDeviceTypeAttr(), + entryOp.getAsyncOnlyAttr(), entryOp.getDataClause(), + /*structured=*/false, /*implicit=*/false, + builder.getStringAttr(*entryOp.getName())); + else + ExitOp::create(builder, entryOp.getLoc(), entryOp.getAccVar(), + entryOp.getBounds(), entryOp.getAsyncOperands(), + entryOp.getAsyncOperandsDeviceTypeAttr(), + entryOp.getAsyncOnlyAttr(), entryOp.getDataClause(), + /*structured=*/false, /*implicit=*/false, + builder.getStringAttr(*entryOp.getName())); + } else { + mlir::acc::GetDevicePtrOp entryOp = + createDataEntryOp( + builder, loc, var, asFortran, bounds, + /*structured=*/false, /*implicit=*/false, clause, var.getType(), + /*async=*/{}, /*asyncDeviceTypes=*/{}, /*asyncOnlyDeviceTypes=*/{}); + mlir::acc::DeclareExitOp::create(builder, loc, mlir::Value{}, + mlir::ValueRange(entryOp.getAccVar())); + + if constexpr (std::is_same_v || + std::is_same_v) + ExitOp::create(builder, entryOp.getLoc(), entryOp.getAccVar(), + entryOp.getVar(), entryOp.getVarType(), + entryOp.getBounds(), entryOp.getAsyncOperands(), + entryOp.getAsyncOperandsDeviceTypeAttr(), + entryOp.getAsyncOnlyAttr(), entryOp.getDataClause(), + /*structured=*/false, /*implicit=*/false, + builder.getStringAttr(*entryOp.getName())); + else + ExitOp::create(builder, entryOp.getLoc(), entryOp.getAccVar(), + entryOp.getBounds(), entryOp.getAsyncOperands(), + entryOp.getAsyncOperandsDeviceTypeAttr(), + entryOp.getAsyncOnlyAttr(), entryOp.getDataClause(), + /*structured=*/false, /*implicit=*/false, + builder.getStringAttr(*entryOp.getName())); + } // Generate the post dealloc function. modBuilder.setInsertionPointAfter(preDeallocOp); @@ -338,15 +378,28 @@ static void createDeclareDeallocFuncWithArg( asFortran << accFirDescriptorPostfix.str(); } - mlir::acc::UpdateDeviceOp updateDeviceOp = - createDataEntryOp( - builder, loc, var, asFortran, bounds, - /*structured=*/false, /*implicit=*/true, - mlir::acc::DataClause::acc_update_device, var.getType(), - /*async=*/{}, /*asyncDeviceTypes=*/{}, /*asyncOnlyDeviceTypes=*/{}); - llvm::SmallVector operandSegments{0, 0, 0, 1}; - llvm::SmallVector operands{updateDeviceOp.getResult()}; - createSimpleOp(builder, loc, operands, operandSegments); + if (unwrapFirBox) { + // Old behavior: update descriptor after deallocation. + mlir::acc::UpdateDeviceOp updateDeviceOp = + createDataEntryOp( + builder, loc, var, asFortran, bounds, + /*structured=*/false, /*implicit=*/true, + mlir::acc::DataClause::acc_update_device, var.getType(), + /*async=*/{}, /*asyncDeviceTypes=*/{}, /*asyncOnlyDeviceTypes=*/{}); + llvm::SmallVector operandSegments{0, 0, 0, 1}; + llvm::SmallVector operands{updateDeviceOp.getResult()}; + createSimpleOp(builder, loc, operands, + operandSegments); + } else { + // New behavior: end structured region with declare_exit. + mlir::acc::GetDevicePtrOp postEntryOp = + createDataEntryOp( + builder, loc, var, asFortran, bounds, + /*structured=*/false, /*implicit=*/true, clause, var.getType(), + /*async=*/{}, /*asyncDeviceTypes=*/{}, /*asyncOnlyDeviceTypes=*/{}); + mlir::acc::DeclareExitOp::create(builder, loc, mlir::Value{}, + mlir::ValueRange(postEntryOp.getAccVar())); + } modBuilder.setInsertionPointAfter(postDeallocOp); builder.restoreInsertionPoint(crtInsPt); } @@ -3989,17 +4042,28 @@ static void createDeclareAllocFunc(mlir::OpBuilder &modBuilder, asFortranDesc << accFirDescriptorPostfix.str(); llvm::SmallVector bounds; - // Updating descriptor must occur before the mapping of the data so that - // attached data pointer is not overwritten. - mlir::acc::UpdateDeviceOp updateDeviceOp = - createDataEntryOp( - builder, loc, addrOp, asFortranDesc, bounds, - /*structured=*/false, /*implicit=*/true, - mlir::acc::DataClause::acc_update_device, addrOp.getType(), - /*async=*/{}, /*asyncDeviceTypes=*/{}, /*asyncOnlyDeviceTypes=*/{}); - llvm::SmallVector operandSegments{0, 0, 0, 1}; - llvm::SmallVector operands{updateDeviceOp.getResult()}; - createSimpleOp(builder, loc, operands, operandSegments); + // For unwrapFirBox=false this remains declare_enter; for unwrapFirBox=true, + // the descriptor post-alloc remains update behavior. + if (unwrapFirBox) { + mlir::acc::UpdateDeviceOp updDesc = + createDataEntryOp( + builder, loc, addrOp, asFortranDesc, bounds, + /*structured=*/false, /*implicit=*/true, + mlir::acc::DataClause::acc_update_device, addrOp.getType(), + /*async=*/{}, /*asyncDeviceTypes=*/{}, /*asyncOnlyDeviceTypes=*/{}); + llvm::SmallVector seg{0, 0, 0, 1}; + llvm::SmallVector ops{updDesc.getResult()}; + createSimpleOp(builder, loc, ops, seg); + } else { + EntryOp descEntryOp = createDataEntryOp( + builder, loc, addrOp, asFortranDesc, bounds, + /*structured=*/false, /*implicit=*/true, clause, addrOp.getType(), + /*async=*/{}, /*asyncDeviceTypes=*/{}, /*asyncOnlyDeviceTypes=*/{}); + mlir::acc::DeclareEnterOp::create( + builder, loc, + mlir::acc::DeclareTokenType::get(descEntryOp.getContext()), + mlir::ValueRange(descEntryOp.getAccVar())); + } if (unwrapFirBox) { auto loadOp = fir::LoadOp::create(builder, loc, addrOp.getResult()); @@ -4092,15 +4156,27 @@ static void createDeclareDeallocFunc(mlir::OpBuilder &modBuilder, if (unwrapFirBox) asFortran << accFirDescriptorPostfix.str(); llvm::SmallVector bounds; - mlir::acc::UpdateDeviceOp updateDeviceOp = - createDataEntryOp( - builder, loc, addrOp, asFortran, bounds, - /*structured=*/false, /*implicit=*/true, - mlir::acc::DataClause::acc_update_device, addrOp.getType(), - /*async=*/{}, /*asyncDeviceTypes=*/{}, /*asyncOnlyDeviceTypes=*/{}); - llvm::SmallVector operandSegments{0, 0, 0, 1}; - llvm::SmallVector operands{updateDeviceOp.getResult()}; - createSimpleOp(builder, loc, operands, operandSegments); + if (unwrapFirBox) { + // Unwrap mode: update the descriptor after deallocation (no declare_exit). + mlir::acc::UpdateDeviceOp updDesc = + createDataEntryOp( + builder, loc, addrOp, asFortran, bounds, + /*structured=*/false, /*implicit=*/true, + mlir::acc::DataClause::acc_update_device, addrOp.getType(), + /*async=*/{}, /*asyncDeviceTypes=*/{}, /*asyncOnlyDeviceTypes=*/{}); + llvm::SmallVector seg{0, 0, 0, 1}; + llvm::SmallVector ops{updDesc.getResult()}; + createSimpleOp(builder, loc, ops, seg); + } else { + // Default: end the structured declare region using declare_exit. + mlir::acc::GetDevicePtrOp descEntryOp = + createDataEntryOp( + builder, loc, addrOp, asFortran, bounds, + /*structured=*/false, /*implicit=*/true, clause, addrOp.getType(), + /*async=*/{}, /*asyncDeviceTypes=*/{}, /*asyncOnlyDeviceTypes=*/{}); + mlir::acc::DeclareExitOp::create(builder, loc, mlir::Value{}, + mlir::ValueRange(descEntryOp.getAccVar())); + } modBuilder.setInsertionPointAfter(postDeallocOp); } diff --git a/flang/test/Lower/OpenACC/acc-declare-unwrap-defaultbounds.f90 b/flang/test/Lower/OpenACC/acc-declare-unwrap-defaultbounds.f90 index 6869af863644d..4b181f8a26987 100644 --- a/flang/test/Lower/OpenACC/acc-declare-unwrap-defaultbounds.f90 +++ b/flang/test/Lower/OpenACC/acc-declare-unwrap-defaultbounds.f90 @@ -240,23 +240,23 @@ subroutine acc_declare_allocate() allocate(a(100)) ! CHECK: %{{.*}} = fir.allocmem !fir.array, %{{.*}} {fir.must_be_heap = true, uniq_name = "_QMacc_declareFacc_declare_allocateEa.alloc"} -! CHECK: fir.store %{{.*}} to %{{.*}} {acc.declare_action = #acc.declare_action} : !fir.ref>>> +! CHECK: fir.store %{{.*}} to %{{.*}} {acc.declare_action = #acc.declare_action} : !fir.ref>>> deallocate(a) -! CHECK: %{{.*}} = fir.box_addr %{{.*}} {acc.declare_action = #acc.declare_action} : (!fir.box>>) -> !fir.heap> +! CHECK: %{{.*}} = fir.box_addr %{{.*}} {acc.declare_action = #acc.declare_action} : (!fir.box>>) -> !fir.heap> ! CHECK: fir.freemem %{{.*}} : !fir.heap> -! CHECK: fir.store %{{.*}} to %{{.*}} {acc.declare_action = #acc.declare_action} : !fir.ref>>> +! CHECK: fir.store %{{.*}} to %{{.*}} {acc.declare_action = #acc.declare_action} : !fir.ref>>> ! CHECK: fir.if ! CHECK: fir.freemem %{{.*}} : !fir.heap> -! CHECK: fir.store %{{.*}} to %{{.*}}#0 {acc.declare_action = #acc.declare_action} : !fir.ref>>> +! CHECK: fir.store %{{.*}} to %{{.*}}#0 {acc.declare_action = #acc.declare_action} : !fir.ref>>> ! CHECK: } end subroutine -! CHECK-LABEL: func.func private @_QMacc_declareFacc_declare_allocateEa_acc_declare_update_desc_post_alloc( +! CHECK-LABEL: func.func private @_QMacc_declareFacc_declare_allocateEa_acc_declare_post_alloc( ! CHECK-SAME: %[[ARG0:.*]]: !fir.ref>>>) { ! CHECK: %[[UPDATE:.*]] = acc.update_device varPtr(%[[ARG0]] : !fir.ref>>>) -> !fir.ref>>> {implicit = true, name = "a_desc", structured = false} ! CHECK: acc.update dataOperands(%[[UPDATE]] : !fir.ref>>>) @@ -267,7 +267,7 @@ subroutine acc_declare_allocate() ! CHECK: return ! CHECK: } -! CHECK-LABEL: func.func private @_QMacc_declareFacc_declare_allocateEa_acc_declare_update_desc_pre_dealloc( +! CHECK-LABEL: func.func private @_QMacc_declareFacc_declare_allocateEa_acc_declare_pre_dealloc( ! CHECK-SAME: %[[ARG0:.*]]: !fir.ref>>>) { ! CHECK: %[[LOAD:.*]] = fir.load %[[ARG0]] : !fir.ref>>> ! CHECK: %[[BOX_ADDR:.*]] = fir.box_addr %[[LOAD]] {acc.declare = #acc.declare} : (!fir.box>>) -> !fir.heap> @@ -277,7 +277,7 @@ subroutine acc_declare_allocate() ! CHECK: return ! CHECK: } -! CHECK-LABEL: func.func private @_QMacc_declareFacc_declare_allocateEa_acc_declare_update_desc_post_dealloc( +! CHECK-LABEL: func.func private @_QMacc_declareFacc_declare_allocateEa_acc_declare_post_dealloc( ! CHECK-SAME: %[[ARG0:.*]]: !fir.ref>>>) { ! CHECK: %[[LOAD:.*]] = fir.load %[[ARG0]] : !fir.ref>>> ! CHECK: %[[BOX_ADDR:.*]] = fir.box_addr %[[LOAD]] : (!fir.box>>) -> !fir.heap> @@ -337,8 +337,8 @@ subroutine acc_declare_allocate_with_stat() end subroutine ! CHECK-LABEL: func.func @_QMacc_declarePacc_declare_allocate_with_stat() -! CHECK: fir.call @_FortranAPointerAllocate(%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}) {{.*}} {acc.declare_action = #acc.declare_action} -! CHECK: fir.call @_FortranAPointerDeallocate(%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}) {{.*}} {acc.declare_action = #acc.declare_action} +! CHECK: fir.call @_FortranAPointerAllocate(%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}) {{.*}} {acc.declare_action = #acc.declare_action} +! CHECK: fir.call @_FortranAPointerDeallocate(%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}) {{.*}} {acc.declare_action = #acc.declare_action} end module module acc_declare_allocatable_test @@ -353,7 +353,7 @@ module acc_declare_allocatable_test ! CHECK: acc.terminator ! CHECK: } -! CHECK-LABEL: func.func private @_QMacc_declare_allocatable_testEdata1_acc_declare_update_desc_post_alloc() { +! CHECK-LABEL: func.func private @_QMacc_declare_allocatable_testEdata1_acc_declare_post_alloc() { ! CHECK: %[[GLOBAL_ADDR:.*]] = fir.address_of(@_QMacc_declare_allocatable_testEdata1) : !fir.ref>>> ! CHECK: %[[UPDATE:.*]] = acc.update_device varPtr(%[[GLOBAL_ADDR]] : !fir.ref>>>) -> !fir.ref>>> {implicit = true, name = "data1_desc", structured = false} ! CHECK: acc.update dataOperands(%[[UPDATE]] : !fir.ref>>>) @@ -364,7 +364,7 @@ module acc_declare_allocatable_test ! CHECK: return ! CHECK: } -! CHECK-LABEL: func.func private @_QMacc_declare_allocatable_testEdata1_acc_declare_update_desc_pre_dealloc() { +! CHECK-LABEL: func.func private @_QMacc_declare_allocatable_testEdata1_acc_declare_pre_dealloc() { ! CHECK: %[[GLOBAL_ADDR:.*]] = fir.address_of(@_QMacc_declare_allocatable_testEdata1) : !fir.ref>>> ! CHECK: %[[LOAD:.*]] = fir.load %[[GLOBAL_ADDR]] : !fir.ref>>> ! CHECK: %[[BOXADDR:.*]] = fir.box_addr %[[LOAD]] {acc.declare = #acc.declare} : (!fir.box>>) -> !fir.heap> @@ -374,7 +374,7 @@ module acc_declare_allocatable_test ! CHECK: return ! CHECK: } -! CHECK-LABEL: func.func private @_QMacc_declare_allocatable_testEdata1_acc_declare_update_desc_post_dealloc() { +! CHECK-LABEL: func.func private @_QMacc_declare_allocatable_testEdata1_acc_declare_post_dealloc() { ! CHECK: %[[GLOBAL_ADDR:.*]] = fir.address_of(@_QMacc_declare_allocatable_testEdata1) : !fir.ref>>> ! CHECK: %[[UPDATE:.*]] = acc.update_device varPtr(%[[GLOBAL_ADDR]] : !fir.ref>>>) -> !fir.ref>>> {implicit = true, name = "data1_desc", structured = false} ! CHECK: acc.update dataOperands(%[[UPDATE]] : !fir.ref>>>) @@ -440,14 +440,14 @@ module acc_declare_allocatable_test2 subroutine init() use acc_declare_allocatable_test allocate(data1(100)) -! CHECK: fir.store %{{.*}} to %{{.*}} {acc.declare_action = #acc.declare_action} : !fir.ref>>> +! CHECK: fir.store %{{.*}} to %{{.*}} {acc.declare_action = #acc.declare_action} : !fir.ref>>> end subroutine subroutine finalize() use acc_declare_allocatable_test deallocate(data1) -! CHECK: %{{.*}} = fir.box_addr %{{.*}} {acc.declare_action = #acc.declare_action} : (!fir.box>>) -> !fir.heap> -! CHECK: fir.store %{{.*}} to %{{.*}} {acc.declare_action = #acc.declare_action} : !fir.ref>>> +! CHECK: %{{.*}} = fir.box_addr %{{.*}} {acc.declare_action = #acc.declare_action} : (!fir.box>>) -> !fir.heap> +! CHECK: fir.store %{{.*}} to %{{.*}} {acc.declare_action = #acc.declare_action} : !fir.ref>>> end subroutine end module @@ -473,6 +473,6 @@ subroutine init() end module ! CHECK-LABEL: func.func @_QMacc_declare_post_action_statPinit() -! CHECK: fir.call @_FortranAAllocatableAllocate({{.*}}) fastmath {acc.declare_action = #acc.declare_action} : (!fir.ref>, !fir.ref, i1, !fir.box, !fir.ref, i32) -> i32 +! CHECK: fir.call @_FortranAAllocatableAllocate({{.*}}) fastmath {acc.declare_action = #acc.declare_action} : (!fir.ref>, !fir.ref, i1, !fir.box, !fir.ref, i32) -> i32 ! CHECK: fir.if -! CHECK: fir.call @_FortranAAllocatableAllocate({{.*}}) fastmath {acc.declare_action = #acc.declare_action} : (!fir.ref>, !fir.ref, i1, !fir.box, !fir.ref, i32) -> i32 +! CHECK: fir.call @_FortranAAllocatableAllocate({{.*}}) fastmath {acc.declare_action = #acc.declare_action} : (!fir.ref>, !fir.ref, i1, !fir.box, !fir.ref, i32) -> i32 diff --git a/flang/test/Lower/OpenACC/acc-declare.f90 b/flang/test/Lower/OpenACC/acc-declare.f90 index 4d95ffa10edaf..edae0e6a4d37e 100644 --- a/flang/test/Lower/OpenACC/acc-declare.f90 +++ b/flang/test/Lower/OpenACC/acc-declare.f90 @@ -232,33 +232,33 @@ subroutine acc_declare_allocate() allocate(a(100)) ! CHECK: %{{.*}} = fir.allocmem !fir.array, %{{.*}} {fir.must_be_heap = true, uniq_name = "_QMacc_declareFacc_declare_allocateEa.alloc"} -! CHECK: fir.store %{{.*}} to %{{.*}} {acc.declare_action = #acc.declare_action} : !fir.ref>>> +! CHECK: fir.store %{{.*}} to %{{.*}} {acc.declare_action = #acc.declare_action} : !fir.ref>>> deallocate(a) -! CHECK: %{{.*}} = fir.box_addr %{{.*}} {acc.declare_action = #acc.declare_action} : (!fir.box>>) -> !fir.heap> +! CHECK: %{{.*}} = fir.box_addr %{{.*}} {acc.declare_action = #acc.declare_action} : (!fir.box>>) -> !fir.heap> ! CHECK: fir.freemem %{{.*}} : !fir.heap> -! CHECK: fir.store %{{.*}} to %{{.*}} {acc.declare_action = #acc.declare_action} : !fir.ref>>> +! CHECK: fir.store %{{.*}} to %{{.*}} {acc.declare_action = #acc.declare_action} : !fir.ref>>> ! CHECK: fir.if ! CHECK: fir.freemem %{{.*}} : !fir.heap> -! CHECK: fir.store %{{.*}} to %{{.*}}#0 {acc.declare_action = #acc.declare_action} : !fir.ref>>> +! CHECK: fir.store %{{.*}} to %{{.*}}#0 {acc.declare_action = #acc.declare_action} : !fir.ref>>> ! CHECK: } end subroutine -! CHECK-LABEL: func.func private @_QMacc_declareFacc_declare_allocateEa_acc_declare_update_desc_post_alloc( +! CHECK-LABEL: func.func private @_QMacc_declareFacc_declare_allocateEa_acc_declare_post_alloc( ! CHECK-SAME: %[[ARG0:.*]]: !fir.ref>>>) { -! CHECK: %[[UPDATE:.*]] = acc.update_device varPtr(%[[ARG0]] : !fir.ref>>>) -> !fir.ref>>> {implicit = true, name = "a", structured = false} -! CHECK: acc.update dataOperands(%[[UPDATE]] : !fir.ref>>>) +! CHECK: %[[CREATE_DESC:.*]] = acc.create varPtr(%[[ARG0]] : !fir.ref>>>) -> !fir.ref>>> {implicit = true, name = "a", structured = false} +! CHECK: acc.declare_enter dataOperands(%[[CREATE_DESC]] : !fir.ref>>>) ! CHECK: return ! CHECK: } -! CHECK-LABEL: func.func private @_QMacc_declareFacc_declare_allocateEa_acc_declare_update_desc_post_dealloc( +! CHECK-LABEL: func.func private @_QMacc_declareFacc_declare_allocateEa_acc_declare_post_dealloc( ! CHECK-SAME: %[[ARG0:.*]]: !fir.ref>>>) { -! CHECK: %[[UPDATE:.*]] = acc.update_device varPtr(%[[ARG0]] : !fir.ref>>>) -> !fir.ref>>> {implicit = true, name = "a", structured = false} -! CHECK: acc.update dataOperands(%[[UPDATE]] : !fir.ref>>>) +! CHECK: %[[DEVPTR:.*]] = acc.getdeviceptr varPtr(%[[ARG0]] : !fir.ref>>>) -> !fir.ref>>> {dataClause = #acc, implicit = true, name = "a", structured = false} +! CHECK: acc.declare_exit dataOperands(%[[DEVPTR]] : !fir.ref>>>) ! CHECK: return ! CHECK: } @@ -312,8 +312,8 @@ subroutine acc_declare_allocate_with_stat() end subroutine ! CHECK-LABEL: func.func @_QMacc_declarePacc_declare_allocate_with_stat() -! CHECK: fir.call @_FortranAPointerAllocate(%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}) {{.*}} {acc.declare_action = #acc.declare_action} -! CHECK: fir.call @_FortranAPointerDeallocate(%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}) {{.*}} {acc.declare_action = #acc.declare_action} +! CHECK: fir.call @_FortranAPointerAllocate(%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}) {{.*}} {acc.declare_action = #acc.declare_action} +! CHECK: fir.call @_FortranAPointerDeallocate(%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}) {{.*}} {acc.declare_action = #acc.declare_action} end module module acc_declare_allocatable_test @@ -328,17 +328,17 @@ module acc_declare_allocatable_test ! CHECK: acc.terminator ! CHECK: } -! CHECK-LABEL: func.func private @_QMacc_declare_allocatable_testEdata1_acc_declare_update_desc_post_alloc() { +! CHECK-LABEL: func.func private @_QMacc_declare_allocatable_testEdata1_acc_declare_post_alloc() { ! CHECK: %[[GLOBAL_ADDR:.*]] = fir.address_of(@_QMacc_declare_allocatable_testEdata1) : !fir.ref>>> -! CHECK: %[[UPDATE:.*]] = acc.update_device varPtr(%[[GLOBAL_ADDR]] : !fir.ref>>>) -> !fir.ref>>> {implicit = true, name = "data1", structured = false} -! CHECK: acc.update dataOperands(%[[UPDATE]] : !fir.ref>>>) +! CHECK: %[[CREATE_DESC:.*]] = acc.create varPtr(%[[GLOBAL_ADDR]] : !fir.ref>>>) -> !fir.ref>>> {implicit = true, name = "data1", structured = false} +! CHECK: acc.declare_enter dataOperands(%[[CREATE_DESC]] : !fir.ref>>>) ! CHECK: return ! CHECK: } -! CHECK-LABEL: func.func private @_QMacc_declare_allocatable_testEdata1_acc_declare_update_desc_post_dealloc() { +! CHECK-LABEL: func.func private @_QMacc_declare_allocatable_testEdata1_acc_declare_post_dealloc() { ! CHECK: %[[GLOBAL_ADDR:.*]] = fir.address_of(@_QMacc_declare_allocatable_testEdata1) : !fir.ref>>> -! CHECK: %[[UPDATE:.*]] = acc.update_device varPtr(%[[GLOBAL_ADDR]] : !fir.ref>>>) -> !fir.ref>>> {implicit = true, name = "data1", structured = false} -! CHECK: acc.update dataOperands(%[[UPDATE]] : !fir.ref>>>) +! CHECK: %[[DEVPTR:.*]] = acc.getdeviceptr varPtr(%[[GLOBAL_ADDR]] : !fir.ref>>>) -> !fir.ref>>> {dataClause = #acc, implicit = true, name = "data1", structured = false} +! CHECK: acc.declare_exit dataOperands(%[[DEVPTR]] : !fir.ref>>>) ! CHECK: return ! CHECK: } @@ -401,14 +401,14 @@ module acc_declare_allocatable_test2 subroutine init() use acc_declare_allocatable_test allocate(data1(100)) -! CHECK: fir.store %{{.*}} to %{{.*}} {acc.declare_action = #acc.declare_action} : !fir.ref>>> +! CHECK: fir.store %{{.*}} to %{{.*}} {acc.declare_action = #acc.declare_action} : !fir.ref>>> end subroutine subroutine finalize() use acc_declare_allocatable_test deallocate(data1) -! CHECK: %{{.*}} = fir.box_addr %{{.*}} {acc.declare_action = #acc.declare_action} : (!fir.box>>) -> !fir.heap> -! CHECK: fir.store %{{.*}} to %{{.*}} {acc.declare_action = #acc.declare_action} : !fir.ref>>> +! CHECK: %{{.*}} = fir.box_addr %{{.*}} {acc.declare_action = #acc.declare_action} : (!fir.box>>) -> !fir.heap> +! CHECK: fir.store %{{.*}} to %{{.*}} {acc.declare_action = #acc.declare_action} : !fir.ref>>> end subroutine end module @@ -434,6 +434,6 @@ subroutine init() end module ! CHECK-LABEL: func.func @_QMacc_declare_post_action_statPinit() -! CHECK: fir.call @_FortranAAllocatableAllocate({{.*}}) fastmath {acc.declare_action = #acc.declare_action} : (!fir.ref>, !fir.ref, i1, !fir.box, !fir.ref, i32) -> i32 +! CHECK: fir.call @_FortranAAllocatableAllocate({{.*}}) fastmath {acc.declare_action = #acc.declare_action} : (!fir.ref>, !fir.ref, i1, !fir.box, !fir.ref, i32) -> i32 ! CHECK: fir.if -! CHECK: fir.call @_FortranAAllocatableAllocate({{.*}}) fastmath {acc.declare_action = #acc.declare_action} : (!fir.ref>, !fir.ref, i1, !fir.box, !fir.ref, i32) -> i32 +! CHECK: fir.call @_FortranAAllocatableAllocate({{.*}}) fastmath {acc.declare_action = #acc.declare_action} : (!fir.ref>, !fir.ref, i1, !fir.box, !fir.ref, i32) -> i32