[flang-commits] [flang] 25b4609 - [flang][NFC] Converted five tests from old lowering to new lowering (part 14) (#179852)
via flang-commits
flang-commits at lists.llvm.org
Thu Feb 5 07:32:53 PST 2026
Author: Eugene Epshteyn
Date: 2026-02-05T10:32:47-05:00
New Revision: 25b4609b55135f1fc0e6deffebc3a2f948785d4a
URL: https://github.com/llvm/llvm-project/commit/25b4609b55135f1fc0e6deffebc3a2f948785d4a
DIFF: https://github.com/llvm/llvm-project/commit/25b4609b55135f1fc0e6deffebc3a2f948785d4a.diff
LOG: [flang][NFC] Converted five tests from old lowering to new lowering (part 14) (#179852)
Tests converted from test/Lower: dummy-procedure-character.f90,
dummy-procedure-in-entry.f90, dummy-procedure.f90, equivalence-1.f90,
equivalence-2.f90
Added:
Modified:
flang/test/Lower/dummy-procedure-character.f90
flang/test/Lower/dummy-procedure-in-entry.f90
flang/test/Lower/dummy-procedure.f90
flang/test/Lower/equivalence-1.f90
flang/test/Lower/equivalence-2.f90
Removed:
################################################################################
diff --git a/flang/test/Lower/dummy-procedure-character.f90 b/flang/test/Lower/dummy-procedure-character.f90
index 7a6bb249d30d0..36654927df221 100644
--- a/flang/test/Lower/dummy-procedure-character.f90
+++ b/flang/test/Lower/dummy-procedure-character.f90
@@ -1,12 +1,12 @@
! Test lowering of character function dummy procedure. The length must be
! passed along the function address.
-! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s
+! RUN: %flang_fc1 -emit-hlfir %s -o - | FileCheck %s
! -----------------------------------------------------------------------------
! Test passing a character function as dummy procedure
! -----------------------------------------------------------------------------
-! CHECK-LABEL: func @_QPcst_len
+! CHECK-LABEL: func.func @_QPcst_len() {
subroutine cst_len()
interface
character(7) function bar1()
@@ -22,7 +22,7 @@ character(7) function bar1()
! CHECK: fir.call @_QPfoo1(%[[VAL_5]]) {{.*}}: (tuple<!fir.boxproc<() -> ()>, i64>) -> ()
end subroutine
-! CHECK-LABEL: func @_QPcst_len_array
+! CHECK-LABEL: func.func @_QPcst_len_array() {
subroutine cst_len_array()
interface
function bar1_array()
@@ -39,7 +39,7 @@ function bar1_array()
call foo1b(bar1_array)
end subroutine
-! CHECK-LABEL: func @_QPcst_len_2
+! CHECK-LABEL: func.func @_QPcst_len_2() {
subroutine cst_len_2()
character(7) :: bar2
external :: bar2
@@ -53,14 +53,15 @@ subroutine cst_len_2()
call foo2(bar2)
end subroutine
-! CHECK-LABEL: func @_QPdyn_len(
+! CHECK-LABEL: func.func @_QPdyn_len(
! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i32>{{.*}}) {
subroutine dyn_len(n)
integer :: n
character(n) :: bar3
external :: bar3
+! CHECK: %[[VAL_ARG:.*]]:2 = hlfir.declare %[[VAL_0]] {{.*}}
! CHECK: %[[VAL_1:.*]] = fir.address_of(@_QPbar3) : (!fir.ref<!fir.char<1,?>>, index) -> !fir.boxchar<1>
-! CHECK: %[[VAL_2:.*]] = fir.load %[[VAL_0]] : !fir.ref<i32>
+! CHECK: %[[VAL_2:.*]] = fir.load %[[VAL_ARG]]#0 : !fir.ref<i32>
! CHECK: %[[VAL_3:.*]] = fir.convert %[[VAL_2]] : (i32) -> i64
! CHECK: %[[VAL_4:.*]] = arith.constant 0 : i64
! CHECK: %[[VAL_5:.*]] = arith.cmpi sgt, %[[VAL_3]], %[[VAL_4]] : i64
@@ -73,7 +74,7 @@ subroutine dyn_len(n)
call foo3(bar3)
end subroutine
-! CHECK-LABEL: func @_QPcannot_compute_len_yet
+! CHECK-LABEL: func.func @_QPcannot_compute_len_yet() {
subroutine cannot_compute_len_yet()
interface
function bar4(n)
@@ -92,7 +93,7 @@ function bar4(n)
call foo4(bar4)
end subroutine
-! CHECK-LABEL: func @_QPcannot_compute_len_yet_2
+! CHECK-LABEL: func.func @_QPcannot_compute_len_yet_2() {
subroutine cannot_compute_len_yet_2()
character(*) :: bar5
external :: bar5
@@ -107,7 +108,7 @@ subroutine cannot_compute_len_yet_2()
call foo5(bar5)
end subroutine
-! CHECK-LABEL: func @_QPforward_incoming_length
+! CHECK-LABEL: func.func @_QPforward_incoming_length(
! CHECK-SAME: %[[VAL_0:.*]]: tuple<!fir.boxproc<() -> ()>, i64> {fir.char_proc}) {
subroutine forward_incoming_length(bar6)
character(*) :: bar6
@@ -123,7 +124,7 @@ subroutine forward_incoming_length(bar6)
call foo6(bar6)
end subroutine
-! CHECK-LABEL: func @_QPoverride_incoming_length
+! CHECK-LABEL: func.func @_QPoverride_incoming_length(
! CHECK-SAME: %[[VAL_0:.*]]: tuple<!fir.boxproc<() -> ()>, i64> {fir.char_proc}) {
subroutine override_incoming_length(bar7)
character(7) :: bar7
@@ -143,40 +144,56 @@ subroutine override_incoming_length(bar7)
! Test calling character dummy function
! -----------------------------------------------------------------------------
-! CHECK-LABEL: func @_QPcall_assumed_length
+! CHECK-LABEL: func.func @_QPcall_assumed_length(
! CHECK-SAME: %[[VAL_0:.*]]: tuple<!fir.boxproc<() -> ()>, i64> {fir.char_proc}) {
subroutine call_assumed_length(bar8)
character(*) :: bar8
external :: bar8
+! CHECK: %[[VAL_CONST:.*]] = arith.constant 42 : i32
+! CHECK: %[[VAL_ASSOC:.*]]:3 = hlfir.associate %[[VAL_CONST]] {{.*}}
! CHECK: %[[VAL_3:.*]] = fir.extract_value %[[VAL_0]], [0 : index] : (tuple<!fir.boxproc<() -> ()>, i64>) -> !fir.boxproc<() -> ()>
! CHECK: %[[WAL_2:.*]] = fir.box_addr %[[VAL_3]] : (!fir.boxproc<() -> ()>) -> (() -> ())
! CHECK: %[[VAL_4:.*]] = fir.extract_value %[[VAL_0]], [1 : index] : (tuple<!fir.boxproc<() -> ()>, i64>) -> i64
-! CHECK: %[[VAL_6:.*]] = fir.alloca !fir.char<1,?>(%[[VAL_4]] : i64) {bindc_name = ".result"}
-! CHECK: %[[VAL_7:.*]] = fir.convert %[[WAL_2]] : (() -> ()) -> ((!fir.ref<!fir.char<1,?>>, index, !fir.ref<i32>) -> !fir.boxchar<1>)
-! CHECK: %[[VAL_8:.*]] = fir.convert %[[VAL_4]] : (i64) -> index
-! CHECK: fir.call %[[VAL_7]](%[[VAL_6]], %[[VAL_8]], %{{.*}}) {{.*}}: (!fir.ref<!fir.char<1,?>>, index, !fir.ref<i32>) -> !fir.boxchar<1>
+! CHECK: %[[EMBOX:.*]] = fir.emboxproc %[[WAL_2]] : (() -> ()) -> !fir.boxproc<() -> ()>
+! CHECK: %[[TUPLE:.*]] = fir.undefined tuple<!fir.boxproc<() -> ()>, i64>
+! CHECK: %[[INS1:.*]] = fir.insert_value %[[TUPLE]], %[[EMBOX]], [0 : index] : (tuple<!fir.boxproc<() -> ()>, i64>, !fir.boxproc<() -> ()>) -> tuple<!fir.boxproc<() -> ()>, i64>
+! CHECK: %[[INS2:.*]] = fir.insert_value %[[INS1]], %[[VAL_4]], [1 : index] : (tuple<!fir.boxproc<() -> ()>, i64>, i64) -> tuple<!fir.boxproc<() -> ()>, i64>
+! CHECK: %[[VAL_EXT0:.*]] = fir.extract_value %[[INS2]], [0 : index] : (tuple<!fir.boxproc<() -> ()>, i64>) -> !fir.boxproc<() -> ()>
+! CHECK: %[[VAL_EXT1:.*]] = fir.extract_value %[[INS2]], [1 : index] : (tuple<!fir.boxproc<() -> ()>, i64>) -> i64
+! CHECK: %[[VAL_6:.*]] = fir.alloca !fir.char<1,?>(%[[VAL_EXT1]] : i64) {bindc_name = ".result"}
+! CHECK: %[[VAL_7:.*]] = fir.box_addr %[[VAL_EXT0]] : (!fir.boxproc<() -> ()>) -> ((!fir.ref<!fir.char<1,?>>, index, !fir.ref<i32>) -> !fir.boxchar<1>)
+! CHECK: %[[VAL_8:.*]] = fir.convert %[[VAL_EXT1]] : (i64) -> index
+! CHECK: fir.call %[[VAL_7]](%[[VAL_6]], %[[VAL_8]], %[[VAL_ASSOC]]#0) {{.*}}: (!fir.ref<!fir.char<1,?>>, index, !fir.ref<i32>) -> !fir.boxchar<1>
call test(bar8(42))
end subroutine
-! CHECK-LABEL: func @_QPcall_explicit_length
+! CHECK-LABEL: func.func @_QPcall_explicit_length(
! CHECK-SAME: %[[VAL_0:.*]]: tuple<!fir.boxproc<() -> ()>, i64> {fir.char_proc}) {
subroutine call_explicit_length(bar9)
character(7) :: bar9
external :: bar9
! CHECK: %[[VAL_1:.*]] = fir.alloca !fir.char<1,7> {bindc_name = ".result"}
+! CHECK: %[[VAL_CONST:.*]] = arith.constant 42 : i32
+! CHECK: %[[VAL_ASSOC:.*]]:3 = hlfir.associate %[[VAL_CONST]] {{.*}}
! CHECK: %[[VAL_4:.*]] = fir.extract_value %[[VAL_0]], [0 : index] : (tuple<!fir.boxproc<() -> ()>, i64>) -> !fir.boxproc<() -> ()>
! CHECK: %[[WAL_1:.*]] = fir.box_addr %[[VAL_4]] : (!fir.boxproc<() -> ()>) -> (() -> ())
! CHECK: %[[VAL_5:.*]] = arith.constant 7 : i64
-! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_5]] : (i64) -> index
+! CHECK: %[[EMBOX:.*]] = fir.emboxproc %[[WAL_1]] : (() -> ()) -> !fir.boxproc<() -> ()>
+! CHECK: %[[TUPLE:.*]] = fir.undefined tuple<!fir.boxproc<() -> ()>, i64>
+! CHECK: %[[INS1:.*]] = fir.insert_value %[[TUPLE]], %[[EMBOX]], [0 : index] : (tuple<!fir.boxproc<() -> ()>, i64>, !fir.boxproc<() -> ()>) -> tuple<!fir.boxproc<() -> ()>, i64>
+! CHECK: %[[INS2:.*]] = fir.insert_value %[[INS1]], %[[VAL_5]], [1 : index] : (tuple<!fir.boxproc<() -> ()>, i64>, i64) -> tuple<!fir.boxproc<() -> ()>, i64>
+! CHECK: %[[VAL_EXT0:.*]] = fir.extract_value %[[INS2]], [0 : index] : (tuple<!fir.boxproc<() -> ()>, i64>) -> !fir.boxproc<() -> ()>
+! CHECK: %[[VAL_5_NEW:.*]] = arith.constant 7 : i64
+! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_5_NEW]] : (i64) -> index
! CHECK: %[[C0:.*]] = arith.constant 0 : index
! CHECK: %[[CMPI:.*]] = arith.cmpi sgt, %[[VAL_6]], %[[C0]] : index
! CHECK: %[[SELECT:.*]] = arith.select %[[CMPI]], %[[VAL_6]], %[[C0]] : index
-! CHECK: %[[VAL_8:.*]] = fir.convert %[[WAL_1]] : (() -> ()) -> ((!fir.ref<!fir.char<1,7>>, index, !fir.ref<i32>) -> !fir.boxchar<1>)
-! CHECK: fir.call %[[VAL_8]](%[[VAL_1]], %[[SELECT]], %{{.*}}) {{.*}}: (!fir.ref<!fir.char<1,7>>, index, !fir.ref<i32>) -> !fir.boxchar<1>
+! CHECK: %[[VAL_7:.*]] = fir.box_addr %[[VAL_EXT0]] : (!fir.boxproc<() -> ()>) -> ((!fir.ref<!fir.char<1,7>>, index, !fir.ref<i32>) -> !fir.boxchar<1>)
+! CHECK: fir.call %[[VAL_7]](%[[VAL_1]], %[[SELECT]], %[[VAL_ASSOC]]#0) {{.*}}: (!fir.ref<!fir.char<1,7>>, index, !fir.ref<i32>) -> !fir.boxchar<1>
call test(bar9(42))
end subroutine
-! CHECK-LABEL: func @_QPcall_explicit_length_with_iface
+! CHECK-LABEL: func.func @_QPcall_explicit_length_with_iface(
! CHECK-SAME: %[[VAL_0:.*]]: tuple<!fir.boxproc<() -> ()>, i64> {fir.char_proc}) {
subroutine call_explicit_length_with_iface(bar10)
interface
@@ -185,25 +202,33 @@ function bar10(n)
character(n) :: bar10
end function
end interface
-! CHECK: %[[VAL_1:.*]] = fir.alloca i64
! CHECK: %[[VAL_2:.*]] = arith.constant 42 : i64
-! CHECK: fir.store %[[VAL_2]] to %[[VAL_1]] : !fir.ref<i64>
+! CHECK: %[[VAL_ASSOC:.*]]:3 = hlfir.associate %[[VAL_2]] {{.*}}
+! CHECK: %[[VAL_DECL:.*]]:2 = hlfir.declare %[[VAL_ASSOC]]#0 {{.*}}
! CHECK: %[[VAL_3:.*]] = fir.extract_value %[[VAL_0]], [0 : index] : (tuple<!fir.boxproc<() -> ()>, i64>) -> !fir.boxproc<() -> ()>
! CHECK: %[[WAL_1:.*]] = fir.box_addr %[[VAL_3]] : (!fir.boxproc<() -> ()>) -> (() -> ())
-! CHECK: %[[VAL_4:.*]] = fir.load %[[VAL_1]] : !fir.ref<i64>
-! CHECK: %[[VAL_5:.*]] = fir.convert %[[VAL_4]] : (i64) -> index
-! CHECK: %[[C0:.*]] = arith.constant 0 : index
-! CHECK: %[[COMPI:.*]] = arith.cmpi sgt, %[[VAL_5]], %[[C0]] : index
-! CHECK: %[[SELECT:.*]] = arith.select %[[CMPI]], %[[VAL_5]], %[[C0]] : index
-! CHECK: %[[VAL_6:.*]] = llvm.intr.stacksave : !llvm.ptr
-! CHECK: %[[VAL_7:.*]] = fir.alloca !fir.char<1,?>(%[[SELECT]] : index) {bindc_name = ".result"}
-! CHECK: %[[VAL_8:.*]] = fir.convert %[[WAL_1]] : (() -> ()) -> ((!fir.ref<!fir.char<1,?>>, index, !fir.ref<i64>) -> !fir.boxchar<1>)
-! CHECK: fir.call %[[VAL_8]](%[[VAL_7]], %[[SELECT]], %[[VAL_1]]) {{.*}}: (!fir.ref<!fir.char<1,?>>, index, !fir.ref<i64>) -> !fir.boxchar<1>
+! CHECK: %[[VAL_4:.*]] = fir.load %[[VAL_DECL]]#0 : !fir.ref<i64>
+! CHECK: %[[C0:.*]] = arith.constant 0 : i64
+! CHECK: %[[COMPI:.*]] = arith.cmpi sgt, %[[VAL_4]], %[[C0]] : i64
+! CHECK: %[[SELECT:.*]] = arith.select %[[COMPI]], %[[VAL_4]], %[[C0]] : i64
+! CHECK: %[[EMBOX:.*]] = fir.emboxproc %[[WAL_1]] : (() -> ()) -> !fir.boxproc<() -> ()>
+! CHECK: %[[TUPLE:.*]] = fir.undefined tuple<!fir.boxproc<() -> ()>, i64>
+! CHECK: %[[INS1:.*]] = fir.insert_value %[[TUPLE]], %[[EMBOX]], [0 : index] : (tuple<!fir.boxproc<() -> ()>, i64>, !fir.boxproc<() -> ()>) -> tuple<!fir.boxproc<() -> ()>, i64>
+! CHECK: %[[INS2:.*]] = fir.insert_value %[[INS1]], %[[SELECT]], [1 : index] : (tuple<!fir.boxproc<() -> ()>, i64>, i64) -> tuple<!fir.boxproc<() -> ()>, i64>
+! CHECK: %[[VAL_EXT0:.*]] = fir.extract_value %[[INS2]], [0 : index] : (tuple<!fir.boxproc<() -> ()>, i64>) -> !fir.boxproc<() -> ()>
+! CHECK: %[[VAL_13:.*]] = fir.load %[[VAL_DECL]]#0 : !fir.ref<i64>
+! CHECK: %[[VAL_14:.*]] = fir.convert %[[VAL_13]] : (i64) -> index
+! CHECK: %[[C0_IDX:.*]] = arith.constant 0 : index
+! CHECK: %[[CMP_IDX:.*]] = arith.cmpi sgt, %[[VAL_14]], %[[C0_IDX]] : index
+! CHECK: %[[SELECT_IDX:.*]] = arith.select %[[CMP_IDX]], %[[VAL_14]], %[[C0_IDX]] : index
+! CHECK: %[[VAL_7:.*]] = fir.alloca !fir.char<1,?>(%[[SELECT_IDX]] : index) {bindc_name = ".result"}
+! CHECK: %[[VAL_8:.*]] = fir.box_addr %[[VAL_EXT0]] : (!fir.boxproc<() -> ()>) -> ((!fir.ref<!fir.char<1,?>>, index, !fir.ref<i64>) -> !fir.boxchar<1>)
+! CHECK: fir.call %[[VAL_8]](%[[VAL_7]], %[[SELECT_IDX]], %[[VAL_ASSOC]]#0) {{.*}}: (!fir.ref<!fir.char<1,?>>, index, !fir.ref<i64>) -> !fir.boxchar<1>
call test(bar10(42_8))
end subroutine
-! CHECK-LABEL: func @_QPhost(
+! CHECK-LABEL: func.func @_QPhost(
! CHECK-SAME: %[[VAL_0:.*]]: tuple<!fir.boxproc<() -> ()>, i64>
subroutine host(f)
character*(*) :: f
@@ -213,7 +238,7 @@ subroutine host(f)
! CHECK: fir.call @_QFhostPintern(%[[VAL_1]])
call intern()
contains
-! CHECK-LABEL: func private @_QFhostPintern(
+! CHECK-LABEL: func.func private @_QFhostPintern(
! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<tuple<tuple<!fir.boxproc<() -> ()>, i64>>> {fir.host_assoc})
subroutine intern()
! CHECK: %[[VAL_1:.*]] = arith.constant 0 : i32
@@ -222,15 +247,22 @@ subroutine intern()
! CHECK: %[[VAL_4:.*]] = fir.extract_value %[[VAL_3]], [0 : index] : (tuple<!fir.boxproc<() -> ()>, i64>) -> !fir.boxproc<() -> ()>
! CHECK: %[[WAL_1:.*]] = fir.box_addr %[[VAL_4]] : (!fir.boxproc<() -> ()>) -> (() -> ())
! CHECK: %[[VAL_5:.*]] = fir.extract_value %[[VAL_3]], [1 : index] : (tuple<!fir.boxproc<() -> ()>, i64>) -> i64
-! CHECK: %[[VAL_7:.*]] = fir.alloca !fir.char<1,?>(%[[VAL_5]] : i64) {bindc_name = ".result"}
-! CHECK: %[[VAL_8:.*]] = fir.convert %[[WAL_1]] : (() -> ()) -> ((!fir.ref<!fir.char<1,?>>, index) -> !fir.boxchar<1>)
-! CHECK: %[[VAL_9:.*]] = fir.convert %[[VAL_5]] : (i64) -> index
-! CHECK: fir.call %[[VAL_8]](%[[VAL_7]], %[[VAL_9]]) {{.*}}: (!fir.ref<!fir.char<1,?>>, index) -> !fir.boxchar<1>
+! CHECK: %[[VAL_6:.*]] = fir.emboxproc %[[WAL_1]] : (() -> ()) -> !fir.boxproc<() -> ()>
+! CHECK: %[[VAL_7:.*]] = fir.undefined tuple<!fir.boxproc<() -> ()>, i64>
+! CHECK: %[[VAL_8:.*]] = fir.insert_value %[[VAL_7]], %[[VAL_6]], [0 : index] : (tuple<!fir.boxproc<() -> ()>, i64>, !fir.boxproc<() -> ()>) -> tuple<!fir.boxproc<() -> ()>, i64>
+! CHECK: %[[VAL_9:.*]] = fir.insert_value %[[VAL_8]], %[[VAL_5]], [1 : index] : (tuple<!fir.boxproc<() -> ()>, i64>, i64) -> tuple<!fir.boxproc<() -> ()>, i64>
+! CHECK: %[[VAL_10:.*]] = fir.extract_value %[[VAL_9]], [0 : index] : (tuple<!fir.boxproc<() -> ()>, i64>) -> !fir.boxproc<() -> ()>
+! CHECK: %[[VAL_11:.*]] = fir.extract_value %[[VAL_9]], [1 : index] : (tuple<!fir.boxproc<() -> ()>, i64>) -> i64
+! CHECK: %[[VAL_12:.*]] = llvm.intr.stacksave : !llvm.ptr
+! CHECK: %[[VAL_13:.*]] = fir.alloca !fir.char<1,?>(%[[VAL_11]] : i64) {bindc_name = ".result"}
+! CHECK: %[[VAL_14:.*]] = fir.box_addr %[[VAL_10]] : (!fir.boxproc<() -> ()>) -> ((!fir.ref<!fir.char<1,?>>, index) -> !fir.boxchar<1>)
+! CHECK: %[[VAL_15:.*]] = fir.convert %[[VAL_11]] : (i64) -> index
+! CHECK: fir.call %[[VAL_14]](%[[VAL_13]], %[[VAL_15]]) {{.*}}: (!fir.ref<!fir.char<1,?>>, index) -> !fir.boxchar<1>
call test(f())
end subroutine
end subroutine
-! CHECK-LABEL: func @_QPhost2(
+! CHECK-LABEL: func.func @_QPhost2(
! CHECK-SAME: %[[VAL_0:.*]]: tuple<!fir.boxproc<() -> ()>, i64> {fir.char_proc})
subroutine host2(f)
! Test that dummy length is overridden by local length even when used
@@ -242,7 +274,7 @@ subroutine host2(f)
! CHECK: fir.call @_QFhost2Pintern(%[[VAL_1]])
call intern()
contains
-! CHECK-LABEL: func private @_QFhost2Pintern(
+! CHECK-LABEL: func.func private @_QFhost2Pintern(
! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<tuple<tuple<!fir.boxproc<() -> ()>, i64>>> {fir.host_assoc})
subroutine intern()
! CHECK: %[[VAL_1:.*]] = fir.alloca !fir.char<1,42> {bindc_name = ".result"}
@@ -252,11 +284,17 @@ subroutine intern()
! CHECK: %[[VAL_5:.*]] = fir.extract_value %[[VAL_4]], [0 : index] : (tuple<!fir.boxproc<() -> ()>, i64>) -> !fir.boxproc<() -> ()>
! CHECK: %[[WAL_1:.*]] = fir.box_addr %[[VAL_5]] : (!fir.boxproc<() -> ()>) -> (() -> ())
! CHECK: %[[VAL_6:.*]] = arith.constant 42 : i64
- ! CHECK: %[[VAL_7:.*]] = fir.convert %[[VAL_6]] : (i64) -> index
+ ! CHECK: %[[VAL_NEW_EMBOX:.*]] = fir.emboxproc %[[WAL_1]] : (() -> ()) -> !fir.boxproc<() -> ()>
+ ! CHECK: %[[VAL_NEW_TUPLE:.*]] = fir.undefined tuple<!fir.boxproc<() -> ()>, i64>
+ ! CHECK: %[[VAL_INS1:.*]] = fir.insert_value %[[VAL_NEW_TUPLE]], %[[VAL_NEW_EMBOX]], [0 : index] : (tuple<!fir.boxproc<() -> ()>, i64>, !fir.boxproc<() -> ()>) -> tuple<!fir.boxproc<() -> ()>, i64>
+ ! CHECK: %[[VAL_INS2:.*]] = fir.insert_value %[[VAL_INS1]], %[[VAL_6]], [1 : index] : (tuple<!fir.boxproc<() -> ()>, i64>, i64) -> tuple<!fir.boxproc<() -> ()>, i64>
+ ! CHECK: %[[VAL_EXT1:.*]] = fir.extract_value %[[VAL_INS2]], [0 : index] : (tuple<!fir.boxproc<() -> ()>, i64>) -> !fir.boxproc<() -> ()>
+ ! CHECK: %[[VAL_CONST_42:.*]] = arith.constant 42 : i64
+ ! CHECK: %[[VAL_7:.*]] = fir.convert %[[VAL_CONST_42]] : (i64) -> index
! CHECK: %[[C0:.*]] = arith.constant 0 : index
! CHECK: %[[CMPI:.*]] = arith.cmpi sgt, %[[VAL_7]], %[[C0]] : index
! CHECK: %[[SELECT:.*]] = arith.select %[[CMPI]], %[[VAL_7]], %[[C0]] : index
- ! CHECK: %[[VAL_9:.*]] = fir.convert %[[WAL_1]] : (() -> ()) -> ((!fir.ref<!fir.char<1,42>>, index) -> !fir.boxchar<1>)
+ ! CHECK: %[[VAL_9:.*]] = fir.box_addr %[[VAL_EXT1]] : (!fir.boxproc<() -> ()>) -> ((!fir.ref<!fir.char<1,42>>, index) -> !fir.boxchar<1>)
! CHECK: fir.call %[[VAL_9]](%[[VAL_1]], %[[SELECT]]) {{.*}}: (!fir.ref<!fir.char<1,42>>, index) -> !fir.boxchar<1>
call test(f())
end subroutine
diff --git a/flang/test/Lower/dummy-procedure-in-entry.f90 b/flang/test/Lower/dummy-procedure-in-entry.f90
index 6ba12e1afdaa1..ee85da35275d3 100644
--- a/flang/test/Lower/dummy-procedure-in-entry.f90
+++ b/flang/test/Lower/dummy-procedure-in-entry.f90
@@ -1,7 +1,7 @@
! Test dummy procedures that are not an argument in every entry.
! This requires creating a mock value in the entries where it is
! not an argument.
-! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s
+! RUN: %flang_fc1 -emit-hlfir %s -o - | FileCheck %s
subroutine dummy_with_iface()
interface
@@ -11,40 +11,38 @@ real function x()
entry dummy_with_iface_entry(x)
call takes_real(x())
end subroutine
-! CHECK-LABEL: func @_QPdummy_with_iface() {
-! CHECK: %[[VAL_0:.*]] = fir.alloca f32 {adapt.valuebyref}
+! CHECK-LABEL: func.func @_QPdummy_with_iface() {
! CHECK: %[[VAL_1:.*]] = fir.undefined !fir.boxproc<() -> ()>
-! CHECK: br ^bb1
+! CHECK: cf.br ^bb1
! CHECK: ^bb1:
! CHECK: %[[VAL_2:.*]] = fir.box_addr %[[VAL_1]] : (!fir.boxproc<() -> ()>) -> (() -> f32)
! CHECK: %[[VAL_3:.*]] = fir.call %[[VAL_2]]() {{.*}}: () -> f32
-! CHECK: fir.store %[[VAL_3]] to %[[VAL_0]] : !fir.ref<f32>
-! CHECK: fir.call @_QPtakes_real(%[[VAL_0]]) {{.*}}: (!fir.ref<f32>) -> ()
+! CHECK: %[[VAL_4:.*]]:3 = hlfir.associate %[[VAL_3]] {adapt.valuebyref} : (f32) -> (!fir.ref<f32>, !fir.ref<f32>, i1)
+! CHECK: fir.call @_QPtakes_real(%[[VAL_4]]#0) {{.*}}: (!fir.ref<f32>) -> ()
-! CHECK-LABEL: func @_QPdummy_with_iface_entry(
+! CHECK-LABEL: func.func @_QPdummy_with_iface_entry(
! CHECK-SAME: %[[VAL_0:.*]]: !fir.boxproc<() -> ()>) {
-! CHECK: %[[VAL_1:.*]] = fir.alloca f32 {adapt.valuebyref}
-! CHECK: br ^bb1
+! CHECK: cf.br ^bb1
! CHECK: ^bb1:
! CHECK: %[[VAL_2:.*]] = fir.box_addr %[[VAL_0]] : (!fir.boxproc<() -> ()>) -> (() -> f32)
! CHECK: %[[VAL_3:.*]] = fir.call %[[VAL_2]]() {{.*}}: () -> f32
-! CHECK: fir.store %[[VAL_3]] to %[[VAL_1]] : !fir.ref<f32>
-! CHECK: fir.call @_QPtakes_real(%[[VAL_1]]) {{.*}}: (!fir.ref<f32>) -> ()
+! CHECK: %[[VAL_4:.*]]:3 = hlfir.associate %[[VAL_3]] {adapt.valuebyref} : (f32) -> (!fir.ref<f32>, !fir.ref<f32>, i1)
+! CHECK: fir.call @_QPtakes_real(%[[VAL_4]]#0) {{.*}}: (!fir.ref<f32>) -> ()
subroutine subroutine_dummy()
entry subroutine_dummy_entry(x)
call x()
end subroutine
-! CHECK-LABEL: func @_QPsubroutine_dummy() {
+! CHECK-LABEL: func.func @_QPsubroutine_dummy() {
! CHECK: %[[VAL_0:.*]] = fir.undefined !fir.boxproc<() -> ()>
-! CHECK: br ^bb1
+! CHECK: cf.br ^bb1
! CHECK: ^bb1:
! CHECK: %[[VAL_1:.*]] = fir.box_addr %[[VAL_0]] : (!fir.boxproc<() -> ()>) -> (() -> ())
! CHECK: fir.call %[[VAL_1]]() {{.*}}: () -> ()
-! CHECK-LABEL: func @_QPsubroutine_dummy_entry(
+! CHECK-LABEL: func.func @_QPsubroutine_dummy_entry(
! CHECK-SAME: %[[VAL_0:.*]]: !fir.boxproc<() -> ()>) {
-! CHECK: br ^bb1
+! CHECK: cf.br ^bb1
! CHECK: ^bb1:
! CHECK: %[[VAL_1:.*]] = fir.box_addr %[[VAL_0]] : (!fir.boxproc<() -> ()>) -> (() -> ())
! CHECK: fir.call %[[VAL_1]]() {{.*}}: () -> ()
diff --git a/flang/test/Lower/dummy-procedure.f90 b/flang/test/Lower/dummy-procedure.f90
index a02aa21d2cc2e..0359897258d2f 100644
--- a/flang/test/Lower/dummy-procedure.f90
+++ b/flang/test/Lower/dummy-procedure.f90
@@ -1,21 +1,22 @@
-! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s
+! RUN: %flang_fc1 -emit-hlfir %s -o - | FileCheck %s
! Test dummy procedures
! Test of dummy procedure call
-! CHECK-LABEL: func @_QPfoo(
+! CHECK-LABEL: func.func @_QPfoo(
! CHECK-SAME: %{{.*}}: !fir.boxproc<() -> ()>{{.*}}) -> f32
real function foo(bar)
real :: bar, x
! CHECK: %[[x:.*]] = fir.alloca f32 {{{.*}}uniq_name = "{{.*}}Ex"}
+ ! CHECK: %[[x_decl:.*]]:2 = hlfir.declare %[[x]]
x = 42.
! CHECK: %[[funccast:.*]] = fir.box_addr %arg0 : (!fir.boxproc<() -> ()>) -> ((!fir.ref<f32>) -> f32)
- ! CHECK: fir.call %[[funccast]](%[[x]]) {{.*}}: (!fir.ref<f32>) -> f32
+ ! CHECK: fir.call %[[funccast]](%[[x_decl]]#0) {{.*}}: (!fir.ref<f32>) -> f32
foo = bar(x)
end function
! Test case where dummy procedure is only transiting.
-! CHECK-LABEL: func @_QPprefoo(
+! CHECK-LABEL: func.func @_QPprefoo(
! CHECK-SAME: %{{.*}}: !fir.boxproc<() -> ()>{{.*}}) -> f32
real function prefoo(bar)
external :: bar
@@ -24,7 +25,7 @@ real function prefoo(bar)
end function
! Function that will be passed as dummy argument
-! CHECK-LABEL: func @_QPfunc(
+! CHECK-LABEL: func.func @_QPfunc(
! CHECK-SAME: %{{.*}}: !fir.ref<f32>{{.*}}) -> f32
real function func(x)
real :: x
@@ -32,7 +33,7 @@ real function func(x)
end function
! Test passing functions as dummy procedure arguments
-! CHECK-LABEL: func @_QPtest_func
+! CHECK-LABEL: func.func @_QPtest_func
real function test_func()
real :: func, prefoo
external :: func
@@ -44,18 +45,19 @@ real function test_func()
! Repeat test with dummy subroutine
-! CHECK-LABEL: func @_QPfoo_sub(
+! CHECK-LABEL: func.func @_QPfoo_sub(
! CHECK-SAME: %{{.*}}: !fir.boxproc<() -> ()>{{.*}})
subroutine foo_sub(bar_sub)
! CHECK: %[[x:.*]] = fir.alloca f32 {{{.*}}uniq_name = "{{.*}}Ex"}
+ ! CHECK: %[[x_decl:.*]]:2 = hlfir.declare %[[x]]
x = 42.
! CHECK: %[[funccast:.*]] = fir.box_addr %arg0 : (!fir.boxproc<() -> ()>) -> ((!fir.ref<f32>) -> ())
- ! CHECK: fir.call %[[funccast]](%[[x]]) {{.*}}: (!fir.ref<f32>)
+ ! CHECK: fir.call %[[funccast]](%[[x_decl]]#0) {{.*}}: (!fir.ref<f32>)
call bar_sub(x)
end subroutine
! Test case where dummy procedure is only transiting.
-! CHECK-LABEL: func @_QPprefoo_sub(
+! CHECK-LABEL: func.func @_QPprefoo_sub(
! CHECK-SAME: %{{.*}}: !fir.boxproc<() -> ()>{{.*}})
subroutine prefoo_sub(bar_sub)
external :: bar_sub
@@ -64,7 +66,7 @@ subroutine prefoo_sub(bar_sub)
end subroutine
! Subroutine that will be passed as dummy argument
-! CHECK-LABEL: func @_QPsub(
+! CHECK-LABEL: func.func @_QPsub(
! CHECK-SAME: %{{.*}}: !fir.ref<f32>{{.*}})
subroutine sub(x)
real :: x
@@ -72,7 +74,7 @@ subroutine sub(x)
end subroutine
! Test passing functions as dummy procedure arguments
-! CHECK-LABEL: func @_QPtest_sub
+! CHECK-LABEL: func.func @_QPtest_sub
subroutine test_sub()
external :: sub
!CHECK: %[[f:.*]] = fir.address_of(@_QPsub) : (!fir.ref<f32>) -> ()
@@ -81,7 +83,7 @@ subroutine test_sub()
call prefoo_sub(sub)
end subroutine
-! CHECK-LABEL: func @_QPpassing_not_defined_in_file()
+! CHECK-LABEL: func.func @_QPpassing_not_defined_in_file()
subroutine passing_not_defined_in_file()
external proc_not_defined_in_file
! CHECK: %[[addr:.*]] = fir.address_of(@_QPproc_not_defined_in_file) : () -> ()
@@ -93,7 +95,7 @@ subroutine passing_not_defined_in_file()
! Test passing unrestricted intrinsics
! Intrinsic using runtime
-! CHECK-LABEL: func @_QPtest_acos
+! CHECK-LABEL: func.func @_QPtest_acos
subroutine test_acos(x)
intrinsic :: acos
!CHECK: %[[f:.*]] = fir.address_of(@fir.acos.f32.ref_f32) : (!fir.ref<f32>) -> f32
@@ -102,7 +104,7 @@ subroutine test_acos(x)
call foo_acos(acos)
end subroutine
-! CHECK-LABEL: func @_QPtest_atan2
+! CHECK-LABEL: func.func @_QPtest_atan2
subroutine test_atan2()
intrinsic :: atan2
! CHECK: %[[f:.*]] = fir.address_of(@fir.atan2.f32.ref_f32.ref_f32) : (!fir.ref<f32>, !fir.ref<f32>) -> f32
@@ -112,7 +114,7 @@ subroutine test_atan2()
end subroutine
! Intrinsic implemented inlined
-! CHECK-LABEL: func @_QPtest_aimag
+! CHECK-LABEL: func.func @_QPtest_aimag
subroutine test_aimag()
intrinsic :: aimag
!CHECK: %[[f:.*]] = fir.address_of(@fir.aimag.f32.ref_z32) : (!fir.ref<complex<f32>>) -> f32
@@ -122,7 +124,7 @@ subroutine test_aimag()
end subroutine
! Character Intrinsic implemented inlined
-! CHECK-LABEL: func @_QPtest_len
+! CHECK-LABEL: func.func @_QPtest_len
subroutine test_len()
intrinsic :: len
! CHECK: %[[f:.*]] = fir.address_of(@fir.len.i32.bc1) : (!fir.boxchar<1>) -> i32
@@ -132,7 +134,7 @@ subroutine test_len()
end subroutine
! Intrinsic implemented inlined with specific name
diff erent from generic
-! CHECK-LABEL: func @_QPtest_iabs
+! CHECK-LABEL: func.func @_QPtest_iabs
subroutine test_iabs()
intrinsic :: iabs
! CHECK: %[[f:.*]] = fir.address_of(@fir.abs.i32.ref_i32) : (!fir.ref<i32>) -> i32
@@ -144,32 +146,32 @@ subroutine test_iabs()
! TODO: exhaustive test of unrestricted intrinsic table 16.2
! TODO: improve dummy procedure types when interface is given.
-! CHECK: func @_QPtodo3(
+! CHECK: func.func @_QPtodo3(
! CHECK-SAME: %{{.*}}: !fir.boxproc<() -> ()>{{.*}})
-! SHOULD-CHECK: func @_QPtodo3(%arg0: (!fir.ref<f32>) -> f32)
+! SHOULD-CHECK: func.func @_QPtodo3(%arg0: (!fir.ref<f32>) -> f32)
subroutine todo3(dummy_proc)
intrinsic :: acos
procedure(acos) :: dummy_proc
end subroutine
-! CHECK-LABEL: func private @fir.acos.f32.ref_f32(%arg0: !fir.ref<f32>) -> f32
+! CHECK-LABEL: func.func private @fir.acos.f32.ref_f32(%arg0: !fir.ref<f32>) -> f32
!CHECK: %[[load:.*]] = fir.load %arg0
!CHECK: %[[res:.*]] = math.acos %[[load]] fastmath<contract> : f32
!CHECK: return %[[res]] : f32
-! CHECK-LABEL: func private @fir.atan2.f32.ref_f32.ref_f32(
+! CHECK-LABEL: func.func private @fir.atan2.f32.ref_f32.ref_f32(
! CHECK-SAME: %[[x:.*]]: !fir.ref<f32>, %[[y:.*]]: !fir.ref<f32>) -> f32
! CHECK-DAG: %[[xload:.*]] = fir.load %[[x]] : !fir.ref<f32>
! CHECK-DAG: %[[yload:.*]] = fir.load %[[y]] : !fir.ref<f32>
! CHECK: %[[atan2:.*]] = math.atan2 %[[xload]], %[[yload]] fastmath<contract> : f32
! CHECK: return %[[atan2]] : f32
-!CHECK-LABEL: func private @fir.aimag.f32.ref_z32(%arg0: !fir.ref<complex<f32>>)
+!CHECK-LABEL: func.func private @fir.aimag.f32.ref_z32(%arg0: !fir.ref<complex<f32>>)
!CHECK: %[[load:.*]] = fir.load %arg0
!CHECK: %[[imag:.*]] = fir.extract_value %[[load]], [1 : index] : (complex<f32>) -> f32
!CHECK: return %[[imag]] : f32
-!CHECK-LABEL: func private @fir.len.i32.bc1(%arg0: !fir.boxchar<1>)
+!CHECK-LABEL: func.func private @fir.len.i32.bc1(%arg0: !fir.boxchar<1>)
!CHECK: %[[unboxed:.*]]:2 = fir.unboxchar %arg0 : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
!CHECK: %[[len:.*]] = fir.convert %[[unboxed]]#1 : (index) -> i32
!CHECK: return %[[len]] : i32
diff --git a/flang/test/Lower/equivalence-1.f90 b/flang/test/Lower/equivalence-1.f90
index deb3a5b5614f4..b27cb55297d7d 100644
--- a/flang/test/Lower/equivalence-1.f90
+++ b/flang/test/Lower/equivalence-1.f90
@@ -1,38 +1,44 @@
-! RUN: bbc -hlfir=false -o - %s | FileCheck %s
+! RUN: %flang_fc1 -emit-hlfir -o - %s | FileCheck %s
-! CHECK-LABEL: func @_QPs1
+! CHECK-LABEL: func.func @_QPs1()
SUBROUTINE s1
INTEGER i
REAL r
- ! CHECK: = fir.alloca !fir.array<4xi8> {uniq_name = "_QFs1Ei"}
+ ! CHECK: %[[group:.*]] = fir.alloca !fir.array<4xi8> {uniq_name = "_QFs1Ei"}
EQUIVALENCE (r,i)
- ! CHECK: %[[coor:.*]] = fir.coordinate_of %{{.*}}, %{{.*}} : (!fir.ref<!fir.array<4xi8>>, index) -> !fir.ref<i8>
+ ! CHECK: %[[coor:.*]] = fir.coordinate_of %[[group]], %c0{{.*}} : (!fir.ref<!fir.array<4xi8>>, index) -> !fir.ref<i8>
! CHECK: %[[iloc:.*]] = fir.convert %[[coor]] : (!fir.ref<i8>) -> !fir.ptr<i32>
- ! CHECK-DAG: fir.store %{{.*}} to %[[iloc]] : !fir.ptr<i32>
+ ! CHECK: %[[i_decl:.*]]:2 = hlfir.declare %[[iloc]] storage(%[[group]][0]) {uniq_name = "_QFs1Ei"}
+ ! CHECK: %[[coor2:.*]] = fir.coordinate_of %[[group]], %c0{{.*}} : (!fir.ref<!fir.array<4xi8>>, index) -> !fir.ref<i8>
+ ! CHECK: %[[rloc:.*]] = fir.convert %[[coor2]] : (!fir.ref<i8>) -> !fir.ptr<f32>
+ ! CHECK: %[[r_decl:.*]]:2 = hlfir.declare %[[rloc]] storage(%[[group]][0]) {uniq_name = "_QFs1Er"}
i = 4
- ! CHECK-DAG: %[[floc:.*]] = fir.convert %[[coor]] : (!fir.ref<i8>) -> !fir.ptr<f32>
- ! CHECK: %[[ld:.*]] = fir.load %[[floc]] : !fir.ptr<f32>
+ ! CHECK: hlfir.assign %c4{{.*}} to %[[i_decl]]#0
PRINT *, r
+ ! CHECK: fir.load %[[r_decl]]#0
END SUBROUTINE s1
-! CHECK-LABEL: func @_QPs2
+! CHECK-LABEL: func.func @_QPs2()
SUBROUTINE s2
INTEGER i(10)
REAL r(10)
! CHECK: %[[arr:.*]] = fir.alloca !fir.array<48xi8>
EQUIVALENCE (r(3),i(5))
- ! CHECK: %[[iarr:.*]] = fir.convert %{{.*}} : (!fir.ref<i8>) -> !fir.ptr<!fir.array<10xi32>>
- ! CHECK: %[[foff:.*]] = fir.coordinate_of %[[arr]], %{{.*}} : (!fir.ref<!fir.array<48xi8>>, index) -> !fir.ref<i8>
- ! CHECK: %[[farr:.*]] = fir.convert %[[foff]] : (!fir.ref<i8>) -> !fir.ptr<!fir.array<10xf32>>
- ! CHECK: %[[ia:.*]] = fir.coordinate_of %[[iarr]], %{{.*}} : (!fir.ptr<!fir.array<10xi32>>, i64) -> !fir.ref<i32>
- ! CHECK: fir.store %{{.*}} to %[[ia]] : !fir.ref<i32>
+ ! CHECK: %[[coor:.*]] = fir.coordinate_of %[[arr]], %c0{{.*}} : (!fir.ref<!fir.array<48xi8>>, index) -> !fir.ref<i8>
+ ! CHECK: %[[iarr:.*]] = fir.convert %[[coor]] : (!fir.ref<i8>) -> !fir.ptr<!fir.array<10xi32>>
+ ! CHECK: %[[i_decl:.*]]:2 = hlfir.declare %[[iarr]](%{{.*}}) storage(%[[arr]][0]) {uniq_name = "_QFs2Ei"}
+ ! CHECK: %[[coor2:.*]] = fir.coordinate_of %[[arr]], %c8{{.*}} : (!fir.ref<!fir.array<48xi8>>, index) -> !fir.ref<i8>
+ ! CHECK: %[[rarr:.*]] = fir.convert %[[coor2]] : (!fir.ref<i8>) -> !fir.ptr<!fir.array<10xf32>>
+ ! CHECK: %[[r_decl:.*]]:2 = hlfir.declare %[[rarr]](%{{.*}}) storage(%[[arr]][8]) {uniq_name = "_QFs2Er"}
i(5) = 18
- ! CHECK: %[[fld:.*]] = fir.coordinate_of %[[farr]], %{{.*}} : (!fir.ptr<!fir.array<10xf32>>, i64) -> !fir.ref<f32>
- ! CHECK: = fir.load %[[fld]] : !fir.ref<f32>
+ ! CHECK: %[[ides:.*]] = hlfir.designate %[[i_decl]]#0 (%c5{{.*}})
+ ! CHECK: hlfir.assign %c18{{.*}} to %[[ides]]
PRINT *, r(3)
+ ! CHECK: %[[rdes:.*]] = hlfir.designate %[[r_decl]]#0 (%c3{{.*}})
+ ! CHECK: fir.load %[[rdes]]
END SUBROUTINE s2
-! CHECK-LABEL: func @_QPs3
+! CHECK-LABEL: func.func @_QPs3()
SUBROUTINE s3
REAL r(10)
TYPE t
@@ -42,16 +48,14 @@ SUBROUTINE s3
TYPE(t) x
! CHECK: %[[group:.*]] = fir.alloca !fir.array<40xi8>
EQUIVALENCE (r,x)
- ! CHECK: %[[coor:.*]] = fir.coordinate_of %[[group]], %c0 : (!fir.ref<!fir.array<40xi8>>, index) -> !fir.ref<i8>
- ! CHECK: %[[rloc:.*]] = fir.convert %[[coor]] : (!fir.ref<i8>) -> !fir.ptr<!fir.array<10xf32>>
- ! CHECK: %[[xloc:.*]] = fir.convert %[[coor]] : (!fir.ref<i8>) -> !fir.ptr<!fir.type<_QFs3Tt{r:!fir.array<10xf32>}>>
- ! CHECK: %[[xrloc:.*]] = fir.coordinate_of %[[xloc]], r
- ! CHECK: %[[v1loc:.*]] = fir.coordinate_of %[[xrloc]], %c8_i64 : (!fir.ref<!fir.array<10xf32>>, i64) -> !fir.ref<f32>
- ! CHECK: fir.store %{{.*}} to %[[v1loc]] : !fir.ref<f32>
+ ! CHECK: %[[r_decl:.*]]:2 = hlfir.declare %{{.*}} storage(%[[group]][0]) {uniq_name = "_QFs3Er"}
+ ! CHECK: %[[x_decl:.*]]:2 = hlfir.declare %{{.*}} storage(%[[group]][0]) {uniq_name = "_QFs3Ex"}
x%r(9) = 9.0
- ! CHECK: %[[v2loc:.*]] = fir.coordinate_of %[[rloc]], %c8_i64 : (!fir.ptr<!fir.array<10xf32>>, i64) -> !fir.ref<f32>
- ! CHECK: %{{.*}} = fir.load %[[v2loc]] : !fir.ref<f32>
+ ! CHECK: %[[xdes:.*]] = hlfir.designate %[[x_decl]]#0{"r"} <%{{.*}}> (%c9{{.*}})
+ ! CHECK: hlfir.assign %{{.*}} to %[[xdes]]
PRINT *, r(9)
+ ! CHECK: %[[rdes:.*]] = hlfir.designate %[[r_decl]]#0 (%c9{{.*}})
+ ! CHECK: fir.load %[[rdes]]
END SUBROUTINE s3
! test that equivalence in main program containing arrays are placed in global memory.
diff --git a/flang/test/Lower/equivalence-2.f90 b/flang/test/Lower/equivalence-2.f90
index 1c4506054c76a..12e878f743711 100644
--- a/flang/test/Lower/equivalence-2.f90
+++ b/flang/test/Lower/equivalence-2.f90
@@ -1,26 +1,36 @@
-! RUN: bbc -emit-fir -hlfir=false -o - %s | FileCheck %s
+! RUN: %flang_fc1 -emit-hlfir -o - %s | FileCheck %s
! Check more advanced equivalence cases
! Several set of local and global equivalences in the same scope
-! CHECK-LABEL: @_QPtest_eq_sets
+! CHECK-LABEL: func.func @_QPtest_eq_sets
subroutine test_eq_sets
DIMENSION Al(4), Bl(4)
EQUIVALENCE (Al(1), Bl(2))
! CHECK-DAG: %[[albl:.*]] = fir.alloca !fir.array<20xi8>
! CHECK-DAG: %[[alAddr:.*]] = fir.coordinate_of %[[albl]], %c4{{.*}} : (!fir.ref<!fir.array<20xi8>>, index) -> !fir.ref<i8>
! CHECK-DAG: %[[al:.*]] = fir.convert %[[alAddr]] : (!fir.ref<i8>) -> !fir.ptr<!fir.array<4xf32>>
+ ! CHECK-DAG: %[[al_decl:.*]]:2 = hlfir.declare %[[al]](%{{.*}}) storage(%[[albl]][4]) {uniq_name = "_QFtest_eq_setsEal"}
! CHECK-DAG: %[[blAddr:.*]] = fir.coordinate_of %[[albl]], %c0{{.*}} : (!fir.ref<!fir.array<20xi8>>, index) -> !fir.ref<i8>
! CHECK-DAG: %[[bl:.*]] = fir.convert %[[blAddr]] : (!fir.ref<i8>) -> !fir.ptr<!fir.array<4xf32>>
+ ! CHECK-DAG: %[[bl_decl:.*]]:2 = hlfir.declare %[[bl]](%{{.*}}) storage(%[[albl]][0]) {uniq_name = "_QFtest_eq_setsEbl"}
DIMENSION Il(2), Xl(2)
EQUIVALENCE (Il(2), Xl(1))
! CHECK-DAG: %[[ilxl:.*]] = fir.alloca !fir.array<12xi8>
+ ! CHECK-DAG: %[[igAddr:.*]] = fir.coordinate_of %{{.*}}, %c0{{.*}} : (!fir.ref<!fir.array<8xi8>>, index) -> !fir.ref<i8>
+ ! CHECK-DAG: %[[ig:.*]] = fir.convert %[[igAddr]] : (!fir.ref<i8>) -> !fir.ptr<!fir.array<2xi32>>
+ ! CHECK-DAG: %[[ig_decl:.*]]:2 = hlfir.declare %[[ig]](%{{.*}}) storage(%{{.*}}[0]) {uniq_name = "_QFtest_eq_setsEig"}
! CHECK-DAG: %[[ilAddr:.*]] = fir.coordinate_of %[[ilxl]], %c0{{.*}} : (!fir.ref<!fir.array<12xi8>>, index) -> !fir.ref<i8>
! CHECK-DAG: %[[il:.*]] = fir.convert %[[ilAddr]] : (!fir.ref<i8>) -> !fir.ptr<!fir.array<2xi32>>
+ ! CHECK-DAG: %[[il_decl:.*]]:2 = hlfir.declare %[[il]](%{{.*}}) storage(%[[ilxl]][0]) {uniq_name = "_QFtest_eq_setsEil"}
+ ! CHECK-DAG: %[[xgAddr:.*]] = fir.coordinate_of %{{.*}}, %c0{{.*}} : (!fir.ref<!fir.array<8xi8>>, index) -> !fir.ref<i8>
+ ! CHECK-DAG: %[[xg:.*]] = fir.convert %[[xgAddr]] : (!fir.ref<i8>) -> !fir.ptr<!fir.array<2xf32>>
+ ! CHECK-DAG: %[[xg_decl:.*]]:2 = hlfir.declare %[[xg]](%{{.*}}) storage(%{{.*}}[0]) {uniq_name = "_QFtest_eq_setsExg"}
! CHECK-DAG: %[[xlAddr:.*]] = fir.coordinate_of %[[ilxl]], %c4{{.*}} : (!fir.ref<!fir.array<12xi8>>, index) -> !fir.ref<i8>
! CHECK-DAG: %[[xl:.*]] = fir.convert %[[xlAddr]] : (!fir.ref<i8>) -> !fir.ptr<!fir.array<2xf32>>
+ ! CHECK-DAG: %[[xl_decl:.*]]:2 = hlfir.declare %[[xl]](%{{.*}}) storage(%[[ilxl]][4]) {uniq_name = "_QFtest_eq_setsExl"}
DIMENSION Ag(2), Bg(2)
SAVE Ag, Bg
@@ -28,27 +38,24 @@ subroutine test_eq_sets
! CHECK-DAG: %[[agbg:.*]] = fir.address_of(@_QFtest_eq_setsEag) : !fir.ref<!fir.array<12xi8>>
! CHECK-DAG: %[[agAddr:.*]] = fir.coordinate_of %[[agbg]], %c4{{.*}} : (!fir.ref<!fir.array<12xi8>>, index) -> !fir.ref<i8>
! CHECK-DAG: %[[ag:.*]] = fir.convert %[[agAddr]] : (!fir.ref<i8>) -> !fir.ptr<!fir.array<2xf32>>
+ ! CHECK-DAG: %[[ag_decl:.*]]:2 = hlfir.declare %[[ag]](%{{.*}}) storage(%[[agbg]][4]) {uniq_name = "_QFtest_eq_setsEag"}
! CHECK-DAG: %[[bgAddr:.*]] = fir.coordinate_of %[[agbg]], %c0{{.*}} : (!fir.ref<!fir.array<12xi8>>, index) -> !fir.ref<i8>
! CHECK-DAG: %[[bg:.*]] = fir.convert %[[bgAddr]] : (!fir.ref<i8>) -> !fir.ptr<!fir.array<2xf32>>
+ ! CHECK-DAG: %[[bg_decl:.*]]:2 = hlfir.declare %[[bg]](%{{.*}}) storage(%[[agbg]][0]) {uniq_name = "_QFtest_eq_setsEbg"}
DIMENSION Ig(2), Xg(2)
SAVE Ig, Xg
EQUIVALENCE (Ig(1), Xg(1))
! CHECK-DAG: %[[igxg:.*]] = fir.address_of(@_QFtest_eq_setsEig) : !fir.ref<!fir.array<8xi8>>
- ! CHECK-DAG: %[[igOffset:.*]] = arith.constant 0 : index
- ! CHECK-DAG: %[[igAddr:.*]] = fir.coordinate_of %[[igxg]], %c0{{.*}} : (!fir.ref<!fir.array<8xi8>>, index) -> !fir.ref<i8>
- ! CHECK-DAG: %[[ig:.*]] = fir.convert %[[igAddr]] : (!fir.ref<i8>) -> !fir.ptr<!fir.array<2xi32>>
- ! CHECK-DAG: %[[xgAddr:.*]] = fir.coordinate_of %[[igxg]], %c0{{.*}} : (!fir.ref<!fir.array<8xi8>>, index) -> !fir.ref<i8>
- ! CHECK-DAG: %[[xg:.*]] = fir.convert %[[xgAddr]] : (!fir.ref<i8>) -> !fir.ptr<!fir.array<2xf32>>
- ! CHECK: %[[alCast:.*]] = fir.convert %[[al]] : (!fir.ptr<!fir.array<4xf32>>) -> !fir.ref<!fir.array<4xf32>>
- ! CHECK: %[[blCast:.*]] = fir.convert %[[bl]] : (!fir.ptr<!fir.array<4xf32>>) -> !fir.ref<!fir.array<4xf32>>
- ! CHECK: %[[ilCast:.*]] = fir.convert %[[il]] : (!fir.ptr<!fir.array<2xi32>>) -> !fir.ref<!fir.array<2xi32>>
- ! CHECK: %[[xlCast:.*]] = fir.convert %[[xl]] : (!fir.ptr<!fir.array<2xf32>>) -> !fir.ref<!fir.array<2xf32>>
- ! CHECK: %[[agCast:.*]] = fir.convert %[[ag]] : (!fir.ptr<!fir.array<2xf32>>) -> !fir.ref<!fir.array<2xf32>>
- ! CHECK: %[[bgCast:.*]] = fir.convert %[[bg]] : (!fir.ptr<!fir.array<2xf32>>) -> !fir.ref<!fir.array<2xf32>>
- ! CHECK: %[[xgCast:.*]] = fir.convert %[[xg]] : (!fir.ptr<!fir.array<2xf32>>) -> !fir.ref<!fir.array<2xf32>>
- ! CHECK: %[[igCast:.*]] = fir.convert %[[ig]] : (!fir.ptr<!fir.array<2xi32>>) -> !fir.ref<!fir.array<2xi32>>
+ ! CHECK: %[[alCast:.*]] = fir.convert %[[al_decl]]#0 : (!fir.ptr<!fir.array<4xf32>>) -> !fir.ref<!fir.array<4xf32>>
+ ! CHECK: %[[blCast:.*]] = fir.convert %[[bl_decl]]#0 : (!fir.ptr<!fir.array<4xf32>>) -> !fir.ref<!fir.array<4xf32>>
+ ! CHECK: %[[ilCast:.*]] = fir.convert %[[il_decl]]#0 : (!fir.ptr<!fir.array<2xi32>>) -> !fir.ref<!fir.array<2xi32>>
+ ! CHECK: %[[xlCast:.*]] = fir.convert %[[xl_decl]]#0 : (!fir.ptr<!fir.array<2xf32>>) -> !fir.ref<!fir.array<2xf32>>
+ ! CHECK: %[[agCast:.*]] = fir.convert %[[ag_decl]]#0 : (!fir.ptr<!fir.array<2xf32>>) -> !fir.ref<!fir.array<2xf32>>
+ ! CHECK: %[[bgCast:.*]] = fir.convert %[[bg_decl]]#0 : (!fir.ptr<!fir.array<2xf32>>) -> !fir.ref<!fir.array<2xf32>>
+ ! CHECK: %[[xgCast:.*]] = fir.convert %[[xg_decl]]#0 : (!fir.ptr<!fir.array<2xf32>>) -> !fir.ref<!fir.array<2xf32>>
+ ! CHECK: %[[igCast:.*]] = fir.convert %[[ig_decl]]#0 : (!fir.ptr<!fir.array<2xi32>>) -> !fir.ref<!fir.array<2xi32>>
call fooc(Al, Bl, Il, Xl, Ag, Bg, Xg, Ig)
! CHECK: fir.call @_QPfooc(%[[alCast]], %[[blCast]], %[[ilCast]], %[[xlCast]], %[[agCast]], %[[bgCast]], %[[xgCast]], %[[igCast]])
@@ -57,7 +64,7 @@ subroutine test_eq_sets
! Mixing global equivalence and entry
-! CHECK-LABEL: @_QPeq_and_entry_foo()
+! CHECK-LABEL: func.func @_QPeq_and_entry_foo()
subroutine eq_and_entry_foo
SAVE x, i
DIMENSION :: x(2)
@@ -68,40 +75,46 @@ subroutine eq_and_entry_foo
! CHECK-DAG: %[[iOffset:.*]] = arith.constant 4 : index
! CHECK-DAG: %[[iAddr:.*]] = fir.coordinate_of %[[xi]], %[[iOffset]] : (!fir.ref<!fir.array<8xi8>>, index) -> !fir.ref<i8>
! CHECK-DAG: %[[i:.*]] = fir.convert %[[iAddr]] : (!fir.ref<i8>) -> !fir.ptr<i32>
+ ! CHECK-DAG: %[[i_decl:.*]]:2 = hlfir.declare %[[i]] storage(%[[xi]][4]) {uniq_name = "_QFeq_and_entry_fooEi"}
! CHECK-DAG: %[[xOffset:.*]] = arith.constant 0 : index
! CHECK-DAG: %[[xAddr:.*]] = fir.coordinate_of %[[xi]], %[[xOffset]] : (!fir.ref<!fir.array<8xi8>>, index) -> !fir.ref<i8>
! CHECK-DAG: %[[x:.*]] = fir.convert %[[xAddr]] : (!fir.ref<i8>) -> !fir.ptr<!fir.array<2xf32>>
+ ! CHECK-DAG: %[[x_decl:.*]]:2 = hlfir.declare %[[x]](%{{.*}}) storage(%[[xi]][0]) {uniq_name = "_QFeq_and_entry_fooEx"}
+
call foo2(x, i)
- ! CHECK: %[[xCast:.*]] = fir.convert %[[x]] : (!fir.ptr<!fir.array<2xf32>>) -> !fir.ref<!fir.array<2xf32>>
- ! CHECK: %[[iCast:.*]] = fir.convert %[[i]] : (!fir.ptr<i32>) -> !fir.ref<i32>
+ ! CHECK: %[[xCast:.*]] = fir.convert %[[x_decl]]#0 : (!fir.ptr<!fir.array<2xf32>>) -> !fir.ref<!fir.array<2xf32>>
+ ! CHECK: %[[iCast:.*]] = fir.convert %[[i_decl]]#0 : (!fir.ptr<i32>) -> !fir.ref<i32>
! CHECK: fir.call @_QPfoo1(%[[xCast]], %[[iCast]]) {{.*}}: (!fir.ref<!fir.array<2xf32>>, !fir.ref<i32>) -> ()
entry eq_and_entry_bar
call foo2(x, i)
- ! CHECK: %[[xCast2:.*]] = fir.convert %[[x]] : (!fir.ptr<!fir.array<2xf32>>) -> !fir.ref<!fir.array<2xf32>>
- ! CHECK: %[[iCast2:.*]] = fir.convert %[[i]] : (!fir.ptr<i32>) -> !fir.ref<i32>
+ ! CHECK: %[[xCast2:.*]] = fir.convert %[[x_decl]]#0 : (!fir.ptr<!fir.array<2xf32>>) -> !fir.ref<!fir.array<2xf32>>
+ ! CHECK: %[[iCast2:.*]] = fir.convert %[[i_decl]]#0 : (!fir.ptr<i32>) -> !fir.ref<i32>
! CHECK: fir.call @_QPfoo2(%[[xCast2]], %[[iCast2]]) {{.*}}: (!fir.ref<!fir.array<2xf32>>, !fir.ref<i32>) -> ()
end
-! CHECK-LABEL: @_QPeq_and_entry_bar()
+! CHECK-LABEL: func.func @_QPeq_and_entry_bar()
! CHECK: %[[xi:.*]] = fir.address_of(@_QFeq_and_entry_fooEi) : !fir.ref<!fir.array<8xi8>>
! CHECK-DAG: %[[iOffset:.*]] = arith.constant 4 : index
! CHECK-DAG: %[[iAddr:.*]] = fir.coordinate_of %[[xi]], %[[iOffset]] : (!fir.ref<!fir.array<8xi8>>, index) -> !fir.ref<i8>
! CHECK-DAG: %[[i:.*]] = fir.convert %[[iAddr]] : (!fir.ref<i8>) -> !fir.ptr<i32>
+ ! CHECK-DAG: %[[i_decl:.*]]:2 = hlfir.declare %[[i]] storage(%[[xi]][4]) {uniq_name = "_QFeq_and_entry_fooEi"}
! CHECK-DAG: %[[xOffset:.*]] = arith.constant 0 : index
! CHECK-DAG: %[[xAddr:.*]] = fir.coordinate_of %[[xi]], %[[xOffset]] : (!fir.ref<!fir.array<8xi8>>, index) -> !fir.ref<i8>
! CHECK-DAG: %[[x:.*]] = fir.convert %[[xAddr]] : (!fir.ref<i8>) -> !fir.ptr<!fir.array<2xf32>>
+ ! CHECK-DAG: %[[x_decl:.*]]:2 = hlfir.declare %[[x]](%{{.*}}) storage(%[[xi]][0]) {uniq_name = "_QFeq_and_entry_fooEx"}
+
! CHECK-NOT: fir.call @_QPfoo1
- ! CHECK: %[[xCast:.*]] = fir.convert %[[x]] : (!fir.ptr<!fir.array<2xf32>>) -> !fir.ref<!fir.array<2xf32>>
- ! CHECK: %[[iCast:.*]] = fir.convert %[[i]] : (!fir.ptr<i32>) -> !fir.ref<i32>
+ ! CHECK: %[[xCast:.*]] = fir.convert %[[x_decl]]#0 : (!fir.ptr<!fir.array<2xf32>>) -> !fir.ref<!fir.array<2xf32>>
+ ! CHECK: %[[iCast:.*]] = fir.convert %[[i_decl]]#0 : (!fir.ptr<i32>) -> !fir.ref<i32>
! CHECK: fir.call @_QPfoo2(%[[xCast]], %[[iCast]]) {{.*}}: (!fir.ref<!fir.array<2xf32>>, !fir.ref<i32>) -> ()
! Check that cases where equivalenced local variables and common blocks will
! share the same offset use the correct stores
-! CHECK-LABEL: @_QPeq_and_comm_same_offset()
+! CHECK-LABEL: func.func @_QPeq_and_comm_same_offset()
subroutine eq_and_comm_same_offset
real common_arr1(133),common_arr2(133)
common /my_common_block/ common_arr1,common_arr2
@@ -115,15 +128,25 @@ subroutine eq_and_comm_same_offset
! CHECK: %[[c0:.*]] = arith.constant 0 : index
! CHECK: %[[mcbCoor:.*]] = fir.coordinate_of %[[mcbAddr]], %[[c0]] : (!fir.ref<!fir.array<1064xi8>>, index) -> !fir.ref<i8>
! CHECK: %[[mcbCoorCast:.*]] = fir.convert %[[mcbCoor]] : (!fir.ref<i8>) -> !fir.ptr<!fir.array<133xf32>>
+ ! CHECK: %[[c133:.*]] = arith.constant 133 : index
+ ! CHECK: %[[shape1:.*]] = fir.shape %[[c133]] : (index) -> !fir.shape<1>
+ ! CHECK: %[[arr1_decl:.*]]:2 = hlfir.declare %[[mcbCoorCast]](%[[shape1]]) storage(%[[mcbAddr]][0]) {uniq_name = "_QFeq_and_comm_same_offsetEarr1"}
+
! CHECK: %[[c1:.*]] = arith.constant 0 : index
! CHECK: %[[arr4Addr:.*]] = fir.coordinate_of %[[arr4Store]], %[[c1]] : (!fir.ref<!fir.array<70756xi8>>, index) -> !fir.ref<i8>
! CHECK: %[[arr4Cast:.*]] = fir.convert %[[arr4Addr]] : (!fir.ref<i8>) -> !fir.ptr<!fir.array<133x133xf32>>
+ ! CHECK: %[[arr3_decl:.*]]:2 = hlfir.declare %[[arr4Cast]](%{{.*}}) storage(%[[arr4Store]][0]) {uniq_name = "_QFeq_and_comm_same_offsetEarr3"}
+
+ ! CHECK: %[[c0_new:.*]] = arith.constant 0 : index
+ ! CHECK: %[[arr4Addr_new:.*]] = fir.coordinate_of %[[arr4Store]], %[[c0_new]] : (!fir.ref<!fir.array<70756xi8>>, index) -> !fir.ref<i8>
+ ! CHECK: %[[arr4Cast_new:.*]] = fir.convert %[[arr4Addr_new]] : (!fir.ref<i8>) -> !fir.ptr<!fir.array<133x133xf32>>
+ ! CHECK: %[[arr4_decl:.*]]:2 = hlfir.declare %[[arr4Cast_new]](%{{.*}}) storage(%[[arr4Store]][0]) {uniq_name = "_QFeq_and_comm_same_offsetEarr4"}
arr1(1) = 1
- ! CHECK:%[[mcbFinalAddr:.*]] = fir.coordinate_of %[[mcbCoorCast]], %{{.*}} : (!fir.ptr<!fir.array<133xf32>>, i64) -> !fir.ref<f32>
- ! CHECK:fir.store %{{.*}} to %[[mcbFinalAddr]] : !fir.ref<f32>
+ ! CHECK:%[[mcbFinalAddr:.*]] = hlfir.designate %[[arr1_decl]]#0 (%c1{{.*}})
+ ! CHECK:hlfir.assign %{{.*}} to %[[mcbFinalAddr]]
arr4(1,1) = 2
- ! CHECK: %[[arr4FinalAddr:.*]] = fir.coordinate_of %[[arr4Cast]], %{{.*}}, %{{.*}} : (!fir.ptr<!fir.array<133x133xf32>>, i64, i64) -> !fir.ref<f32>
- ! CHECK: fir.store %{{.*}} to %[[arr4FinalAddr]] : !fir.ref<f32>
+ ! CHECK: %[[arr4FinalAddr:.*]] = hlfir.designate %[[arr4_decl]]#0 (%c1{{.*}}, %c1{{.*}})
+ ! CHECK: hlfir.assign %{{.*}} to %[[arr4FinalAddr]]
end subroutine
More information about the flang-commits
mailing list