Skip to content

Commit e7d63eb

Browse files
authored
[flang] enable copy-in/out of assumed-rank arrays (#96080)
Just remove the TODO and add a test. There is nothing special to do to deal with assumed-rank copy-in/out after the previous copy-in/out API change in #95822.
1 parent 76d3ab2 commit e7d63eb

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

flang/lib/Lower/ConvertCall.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,8 +1265,6 @@ static PreparedDummyArgument preparePresentUserCallActualArgument(
12651265
preparedDummy.pushExprAssociateCleanUp(associate);
12661266
} else if (mustDoCopyInOut) {
12671267
// Copy-in non contiguous variables.
1268-
if (actualIsAssumedRank)
1269-
TODO(loc, "copy-in and copy-out of assumed-rank arguments");
12701268
// TODO: for non-finalizable monomorphic derived type actual
12711269
// arguments associated with INTENT(OUT) dummy arguments
12721270
// we may avoid doing the copy and only allocate the temporary.

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,40 @@ subroutine takes_assumed_rank_t(x)
6161
! CHECK: fir.call @_QPtakes_assumed_rank_t(%[[VAL_3]]) fastmath<contract> : (!fir.box<!fir.array<*:!fir.type<_QFtest_poly_to_nonepolyTt{i:i32}>>>) -> ()
6262
! CHECK: return
6363
! CHECK: }
64+
65+
66+
subroutine test_copy_in_out(x)
67+
real :: x(..)
68+
interface
69+
subroutine takes_contiguous(x)
70+
real, contiguous :: x(..)
71+
end subroutine
72+
end interface
73+
call takes_contiguous(x)
74+
end subroutine
75+
! CHECK-LABEL: func.func @_QPtest_copy_in_out(
76+
! CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<*:f32>> {fir.bindc_name = "x"}) {
77+
! CHECK: %[[VAL_1:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<*:f32>>>
78+
! CHECK: %[[VAL_2:.*]] = fir.dummy_scope : !fir.dscope
79+
! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %[[VAL_2]] {uniq_name = "_QFtest_copy_in_outEx"} : (!fir.box<!fir.array<*:f32>>, !fir.dscope) -> (!fir.box<!fir.array<*:f32>>, !fir.box<!fir.array<*:f32>>)
80+
! CHECK: %[[VAL_4:.*]]:2 = hlfir.copy_in %[[VAL_3]]#0 to %[[VAL_1]] : (!fir.box<!fir.array<*:f32>>, !fir.ref<!fir.box<!fir.heap<!fir.array<*:f32>>>>) -> (!fir.box<!fir.array<*:f32>>, i1)
81+
! CHECK: fir.call @_QPtakes_contiguous(%[[VAL_4]]#0) fastmath<contract> : (!fir.box<!fir.array<*:f32>>) -> ()
82+
! CHECK: hlfir.copy_out %[[VAL_1]], %[[VAL_4]]#1 to %[[VAL_3]]#0 : (!fir.ref<!fir.box<!fir.heap<!fir.array<*:f32>>>>, i1, !fir.box<!fir.array<*:f32>>) -> ()
83+
84+
subroutine test_copy_in_out_2(x)
85+
real :: x(..)
86+
interface
87+
subroutine takes_contiguous_intentin(x)
88+
real, intent(in), contiguous :: x(..)
89+
end subroutine
90+
end interface
91+
call takes_contiguous_intentin(x)
92+
end subroutine
93+
! CHECK-LABEL: func.func @_QPtest_copy_in_out_2(
94+
! CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<*:f32>> {fir.bindc_name = "x"}) {
95+
! CHECK: %[[VAL_1:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<*:f32>>>
96+
! CHECK: %[[VAL_2:.*]] = fir.dummy_scope : !fir.dscope
97+
! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %[[VAL_2]] {uniq_name = "_QFtest_copy_in_out_2Ex"} : (!fir.box<!fir.array<*:f32>>, !fir.dscope) -> (!fir.box<!fir.array<*:f32>>, !fir.box<!fir.array<*:f32>>)
98+
! CHECK: %[[VAL_4:.*]]:2 = hlfir.copy_in %[[VAL_3]]#0 to %[[VAL_1]] : (!fir.box<!fir.array<*:f32>>, !fir.ref<!fir.box<!fir.heap<!fir.array<*:f32>>>>) -> (!fir.box<!fir.array<*:f32>>, i1)
99+
! CHECK: fir.call @_QPtakes_contiguous_intentin(%[[VAL_4]]#0) fastmath<contract> : (!fir.box<!fir.array<*:f32>>) -> ()
100+
! CHECK: hlfir.copy_out %[[VAL_1]], %[[VAL_4]]#1 : (!fir.ref<!fir.box<!fir.heap<!fir.array<*:f32>>>>, i1) -> ()

0 commit comments

Comments
 (0)