! This test checks whether the OpenACC use_device clause is applied on both results of hlfir.declare. ! RUN: bbc -fopenacc -emit-hlfir %s -o - | FileCheck %s ! Test for automatic variable appearing in use_device clause. subroutine test() integer :: N = 100 real*8 :: b(-1:N) ! CHECK: %[[A0:.*]] = fir.alloca !fir.array, %{{.*}} {bindc_name = "b", uniq_name = "_QFtestEb"} ! CHECK: %[[A1:.*]] = fir.shape_shift {{.*}} : (index, index) -> !fir.shapeshift<1> ! CHECK: %[[A:.*]]:2 = hlfir.declare %[[A0]](%[[A1]]) {uniq_name = "_QFtestEb"} : (!fir.ref>, !fir.shapeshift<1>) -> (!fir.box>, !fir.ref>) !$acc data copy(b) ! CHECK: %[[B:.*]] = acc.copyin var(%[[A]]#0 : !fir.box>) -> !fir.box> {dataClause = #acc, name = "b"} ! CHECK: acc.data dataOperands(%[[B]] : !fir.box>) { !$acc host_data use_device(b) call vadd(b) !$acc end host_data ! CHECK: %[[C:.*]] = acc.use_device var(%[[A]]#0 : !fir.box>) -> !fir.box> {name = "b"} ! CHECK: acc.host_data dataOperands(%[[C]] : !fir.box>) { ! CHECK: %[[ADDR:.*]] = fir.box_addr %[[C]] ! CHECK: %[[REDCLARE:.*]]:2 = hlfir.declare %[[ADDR]] ! CHECK: fir.call @_QPvadd(%[[REDCLARE]]#1) fastmath : (!fir.ref>) -> () !$acc end data ! CHECK: acc.copyout accVar(%[[B]] : !fir.box>) to var(%[[A]]#0 : !fir.box>) {dataClause = #acc, name = "b"} end ! Test for allocatable, pointer and assumed-shape variables appearing in use_device clause. subroutine test2(a, b, c) integer :: N = 100 real*8, allocatable :: a(:) real*8, target, allocatable :: d(:) real*8 :: b(:) real*8, pointer :: c(:) call allocate(a(N)) call allocate(d(N)) c => d ! CHECK: %[[DS:.*]] = fir.dummy_scope : !fir.dscope ! CHECK: %[[E:.*]]:2 = hlfir.declare %arg0 dummy_scope %[[DS]] {{.*}} {fortran_attrs = #fir.var_attrs, uniq_name = "_QFtest2Ea"} : (!fir.ref>>>, !fir.dscope) -> (!fir.ref>>>, !fir.ref>>>) ! CHECK: %[[F:.*]]:2 = hlfir.declare %arg1 dummy_scope %[[DS]] {{.*}} {uniq_name = "_QFtest2Eb"} : (!fir.box>, !fir.dscope) -> (!fir.box>, !fir.box>) ! CHECK: %[[G:.*]]:2 = hlfir.declare %arg2 dummy_scope %[[DS]] {{.*}} {fortran_attrs = #fir.var_attrs, uniq_name = "_QFtest2Ec"} : (!fir.ref>>>, !fir.dscope) -> (!fir.ref>>>, !fir.ref>>>) !$acc data copy(a,b,c,d) !$acc host_data use_device(a,b,c) call vadd2(a,b,c) !$acc end host_data ! CHECK: %[[H:.*]] = acc.use_device varPtr(%[[E]]#0 : !fir.ref>>>) -> !fir.ref>>> {name = "a"} ! CHECK: %[[J:.*]] = acc.use_device var(%[[F]]#0 : !fir.box>) -> !fir.box> {name = "b"} ! CHECK: %[[L:.*]] = acc.use_device varPtr(%[[G]]#0 : !fir.ref>>>) -> !fir.ref>>> {name = "c"} ! CHECK: acc.host_data dataOperands(%[[H]], %[[J]], %[[L]] : !fir.ref>>>, !fir.box>, !fir.ref>>>) { !$acc end data end