[flang-commits] [flang] [flang][NFC] Converted five tests from old lowering to new lowering (part 4) (PR #174906)
via flang-commits
flang-commits at lists.llvm.org
Wed Jan 7 19:50:24 PST 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-fir-hlfir
Author: Eugene Epshteyn (eugeneepshteyn)
<details>
<summary>Changes</summary>
>From this point on, the conversion is done to HLFIR, not to FIR.
Tests converted in Lower: allocatables.f90, allocate-source-pointers.f90, array-constructor-2.f90, array-elemental-calls-3.f90, array-elemental-calls.f90
---
Patch is 68.97 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/174906.diff
5 Files Affected:
- (modified) flang/test/Lower/allocatables.f90 (+59-53)
- (modified) flang/test/Lower/allocate-source-pointers.f90 (+104-286)
- (modified) flang/test/Lower/array-constructor-2.f90 (+64-83)
- (modified) flang/test/Lower/array-elemental-calls-3.f90 (+19-8)
- (modified) flang/test/Lower/array-elemental-calls.f90 (+28-50)
``````````diff
diff --git a/flang/test/Lower/allocatables.f90 b/flang/test/Lower/allocatables.f90
index 60b7de3301c48..2600162eee8c7 100644
--- a/flang/test/Lower/allocatables.f90
+++ b/flang/test/Lower/allocatables.f90
@@ -1,72 +1,76 @@
-! RUN: bbc --use-desc-for-alloc=false -emit-fir -hlfir=false %s -o - | FileCheck %s
+! RUN: bbc -emit-hlfir %s -o - | FileCheck %s
! Test lowering of allocatables using runtime for allocate/deallcoate statements.
! CHECK-LABEL: _QPfooscalar
subroutine fooscalar()
! Test lowering of local allocatable specification
real, allocatable :: x
- ! CHECK: %[[xAddrVar:.*]] = fir.alloca !fir.heap<f32> {{{.*}}uniq_name = "_QFfooscalarEx.addr"}
+ ! CHECK: %[[xAddrVar:.*]] = fir.alloca !fir.box<!fir.heap<f32>> {{{.*}}uniq_name = "_QFfooscalarEx"}
! CHECK: %[[nullAddr:.*]] = fir.zero_bits !fir.heap<f32>
- ! CHECK: fir.store %[[nullAddr]] to %[[xAddrVar]] : !fir.ref<!fir.heap<f32>>
+ ! CHECK: %[[box:.*]] = fir.embox %[[nullAddr]] : (!fir.heap<f32>) -> !fir.box<!fir.heap<f32>>
+ ! CHECK: fir.store %[[box]] to %[[xAddrVar]] : !fir.ref<!fir.box<!fir.heap<f32>>>
+ ! CHECK: %[[decl:.*]]:2 = hlfir.declare %[[xAddrVar]] {{{.*}}uniq_name = "_QFfooscalarEx"} : (!fir.ref<!fir.box<!fir.heap<f32>>>) -> (!fir.ref<!fir.box<!fir.heap<f32>>>, !fir.ref<!fir.box<!fir.heap<f32>>>)
! Test allocation of local allocatables
allocate(x)
! CHECK: %[[alloc:.*]] = fir.allocmem f32 {{{.*}}uniq_name = "_QFfooscalarEx.alloc"}
- ! CHECK: fir.store %[[alloc]] to %[[xAddrVar]] : !fir.ref<!fir.heap<f32>>
+ ! CHECK: %[[box2:.*]] = fir.embox %[[alloc]] : (!fir.heap<f32>) -> !fir.box<!fir.heap<f32>>
+ ! CHECK: fir.store %[[box2]] to %[[decl]]#0 : !fir.ref<!fir.box<!fir.heap<f32>>>
! Test reading allocatable bounds and extents
print *, x
- ! CHECK: %[[xAddr1:.*]] = fir.load %[[xAddrVar]] : !fir.ref<!fir.heap<f32>>
- ! CHECK: = fir.load %[[xAddr1]] : !fir.heap<f32>
+ ! CHECK: %[[xAddr1:.*]] = fir.load %[[decl]]#0 : !fir.ref<!fir.box<!fir.heap<f32>>>
+ ! CHECK: %[[addr:.*]] = fir.box_addr %[[xAddr1]] : (!fir.box<!fir.heap<f32>>) -> !fir.heap<f32>
+ ! CHECK: = fir.load %[[addr]] : !fir.heap<f32>
! Test deallocation
deallocate(x)
- ! CHECK: %[[xAddr2:.*]] = fir.load %[[xAddrVar]] : !fir.ref<!fir.heap<f32>>
- ! CHECK: fir.freemem %[[xAddr2]]
+ ! CHECK: %[[xAddr2:.*]] = fir.load %[[decl]]#0 : !fir.ref<!fir.box<!fir.heap<f32>>>
+ ! CHECK: %[[addr2:.*]] = fir.box_addr %[[xAddr2]] : (!fir.box<!fir.heap<f32>>) -> !fir.heap<f32>
+ ! CHECK: fir.freemem %[[addr2]]
! CHECK: %[[nullAddr1:.*]] = fir.zero_bits !fir.heap<f32>
- ! fir.store %[[nullAddr1]] to %[[xAddrVar]] : !fir.ref<!fir.heap<f32>>
+ ! CHECK: %[[box3:.*]] = fir.embox %[[nullAddr1]] : (!fir.heap<f32>) -> !fir.box<!fir.heap<f32>>
+ ! fir.store %[[box3]] to %[[decl]]#0 : !fir.ref<!fir.box<!fir.heap<f32>>>
end subroutine
! CHECK-LABEL: _QPfoodim1
subroutine foodim1()
! Test lowering of local allocatable specification
real, allocatable :: x(:)
- ! CHECK-DAG: %[[xAddrVar:.*]] = fir.alloca !fir.heap<!fir.array<?xf32>> {{{.*}}uniq_name = "_QFfoodim1Ex.addr"}
- ! CHECK-DAG: %[[xLbVar:.*]] = fir.alloca index {{{.*}}uniq_name = "_QFfoodim1Ex.lb0"}
- ! CHECK-DAG: %[[xExtVar:.*]] = fir.alloca index {{{.*}}uniq_name = "_QFfoodim1Ex.ext0"}
+ ! CHECK: %[[xAddrVar:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?xf32>>> {{{.*}}uniq_name = "_QFfoodim1Ex"}
! CHECK: %[[nullAddr:.*]] = fir.zero_bits !fir.heap<!fir.array<?xf32>>
- ! CHECK: fir.store %[[nullAddr]] to %[[xAddrVar]] : !fir.ref<!fir.heap<!fir.array<?xf32>>>
+ ! CHECK: %[[box:.*]] = fir.embox %[[nullAddr]]
+ ! CHECK: fir.store %[[box]] to %[[xAddrVar]]
! Test allocation of local allocatables
allocate(x(42:100))
- ! CHECK-DAG: %[[c42:.*]] = fir.convert %c42{{.*}} : (i32) -> index
- ! CHECK-DAG: %[[c100:.*]] = fir.convert %c100_i32 : (i32) -> index
- ! CHECK-DAG: %[[diff:.*]] = arith.subi %[[c100]], %[[c42]] : index
+ ! CHECK: %[[c42:.*]] = fir.convert %c42{{.*}} : (i32) -> index
+ ! CHECK: %[[c100:.*]] = fir.convert %c100_i32 : (i32) -> index
+ ! CHECK: %[[diff:.*]] = arith.subi %[[c100]], %[[c42]] : index
! CHECK: %[[rawExtent:.*]] = arith.addi %[[diff]], %c1{{.*}} : index
! CHECK: %[[extentPositive:.*]] = arith.cmpi sgt, %[[rawExtent]], %c0{{.*}} : index
! CHECK: %[[extent:.*]] = arith.select %[[extentPositive]], %[[rawExtent]], %c0{{.*}} : index
! CHECK: %[[alloc:.*]] = fir.allocmem !fir.array<?xf32>, %[[extent]] {{{.*}}uniq_name = "_QFfoodim1Ex.alloc"}
- ! CHECK-DAG: fir.store %[[alloc]] to %[[xAddrVar]] : !fir.ref<!fir.heap<!fir.array<?xf32>>>
- ! CHECK-DAG: fir.store %[[extent]] to %[[xExtVar]] : !fir.ref<index>
- ! CHECK-DAG: fir.store %[[c42]] to %[[xLbVar]] : !fir.ref<index>
+ ! CHECK: %[[shape:.*]] = fir.shape_shift %[[c42]], %[[extent]]
+ ! CHECK: %[[box2:.*]] = fir.embox %[[alloc]](%[[shape]])
+ ! CHECK: fir.store %[[box2]] to %{{.*}}
! Test reading allocatable bounds and extents
print *, x(42)
- ! CHECK-DAG: fir.load %[[xLbVar]] : !fir.ref<index>
- ! CHECK-DAG: fir.load %[[xAddrVar]] : !fir.ref<!fir.heap<!fir.array<?xf32>>>
+ ! CHECK: %[[load:.*]] = fir.load %{{.*}} : !fir.ref<!fir.box<!fir.heap<!fir.array<?xf32>>>>
+ ! CHECK: hlfir.designate %[[load]] (%c42)
deallocate(x)
- ! CHECK: %[[xAddr1:.*]] = fir.load %{{.*}} : !fir.ref<!fir.heap<!fir.array<?xf32>>>
- ! CHECK: fir.freemem %[[xAddr1]]
- ! CHECK: %[[nullAddr1:.*]] = fir.zero_bits !fir.heap<!fir.array<?xf32>>
- ! CHECK: fir.store %[[nullAddr1]] to %[[xAddrVar]] : !fir.ref<!fir.heap<!fir.array<?xf32>>>
+ ! CHECK: %[[load2:.*]] = fir.load %{{.*}} : !fir.ref<!fir.box<!fir.heap<!fir.array<?xf32>>>>
+ ! CHECK: %[[addr:.*]] = fir.box_addr %[[load2]]
+ ! CHECK: fir.freemem %[[addr]]
end subroutine
! CHECK-LABEL: _QPfoodim2
subroutine foodim2()
! Test lowering of local allocatable specification
real, allocatable :: x(:, :)
- ! CHECK-DAG: fir.alloca !fir.heap<!fir.array<?x?xf32>> {{{.*}}uniq_name = "_QFfoodim2Ex.addr"}
+ ! CHECK: fir.alloca !fir.box<!fir.heap<!fir.array<?x?xf32>>> {{{.*}}uniq_name = "_QFfoodim2Ex"}
end subroutine
! test lowering of character allocatables. Focus is placed on the length handling
@@ -74,35 +78,36 @@ subroutine foodim2()
subroutine char_deferred(n)
integer :: n
character(:), allocatable :: c
- ! CHECK-DAG: %[[cAddrVar:.*]] = fir.alloca !fir.heap<!fir.char<1,?>> {{{.*}}uniq_name = "_QFchar_deferredEc.addr"}
- ! CHECK-DAG: %[[cLenVar:.*]] = fir.alloca index {{{.*}}uniq_name = "_QFchar_deferredEc.len"}
+ ! CHECK: %[[cAddrVar:.*]] = fir.alloca !fir.box<!fir.heap<!fir.char<1,?>>> {{{.*}}uniq_name = "_QFchar_deferredEc"}
allocate(character(10):: c)
! CHECK: %[[c10:.]] = fir.convert %c10_i32 : (i32) -> index
- ! CHECK: fir.allocmem !fir.char<1,?>(%[[c10]] : index) {{{.*}}uniq_name = "_QFchar_deferredEc.alloc"}
- ! CHECK: fir.store %[[c10]] to %[[cLenVar]] : !fir.ref<index>
+ ! CHECK: %[[alloc:.*]] = fir.allocmem !fir.char<1,?>(%[[c10]] : index) {{{.*}}uniq_name = "_QFchar_deferredEc.alloc"}
+ ! CHECK: %[[box:.*]] = fir.embox %[[alloc]] typeparams %[[c10]]
+ ! CHECK: fir.store %[[box]] to %{{.*}}
deallocate(c)
! CHECK: fir.freemem %{{.*}}
allocate(character(n):: c)
- ! CHECK: %[[n:.*]] = fir.load %arg0 : !fir.ref<i32>
+ ! CHECK: %[[n:.*]] = fir.load %{{.*}} : !fir.ref<i32>
! CHECK: %[[nPositive:.*]] = arith.cmpi sgt, %[[n]], %c0{{.*}} : i32
! CHECK: %[[ns:.*]] = arith.select %[[nPositive]], %[[n]], %c0{{.*}} : i32
! CHECK: %[[ni:.*]] = fir.convert %[[ns]] : (i32) -> index
- ! CHECK: fir.allocmem !fir.char<1,?>(%[[ni]] : index) {{{.*}}uniq_name = "_QFchar_deferredEc.alloc"}
- ! CHECK: fir.store %[[ni]] to %[[cLenVar]] : !fir.ref<index>
+ ! CHECK: %[[alloc2:.*]] = fir.allocmem !fir.char<1,?>(%[[ni]] : index)
+ ! CHECK: %[[box2:.*]] = fir.embox %[[alloc2]] typeparams %[[ni]]
+ ! CHECK: fir.store %[[box2]] to %{{.*}}
call bar(c)
- ! CHECK-DAG: %[[cLen:.*]] = fir.load %[[cLenVar]] : !fir.ref<index>
- ! CHECK-DAG: %[[cAddr:.*]] = fir.load %[[cAddrVar]] : !fir.ref<!fir.heap<!fir.char<1,?>>>
- ! CHECK: fir.emboxchar %[[cAddr]], %[[cLen]] : (!fir.heap<!fir.char<1,?>>, index) -> !fir.boxchar<1>
+ ! CHECK: %[[load:.*]] = fir.load %{{.*}} : !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>
+ ! CHECK: %[[addr:.*]] = fir.box_addr %[[load]]
+ ! CHECK: %[[load2:.*]] = fir.load %{{.*}}
+ ! CHECK: %[[len:.*]] = fir.box_elesize %[[load2]]
+ ! CHECK: fir.emboxchar %[[addr]], %[[len]]
end subroutine
! CHECK-LABEL: _QPchar_explicit_cst(
subroutine char_explicit_cst(n)
integer :: n
character(10), allocatable :: c
- ! CHECK-DAG: %[[cLen:.*]] = arith.constant 10 : index
- ! CHECK-DAG: %[[cAddrVar:.*]] = fir.alloca !fir.heap<!fir.char<1,10>> {{{.*}}uniq_name = "_QFchar_explicit_cstEc.addr"}
- ! CHECK-NOT: "_QFchar_explicit_cstEc.len"
+ ! CHECK: %[[cAddrVar:.*]] = fir.alloca !fir.box<!fir.heap<!fir.char<1,10>>> {{{.*}}uniq_name = "_QFchar_explicit_cstEc"}
allocate(c)
! CHECK: fir.allocmem !fir.char<1,10> {{{.*}}uniq_name = "_QFchar_explicit_cstEc.alloc"}
deallocate(c)
@@ -114,20 +119,21 @@ subroutine char_explicit_cst(n)
allocate(character(10):: c)
! CHECK: fir.allocmem !fir.char<1,10> {{{.*}}uniq_name = "_QFchar_explicit_cstEc.alloc"}
call bar(c)
- ! CHECK: %[[cAddr:.*]] = fir.load %[[cAddrVar]] : !fir.ref<!fir.heap<!fir.char<1,10>>>
- ! CHECK: fir.emboxchar %[[cAddr]], %[[cLen]] : (!fir.heap<!fir.char<1,10>>, index) -> !fir.boxchar<1>
+ ! CHECK: %[[load:.*]] = fir.load %{{.*}}
+ ! CHECK: %[[addr:.*]] = fir.box_addr %[[load]]
+ ! CHECK: %[[cast:.*]] = fir.convert %[[addr]] : (!fir.heap<!fir.char<1,10>>) -> !fir.ref<!fir.char<1,10>>
+ ! CHECK: fir.emboxchar %[[cast]], %c10
end subroutine
! CHECK-LABEL: _QPchar_explicit_dyn(
subroutine char_explicit_dyn(l1, l2)
integer :: l1, l2
character(l1), allocatable :: c
- ! CHECK: %[[l1:.*]] = fir.load %arg0 : !fir.ref<i32>
+ ! CHECK: %[[cAddrVar:.*]] = fir.alloca !fir.box<!fir.heap<!fir.char<1,?>>> {{{.*}}uniq_name = "_QFchar_explicit_dynEc"}
+ ! CHECK: %[[l1:.*]] = fir.load %{{.*}} : !fir.ref<i32>
! CHECK: %[[c0_i32:.*]] = arith.constant 0 : i32
! CHECK: %[[cmp:.*]] = arith.cmpi sgt, %[[l1]], %[[c0_i32]] : i32
! CHECK: %[[cLen:.*]] = arith.select %[[cmp]], %[[l1]], %[[c0_i32]] : i32
- ! CHECK: %[[cAddrVar:.*]] = fir.alloca !fir.heap<!fir.char<1,?>> {{{.*}}uniq_name = "_QFchar_explicit_dynEc.addr"}
- ! CHECK-NOT: "_QFchar_explicit_dynEc.len"
allocate(c)
! CHECK: %[[cLenCast1:.*]] = fir.convert %[[cLen]] : (i32) -> index
! CHECK: fir.allocmem !fir.char<1,?>(%[[cLenCast1]] : index) {{{.*}}uniq_name = "_QFchar_explicit_dynEc.alloc"}
@@ -142,9 +148,9 @@ subroutine char_explicit_dyn(l1, l2)
! CHECK: %[[cLenCast3:.*]] = fir.convert %[[cLen]] : (i32) -> index
! CHECK: fir.allocmem !fir.char<1,?>(%[[cLenCast3]] : index) {{{.*}}uniq_name = "_QFchar_explicit_dynEc.alloc"}
call bar(c)
- ! CHECK-DAG: %[[cLenCast4:.*]] = fir.convert %[[cLen]] : (i32) -> index
- ! CHECK-DAG: %[[cAddr:.*]] = fir.load %[[cAddrVar]] : !fir.ref<!fir.heap<!fir.char<1,?>>>
- ! CHECK: fir.emboxchar %[[cAddr]], %[[cLenCast4]] : (!fir.heap<!fir.char<1,?>>, index) -> !fir.boxchar<1>
+ ! CHECK: %[[load:.*]] = fir.load %{{.*}}
+ ! CHECK: %[[addr:.*]] = fir.box_addr %[[load]]
+ ! CHECK: fir.emboxchar %[[addr]], %[[cLen]]
end subroutine
! CHECK-LABEL: _QPspecifiers(
@@ -155,16 +161,16 @@ subroutine specifiers
character*30 :: mmm = "None"
! CHECK: fir.call @_FortranAAllocatableSetBounds
! CHECK: [[RESULT:%[0-9]+]] = fir.call @_FortranAAllocatableAllocate
- ! CHECK: fir.store [[RESULT]] to [[STAT]]
+ ! CHECK: fir.store [[RESULT]] to %{{.*}}
! CHECK: fir.if %{{[0-9]+}} {
! CHECK: fir.call @_FortranAAllocatableSetBounds
! CHECK: fir.call @_FortranAAllocatableSetBounds
! CHECK: [[RESULT:%[0-9]+]] = fir.call @_FortranAAllocatableAllocate
- ! CHECK: fir.store [[RESULT]] to [[STAT]]
+ ! CHECK: fir.store [[RESULT]] to %{{.*}}
! CHECK: fir.if %{{[0-9]+}} {
! CHECK: fir.call @_FortranAAllocatableSetBounds
! CHECK: [[RESULT:%[0-9]+]] = fir.call @_FortranAAllocatableAllocate
- ! CHECK: fir.store [[RESULT]] to [[STAT]]
+ ! CHECK: fir.store [[RESULT]] to %{{.*}}
! CHECK-NOT: fir.if %{{[0-9]+}} {
! CHECK-COUNT-2: }
! CHECK-NOT: }
@@ -178,13 +184,13 @@ subroutine specifiers
! CHECK: [[RESULT:%[0-9]+]] = fir.call @_FortranAAllocatableAllocate
allocate(jj1(3), jj2(3,3), jj3(3), stat=sss, errmsg=mmm)
! CHECK: [[RESULT:%[0-9]+]] = fir.call @_FortranAAllocatableDeallocate
- ! CHECK: fir.store [[RESULT]] to [[STAT]]
+ ! CHECK: fir.store [[RESULT]] to %{{.*}}
! CHECK: fir.if %{{[0-9]+}} {
! CHECK: [[RESULT:%[0-9]+]] = fir.call @_FortranAAllocatableDeallocate
- ! CHECK: fir.store [[RESULT]] to [[STAT]]
+ ! CHECK: fir.store [[RESULT]] to %{{.*}}
! CHECK: fir.if %{{[0-9]+}} {
! CHECK: [[RESULT:%[0-9]+]] = fir.call @_FortranAAllocatableDeallocate
- ! CHECK: fir.store [[RESULT]] to [[STAT]]
+ ! CHECK: fir.store [[RESULT]] to %{{.*}}
! CHECK-NOT: fir.if %{{[0-9]+}} {
! CHECK-COUNT-2: }
! CHECK-NOT: }
diff --git a/flang/test/Lower/allocate-source-pointers.f90 b/flang/test/Lower/allocate-source-pointers.f90
index 7e6ef0c049c06..0a144e494fbb1 100644
--- a/flang/test/Lower/allocate-source-pointers.f90
+++ b/flang/test/Lower/allocate-source-pointers.f90
@@ -1,20 +1,23 @@
-! RUN: bbc --use-desc-for-alloc=false -emit-fir -hlfir=false %s -o - | FileCheck %s
+! RUN: bbc -emit-hlfir %s -o - | FileCheck %s
! Test lowering of pointers for allocate statements with source.
! CHECK-LABEL: func.func @_QPtest_pointer_scalar(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<f32> {fir.bindc_name = "a"}) {
-! CHECK: %[[VAL_1:.*]] = fir.address_of(@_QFtest_pointer_scalarEx1) : !fir.ref<!fir.box<!fir.ptr<f32>>>
-! CHECK: %[[VAL_2:.*]] = fir.address_of(@_QFtest_pointer_scalarEx2) : !fir.ref<!fir.box<!fir.ptr<f32>>>
-! CHECK: %[[VAL_3:.*]] = arith.constant false
-! CHECK: %[[VAL_4:.*]] = fir.absent !fir.box<none>
-! CHECK: %[[VAL_7:.*]] = fir.embox %[[VAL_0]] : (!fir.ref<f32>) -> !fir.box<f32>
-! CHECK: %[[VAL_8:.*]] = fir.zero_bits !fir.ptr<f32>
-! CHECK: %[[VAL_9:.*]] = fir.embox %[[VAL_8]] : (!fir.ptr<f32>) -> !fir.box<!fir.ptr<f32>>
-! CHECK: fir.store %[[VAL_9]] to %[[VAL_1]] : !fir.ref<!fir.box<!fir.ptr<f32>>>
-! CHECK: %[[VAL_10:.*]] = fir.convert %[[VAL_1]] : (!fir.ref<!fir.box<!fir.ptr<f32>>>) -> !fir.ref<!fir.box<none>>
-! CHECK: %[[VAL_11:.*]] = fir.convert %[[VAL_7]] : (!fir.box<f32>) -> !fir.box<none>
-! CHECK: %[[VAL_13:.*]] = fir.call @_FortranAPointerAllocateSource(%[[VAL_10]], %[[VAL_11]], %[[VAL_3]], %[[VAL_4]], %{{.*}}, %{{.*}}) {{.*}}: (!fir.ref<!fir.box<none>>, !fir.box<none>, i1, !fir.box<none>, !fir.ref<i8>, i32) -> i32
+! CHECK-SAME: %[[ARG0:.*]]: !fir.ref<f32>
+! CHECK: %[[DECL_A:.*]]:2 = hlfir.declare %[[ARG0]]
+! CHECK: %[[ADDR_X1:.*]] = fir.address_of(@_QFtest_pointer_scalarEx1)
+! CHECK: %[[DECL_X1:.*]]:2 = hlfir.declare %[[ADDR_X1]]
+! CHECK: %[[ADDR_X2:.*]] = fir.address_of(@_QFtest_pointer_scalarEx2)
+! CHECK: %[[DECL_X2:.*]]:2 = hlfir.declare %[[ADDR_X2]]
+! CHECK: %[[FALSE:.*]] = arith.constant false
+! CHECK: %[[ABSENT:.*]] = fir.absent !fir.box<none>
+! CHECK: %[[BOX_A:.*]] = fir.embox %[[DECL_A]]#0
+! CHECK: %[[BOX_X1:.*]] = fir.convert %[[DECL_X1]]#0
+! CHECK: %[[BOX_SOURCE:.*]] = fir.convert %[[BOX_A]]
+! CHECK: fir.call @_FortranAPointerAllocateSource(%[[BOX_X1]], %[[BOX_SOURCE]], %[[FALSE]], %[[ABSENT]], %{{.*}}, %{{.*}})
+! CHECK: %[[BOX_X2:.*]] = fir.convert %[[DECL_X2]]#0
+! CHECK: %[[BOX_SOURCE_2:.*]] = fir.convert %[[BOX_A]]
+! CHECK: fir.call @_FortranAPointerAllocateSource(%[[BOX_X2]], %[[BOX_SOURCE_2]], %[[FALSE]], %[[ABSENT]], %{{.*}}, %{{.*}})
subroutine test_pointer_scalar(a)
real, save, pointer :: x1, x2
@@ -24,67 +27,32 @@ subroutine test_pointer_scalar(a)
end
! CHECK-LABEL: func.func @_QPtest_pointer_2d_array(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i32> {fir.bindc_name = "n"},
-! CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<!fir.array<?x?xi32>> {fir.bindc_name = "a"}) {
-! CHECK: %[[VAL_2:.*]] = fir.alloca i32 {bindc_name = "sss", uniq_name = "_QFtest_pointer_2d_arrayEsss"}
-! CHECK: %[[VAL_3:.*]] = fir.alloca !fir.box<!fir.ptr<!fir.array<?x?xi32>>> {bindc_name = "x1", uniq_name = "_QFtest_pointer_2d_arrayEx1"}
-! CHECK: %[[VAL_4:.*]] = fir.zero_bits !fir.ptr<!fir.array<?x?xi32>>
-! CHECK: %[[VAL_5:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_6:.*]] = fir.shape %[[VAL_5]], %[[VAL_5]] : (index, index) -> !fir.shape<2>
-! CHECK: %[[VAL_7:.*]] = fir.embox %[[VAL_4]](%[[VAL_6]]) : (!fir.ptr<!fir.array<?x?xi32>>, !fir.shape<2>) -> !fir.box<!fir.ptr<!fir.array<?x?xi32>>>
-! CHECK: fir.store %[[VAL_7]] to %[[VAL_3]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?x?xi32>>>>
-! CHECK: %[[VAL_8:.*]] = fir.alloca !fir.box<!fir.ptr<!fir.array<?x?xi32>>> {bindc_name = "x2", uniq_name = "_QFtest_pointer_2d_arrayEx2"}
-! CHECK: %[[VAL_13:.*]] = fir.alloca !fir.box<!fir.ptr<!fir.array<?x?xi32>>> {bindc_name = "x3", uniq_name = "_QFtest_pointer_2d_arrayEx3"}
-! CHECK: %[[VAL_18:.*]] = fir.load %[[VAL_0]] : !fir.ref<i32>
-! CHECK: %[[VAL_19:.*]] = fir.convert %[[VAL_18]] : (i32) -> i64
-! CHECK: %[[VAL_20:.*]] = fir.convert %[[VAL_19]] : (i64) -> index
-! CHECK: %[[VAL_21:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_22:.*]] = arith.cmpi sgt, %[[VAL_20]], %[[VAL_21]] : index
-! CHECK: %[[VAL_23:.*]] = arith.select %[[VAL_22]], %[[VAL_20]], %[[VAL_21]] : index
-! CHECK: %[[VAL_24:.*]] = fir.load %[[VAL_0]] : !fir.ref<i32>
-! CHECK: %[[VAL_25:.*]] = fir.convert %[[VAL_24]] : (i32) -> i64
-! CHECK: %[[VAL_26:.*]] = fir.convert %[[VAL_25]] : (i64) -> index
-! CHECK: %[[VAL_27:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_28:.*]] = arith.cmpi sgt, %[[VAL_26]], %[[VAL_27]] : index
-! CHECK: %[[VAL_29:.*]] = arith.select %[[VAL_28]], %[[VAL_26]], %[[VAL_27]] : index
-! CHECK: %[[VAL_30:.*]] = arith.constant false
-! CHECK: %[[VAL_31:.*]] = fir.absent !fir.box<none>
-! CHECK: %[[VAL_34:.*]] = fir.shape %[[VAL_23]], %[[VAL_29]] : (index, index) -> !fir.shape<2>
-! CHECK: %[[VAL_35:.*]] = fir.embox %[[VAL_1]](%[[VAL_34]]) : (!fir.ref<!fir.array<?x?xi32>>, !fir.shape<2>) -> !fir.box<!fir.array<?x?xi32>>
-! CHECK: %[[VAL_36:.*]] = fir.zero_bits !fir.ptr<!fir.array<?x?xi32>>
-! CHECK: %[[VAL_37:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_38:.*]] = fir.shape %[[VAL_37]], %[[VAL_37]] : (index, index) -> !fir.shape<2>
-! CHECK: %[[VAL_39:.*]] = fir.embox %[[VAL_36]](%[[VAL_38]]) : (!fir.ptr<!fir.array<?x?xi32>>, !fir.shape<2>) -> !fir.box<!fir.ptr<!fir.array<?x?xi32>>>
-! CHECK: fir.store %[[VAL_39]] to %[[VAL_3]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?x?xi32>>>>
-! CHECK: %[[VAL_40:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_41:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_42:.*]]:3 = fir.box_dims %[[VAL_35]], %[[VAL_41]] : (!fir.box<!fir.array<?x?xi32>>, index) -> (index, index, index)
-! CHECK: %[[VAL_43:.*]] = arith.addi %[[VAL_42]]#1, %[[VAL_40]] : index
-! CHECK: %[[VAL_44:.*]] = arith.subi %[[VAL_43]], %[[VAL_40]] : index
-! CHECK: %[[VAL_45:.*]] = arith.constant 0 : i32
-! CHECK: %[[VAL_46:.*]] = fir.convert %[[VAL_3]] : (!fir.ref<!fir.box<!fir.ptr<!fir.array<?x?xi32>>>>) -> !fir.ref<!fir.box<none>>
-! CHECK: %[[VAL_47:.*]] = fir.convert %[[VAL_40]] : (index) -> i64
-! CHECK: %[[VAL_48:.*]] = fir.convert %[[VAL_44]] : (index) -> i64
-! CHECK: fir.call @_FortranAPointerSetBounds(%[[VAL_46]], %[[VAL_45]], %[[VAL_47]], %[[VAL_48]]) {{.*}}: (!fir.ref<!fir.box<none>>, i32, i64, i64) -> ()
-! CHECK: %[[VAL_50:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_51:.*]]:3 = fir.box_dims %[[VAL_35]], %[[VAL_50]] : (!fir.box<!fir.array<?x?xi32>>, index) -> (index, index, index)
-! CHECK: %[[VAL_52:.*]] = arith.addi %[[VAL_51]]#1, %[[VAL_40]] : index
-! CHECK: %[[VAL_53:.*]] = arith.subi %[[VAL_52]], %[[VAL_40]] : index
-! CHECK: %[[VAL_54:.*]] = arith.constant 1 : i32
-! CHE...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/174906
More information about the flang-commits
mailing list