Skip to content

Commit d799be8

Browse files
authored
[flang] implement passing assumed-size array to assumed-rank arguments (#87511)
Remove the TODO, the patch that ensured that the descriptor upper bound is set to -1 was #79156.
1 parent a9d963f commit d799be8

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

flang/lib/Lower/ConvertCall.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1340,15 +1340,6 @@ static PreparedDummyArgument preparePresentUserCallActualArgument(
13401340
} else {
13411341
addr = hlfir::genVariableRawAddress(loc, builder, entity);
13421342
}
1343-
// The last extent created for assumed-rank descriptors must be -1 (18.5.3
1344-
// point 5.). This should be done when creating the assumed-size shape for
1345-
// consistency.
1346-
if (auto baseBoxDummy = mlir::dyn_cast<fir::BaseBoxType>(dummyType))
1347-
if (baseBoxDummy.isAssumedRank())
1348-
if (const Fortran::semantics::Symbol *sym =
1349-
Fortran::evaluate::UnwrapWholeSymbolDataRef(*arg.entity))
1350-
if (Fortran::semantics::IsAssumedSizeArray(sym->GetUltimate()))
1351-
TODO(loc, "passing assumed-size to assumed-rank array");
13521343

13531344
// For ranked actual passed to assumed-rank dummy, the cast to assumed-rank
13541345
// box is inserted when building the fir.call op. Inserting it here would

flang/test/Lower/HLFIR/assumed-rank-iface.f90

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,20 @@ subroutine int_allocatable_to_assumed_rank_opt(x)
133133
! CHECK: %[[VAL_11:.*]] = fir.convert %[[VAL_7]] : (!fir.box<!fir.array<?x?xi32>>) -> !fir.box<!fir.array<*:i32>>
134134
! CHECK: fir.call @_QPint_opt_assumed_rank(%[[VAL_11]]) fastmath<contract> : (!fir.box<!fir.array<*:i32>>) -> ()
135135

136-
! TODO: set assumed size last extent to -1.
137-
!subroutine int_r2_assumed_size_to_assumed_rank(x)
138-
! use ifaces, only : int_assumed_rank
139-
! integer :: x(10, *)
140-
! call int_assumed_rank(x)
141-
!end subroutine
136+
subroutine int_r2_assumed_size_to_assumed_rank(x)
137+
use ifaces, only : int_assumed_rank
138+
integer :: x(10, *)
139+
call int_assumed_rank(x)
140+
end subroutine
141+
! CHECK-LABEL: func.func @_QPint_r2_assumed_size_to_assumed_rank(
142+
! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<10x?xi32>> {fir.bindc_name = "x"}) {
143+
! CHECK: %[[VAL_1:.*]] = arith.constant 10 : i64
144+
! CHECK: %[[VAL_2:.*]] = fir.convert %[[VAL_1]] : (i64) -> index
145+
! CHECK: %[[VAL_3:.*]] = arith.constant 0 : index
146+
! CHECK: %[[VAL_4:.*]] = arith.cmpi sgt, %[[VAL_2]], %[[VAL_3]] : index
147+
! CHECK: %[[VAL_5:.*]] = arith.select %[[VAL_4]], %[[VAL_2]], %[[VAL_3]] : index
148+
! CHECK: %[[VAL_6:.*]] = arith.constant -1 : index
149+
! CHECK: %[[VAL_7:.*]] = fir.shape %[[VAL_5]], %[[VAL_6]] : (index, index) -> !fir.shape<2>
150+
! CHECK: %[[VAL_8:.*]]:2 = hlfir.declare %[[VAL_0]](%[[VAL_7]]) {uniq_name = "_QFint_r2_assumed_size_to_assumed_rankEx"} : (!fir.ref<!fir.array<10x?xi32>>, !fir.shape<2>) -> (!fir.box<!fir.array<10x?xi32>>, !fir.ref<!fir.array<10x?xi32>>)
151+
! CHECK: %[[VAL_9:.*]] = fir.convert %[[VAL_8]]#0 : (!fir.box<!fir.array<10x?xi32>>) -> !fir.box<!fir.array<*:i32>>
152+
! CHECK: fir.call @_QPint_assumed_rank(%[[VAL_9]]) fastmath<contract> : (!fir.box<!fir.array<*:i32>>) -> ()

0 commit comments

Comments
 (0)