Break circular dependency between FIR dialect and utilities
[llvm-project.git] / flang / test / Lower / dummy-procedure-in-entry.f90
blob3ac91fd95ea233a879e8aac8e914fd4eda164099
1 ! Test dummy procedures that are not an argument in every entry.
2 ! This requires creating a mock value in the entries where it is
3 ! not an argument.
4 ! RUN: bbc -emit-fir %s -o - | FileCheck %s
6 subroutine dummy_with_iface()
7 interface
8 real function x()
9 end function
10 end interface
11 entry dummy_with_iface_entry(x)
12 call takes_real(x())
13 end subroutine
14 ! CHECK-LABEL: func @_QPdummy_with_iface() {
15 ! CHECK: %[[VAL_0:.*]] = fir.alloca f32 {adapt.valuebyref}
16 ! CHECK: %[[VAL_1:.*]] = fir.undefined !fir.boxproc<() -> ()>
17 ! CHECK: br ^bb1
18 ! CHECK: ^bb1:
19 ! CHECK: %[[VAL_2:.*]] = fir.box_addr %[[VAL_1]] : (!fir.boxproc<() -> ()>) -> (() -> f32)
20 ! CHECK: %[[VAL_3:.*]] = fir.call %[[VAL_2]]() {{.*}}: () -> f32
21 ! CHECK: fir.store %[[VAL_3]] to %[[VAL_0]] : !fir.ref<f32>
22 ! CHECK: fir.call @_QPtakes_real(%[[VAL_0]]) {{.*}}: (!fir.ref<f32>) -> ()
24 ! CHECK-LABEL: func @_QPdummy_with_iface_entry(
25 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.boxproc<() -> ()>) {
26 ! CHECK: %[[VAL_1:.*]] = fir.alloca f32 {adapt.valuebyref}
27 ! CHECK: br ^bb1
28 ! CHECK: ^bb1:
29 ! CHECK: %[[VAL_2:.*]] = fir.box_addr %[[VAL_0]] : (!fir.boxproc<() -> ()>) -> (() -> f32)
30 ! CHECK: %[[VAL_3:.*]] = fir.call %[[VAL_2]]() {{.*}}: () -> f32
31 ! CHECK: fir.store %[[VAL_3]] to %[[VAL_1]] : !fir.ref<f32>
32 ! CHECK: fir.call @_QPtakes_real(%[[VAL_1]]) {{.*}}: (!fir.ref<f32>) -> ()
34 subroutine subroutine_dummy()
35 entry subroutine_dummy_entry(x)
36 call x()
37 end subroutine
38 ! CHECK-LABEL: func @_QPsubroutine_dummy() {
39 ! CHECK: %[[VAL_0:.*]] = fir.undefined !fir.boxproc<() -> ()>
40 ! CHECK: br ^bb1
41 ! CHECK: ^bb1:
42 ! CHECK: %[[VAL_1:.*]] = fir.box_addr %[[VAL_0]] : (!fir.boxproc<() -> ()>) -> (() -> ())
43 ! CHECK: fir.call %[[VAL_1]]() {{.*}}: () -> ()
45 ! CHECK-LABEL: func @_QPsubroutine_dummy_entry(
46 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.boxproc<() -> ()>) {
47 ! CHECK: br ^bb1
48 ! CHECK: ^bb1:
49 ! CHECK: %[[VAL_1:.*]] = fir.box_addr %[[VAL_0]] : (!fir.boxproc<() -> ()>) -> (() -> ())
50 ! CHECK: fir.call %[[VAL_1]]() {{.*}}: () -> ()