diff --git a/flang/test/Lower/CUDA/cuda-mod.cuf b/flang/test/Lower/CUDA/cuda-mod.cuf index 2cc6439789a27..ae5bf63d2da49 100644 --- a/flang/test/Lower/CUDA/cuda-mod.cuf +++ b/flang/test/Lower/CUDA/cuda-mod.cuf @@ -4,6 +4,12 @@ module cuf_mod real, device :: md + +contains + attributes(device) subroutine devsub() + end end module ! CHECK: fir.global @_QMcuf_modEmd {cuda_attr = #fir.cuda} : f32 + +! CHECK: func.func @_QMcuf_modPdevsub() attributes {fir.cuda_attr = #fir.cuda_proc} diff --git a/flang/test/Lower/CUDA/cuda-module-use.cuf b/flang/test/Lower/CUDA/cuda-module-use.cuf index 43ab0f6ff8d68..f54083b026ee8 100644 --- a/flang/test/Lower/CUDA/cuda-module-use.cuf +++ b/flang/test/Lower/CUDA/cuda-module-use.cuf @@ -1,7 +1,7 @@ ! RUN: bbc -emit-hlfir -fcuda %S/cuda-mod.cuf ! RUN: bbc -emit-hlfir -fcuda %s -o - | FileCheck %s -! Test importing module with variable with CUDA attributes. +! Test importing module containing variable and subroutine with CUDA attributes. subroutine sub1() use cuf_mod @@ -12,4 +12,14 @@ end ! CHECK: %[[ADDR:.*]] = fir.address_of(@_QMcuf_modEmd) : !fir.ref ! CHECK: %{{.*}}:2 = hlfir.declare %[[ADDR]] {cuda_attr = #fir.cuda, uniq_name = "_QMcuf_modEmd"} : (!fir.ref) -> (!fir.ref, !fir.ref) -! CHECK: fir.global @_QMcuf_modEmd {cuda_attr = #fir.cuda} : f32 +attributes(device) subroutine sub2() + use cuf_mod + call devsub() +end + +! CHECK-LABEL: func.func @_QPsub2() attributes {fir.cuda_attr = #fir.cuda_proc} +! CHECK: fir.call @_QMcuf_modPdevsub() + +! CHECK-LABEL: fir.global @_QMcuf_modEmd {cuda_attr = #fir.cuda} : f32 + +! CHECK-LABEL: func.func private @_QMcuf_modPdevsub() attributes {fir.cuda_attr = #fir.cuda_proc}