[flang-commits] [flang] [flang][NFC] Converted five tests from old lowering to new lowering (part 48) (PR #193889)
via flang-commits
flang-commits at lists.llvm.org
Fri Apr 24 03:14:56 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-fir-hlfir
Author: Eugene Epshteyn (eugeneepshteyn)
<details>
<summary>Changes</summary>
Tests converted from test/Lower: pointer-args-caller.f90, pointer-assignments.f90, pointer-association-polymorphic.f90, pointer-default-init.f90, pointer-disassociate.f90
---
Patch is 82.79 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/193889.diff
5 Files Affected:
- (modified) flang/test/Lower/pointer-args-caller.f90 (+38-27)
- (modified) flang/test/Lower/pointer-assignments.f90 (+160-147)
- (modified) flang/test/Lower/pointer-association-polymorphic.f90 (+73-93)
- (modified) flang/test/Lower/pointer-default-init.f90 (+5-4)
- (modified) flang/test/Lower/pointer-disassociate.f90 (+38-36)
``````````diff
diff --git a/flang/test/Lower/pointer-args-caller.f90 b/flang/test/Lower/pointer-args-caller.f90
index 2fba599b302f8..4fc56bbb333ea 100644
--- a/flang/test/Lower/pointer-args-caller.f90
+++ b/flang/test/Lower/pointer-args-caller.f90
@@ -1,5 +1,5 @@
! Test calls with POINTER dummy arguments on the caller side.
-! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s
+! RUN: %flang_fc1 -emit-hlfir %s -o - | FileCheck %s
module call_defs
interface
@@ -23,34 +23,37 @@ subroutine non_deferred_char_array_ptr(p)
! -----------------------------------------------------------------------------
! CHECK-LABEL: func @_QMcall_defsPtest_ptr_to_scalar_ptr(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.ptr<i32>>> {fir.bindc_name = "p"}) {
+! CHECK-SAME: %[[ARG0:.*]]: !fir.ref<!fir.box<!fir.ptr<i32>>> {fir.bindc_name = "p"}) {
subroutine test_ptr_to_scalar_ptr(p)
integer, pointer :: p
-! CHECK: fir.call @_QPscalar_ptr(%[[VAL_0]]) {{.*}}: (!fir.ref<!fir.box<!fir.ptr<i32>>>) -> ()
+! CHECK: %[[VAL_0:.*]]:2 = hlfir.declare %[[ARG0]]
+! CHECK: fir.call @_QPscalar_ptr(%[[VAL_0]]#0) {{.*}}: (!fir.ref<!fir.box<!fir.ptr<i32>>>) -> ()
call scalar_ptr(p)
end subroutine
! CHECK-LABEL: func @_QMcall_defsPtest_ptr_to_array_ptr(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>> {fir.bindc_name = "p"}) {
+! CHECK-SAME: %[[ARG0:.*]]: !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>> {fir.bindc_name = "p"}) {
subroutine test_ptr_to_array_ptr(p)
integer, pointer :: p(:)
call array_ptr(p)
end subroutine
! CHECK-LABEL: func @_QMcall_defsPtest_ptr_to_char_array_ptr(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.ptr<!fir.array<?x!fir.char<1,?>>>>> {fir.bindc_name = "p"}) {
+! CHECK-SAME: %[[ARG0:.*]]: !fir.ref<!fir.box<!fir.ptr<!fir.array<?x!fir.char<1,?>>>>> {fir.bindc_name = "p"}) {
subroutine test_ptr_to_char_array_ptr(p)
character(:), pointer :: p(:)
-! CHECK: fir.call @_QPchar_array_ptr(%[[VAL_0]]) {{.*}}: (!fir.ref<!fir.box<!fir.ptr<!fir.array<?x!fir.char<1,?>>>>>) -> ()
+! CHECK: %[[VAL_0:.*]]:2 = hlfir.declare %[[ARG0]]
+! CHECK: fir.call @_QPchar_array_ptr(%[[VAL_0]]#0) {{.*}}: (!fir.ref<!fir.box<!fir.ptr<!fir.array<?x!fir.char<1,?>>>>>) -> ()
call char_array_ptr(p)
end subroutine
! CHECK-LABEL: func @_QMcall_defsPtest_ptr_to_non_deferred_char_array_ptr(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.ptr<!fir.array<?x!fir.char<1,?>>>>> {fir.bindc_name = "p"}
+! CHECK-SAME: %[[ARG0:.*]]: !fir.ref<!fir.box<!fir.ptr<!fir.array<?x!fir.char<1,?>>>>> {fir.bindc_name = "p"}
subroutine test_ptr_to_non_deferred_char_array_ptr(p, n)
integer :: n
character(n), pointer :: p(:)
-! CHECK: %[[VAL_1:.*]] = fir.convert %[[VAL_0]] : (!fir.ref<!fir.box<!fir.ptr<!fir.array<?x!fir.char<1,?>>>>>) -> !fir.ref<!fir.box<!fir.ptr<!fir.array<?x!fir.char<1,10>>>>>
+! CHECK: %[[VAL_P:.*]]:2 = hlfir.declare %[[ARG0]] typeparams %{{.*}}
+! CHECK: %[[VAL_1:.*]] = fir.convert %[[VAL_P]]#0 : (!fir.ref<!fir.box<!fir.ptr<!fir.array<?x!fir.char<1,?>>>>>) -> !fir.ref<!fir.box<!fir.ptr<!fir.array<?x!fir.char<1,10>>>>>
! CHECK: fir.call @_QPnon_deferred_char_array_ptr(%[[VAL_1]]) {{.*}}: (!fir.ref<!fir.box<!fir.ptr<!fir.array<?x!fir.char<1,10>>>>>) -> ()
call non_deferred_char_array_ptr(p)
end subroutine
@@ -60,29 +63,31 @@ subroutine test_ptr_to_non_deferred_char_array_ptr(p, n)
! -----------------------------------------------------------------------------
! CHECK-LABEL: func @_QMcall_defsPtest_non_ptr_to_scalar_ptr(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i32> {fir.bindc_name = "p", fir.target}) {
+! CHECK-SAME: %[[ARG0:.*]]: !fir.ref<i32> {fir.bindc_name = "p", fir.target}) {
subroutine test_non_ptr_to_scalar_ptr(p)
integer, target :: p
! CHECK: %[[VAL_1:.*]] = fir.alloca !fir.box<!fir.ptr<i32>>
-! CHECK: %[[VAL_2:.*]] = fir.embox %[[VAL_0]] : (!fir.ref<i32>) -> !fir.box<!fir.ptr<i32>>
+! CHECK: %[[VAL_P:.*]]:2 = hlfir.declare %[[ARG0]]
+! CHECK: %[[VAL_2:.*]] = fir.embox %[[VAL_P]]#0 : (!fir.ref<i32>) -> !fir.box<!fir.ptr<i32>>
! CHECK: fir.store %[[VAL_2]] to %[[VAL_1]] : !fir.ref<!fir.box<!fir.ptr<i32>>>
! CHECK: fir.call @_QPscalar_ptr(%[[VAL_1]]) {{.*}}: (!fir.ref<!fir.box<!fir.ptr<i32>>>) -> ()
call scalar_ptr(p)
end subroutine
! CHECK-LABEL: func @_QMcall_defsPtest_non_ptr_to_array_ptr(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?xi32>> {fir.bindc_name = "p", fir.target}) {
+! CHECK-SAME: %[[ARG0:.*]]: !fir.box<!fir.array<?xi32>> {fir.bindc_name = "p", fir.target}) {
subroutine test_non_ptr_to_array_ptr(p)
integer, target :: p(:)
! CHECK: %[[VAL_1:.*]] = fir.alloca !fir.box<!fir.ptr<!fir.array<?xi32>>>
-! CHECK: %[[VAL_2:.*]] = fir.rebox %[[VAL_0]] : (!fir.box<!fir.array<?xi32>>) -> !fir.box<!fir.ptr<!fir.array<?xi32>>>
+! CHECK: %[[VAL_P:.*]]:2 = hlfir.declare %[[ARG0]]
+! CHECK: %[[VAL_2:.*]] = fir.rebox %[[VAL_P]]#1 : (!fir.box<!fir.array<?xi32>>) -> !fir.box<!fir.ptr<!fir.array<?xi32>>>
! CHECK: fir.store %[[VAL_2]] to %[[VAL_1]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>
! CHECK: fir.call @_QParray_ptr(%[[VAL_1]]) {{.*}}: (!fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>) -> ()
call array_ptr(p)
end subroutine
! CHECK-LABEL: func @_QMcall_defsPtest_non_ptr_to_array_ptr_lower_bounds(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?xi32>> {fir.bindc_name = "p", fir.target}) {
+! CHECK-SAME: %[[ARG0:.*]]: !fir.box<!fir.array<?xi32>> {fir.bindc_name = "p", fir.target}) {
subroutine test_non_ptr_to_array_ptr_lower_bounds(p)
! Test that local lower bounds of the actual argument are applied.
integer, target :: p(42:)
@@ -90,50 +95,56 @@ subroutine test_non_ptr_to_array_ptr_lower_bounds(p)
! CHECK: %[[VAL_2:.*]] = arith.constant 42 : i64
! CHECK: %[[VAL_3:.*]] = fir.convert %[[VAL_2]] : (i64) -> index
! CHECK: %[[VAL_4:.*]] = fir.shift %[[VAL_3]] : (index) -> !fir.shift<1>
- ! CHECK: %[[VAL_5:.*]] = fir.rebox %[[VAL_0]](%[[VAL_4]]) : (!fir.box<!fir.array<?xi32>>, !fir.shift<1>) -> !fir.box<!fir.ptr<!fir.array<?xi32>>>
+ ! CHECK: %[[VAL_P:.*]]:2 = hlfir.declare %[[ARG0]](%[[VAL_4]])
+ ! CHECK: %[[VAL_SHIFT2:.*]] = fir.shift %[[VAL_3]] : (index) -> !fir.shift<1>
+ ! CHECK: %[[VAL_5:.*]] = fir.rebox %[[VAL_P]]#1(%[[VAL_SHIFT2]]) : (!fir.box<!fir.array<?xi32>>, !fir.shift<1>) -> !fir.box<!fir.ptr<!fir.array<?xi32>>>
! CHECK: fir.store %[[VAL_5]] to %[[VAL_1]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>
! CHECK: fir.call @_QParray_ptr(%[[VAL_1]]) {{.*}}: (!fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>) -> ()
call array_ptr(p)
end subroutine
! CHECK-LABEL: func @_QMcall_defsPtest_non_ptr_to_char_array_ptr(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.boxchar<1> {fir.bindc_name = "p", fir.target}) {
+! CHECK-SAME: %[[ARG0:.*]]: !fir.boxchar<1> {fir.bindc_name = "p", fir.target}) {
subroutine test_non_ptr_to_char_array_ptr(p)
character(10), target :: p(10)
! CHECK: %[[VAL_1:.*]] = fir.alloca !fir.box<!fir.ptr<!fir.array<?x!fir.char<1,?>>>>
-! CHECK: %[[VAL_2:.*]]:2 = fir.unboxchar %[[VAL_0]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
-! CHECK: %[[VAL_4:.*]] = fir.convert %[[VAL_2]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<10x!fir.char<1,10>>>
-! CHECK: %[[VAL_3:.*]] = arith.constant 10 : index
-! CHECK: %[[VAL_5:.*]] = arith.constant 10 : index
-! CHECK: %[[VAL_6:.*]] = fir.shape %[[VAL_5]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_7:.*]] = fir.convert %[[VAL_4]] : (!fir.ref<!fir.array<10x!fir.char<1,10>>>) -> !fir.ref<!fir.array<?x!fir.char<1,?>>>
-! CHECK: %[[VAL_8:.*]] = fir.embox %[[VAL_7]](%[[VAL_6]]) typeparams %[[VAL_3]] : (!fir.ref<!fir.array<?x!fir.char<1,?>>>, !fir.shape<1>, index) -> !fir.box<!fir.ptr<!fir.array<?x!fir.char<1,?>>>>
+! CHECK: %[[VAL_2:.*]]:2 = fir.unboxchar %[[ARG0]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
+! CHECK: %[[VAL_3:.*]] = fir.convert %[[VAL_2]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<10x!fir.char<1,10>>>
+! CHECK: %[[C10:.*]] = arith.constant 10 : index
+! CHECK: %[[C10_2:.*]] = arith.constant 10 : index
+! CHECK: %[[SHAPE:.*]] = fir.shape %[[C10_2]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_P:.*]]:2 = hlfir.declare %[[VAL_3]](%[[SHAPE]]) typeparams %[[C10]]
+! CHECK: %[[SHAPE2:.*]] = fir.shape %[[C10_2]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_4:.*]] = fir.convert %[[VAL_P]]#0 : (!fir.ref<!fir.array<10x!fir.char<1,10>>>) -> !fir.ref<!fir.array<?x!fir.char<1,?>>>
+! CHECK: %[[VAL_8:.*]] = fir.embox %[[VAL_4]](%[[SHAPE2]]) typeparams %[[C10]] : (!fir.ref<!fir.array<?x!fir.char<1,?>>>, !fir.shape<1>, index) -> !fir.box<!fir.ptr<!fir.array<?x!fir.char<1,?>>>>
! CHECK: fir.store %[[VAL_8]] to %[[VAL_1]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?x!fir.char<1,?>>>>>
! CHECK: fir.call @_QPchar_array_ptr(%[[VAL_1]]) {{.*}}: (!fir.ref<!fir.box<!fir.ptr<!fir.array<?x!fir.char<1,?>>>>>) -> ()
call char_array_ptr(p)
end subroutine
! CHECK-LABEL: func @_QMcall_defsPtest_non_ptr_to_non_deferred_char_array_ptr(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?x!fir.char<1,?>>> {fir.bindc_name = "p", fir.target}) {
+! CHECK-SAME: %[[ARG0:.*]]: !fir.box<!fir.array<?x!fir.char<1,?>>> {fir.bindc_name = "p", fir.target}) {
subroutine test_non_ptr_to_non_deferred_char_array_ptr(p)
character(*), target :: p(:)
! CHECK: %[[VAL_1:.*]] = fir.alloca !fir.box<!fir.ptr<!fir.array<?x!fir.char<1,10>>>>
-! CHECK: %[[VAL_2:.*]] = fir.rebox %[[VAL_0]] : (!fir.box<!fir.array<?x!fir.char<1,?>>>) -> !fir.box<!fir.ptr<!fir.array<?x!fir.char<1,10>>>>
+! CHECK: %[[VAL_P:.*]]:2 = hlfir.declare %[[ARG0]]
+! CHECK: %[[VAL_2:.*]] = fir.rebox %[[VAL_P]]#1 : (!fir.box<!fir.array<?x!fir.char<1,?>>>) -> !fir.box<!fir.ptr<!fir.array<?x!fir.char<1,10>>>>
! CHECK: fir.store %[[VAL_2]] to %[[VAL_1]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?x!fir.char<1,10>>>>>
! CHECK: fir.call @_QPnon_deferred_char_array_ptr(%[[VAL_1]]) {{.*}}: (!fir.ref<!fir.box<!fir.ptr<!fir.array<?x!fir.char<1,10>>>>>) -> ()
call non_deferred_char_array_ptr(p)
end subroutine
! CHECK-LABEL: func @_QMcall_defsPtest_allocatable_to_array_ptr(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>> {fir.bindc_name = "p", fir.target}) {
+! CHECK-SAME: %[[ARG0:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>> {fir.bindc_name = "p", fir.target}) {
subroutine test_allocatable_to_array_ptr(p)
integer, allocatable, target :: p(:)
call array_ptr(p)
! CHECK: %[[VAL_1:.*]] = fir.alloca !fir.box<!fir.ptr<!fir.array<?xi32>>>
- ! CHECK: %[[VAL_2:.*]] = fir.load %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>
+ ! CHECK: %[[VAL_P:.*]]:2 = hlfir.declare %[[ARG0]]
+ ! CHECK: %[[VAL_2:.*]] = fir.load %[[VAL_P]]#0 : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>
+ ! CHECK: %[[VAL_5:.*]] = fir.box_addr %[[VAL_2]] : (!fir.box<!fir.heap<!fir.array<?xi32>>>) -> !fir.heap<!fir.array<?xi32>>
! CHECK: %[[VAL_3:.*]] = arith.constant 0 : index
! CHECK: %[[VAL_4:.*]]:3 = fir.box_dims %[[VAL_2]], %[[VAL_3]] : (!fir.box<!fir.heap<!fir.array<?xi32>>>, index) -> (index, index, index)
- ! CHECK: %[[VAL_5:.*]] = fir.box_addr %[[VAL_2]] : (!fir.box<!fir.heap<!fir.array<?xi32>>>) -> !fir.heap<!fir.array<?xi32>>
! CHECK: %[[VAL_6:.*]] = fir.shape_shift %[[VAL_4]]#0, %[[VAL_4]]#1 : (index, index) -> !fir.shapeshift<1>
! CHECK: %[[VAL_7:.*]] = fir.embox %[[VAL_5]](%[[VAL_6]]) : (!fir.heap<!fir.array<?xi32>>, !fir.shapeshift<1>) -> !fir.box<!fir.ptr<!fir.array<?xi32>>>
! CHECK: fir.store %[[VAL_7]] to %[[VAL_1]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>
diff --git a/flang/test/Lower/pointer-assignments.f90 b/flang/test/Lower/pointer-assignments.f90
index 98fd61df3602f..87e69518c6d92 100644
--- a/flang/test/Lower/pointer-assignments.f90
+++ b/flang/test/Lower/pointer-assignments.f90
@@ -1,5 +1,5 @@
! Test lowering of pointer assignments
-! RUN: bbc --use-desc-for-alloc=false -emit-fir -hlfir=false %s -o - | FileCheck %s
+! RUN: %flang_fc1 -emit-hlfir %s -o - | FileCheck %s
! Note that p => NULL() are tested in pointer-disassociate.f90
@@ -9,81 +9,88 @@
! -----------------------------------------------------------------------------
! CHECK-LABEL: func @_QPtest_scalar(
-! CHECK-SAME: %[[p:.*]]: !fir.ref<!fir.box<!fir.ptr<f32>>>{{.*}}, %[[x:.*]]: !fir.ref<f32> {{{.*}}, fir.target})
+! CHECK-SAME: %[[arg0:[^:]*]]: !fir.ref<!fir.box<!fir.ptr<f32>>>{{.*}}, %[[arg1:[^:]*]]: !fir.ref<f32> {{{.*}}, fir.target})
subroutine test_scalar(p, x)
real, target :: x
real, pointer :: p
- ! CHECK: %[[box:.*]] = fir.embox %[[x]] : (!fir.ref<f32>) -> !fir.box<!fir.ptr<f32>>
- ! CHECK: fir.store %[[box]] to %[[p]] : !fir.ref<!fir.box<!fir.ptr<f32>>>
+ ! CHECK: %[[p:.*]]:2 = hlfir.declare %[[arg0]]
+ ! CHECK: %[[x:.*]]:2 = hlfir.declare %[[arg1]]
+ ! CHECK: %[[box:.*]] = fir.embox %[[x]]#0 : (!fir.ref<f32>) -> !fir.box<!fir.ptr<f32>>
+ ! CHECK: fir.store %[[box]] to %[[p]]#0 : !fir.ref<!fir.box<!fir.ptr<f32>>>
p => x
end subroutine
! CHECK-LABEL: func @_QPtest_scalar_char(
-! CHECK-SAME: %[[p:.*]]: !fir.ref<!fir.box<!fir.ptr<!fir.char<1,?>>>>{{.*}}, %[[x:.*]]: !fir.boxchar<1> {{{.*}}, fir.target})
+! CHECK-SAME: %[[arg0:[^:]*]]: !fir.ref<!fir.box<!fir.ptr<!fir.char<1,?>>>>{{.*}}, %[[arg1:[^:]*]]: !fir.boxchar<1> {{{.*}}, fir.target})
subroutine test_scalar_char(p, x)
character(*), target :: x
character(:), pointer :: p
- ! CHECK: %[[c:.*]]:2 = fir.unboxchar %arg1 : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
- ! CHECK: %[[box:.*]] = fir.embox %[[c]]#0 typeparams %[[c]]#1 : (!fir.ref<!fir.char<1,?>>, index) -> !fir.box<!fir.ptr<!fir.char<1,?>>>
- ! CHECK: fir.store %[[box]] to %[[p]] : !fir.ref<!fir.box<!fir.ptr<!fir.char<1,?>>>>
+ ! CHECK: %[[p:.*]]:2 = hlfir.declare %[[arg0]]
+ ! CHECK: %[[c:.*]]:2 = fir.unboxchar %[[arg1]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
+ ! CHECK: %[[x:.*]]:2 = hlfir.declare %[[c]]#0 typeparams %[[c]]#1
+ ! CHECK: %[[unbox:.*]]:2 = fir.unboxchar %[[x]]#0 : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
+ ! CHECK: %[[box:.*]] = fir.embox %[[unbox]]#0 typeparams %[[c]]#1 : (!fir.ref<!fir.char<1,?>>, index) -> !fir.box<!fir.ptr<!fir.char<1,?>>>
+ ! CHECK: fir.store %[[box]] to %[[p]]#0 : !fir.ref<!fir.box<!fir.ptr<!fir.char<1,?>>>>
p => x
end subroutine
! CHECK-LABEL: func @_QPtest_array(
-! CHECK-SAME: %[[p:.*]]: !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>{{.*}}, %[[x:.*]]: !fir.ref<!fir.array<100xf32>> {{{.*}}, fir.target})
+! CHECK-SAME: %[[arg0:[^:]*]]: !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>{{.*}}, %[[arg1:[^:]*]]: !fir.ref<!fir.array<100xf32>> {{{.*}}, fir.target})
subroutine test_array(p, x)
real, target :: x(100)
real, pointer :: p(:)
+ ! CHECK: %[[p:.*]]:2 = hlfir.declare %[[arg0]]
! CHECK: %[[shape:.*]] = fir.shape %c100{{.*}}
- ! CHECK: %[[box:.*]] = fir.embox %[[x]](%[[shape]]) : (!fir.ref<!fir.array<100xf32>>, !fir.shape<1>) -> !fir.box<!fir.ptr<!fir.array<?xf32>>>
- ! CHECK: fir.store %[[box]] to %[[p]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>
+ ! CHECK: %[[x:.*]]:2 = hlfir.declare %[[arg1]](%[[shape]])
+ ! CHECK: %[[addr:.*]] = fir.convert %[[x]]#0 : (!fir.ref<!fir.array<100xf32>>) -> !fir.ref<!fir.array<?xf32>>
+ ! CHECK: %[[box:.*]] = fir.embox %[[addr]](%[[shape]]) : (!fir.ref<!fir.array<?xf32>>, !fir.shape<1>) -> !fir.box<!fir.ptr<!fir.array<?xf32>>>
+ ! CHECK: fir.store %[[box]] to %[[p]]#0 : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>
p => x
end subroutine
! CHECK-LABEL: func @_QPtest_array_char(
-! CHECK-SAME: %[[p:.*]]: !fir.ref<!fir.box<!fir.ptr<!fir.array<?x!fir.char<1,?>>>>>{{.*}}, %[[x:.*]]: !fir.boxchar<1> {{{.*}}, fir.target}) {
+! CHECK-SAME: %[[arg0:[^:]*]]: !fir.ref<!fir.box<!fir.ptr<!fir.array<?x!fir.char<1,?>>>>>{{.*}}, %[[arg1:[^:]*]]: !fir.boxchar<1> {{{.*}}, fir.target}) {
subroutine test_array_char(p, x)
character(*), target :: x(100)
character(:), pointer :: p(:)
- ! CHECK: %[[c:.*]]:2 = fir.unboxchar %arg1 : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
- ! CHECK: %[[xaddr:.*]] = fir.convert %[[c]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<100x!fir.char<1,?>>>
- ! CHECK-DAG: %[[xaddr2:.*]] = fir.convert %[[xaddr]] : (!fir.ref<!fir.array<100x!fir.char<1,?>>>) -> !fir.ref<!fir.array<?x!fir.char<1,?>>>
- ! CHECK-DAG: %[[shape:.*]] = fir.shape %c100{{.*}}
- ! CHECK: %[[box:.*]] = fir.embox %[[xaddr2]](%[[shape]]) typeparams %[[c]]#1
- ! CHECK: fir.store %[[box]] to %[[p]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?x!fir.char<1,?>>>>>
+ ! CHECK: %[[p:.*]]:2 = hlfir.declare %[[arg0]]
+ ! CHECK: %[[c:.*]]:2 = fir.unboxchar %[[arg1]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
+ ! CHECK: %[[x:.*]]:2 = hlfir.declare %{{.*}}(%{{.*}}) typeparams %[[c]]#1
+ ! CHECK: %[[box:.*]] = fir.rebox %[[x]]#0 : (!fir.box<!fir.array<100x!fir.char<1,?>>>) -> !fir.box<!fir.ptr<!fir.array<?x!fir.char<1,?>>>>
+ ! CHECK: fir.store %[[box]] to %[[p]]#0 : !fir.ref<!fir.box<!fir.ptr<!fir.array<?x!fir.char<1,?>>>>>
p => x
end subroutine
! Test 10.2.2.3 point 10: lower bounds requirements:
! pointer takes lbounds from rhs if no bounds spec.
! CHECK-LABEL: func @_QPtest_array_with_lbs(
-! CHECK-SAME: %[[p:.*]]: !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>
+! CHECK-SAME: %[[arg0:[^:]*]]: !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>
subroutine test_array_with_lbs(p, x)
real, target :: x(51:150)
real, pointer :: p(:)
- ! CHECK: %[[shape:.*]] = fir.shape_shift %c51{{.*}}, %c100{{.*}}
- ! CHECK: %[[box:.*]] = fir.embox %{{.*}}(%[[shape]]) : (!fir.ref<!fir.array<100xf32>>, !fir.shapeshift<1>) -> !fir.box<!fir.ptr<!fir.array<?xf32>>>
- ! CHECK: fir.store %[[box]] to %[[p]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>
+ ! CHECK: %[[p:.*]]:2 = hlfir.declare %[[arg0]]
+ ! CHECK: %[[ss:.*]] = fir.shape_shift %c51{{.*}}, %c100{{.*}}
+ ! CHECK: %[[x:.*]]:2 = hlfir.declare %{{.*}}(%[[ss]])
+ ! CHECK: %[[shift:.*]] = fir.shift %c51{{.*}} : (index) -> !fir.shift<1>
+ ! CHECK: %[[box:.*]] = fir.rebox %[[x]]#0(%[[shift]]) : (!fir.box<!fir.array<100xf32>>, !fir.shift<1>) -> !fir.box<!fir.ptr<!fir.array<?xf32>>>
+ ! CHECK: fir.store %[[box]] to %[[p]]#0 : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>
p => x
end subroutine
! Test that the lhs takes the bounds from rhs.
! CHECK-LABEL: func @_QPtest_pointer_component(
-! CHECK-SAME: %[[temp:.*]]: !fir.ref<!fir.type<_QFtest_pointer_componentTmytype{ptr:!fir.box<!fir.ptr<!fir.array<?xf32>>>}>> {fir.bindc_name = "temp"}, %[[temp_ptr:.*]]: !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>> {fir.bindc_name = "temp_ptr"}) {
+! CHECK-SAME: %[[arg_temp:[^:]*]]: !fir.ref<!fir.type<_QFtest_pointer_componentTmytype{ptr:!fir.box<!fir.ptr<!fir.array<?xf32>>>}>> {fir.bindc_name = "temp"}, %[[arg_temp_ptr:[^:]*]]: !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>> {fir.bindc_name = "temp_ptr"}) {
subroutine test_pointer_component(temp, temp_ptr)
type mytype
real, pointer :: ptr(:)
end type mytype
type(mytype) :: temp
real, pointer :: temp_ptr(:)
- ! CHECK: %[[ptr_addr:.*]] = fir.coordinate_of %[[temp]], ptr : (!fir.ref<!fir.type<_QFtest_pointer_componentTmytype{ptr:!fir.box<!fir.ptr<!fir.array<?xf32>>>}>>) -> !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>
- ! CHECK: %[[ptr:.*]] = fir.load %[[ptr_addr]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>
- ! CHECK: %[[dims:.*]]:3 = fir.box_dims %[[ptr]], %{{.*}} : (!fir.box<!fir.ptr<!fir.array<?xf32>>>, index) -> (index, index, index)
- ! CHECK: %[[shift:.*]] = fir.shift %[[dims]]#0 : (index) -> !fir.shift<1>
- ! CHECK: %[[arr_box:.*]] = fir.rebox %[[ptr]](%[[shift]]) : (!fir.box<!fir.ptr<!fir.array<?xf32>>>, !fir.shift<1>) -> !fir.box<!fir.array<?xf32>>
- ! CHECK: %[[shift2:.*]] = fir.shift %[[dims]]#0 : (index) -> !fir.shift<1>
- ! CHECK: %[[final_box:.*]] = fir.rebox %[[arr_box]](%[[shift2]]) : (!fir.box<!fir.array<?xf32>>, !fir.shift<1>) -> !fir.box<!fir.ptr<!fir.array<?xf32>>>
- ! CHECK: fir.store %[[final_box]] to %[[temp_ptr]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>
+ ! CHECK: %[[temp:.*]]:2 = hlfir.declare %[[arg_temp]]
+ ! CHECK: %[[temp_ptr:.*]]:2 = hlfir.declare %[[arg_temp_ptr]]
+ ! CHECK: %[[ptr_comp:.*]] = hlfir.designate %[[temp]]#0{"ptr"} {fortran_attrs = #fir.var_attrs<pointer>}
+ ! CHECK: %[[ptr:.*]] = fir.load %[[ptr_comp]] : !fir.ref<!fir.box<!fir.ptr<!fir....
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/193889
More information about the flang-commits
mailing list