diff --git a/flang/lib/Lower/OpenACC.cpp b/flang/lib/Lower/OpenACC.cpp index de47e7e5f9dc1..f899590336a71 100644 --- a/flang/lib/Lower/OpenACC.cpp +++ b/flang/lib/Lower/OpenACC.cpp @@ -2556,27 +2556,24 @@ genDeclareInFunction(Fortran::lower::AbstractConverter &converter, } builder.create(loc, dataClauseOperands); - if (!createEntryOperands.empty() || !copyEntryOperands.empty() || - !copyoutEntryOperands.empty() || !deviceResidentEntryOperands.empty()) { - // Attach declare exit operation generation to function context. - fctCtx.attachCleanup([&builder, loc, dataClauseOperands, - createEntryOperands, copyEntryOperands, - copyoutEntryOperands, deviceResidentEntryOperands]() { - builder.create(loc, dataClauseOperands); - genDataExitOperations( - builder, createEntryOperands, /*structured=*/true, - /*implicit=*/false); - genDataExitOperations( - builder, deviceResidentEntryOperands, /*structured=*/true, - /*implicit=*/false); - genDataExitOperations( - builder, copyEntryOperands, /*structured=*/true, /*implicit=*/false); - genDataExitOperations( - builder, copyoutEntryOperands, /*structured=*/true, - /*implicit=*/false); - }); - } + // Attach declare exit operation generation to function context. + fctCtx.attachCleanup([&builder, loc, dataClauseOperands, createEntryOperands, + copyEntryOperands, copyoutEntryOperands, + deviceResidentEntryOperands]() { + builder.create(loc, dataClauseOperands); + genDataExitOperations( + builder, createEntryOperands, /*structured=*/true, + /*implicit=*/false); + genDataExitOperations( + builder, deviceResidentEntryOperands, /*structured=*/true, + /*implicit=*/false); + genDataExitOperations( + builder, copyEntryOperands, /*structured=*/true, /*implicit=*/false); + genDataExitOperations( + builder, copyoutEntryOperands, /*structured=*/true, + /*implicit=*/false); + }); } static void diff --git a/flang/test/Lower/OpenACC/acc-declare.f90 b/flang/test/Lower/OpenACC/acc-declare.f90 index 227a9e677cf36..2d1a52bd01ab7 100644 --- a/flang/test/Lower/OpenACC/acc-declare.f90 +++ b/flang/test/Lower/OpenACC/acc-declare.f90 @@ -133,7 +133,7 @@ subroutine acc_declare_present(a) ! CHECK: %[[PRESENT:.*]] = acc.present varPtr(%[[ARG0]] : !fir.ref>) bounds(%[[BOUND]]) -> !fir.ref> {name = "a"} ! CHECK: acc.declare_enter dataOperands(%[[PRESENT]] : !fir.ref>) ! CHECK: %{{.*}}:2 = fir.do_loop %{{.*}} = %{{.*}} to %{{.*}} step %{{.*}} iter_args(%arg{{.*}} = %{{.*}}) -> (index, i32) -! CHECK-NOT: acc.declare_exit +! CHECK: acc.declare_exit dataOperands(%[[PRESENT]] : !fir.ref>) subroutine acc_declare_copyin() integer :: a(100), b(10), i @@ -153,7 +153,7 @@ subroutine acc_declare_copyin() ! CHECK: %[[COPYIN_B:.*]] = acc.copyin varPtr(%[[B]] : !fir.ref>) bounds(%[[BOUND]]) -> !fir.ref> {dataClause = #acc, name = "b"} ! CHECK: acc.declare_enter dataOperands(%[[COPYIN_A]], %[[COPYIN_B]] : !fir.ref>, !fir.ref>) ! CHECK: %{{.*}}:2 = fir.do_loop %{{.*}} = %{{.*}} to %{{.*}} step %{{.*}} iter_args(%arg{{.*}} = %{{.*}}) -> (index, i32) -! CHECK-NOT: acc.declare_exit +! CHECK: acc.declare_exit dataOperands(%[[COPYIN_A]], %[[COPYIN_B]] : !fir.ref>, !fir.ref>) subroutine acc_declare_copyout() integer :: a(100), i @@ -187,7 +187,7 @@ subroutine acc_declare_deviceptr(a) ! CHECK: %[[DEVICEPTR:.*]] = acc.deviceptr varPtr(%[[ARG0]] : !fir.ref>) bounds(%{{.*}}) -> !fir.ref> {name = "a"} ! CHECK: acc.declare_enter dataOperands(%[[DEVICEPTR]] : !fir.ref>) ! CHECK: %{{.*}}:2 = fir.do_loop %{{.*}} = %{{.*}} to %{{.*}} step %{{.*}} iter_args(%arg{{.*}} = %{{.*}}) -> (index, i32) -! CHECK-NOT: acc.declare_exit +! CHECK: acc.declare_exit dataOperands(%[[DEVICEPTR]] : !fir.ref>) subroutine acc_declare_link(a) integer :: a(100), i @@ -203,7 +203,7 @@ subroutine acc_declare_link(a) ! CHECK: %[[LINK:.*]] = acc.declare_link varPtr(%[[ARG0]] : !fir.ref>) bounds(%{{.*}}) -> !fir.ref> {name = "a"} ! CHECK: acc.declare_enter dataOperands(%[[LINK]] : !fir.ref>) ! CHECK: %{{.*}}:2 = fir.do_loop %{{.*}} = %{{.*}} to %{{.*}} step %{{.*}} iter_args(%arg{{.*}} = %{{.*}}) -> (index, i32) -! CHECK-NOT: acc.declare_exit +! CHECK: acc.declare_exit dataOperands(%[[LINK]] : !fir.ref>) subroutine acc_declare_device_resident(a) integer :: a(100), i