Skip to content

Commit c1c2c92

Browse files
authored
[flang][cuda][NFC] Add test for attributes on procedure (llvm#83044)
Similar to llvm#82844. Test that CUDA attributes on procedure are correctly imported.
1 parent a6b4e29 commit c1c2c92

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

flang/test/Lower/CUDA/cuda-mod.cuf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44

55
module cuf_mod
66
real, device :: md
7+
8+
contains
9+
attributes(device) subroutine devsub()
10+
end
711
end module
812

913
! CHECK: fir.global @_QMcuf_modEmd {cuda_attr = #fir.cuda<device>} : f32
14+
15+
! CHECK: func.func @_QMcuf_modPdevsub() attributes {fir.cuda_attr = #fir.cuda_proc<device>}

flang/test/Lower/CUDA/cuda-module-use.cuf

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
! RUN: bbc -emit-hlfir -fcuda %S/cuda-mod.cuf
22
! RUN: bbc -emit-hlfir -fcuda %s -o - | FileCheck %s
33

4-
! Test importing module with variable with CUDA attributes.
4+
! Test importing module containing variable and subroutine with CUDA attributes.
55

66
subroutine sub1()
77
use cuf_mod
@@ -12,4 +12,14 @@ end
1212
! CHECK: %[[ADDR:.*]] = fir.address_of(@_QMcuf_modEmd) : !fir.ref<f32>
1313
! CHECK: %{{.*}}:2 = hlfir.declare %[[ADDR]] {cuda_attr = #fir.cuda<device>, uniq_name = "_QMcuf_modEmd"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)
1414

15-
! CHECK: fir.global @_QMcuf_modEmd {cuda_attr = #fir.cuda<device>} : f32
15+
attributes(device) subroutine sub2()
16+
use cuf_mod
17+
call devsub()
18+
end
19+
20+
! CHECK-LABEL: func.func @_QPsub2() attributes {fir.cuda_attr = #fir.cuda_proc<device>}
21+
! CHECK: fir.call @_QMcuf_modPdevsub()
22+
23+
! CHECK-LABEL: fir.global @_QMcuf_modEmd {cuda_attr = #fir.cuda<device>} : f32
24+
25+
! CHECK-LABEL: func.func private @_QMcuf_modPdevsub() attributes {fir.cuda_attr = #fir.cuda_proc<device>}

0 commit comments

Comments
 (0)