[flang-commits] [flang] [flang][NFC] Converted five tests from old lowering to new lowering (part 53) (PR #194772)
via flang-commits
flang-commits at lists.llvm.org
Wed Apr 29 03:25:27 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-fir-hlfir
Author: Eugene Epshteyn (eugeneepshteyn)
<details>
<summary>Changes</summary>
Convert five tests to use new HLFIR lowering instead of legacy FIR lowering:
Lower/allocatable-callee.f90, Lower/allocatable-caller.f90, Lower/assignment.f90, Lower/assumed-shape-caller.f90, Lower/Intrinsics/count.f90
---
Patch is 58.40 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/194772.diff
5 Files Affected:
- (modified) flang/test/Lower/Intrinsics/count.f90 (+35-40)
- (modified) flang/test/Lower/allocatable-callee.f90 (+51-45)
- (modified) flang/test/Lower/allocatable-caller.f90 (+25-17)
- (modified) flang/test/Lower/assignment.f90 (+157-115)
- (modified) flang/test/Lower/assumed-shape-caller.f90 (+33-35)
``````````diff
diff --git a/flang/test/Lower/Intrinsics/count.f90 b/flang/test/Lower/Intrinsics/count.f90
index 064d01163985d..c249ad552dc46 100644
--- a/flang/test/Lower/Intrinsics/count.f90
+++ b/flang/test/Lower/Intrinsics/count.f90
@@ -1,45 +1,40 @@
-! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s
+! RUN: %flang_fc1 -emit-hlfir %s -o - | FileCheck %s
-! CHECK-LABEL: count_test1
+! CHECK-LABEL: func.func @_QPcount_test1(
! CHECK-SAME: %[[arg0:.*]]: !fir.ref<i32>{{.*}}, %[[arg1:.*]]: !fir.box<!fir.array<?x!fir.logical<4>>>{{.*}})
subroutine count_test1(rslt, mask)
- integer :: rslt
- logical :: mask(:)
- ! CHECK-DAG: %[[c1:.*]] = arith.constant 0 : index
- ! CHECK-DAG: %[[a2:.*]] = fir.convert %[[arg1]] : (!fir.box<!fir.array<?x!fir.logical<4>>>) -> !fir.box<none>
- ! CHECK: %[[a4:.*]] = fir.convert %[[c1]] : (index) -> i32
- rslt = count(mask)
- ! CHECK: %[[a5:.*]] = fir.call @_FortranACount(%[[a2]], %{{.*}}, %{{.*}}, %[[a4]]) {{.*}}: (!fir.box<none>, !fir.ref<i8>, i32, i32) -> i64
- end subroutine
+ integer :: rslt
+ logical :: mask(:)
+ ! CHECK: %[[mask_decl:.*]]:2 = hlfir.declare %[[arg1]] {{.*}}
+ ! CHECK: %[[rslt_decl:.*]]:2 = hlfir.declare %[[arg0]] {{.*}}
+ ! CHECK: %[[res:.*]] = hlfir.count %[[mask_decl]]#0 : (!fir.box<!fir.array<?x!fir.logical<4>>>) -> i32
+ ! CHECK: hlfir.assign %[[res]] to %[[rslt_decl]]#0 : i32, !fir.ref<i32>
+ rslt = count(mask)
+end subroutine
- ! CHECK-LABEL: test_count2
- ! CHECK-SAME: %[[arg0:.*]]: !fir.box<!fir.array<?xi32>>{{.*}}, %[[arg1:.*]]: !fir.box<!fir.array<?x?x!fir.logical<4>>>{{.*}})
- subroutine test_count2(rslt, mask)
- integer :: rslt(:)
- logical :: mask(:,:)
- ! CHECK-DAG: %[[c1_i32:.*]] = arith.constant 1 : i32
- ! CHECK-DAG: %[[c4:.*]] = arith.constant 4 : index
- ! CHECK-DAG: %[[a0:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?xi32>>>
- ! CHECK: %[[a5:.*]] = fir.convert %[[a0]] : (!fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>) -> !fir.ref<!fir.box<none>>
- ! CHECK: %[[a6:.*]] = fir.convert %[[arg1]] : (!fir.box<!fir.array<?x?x!fir.logical<4>>>) -> !fir.box<none>
- ! CHECK: %[[a7:.*]] = fir.convert %[[c4]] : (index) -> i32
- rslt = count(mask, dim=1)
- ! CHECK: fir.call @_FortranACountDim(%[[a5]], %[[a6]], %[[c1_i32]], %[[a7]], %{{.*}}, %{{.*}}) {{.*}}: (!fir.ref<!fir.box<none>>, !fir.box<none>, i32, i32, !fir.ref<i8>, i32) -> ()
- ! CHECK: %[[a10:.*]] = fir.load %[[a0]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>
- ! CHECK: %[[a12:.*]] = fir.box_addr %[[a10]] : (!fir.box<!fir.heap<!fir.array<?xi32>>>) -> !fir.heap<!fir.array<?xi32>>
- ! CHECK: fir.freemem %[[a12]]
- end subroutine
-
- ! CHECK-LABEL: test_count3
- ! CHECK-SAME: %[[arg0:.*]]: !fir.ref<i32>{{.*}}, %[[arg1:.*]]: !fir.box<!fir.array<?x!fir.logical<4>>>{{.*}})
- subroutine test_count3(rslt, mask)
- integer :: rslt
- logical :: mask(:)
- ! CHECK-DAG: %[[c0:.*]] = arith.constant 0 : index
- ! CHECK-DAG: %[[a1:.*]] = fir.convert %[[arg1]] : (!fir.box<!fir.array<?x!fir.logical<4>>>) -> !fir.box<none>
- ! CHECK: %[[a3:.*]] = fir.convert %[[c0]] : (index) -> i32
- call bar(count(mask, kind=2))
- ! CHECK: %[[a4:.*]] = fir.call @_FortranACount(%[[a1]], %{{.*}}, %{{.*}}, %[[a3]]) {{.*}}: (!fir.box<none>, !fir.ref<i8>, i32, i32) -> i64
- ! CHECK: %{{.*}} = fir.convert %[[a4]] : (i64) -> i16
- end subroutine
+! CHECK-LABEL: func.func @_QPtest_count2(
+! CHECK-SAME: %[[arg0:.*]]: !fir.box<!fir.array<?xi32>>{{.*}}, %[[arg1:.*]]: !fir.box<!fir.array<?x?x!fir.logical<4>>>{{.*}})
+subroutine test_count2(rslt, mask)
+ integer :: rslt(:)
+ logical :: mask(:,:)
+ ! CHECK: %[[mask_decl:.*]]:2 = hlfir.declare %[[arg1]] {{.*}}
+ ! CHECK: %[[rslt_decl:.*]]:2 = hlfir.declare %[[arg0]] {{.*}}
+ ! CHECK: %[[c1_i32:.*]] = arith.constant 1 : i32
+ ! CHECK: %[[res:.*]] = hlfir.count %[[mask_decl]]#0 dim %[[c1_i32]] : (!fir.box<!fir.array<?x?x!fir.logical<4>>>, i32) -> !hlfir.expr<?xi32>
+ ! CHECK: hlfir.assign %[[res]] to %[[rslt_decl]]#0 : !hlfir.expr<?xi32>, !fir.box<!fir.array<?xi32>>
+ ! CHECK: hlfir.destroy %[[res]] : !hlfir.expr<?xi32>
+ rslt = count(mask, dim=1)
+end subroutine
+! CHECK-LABEL: func.func @_QPtest_count3(
+! CHECK-SAME: %[[arg0:.*]]: !fir.ref<i32>{{.*}}, %[[arg1:.*]]: !fir.box<!fir.array<?x!fir.logical<4>>>{{.*}})
+subroutine test_count3(rslt, mask)
+ integer :: rslt
+ logical :: mask(:)
+ ! CHECK: %[[mask_decl:.*]]:2 = hlfir.declare %[[arg1]] {{.*}}
+ ! CHECK: %[[res:.*]] = hlfir.count %[[mask_decl]]#0 : (!fir.box<!fir.array<?x!fir.logical<4>>>) -> i16
+ ! CHECK: %[[assoc:.*]]:3 = hlfir.associate %[[res]] {{.*}}: (i16) -> (!fir.ref<i16>, !fir.ref<i16>, i1)
+ ! CHECK: fir.call @_QPbar(%[[assoc]]#0) {{.*}}: (!fir.ref<i16>) -> ()
+ ! CHECK: hlfir.end_associate %[[assoc]]#1, %[[assoc]]#2 : !fir.ref<i16>, i1
+ call bar(count(mask, kind=2))
+end subroutine
diff --git a/flang/test/Lower/allocatable-callee.f90 b/flang/test/Lower/allocatable-callee.f90
index 23da3263748ad..15c4a57391c86 100644
--- a/flang/test/Lower/allocatable-callee.f90
+++ b/flang/test/Lower/allocatable-callee.f90
@@ -1,4 +1,4 @@
-! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s
+! RUN: %flang_fc1 -emit-hlfir %s -o - | FileCheck %s
! Test allocatable dummy argument on callee side
@@ -8,7 +8,8 @@ subroutine test_scalar(x)
real, allocatable :: x
print *, x
- ! CHECK: %[[box:.*]] = fir.load %[[arg0]] : !fir.ref<!fir.box<!fir.heap<f32>>>
+ ! CHECK: %[[x:.*]]:2 = hlfir.declare %[[arg0]]{{.*}}allocatable
+ ! CHECK: %[[box:.*]] = fir.load %[[x]]#0 : !fir.ref<!fir.box<!fir.heap<f32>>>
! CHECK: %[[addr:.*]] = fir.box_addr %[[box]] : (!fir.box<!fir.heap<f32>>) -> !fir.heap<f32>
! CHECK: %[[val:.*]] = fir.load %[[addr]] : !fir.heap<f32>
end subroutine
@@ -19,10 +20,10 @@ subroutine test_array(x)
integer, allocatable :: x(:,:)
print *, x(1,2)
- ! CHECK: %[[box:.*]] = fir.load %[[arg0]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?x?xi32>>>>
- ! CHECK-DAG: fir.box_addr %[[box]] : (!fir.box<!fir.heap<!fir.array<?x?xi32>>>) -> !fir.heap<!fir.array<?x?xi32>>
- ! CHECK-DAG: fir.box_dims %[[box]], %c0{{.*}} : (!fir.box<!fir.heap<!fir.array<?x?xi32>>>, index) -> (index, index, index)
- ! CHECK-DAG: fir.box_dims %[[box]], %c1{{.*}} : (!fir.box<!fir.heap<!fir.array<?x?xi32>>>, index) -> (index, index, index)
+ ! CHECK: %[[x:.*]]:2 = hlfir.declare %[[arg0]]{{.*}}allocatable
+ ! CHECK: %[[box:.*]] = fir.load %[[x]]#0 : !fir.ref<!fir.box<!fir.heap<!fir.array<?x?xi32>>>>
+ ! CHECK: %[[elem:.*]] = hlfir.designate %[[box]] (%{{.*}}, %{{.*}}) : (!fir.box<!fir.heap<!fir.array<?x?xi32>>>, index, index) -> !fir.ref<i32>
+ ! CHECK: fir.load %[[elem]] : !fir.ref<i32>
end subroutine
! CHECK-LABEL: func @_QPtest_char_scalar_deferred(
@@ -31,9 +32,11 @@ subroutine test_char_scalar_deferred(c)
character(:), allocatable :: c
external foo1
call foo1(c)
- ! CHECK: %[[box:.*]] = fir.load %[[arg0]] : !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>
+ ! CHECK: %[[c:.*]]:2 = hlfir.declare %[[arg0]]{{.*}}allocatable
+ ! CHECK: %[[box:.*]] = fir.load %[[c]]#0 : !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>
! CHECK-DAG: %[[addr:.*]] = fir.box_addr %[[box]] : (!fir.box<!fir.heap<!fir.char<1,?>>>) -> !fir.heap<!fir.char<1,?>>
- ! CHECK-DAG: %[[len:.*]] = fir.box_elesize %[[box]] : (!fir.box<!fir.heap<!fir.char<1,?>>>) -> index
+ ! CHECK-DAG: %[[box1:.*]] = fir.load %[[c]]#0 : !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>
+ ! CHECK-DAG: %[[len:.*]] = fir.box_elesize %[[box1]] : (!fir.box<!fir.heap<!fir.char<1,?>>>) -> index
! CHECK: %[[boxchar:.*]] = fir.emboxchar %[[addr]], %[[len]] : (!fir.heap<!fir.char<1,?>>, index) -> !fir.boxchar<1>
! CHECK: fir.call @_QPfoo1(%[[boxchar]]) {{.*}}: (!fir.boxchar<1>) -> ()
end subroutine
@@ -44,9 +47,11 @@ subroutine test_char_scalar_explicit_cst(c)
character(10), allocatable :: c
external foo1
call foo1(c)
- ! CHECK: %[[box:.*]] = fir.load %[[arg0]] : !fir.ref<!fir.box<!fir.heap<!fir.char<1,10>>>>
- ! CHECK-DAG: %[[addr:.*]] = fir.box_addr %[[box]] : (!fir.box<!fir.heap<!fir.char<1,10>>>) -> !fir.heap<!fir.char<1,10>>
- ! CHECK: %[[boxchar:.*]] = fir.emboxchar %[[addr]], %c10{{.*}} : (!fir.heap<!fir.char<1,10>>, index) -> !fir.boxchar<1>
+ ! CHECK: %[[c:.*]]:2 = hlfir.declare %[[arg0]]{{.*}}allocatable
+ ! CHECK: %[[box:.*]] = fir.load %[[c]]#0 : !fir.ref<!fir.box<!fir.heap<!fir.char<1,10>>>>
+ ! CHECK: %[[addr:.*]] = fir.box_addr %[[box]] : (!fir.box<!fir.heap<!fir.char<1,10>>>) -> !fir.heap<!fir.char<1,10>>
+ ! CHECK: %[[cast:.*]] = fir.convert %[[addr]] : (!fir.heap<!fir.char<1,10>>) -> !fir.ref<!fir.char<1,10>>
+ ! CHECK: %[[boxchar:.*]] = fir.emboxchar %[[cast]], %c10{{.*}} : (!fir.ref<!fir.char<1,10>>, index) -> !fir.boxchar<1>
! CHECK: fir.call @_QPfoo1(%[[boxchar]]) {{.*}}: (!fir.boxchar<1>) -> ()
end subroutine
@@ -57,17 +62,18 @@ subroutine test_char_scalar_explicit_dynamic(c, n)
character(n), allocatable :: c
external foo1
! Check that the length expr was evaluated before the execution parts.
- ! CHECK: %[[raw_len:.*]] = fir.load %arg1 : !fir.ref<i32>
- ! CHECK: %[[c0_i32:.*]] = arith.constant 0 : i32
- ! CHECK: %[[cmp:.*]] = arith.cmpi sgt, %[[raw_len]], %[[c0_i32]] : i32
- ! CHECK: %[[len:.*]] = arith.select %[[cmp]], %[[raw_len]], %[[c0_i32]] : i32
+ ! CHECK: %[[n:.*]]:2 = hlfir.declare %[[arg1]]
+ ! CHECK: %[[raw_len:.*]] = fir.load %[[n]]#0 : !fir.ref<i32>
+ ! CHECK: %[[c0_i32:.*]] = arith.constant 0 : i32
+ ! CHECK: %[[cmp:.*]] = arith.cmpi sgt, %[[raw_len]], %[[c0_i32]] : i32
+ ! CHECK: %[[len:.*]] = arith.select %[[cmp]], %[[raw_len]], %[[c0_i32]] : i32
+ ! CHECK: %[[c:.*]]:2 = hlfir.declare %[[arg0]] typeparams %[[len]]{{.*}}allocatable
n = n + 1
- ! CHECK: fir.store {{.*}} to %arg1 : !fir.ref<i32>
+ ! CHECK: hlfir.assign %{{.*}} to %[[n]]#0 : i32, !fir.ref<i32>
call foo1(c)
- ! CHECK: %[[box:.*]] = fir.load %[[arg0]] : !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>
- ! CHECK-DAG: %[[addr:.*]] = fir.box_addr %[[box]] : (!fir.box<!fir.heap<!fir.char<1,?>>>) -> !fir.heap<!fir.char<1,?>>
- ! CHECK-DAG: %[[len_cast:.*]] = fir.convert %[[len]] : (i32) -> index
- ! CHECK: %[[boxchar:.*]] = fir.emboxchar %[[addr]], %[[len_cast]] : (!fir.heap<!fir.char<1,?>>, index) -> !fir.boxchar<1>
+ ! CHECK: %[[box:.*]] = fir.load %[[c]]#0 : !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>
+ ! CHECK: %[[addr:.*]] = fir.box_addr %[[box]] : (!fir.box<!fir.heap<!fir.char<1,?>>>) -> !fir.heap<!fir.char<1,?>>
+ ! CHECK: %[[boxchar:.*]] = fir.emboxchar %[[addr]], %[[len]] : (!fir.heap<!fir.char<1,?>>, i32) -> !fir.boxchar<1>
! CHECK: fir.call @_QPfoo1(%[[boxchar]]) {{.*}}: (!fir.boxchar<1>) -> ()
end subroutine
@@ -77,12 +83,10 @@ subroutine test_char_array_deferred(c)
character(:), allocatable :: c(:)
external foo1
call foo1(c(10))
- ! CHECK: %[[box:.*]] = fir.load %[[arg0]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>>>
- ! CHECK-DAG: %[[addr:.*]] = fir.box_addr %[[box]] : (!fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>>) -> !fir.heap<!fir.array<?x!fir.char<1,?>>>
- ! CHECK-DAG: fir.box_dims %[[box]], %c0{{.*}} : (!fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>>, index) -> (index, index, index)
- ! CHECK-DAG: %[[len:.*]] = fir.box_elesize %[[box]] : (!fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>>) -> index
- ! [...] address computation
- ! CHECK: %[[boxchar:.*]] = fir.emboxchar %{{.*}}, %[[len]] : (!fir.ref<!fir.char<1,?>>, index) -> !fir.boxchar<1>
+ ! CHECK: %[[c:.*]]:2 = hlfir.declare %[[arg0]]{{.*}}allocatable
+ ! CHECK: %[[box:.*]] = fir.load %[[c]]#0 : !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>>>
+ ! CHECK: %[[len:.*]] = fir.box_elesize %[[box]] : (!fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>>) -> index
+ ! CHECK: %[[boxchar:.*]] = hlfir.designate %[[box]] (%{{.*}}) typeparams %[[len]] : (!fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>>, index, index) -> !fir.boxchar<1>
! CHECK: fir.call @_QPfoo1(%[[boxchar]]) {{.*}}: (!fir.boxchar<1>) -> ()
end subroutine
@@ -92,10 +96,10 @@ subroutine test_char_array_explicit_cst(c)
character(10), allocatable :: c(:)
external foo1
call foo1(c(3))
- ! CHECK: %[[box:.*]] = fir.load %[[arg0]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,10>>>>>
- ! CHECK-DAG: %[[addr:.*]] = fir.box_addr %[[box]] : (!fir.box<!fir.heap<!fir.array<?x!fir.char<1,10>>>>) -> !fir.heap<!fir.array<?x!fir.char<1,10>>>
- ! [...] address computation
- ! CHECK: %[[boxchar:.*]] = fir.emboxchar %{{.*}}, %c10{{.*}} : (!fir.ref<!fir.char<1,10>>, index) -> !fir.boxchar<1>
+ ! CHECK: %[[c:.*]]:2 = hlfir.declare %[[arg0]]{{.*}}allocatable
+ ! CHECK: %[[box:.*]] = fir.load %[[c]]#0 : !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,10>>>>>
+ ! CHECK: %[[elem:.*]] = hlfir.designate %[[box]] (%{{.*}}) typeparams %c10{{.*}} : (!fir.box<!fir.heap<!fir.array<?x!fir.char<1,10>>>>, index, index) -> !fir.ref<!fir.char<1,10>>
+ ! CHECK: %[[boxchar:.*]] = fir.emboxchar %[[elem]], %c10{{.*}} : (!fir.ref<!fir.char<1,10>>, index) -> !fir.boxchar<1>
! CHECK: fir.call @_QPfoo1(%[[boxchar]]) {{.*}}: (!fir.boxchar<1>) -> ()
end subroutine
@@ -106,19 +110,17 @@ subroutine test_char_array_explicit_dynamic(c, n)
character(n), allocatable :: c(:)
external foo1
! Check that the length expr was evaluated before the execution parts.
- ! CHECK: %[[raw_len:.*]] = fir.load %arg1 : !fir.ref<i32>
- ! CHECK: %[[c0_i32:.*]] = arith.constant 0 : i32
- ! CHECK: %[[cmp:.*]] = arith.cmpi sgt, %[[raw_len]], %[[c0_i32]] : i32
- ! CHECK: %[[len:.*]] = arith.select %[[cmp]], %[[raw_len]], %[[c0_i32]] : i32
+ ! CHECK: %[[n:.*]]:2 = hlfir.declare %[[arg1]]
+ ! CHECK: %[[raw_len:.*]] = fir.load %[[n]]#0 : !fir.ref<i32>
+ ! CHECK: %[[c0_i32:.*]] = arith.constant 0 : i32
+ ! CHECK: %[[cmp:.*]] = arith.cmpi sgt, %[[raw_len]], %[[c0_i32]] : i32
+ ! CHECK: %[[len:.*]] = arith.select %[[cmp]], %[[raw_len]], %[[c0_i32]] : i32
+ ! CHECK: %[[c:.*]]:2 = hlfir.declare %[[arg0]] typeparams %[[len]]{{.*}}allocatable
n = n + 1
- ! CHECK: fir.store {{.*}} to %arg1 : !fir.ref<i32>
+ ! CHECK: hlfir.assign %{{.*}} to %[[n]]#0 : i32, !fir.ref<i32>
call foo1(c(1))
- ! CHECK: %[[box:.*]] = fir.load %[[arg0]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>>>
- ! CHECK-DAG: %[[addr:.*]] = fir.box_addr %[[box]] : (!fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>>) -> !fir.heap<!fir.array<?x!fir.char<1,?>>>
- ! [...] address computation
- ! CHECK: fir.coordinate_of
- ! CHECK-DAG: %[[len_cast:.*]] = fir.convert %[[len]] : (i32) -> index
- ! CHECK: %[[boxchar:.*]] = fir.emboxchar %{{.*}}, %[[len_cast]] : (!fir.ref<!fir.char<1,?>>, index) -> !fir.boxchar<1>
+ ! CHECK: %[[box:.*]] = fir.load %[[c]]#0 : !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>>>
+ ! CHECK: %[[boxchar:.*]] = hlfir.designate %[[box]] (%{{.*}}) typeparams %[[len]] : (!fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>>, index, i32) -> !fir.boxchar<1>
! CHECK: fir.call @_QPfoo1(%[[boxchar]]) {{.*}}: (!fir.boxchar<1>) -> ()
end subroutine
@@ -131,9 +133,11 @@ subroutine test_char_scalar_deferred_k2(c)
character(kind=2, len=:), allocatable :: c
external foo2
call foo2(c)
- ! CHECK: %[[box:.*]] = fir.load %[[arg0]] : !fir.ref<!fir.box<!fir.heap<!fir.char<2,?>>>>
+ ! CHECK: %[[c:.*]]:2 = hlfir.declare %[[arg0]]{{.*}}allocatable
+ ! CHECK: %[[box:.*]] = fir.load %[[c]]#0 : !fir.ref<!fir.box<!fir.heap<!fir.char<2,?>>>>
! CHECK-DAG: %[[addr:.*]] = fir.box_addr %[[box]] : (!fir.box<!fir.heap<!fir.char<2,?>>>) -> !fir.heap<!fir.char<2,?>>
- ! CHECK-DAG: %[[size:.*]] = fir.box_elesize %[[box]] : (!fir.box<!fir.heap<!fir.char<2,?>>>) -> index
+ ! CHECK-DAG: %[[box1:.*]] = fir.load %[[c]]#0 : !fir.ref<!fir.box<!fir.heap<!fir.char<2,?>>>>
+ ! CHECK-DAG: %[[size:.*]] = fir.box_elesize %[[box1]] : (!fir.box<!fir.heap<!fir.char<2,?>>>) -> index
! CHECK-DAG: %[[len:.*]] = arith.divsi %[[size]], %c2{{.*}} : index
! CHECK: %[[boxchar:.*]] = fir.emboxchar %[[addr]], %[[len]] : (!fir.heap<!fir.char<2,?>>, index) -> !fir.boxchar<2>
! CHECK: fir.call @_QPfoo2(%[[boxchar]]) {{.*}}: (!fir.boxchar<2>) -> ()
@@ -149,10 +153,11 @@ subroutine test_char_assumed(a)
character(len=*), allocatable :: a
! CHECK: %[[argLoad:.*]] = fir.load %[[arg0]] : !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>
! CHECK: %[[argLen:.*]] = fir.box_elesize %[[argLoad]] : (!fir.box<!fir.heap<!fir.char<1,?>>>) -> index
+ ! CHECK: hlfir.declare %[[arg0]] typeparams %[[argLen]]{{.*}}allocatable
n = len(a)
! CHECK: %[[argLenCast:.*]] = fir.convert %[[argLen]] : (index) -> i32
- ! CHECK: fir.store %[[argLenCast]] to %{{.*}} : !fir.ref<i32>
+ ! CHECK: hlfir.assign %[[argLenCast]] to %{{.*}} : i32, !fir.ref<i32>
end subroutine
! CHECK-LABEL: _QPtest_char_assumed_optional(
@@ -168,10 +173,11 @@ subroutine test_char_assumed_optional(a)
! CHECK: } else {
! CHECK: %[[undef:.*]] = fir.undefined index
! CHECK: fir.result %[[undef]] : index
+ ! CHECK: %[[a:.*]]:2 = hlfir.declare %[[arg0]] typeparams %[[argLen]]{{.*}}allocatable, optional
if (present(a)) then
n = len(a)
! CHECK: %[[argLenCast:.*]] = fir.convert %[[argLen]] : (index) -> i32
- ! CHECK: fir.store %[[argLenCast]] to %{{.*}} : !fir.ref<i32>
+ ! CHECK: hlfir.assign %[[argLenCast]] to %{{.*}} : i32, !fir.ref<i32>
endif
end subroutine
diff --git a/flang/test/Lower/allocatable-caller.f90 b/flang/test/Lower/allocatable-caller.f90
index 0ea4cf342087e..c40c81705f1f6 100644
--- a/flang/test/Lower/allocatable-caller.f90
+++ b/flang/test/Lower/allocatable-caller.f90
@@ -1,4 +1,4 @@
-! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s
+! RUN: %flang_fc1 -emit-hlfir %s -o - | FileCheck %s
! Test passing allocatables on caller side
@@ -10,9 +10,10 @@ subroutine test_scalar(x)
end subroutine
end interface
real, allocatable :: x
- ! CHECK: %[[box:.*]] = fir.alloca !fir.box<!fir.heap<f32>> {{{.*}}uniq_name = "_QFtest_scalar_callEx"}
+ ! CHECK: %[[alloca:.*]] = fir.alloca !fir.box<!fir.heap<f32>> {{{.*}}uniq_name = "_QFtest_scalar_callEx"}
+ ! CHECK: %[[box:.*]]:2 = hlfir.declare %[[alloca]]{{.*}}allocatable
call test_scalar(x)
- ! CHECK: fir.call @_QPtest_scalar(%[[box]]) {{.*}}: (!fir.ref<!fir.box<!fir.heap<f32>>>) -> ()
+ ! CHECK: fir.call @_QPtest_scalar(%[[box]]#0) {{.*}}: (!fir.ref<!fir.box<!fir.heap<f32>>>) -> ()
end subroutine
! CHECK-LABEL: func @_QPtest_array_call(
@@ -23,9 +24,10 @@ subroutine test_array(x)
end subroutine
end interface
integer, allocatable :: x(:)
- ! CHECK: %[[box:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?xi32>>> {{{.*}}uniq_name = "_QFtest_array_callEx"}
+ ! CHECK: %[[alloca:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?xi32>>> {{{.*}}uniq_name = "_QFtest_array_callEx"}
+ ! CHECK: %[[box:.*]]:2 = hlfir.declare %[[alloca]]{{.*}}allocatable
call test_array(x)
- ! CHECK: fir.call @_QPtest_array(%[[box]]) {{.*}}: (!fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>) -> ()
+ ! CHECK: fir.call @_QPtest_array(%[[box]]#0) {{.*}}: (!fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>) -> ()
end subroutine
! CHECK-LABEL: func @_QPtest_char_scalar_deferred_call(
@@ -36,9 +38,10 @@ subroutine test_char_scalar_deferred(x)
end subroutine
end interface
character(:), allocatable :: x
- ! CHECK: %[[box:.*]] = fir.alloca !fir.box<!fir.heap<!fir.char<1,?>>> {{{.*}}uniq_name = "_QFtest_char_scalar_deferred_callEx"}
+ ! CHECK: %[[alloca:.*]] = fir.alloca !fir.box<!fir.heap<!fir.char<1,?>>> {{{.*}}uniq_name = "_QFtest_char_scalar_deferred_callEx"}
+ ! CHECK: %[[box:.*]]:2 = hlfir.declare %[[alloca]]{{.*}}allocatable
call test_char_scalar_deferred(x)
- ! CHECK: fir.call @_QPtest_char_scalar_deferred(%[[box]]) {{.*}}: (!fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>) -> ()
+ ! CHECK: fir.call @_QPtest_char_scalar_deferred(%[[box]]#0) {{.*}}: (!fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>) -> ()
end subroutine
! CHECK-LABEL: func @_QPtest_char_scalar_explicit_call(
@@ -51,12 +54,14 @@ subroutine test_char_scalar_explicit(x)
end interface
character(10), allocatable :: x
character(n), allocatable :: x2
- ! CHECK-DAG: %[[box:.*]] = fir.alloca !fir.box<!fir.heap<!fir.char<1,10>>> {{{.*}}uniq_name = "_QFtest_char_scalar_explicit_callEx"}
- ! CHECK-DAG: %[[box2:.*]] = fir.alloca !fir.box<!fir.heap<!fir.char<1,?>>> {{{.*}}uniq_name = "_QFtest_char_scalar_explicit_callEx...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/194772
More information about the flang-commits
mailing list