diff options
author | jeanPerier <jperier@nvidia.com> | 2024-06-20 09:00:30 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-20 09:00:30 +0200 |
commit | e7d63ebaa2928056fb837a575a36dc4447dc80b2 (patch) | |
tree | 536a9b142644e7f62c492246e9850c15788bc22a | |
parent | 76d3ab2cc33336c1eece6484c9a55577eac7e79a (diff) | |
download | llvm-e7d63ebaa2928056fb837a575a36dc4447dc80b2.zip llvm-e7d63ebaa2928056fb837a575a36dc4447dc80b2.tar.gz llvm-e7d63ebaa2928056fb837a575a36dc4447dc80b2.tar.bz2 |
[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
https://github.com/llvm/llvm-project/pull/95822.
-rw-r--r-- | flang/lib/Lower/ConvertCall.cpp | 2 | ||||
-rw-r--r-- | flang/test/Lower/HLFIR/assumed-rank-calls.f90 | 37 |
2 files changed, 37 insertions, 2 deletions
diff --git a/flang/lib/Lower/ConvertCall.cpp b/flang/lib/Lower/ConvertCall.cpp index daa22fe..382419a1 100644 --- a/flang/lib/Lower/ConvertCall.cpp +++ b/flang/lib/Lower/ConvertCall.cpp @@ -1265,8 +1265,6 @@ static PreparedDummyArgument preparePresentUserCallActualArgument( preparedDummy.pushExprAssociateCleanUp(associate); } else if (mustDoCopyInOut) { // Copy-in non contiguous variables. - if (actualIsAssumedRank) - TODO(loc, "copy-in and copy-out of assumed-rank arguments"); // TODO: for non-finalizable monomorphic derived type actual // arguments associated with INTENT(OUT) dummy arguments // we may avoid doing the copy and only allocate the temporary. diff --git a/flang/test/Lower/HLFIR/assumed-rank-calls.f90 b/flang/test/Lower/HLFIR/assumed-rank-calls.f90 index f5fb343..071589b 100644 --- a/flang/test/Lower/HLFIR/assumed-rank-calls.f90 +++ b/flang/test/Lower/HLFIR/assumed-rank-calls.f90 @@ -61,3 +61,40 @@ end subroutine ! CHECK: fir.call @_QPtakes_assumed_rank_t(%[[VAL_3]]) fastmath<contract> : (!fir.box<!fir.array<*:!fir.type<_QFtest_poly_to_nonepolyTt{i:i32}>>>) -> () ! CHECK: return ! CHECK: } + + +subroutine test_copy_in_out(x) + real :: x(..) + interface + subroutine takes_contiguous(x) + real, contiguous :: x(..) + end subroutine + end interface + call takes_contiguous(x) +end subroutine +! CHECK-LABEL: func.func @_QPtest_copy_in_out( +! CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<*:f32>> {fir.bindc_name = "x"}) { +! CHECK: %[[VAL_1:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<*:f32>>> +! CHECK: %[[VAL_2:.*]] = fir.dummy_scope : !fir.dscope +! 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>>) +! 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) +! CHECK: fir.call @_QPtakes_contiguous(%[[VAL_4]]#0) fastmath<contract> : (!fir.box<!fir.array<*:f32>>) -> () +! 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>>) -> () + +subroutine test_copy_in_out_2(x) + real :: x(..) + interface + subroutine takes_contiguous_intentin(x) + real, intent(in), contiguous :: x(..) + end subroutine + end interface + call takes_contiguous_intentin(x) +end subroutine +! CHECK-LABEL: func.func @_QPtest_copy_in_out_2( +! CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<*:f32>> {fir.bindc_name = "x"}) { +! CHECK: %[[VAL_1:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<*:f32>>> +! CHECK: %[[VAL_2:.*]] = fir.dummy_scope : !fir.dscope +! 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>>) +! 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) +! CHECK: fir.call @_QPtakes_contiguous_intentin(%[[VAL_4]]#0) fastmath<contract> : (!fir.box<!fir.array<*:f32>>) -> () +! CHECK: hlfir.copy_out %[[VAL_1]], %[[VAL_4]]#1 : (!fir.ref<!fir.box<!fir.heap<!fir.array<*:f32>>>>, i1) -> () |