From 59f67bfd1139d7b5a837c4e3341ca95c4e7c3493 Mon Sep 17 00:00:00 2001 From: Valentin Clement Date: Thu, 1 Sep 2022 22:04:29 +0200 Subject: [PATCH] Revert "[flang] Avoid copyin/copyout if the actual argument is contiguous at runtime" This reverts commit 6ab6f23b14d51d65bfe86df64d0e976ebb573429. --- flang/lib/Lower/ConvertExpr.cpp | 107 ++---------------- flang/test/Lower/call-by-value-attr.f90 | 10 +- flang/test/Lower/call-copy-in-out.f90 | 75 +++--------- .../test/Lower/dummy-argument-optional-2.f90 | 58 ++-------- flang/test/Lower/optional-value-caller.f90 | 19 +--- 5 files changed, 47 insertions(+), 222 deletions(-) diff --git a/flang/lib/Lower/ConvertExpr.cpp b/flang/lib/Lower/ConvertExpr.cpp index 31691e12db62..41930cce7f9d 100644 --- a/flang/lib/Lower/ConvertExpr.cpp +++ b/flang/lib/Lower/ConvertExpr.cpp @@ -41,7 +41,6 @@ #include "flang/Optimizer/Dialect/FIRDialect.h" #include "flang/Optimizer/Dialect/FIROpsSupport.h" #include "flang/Optimizer/Support/FatalError.h" -#include "flang/Runtime/support.h" #include "flang/Semantics/expression.h" #include "flang/Semantics/symbol.h" #include "flang/Semantics/tools.h" @@ -56,8 +55,6 @@ #define DEBUG_TYPE "flang-lower-expr" -using namespace Fortran::runtime; - //===----------------------------------------------------------------------===// // The composition and structure of Fortran::evaluate::Expr is defined in // the various header files in include/flang/Evaluate. You are referred @@ -2839,114 +2836,35 @@ public: bool byValue) { const bool doCopyOut = !byValue && arg.mayBeModifiedByCall(); llvm::StringRef tempName = byValue ? ".copy" : ".copyinout"; - mlir::Location loc = getLoc(); - bool isActualArgBox = fir::isa_box_type(fir::getBase(actualArg).getType()); - mlir::Value isContiguousResult; - mlir::Type addrType = fir::HeapType::get( - fir::unwrapPassByRefType(fir::getBase(actualArg).getType())); - - if (isActualArgBox) { - // Check at runtime if the argument is contiguous so no copy is needed. - mlir::func::FuncOp isContiguousFct = - fir::runtime::getRuntimeFunc(loc, builder); - fir::CallOp isContiguous = builder.create( - loc, isContiguousFct, - mlir::ValueRange{builder.createConvert( - loc, isContiguousFct.getFunctionType().getInput(0), - fir::getBase(actualArg))}); - isContiguousResult = isContiguous.getResult(0); - } - - auto doCopyIn = [&]() -> ExtValue { + if (!restrictCopyAtRuntime) { ExtValue temp = genArrayTempFromMold(actualArg, tempName); if (arg.mayBeReadByCall()) genArrayCopy(temp, actualArg); - return temp; - }; - - auto noCopy = [&]() { - mlir::Value box = fir::getBase(actualArg); - mlir::Value boxAddr = builder.create(loc, addrType, box); - builder.create(loc, boxAddr); - }; - - auto combinedCondition = [&]() { - if (isActualArgBox) { - mlir::Value zero = - builder.createIntegerConstant(loc, builder.getI1Type(), 0); - mlir::Value notContiguous = builder.create( - loc, mlir::arith::CmpIPredicate::eq, isContiguousResult, zero); - if (!restrictCopyAtRuntime) { - restrictCopyAtRuntime = notContiguous; - } else { - mlir::Value cond = builder.create( - loc, *restrictCopyAtRuntime, notContiguous); - restrictCopyAtRuntime = cond; - } - } - }; - - if (!restrictCopyAtRuntime) { - if (isActualArgBox) { - // isContiguousResult = genIsContiguousCall(); - mlir::Value addr = - builder - .genIfOp(loc, {addrType}, isContiguousResult, - /*withElseRegion=*/true) - .genThen([&]() { noCopy(); }) - .genElse([&] { - ExtValue temp = doCopyIn(); - builder.create(loc, fir::getBase(temp)); - }) - .getResults()[0]; - fir::ExtendedValue temp = - fir::substBase(readIfBoxValue(actualArg), addr); - combinedCondition(); - copyOutPairs.emplace_back( - CopyOutPair{actualArg, temp, doCopyOut, restrictCopyAtRuntime}); - return temp; - } - - ExtValue temp = doCopyIn(); - copyOutPairs.emplace_back(CopyOutPair{actualArg, temp, doCopyOut}); + copyOutPairs.emplace_back( + CopyOutPair{actualArg, temp, doCopyOut, restrictCopyAtRuntime}); return temp; } - // Otherwise, need to be careful to only copy-in if allowed at runtime. + mlir::Location loc = getLoc(); + auto addrType = fir::HeapType::get( + fir::unwrapPassByRefType(fir::getBase(actualArg).getType())); mlir::Value addr = builder .genIfOp(loc, {addrType}, *restrictCopyAtRuntime, /*withElseRegion=*/true) .genThen([&]() { - if (isActualArgBox) { - // isContiguousResult = genIsContiguousCall(); - // Avoid copyin if the argument is contiguous at runtime. - mlir::Value addr1 = - builder - .genIfOp(loc, {addrType}, isContiguousResult, - /*withElseRegion=*/true) - .genThen([&]() { noCopy(); }) - .genElse([&]() { - ExtValue temp = doCopyIn(); - builder.create(loc, - fir::getBase(temp)); - }) - .getResults()[0]; - builder.create(loc, addr1); - } else { - ExtValue temp = doCopyIn(); - builder.create(loc, fir::getBase(temp)); - } + auto temp = genArrayTempFromMold(actualArg, tempName); + if (arg.mayBeReadByCall()) + genArrayCopy(temp, actualArg); + builder.create(loc, fir::getBase(temp)); }) .genElse([&]() { - mlir::Value nullPtr = builder.createNullConstant(loc, addrType); + auto nullPtr = builder.createNullConstant(loc, addrType); builder.create(loc, nullPtr); }) .getResults()[0]; - // Associate the temp address with actualArg lengths and extents if a - // temporary is generated. Otherwise the same address is associated. + // Associate the temp address with actualArg lengths and extents. fir::ExtendedValue temp = fir::substBase(readIfBoxValue(actualArg), addr); - combinedCondition(); copyOutPairs.emplace_back( CopyOutPair{actualArg, temp, doCopyOut, restrictCopyAtRuntime}); return temp; @@ -2962,7 +2880,6 @@ public: builder.create(loc, fir::getBase(copyOutPair.temp)); return; } - builder.genIfThen(loc, *copyOutPair.restrictCopyAndFreeAtRuntime) .genThen([&]() { if (copyOutPair.argMayBeModifiedByCall) diff --git a/flang/test/Lower/call-by-value-attr.f90 b/flang/test/Lower/call-by-value-attr.f90 index d354318b87f8..e39f0f755ea2 100644 --- a/flang/test/Lower/call-by-value-attr.f90 +++ b/flang/test/Lower/call-by-value-attr.f90 @@ -67,11 +67,6 @@ program call_by_value_attr !CHECK: %[[SHAPE_7:.*]] = fir.shape %[[CONST_15_1]] : (index) -> !fir.shape<1> !CHECK: %[[SLICE:.*]] = fir.slice %[[CONV_5]], %[[CONV_15]], %[[CONV_1]] : (index, index, index) -> !fir.slice<1> !CHECK: %[[BOX:.*]] = fir.embox %[[ARRAY_B]](%[[SHAPE_7]]) [%[[SLICE]]] : (!fir.ref>, !fir.shape<1>, !fir.slice<1>) -> !fir.box> - !CHECK: %[[BOX_NONE:.*]] = fir.convert %[[BOX]] : (!fir.box>) -> !fir.box - !CHECK: %[[IS_CONTIGUOUS:.*]] = fir.call @_FortranAIsContiguous(%[[BOX_NONE]]) : (!fir.box) -> i1 - !CHECK: %[[ADDR:.*]] = fir.if %[[IS_CONTIGUOUS]] -> (!fir.heap>) { - !CHECK: %[[BOX_ADDR:.*]] = fir.box_addr %[[BOX]] : (!fir.box>) -> !fir.heap> - !CHECKL fir.result %[[BOXADDR]] : !fir.heap> !CHECK: %[[CONST_0:.*]] = arith.constant 0 : index !CHECK: %[[DIMS:.*]]:3 = fir.box_dims %[[BOX]], %[[CONST_0]] : (!fir.box>, index) -> (index, index, index) !CHECK: %[[ARRAY_COPY_2:.*]] = fir.allocmem !fir.array<11xi32>, %[[DIMS]]#1 {uniq_name = ".copy"} @@ -80,9 +75,8 @@ program call_by_value_attr !CHECK: %[[ARRAY_LOAD_8:.*]] = fir.array_load %[[BOX]] : (!fir.box>) -> !fir.array<11xi32> !CHECK: %[[DO_4:.*]] = fir.do_loop {{.*}} { !CHECK: } - !CHECK: fir.array_merge_store %[[ARRAY_LOAD_7]], %[[DO_4]] to %[[ARRAY_COPY_2]] : !fir.array<11xi32>, !fir.array<11xi32>, !fir.heap> - !CHECK: fir.result %[[ARRAY_COPY_2]] : !fir.heap> - !CHECK: %[[CONVERT_B:.*]] = fir.convert %[[ADDR]] : (!fir.heap>) -> !fir.ref> + !CHECK fir.array_merge_store %[[ARRAY_LOAD_7]], %[[DO_4]] to %[[ARRAY_COPY_2]] : !fir.array<11xi32>, !fir.array<11xi32>, !fir.heap> + !CHECK: %[[CONVERT_B:.*]] = fir.convert %[[ARRAY_COPY_2]] : (!fir.heap>) -> !fir.ref> !CHECK: fir.call @_QPsubra(%[[CONVERT_B]]) call subra(b(5:15)) end program call_by_value_attr diff --git a/flang/test/Lower/call-copy-in-out.f90 b/flang/test/Lower/call-copy-in-out.f90 index eebaf128b1aa..4e558d8bc77f 100644 --- a/flang/test/Lower/call-copy-in-out.f90 +++ b/flang/test/Lower/call-copy-in-out.f90 @@ -6,13 +6,6 @@ ! CHECK-SAME: %[[x:.*]]: !fir.box>{{.*}}) { subroutine test_assumed_shape_to_array(x) real :: x(:) - -! CHECK: %[[box_none:.*]] = fir.convert %[[x]] : (!fir.box>) -> !fir.box -! CHECK: %[[is_contiguous:.*]] = fir.call @_FortranAIsContiguous(%[[box_none]]) : (!fir.box) -> i1 -! CHECK: %[[addr:.*]] = fir.if %[[is_contiguous]] -> (!fir.heap>) { -! CHECK: %[[box_addr:.*]] = fir.box_addr %[[x]] : (!fir.box>) -> !fir.heap> -! CHECK: fir.result %[[box_addr]] : !fir.heap> -! CHECK: } else { ! Creating temp ! CHECK: %[[dim:.*]]:3 = fir.box_dims %[[x:.*]], %c0{{.*}} : (!fir.box>, index) -> (index, index, index) ! CHECK: %[[temp:.*]] = fir.allocmem !fir.array, %[[dim]]#1 {uniq_name = ".copyinout"} @@ -27,18 +20,15 @@ subroutine test_assumed_shape_to_array(x) ! CHECK: fir.result %[[update]] : !fir.array ! CHECK: } ! CHECK: fir.array_merge_store %[[temp_load]], %[[copyin:.*]] to %[[temp]] : !fir.array, !fir.array, !fir.heap> -! CHECK: fir.result %[[temp]] : !fir.heap> -! CHECK: %[[dim:.*]]:3 = fir.box_dims %[[x]], %c0{{.*}} : (!fir.box>, index) -> (index, index, index) -! CHECK: %[[cast:.*]] = fir.convert %[[addr]] : (!fir.heap>) -> !fir.ref> +! CHECK: %[[cast:.*]] = fir.convert %[[temp]] : (!fir.heap>) -> !fir.ref> ! CHECK: fir.call @_QPbar(%[[cast]]) : (!fir.ref>) -> () ! Copy-out -! CHECK-DAG: %[[x_load:.*]] = fir.array_load %[[x]] : (!fir.box>) -> !fir.array -! CHECK-DAG: %[[c0:.*]] = arith.constant 0 : index +! CHECK-DAG: %[[x_load:.*]] = fir.array_load %[[x]] : (!fir.box>) -> !fir.array ! CHECK-DAG: %[[shape:.*]] = fir.shape %[[dim]]#1 : (index) -> !fir.shape<1> -! CHECK-DAG: %[[temp_load:.*]] = fir.array_load %[[addr]](%[[shape]]) : (!fir.heap>, !fir.shape<1>) -> !fir.array +! CHECK-DAG: %[[temp_load:.*]] = fir.array_load %[[temp]](%[[shape]]) : (!fir.heap>, !fir.shape<1>) -> !fir.array ! CHECK: %[[copyout:.*]] = fir.do_loop %[[i:.*]] = %{{.*}} to %{{.*}} step %{{.*}} iter_args(%[[res:.*]] = %[[x_load]]) -> (!fir.array) { ! CHECK: %[[fetch:.*]] = fir.array_fetch %[[temp_load]], %[[i]] : (!fir.array, index) -> f32 ! CHECK: %[[update:.*]] = fir.array_update %[[res]], %[[fetch]], %[[i]] : (!fir.array, f32, index) -> !fir.array @@ -46,7 +36,7 @@ subroutine test_assumed_shape_to_array(x) ! CHECK: } ! CHECK: fir.array_merge_store %[[x_load]], %[[copyout:.*]] to %[[x]] : !fir.array, !fir.array, !fir.box> -! CHECK: fir.freemem %[[addr]] : !fir.heap> +! CHECK: fir.freemem %[[temp]] : !fir.heap> call bar(x) end subroutine @@ -60,24 +50,19 @@ subroutine eval_expr_only_once(x) real :: x(200) ! CHECK: fir.call @_QPonly_once() ! CHECK: %[[x_section:.*]] = fir.embox %[[x]](%{{.*}}) [%{{.*}}] : (!fir.ref>, !fir.shape<1>, !fir.slice<1>) -> !fir.box> -! CHECK: %[[box_none:.*]] = fir.convert %[[x_section]] : (!fir.box>) -> !fir.box -! CHECK: %[[is_contiguous:.*]] = fir.call @_FortranAIsContiguous(%[[box_none]]) : (!fir.box) -> i1 -! CHECK: %[[addr:.*]] = fir.if %[[is_contiguous]] -> (!fir.heap>) { - ! CHECK: %[[temp:.*]] = fir.allocmem !fir.array ! CHECK-NOT: fir.call @_QPonly_once() ! CHECK: fir.array_merge_store %{{.*}}, %{{.*}} to %[[temp]] ! CHECK-NOT: fir.call @_QPonly_once() -! CHECK: %[[cast:.*]] = fir.convert %[[addr]] : (!fir.heap>) -> !fir.ref> +! CHECK: %[[cast:.*]] = fir.convert %[[temp]] : (!fir.heap>) -> !fir.ref> ! CHECK: fir.call @_QPbar(%[[cast]]) : (!fir.ref>) -> () call bar(x(1:200:only_once())) ! CHECK-NOT: fir.call @_QPonly_once() ! CHECK: fir.array_merge_store %{{.*}}, %{{.*}} to %[[x_section]] ! CHECK-NOT: fir.call @_QPonly_once() - -! CHECK: fir.freemem %[[addr]] : !fir.heap> +! CHECK: fir.freemem %[[temp]] : !fir.heap> end subroutine ! Test no copy-in/copy-out is generated for contiguous assumed shapes. @@ -119,26 +104,19 @@ subroutine test_intent_out(x) real, intent(out) :: x(100) end subroutine end interface -! CHECK: %[[box_none:.*]] = fir.convert %[[x]] : (!fir.box>) -> !fir.box -! CHECK: %[[is_contiguous:.*]] = fir.call @_FortranAIsContiguous(%[[box_none]]) : (!fir.box) -> i1 -! CHECK: %[[addr:.*]] = fir.if %[[is_contiguous]] -! CHECK: } else { ! CHECK: %[[dim:.*]]:3 = fir.box_dims %[[x]], %c0{{.*}} : (!fir.box>, index) -> (index, index, index) ! CHECK: %[[temp:.*]] = fir.allocmem !fir.array, %[[dim]]#1 ! CHECK-NOT: fir.array_merge_store -! CHECK: %[[not_contiguous:.*]] = arith.cmpi eq, %[[is_contiguous]], %false{{.*}} : i1 -! CHECK: %[[cast:.*]] = fir.convert %[[addr]] : (!fir.heap>) -> !fir.ref> +! CHECK: %[[cast:.*]] = fir.convert %[[temp]] : (!fir.heap>) -> !fir.ref> ! CHECK: fir.call @_QPbar_intent_out(%[[cast]]) : (!fir.ref>) -> () call bar_intent_out(x) - -! CHECK: fir.if %[[not_contiguous]] -! CHECK: fir.array_merge_store %{{.*}}, %{{.*}} to %[[x]] -! CHECK: fir.freemem %[[addr]] : !fir.heap> +! CHECK: fir.array_merge_store %{{.*}}, %{{.*}} to %[[x]] +! CHECK: fir.freemem %[[temp]] : !fir.heap> ! CHECK: return end subroutine ! Test copy-out is skipped for intent(out) arguments. -! CHECK-LABEL: func.func @_QPtest_intent_in( +! CHECK: func @_QPtest_intent_in( ! CHECK: %[[x:.*]]: !fir.box>{{.*}}) { subroutine test_intent_in(x) real :: x(:) @@ -147,20 +125,14 @@ subroutine test_intent_in(x) real, intent(in) :: x(100) end subroutine end interface -! CHECK: %[[box_none:.*]] = fir.convert %[[x]] : (!fir.box>) -> !fir.box -! CHECK: %[[is_contiguous:.*]] = fir.call @_FortranAIsContiguous(%[[box_none]]) : (!fir.box) -> i1 -! CHECK: %[[addr:.*]] = fir.if %[[is_contiguous]] -! CHECK: } else { ! CHECK: %[[dim:.*]]:3 = fir.box_dims %[[x]], %c0{{.*}} : (!fir.box>, index) -> (index, index, index) ! CHECK: %[[temp:.*]] = fir.allocmem !fir.array, %[[dim]]#1 ! CHECK: fir.array_merge_store %{{.*}}, %{{.*}} to %[[temp]] -! CHECK: %[[not_contiguous:.*]] = arith.cmpi eq, %[[is_contiguous]], %false{{.*}} : i1 -! CHECK: %[[cast:.*]] = fir.convert %[[addr]] : (!fir.heap>) -> !fir.ref> +! CHECK: %[[cast:.*]] = fir.convert %[[temp]] : (!fir.heap>) -> !fir.ref> ! CHECK: fir.call @_QPbar_intent_in(%[[cast]]) : (!fir.ref>) -> () call bar_intent_in(x) -! CHECK: fir.if %[[not_contiguous]] ! CHECK-NOT: fir.array_merge_store -! CHECK: fir.freemem %[[addr]] : !fir.heap> +! CHECK: fir.freemem %[[temp]] : !fir.heap> ! CHECK: return end subroutine @@ -174,20 +146,14 @@ subroutine test_intent_inout(x) real, intent(inout) :: x(100) end subroutine end interface -! CHECK: %[[box_none:.*]] = fir.convert %[[x]] : (!fir.box>) -> !fir.box -! CHECK: %[[is_contiguous:.*]] = fir.call @_FortranAIsContiguous(%[[box_none]]) : (!fir.box) -> i1 -! CHECK: %[[addr:.*]] = fir.if %[[is_contiguous]] -! CHECK: } else { ! CHECK: %[[dim:.*]]:3 = fir.box_dims %[[x]], %c0{{.*}} : (!fir.box>, index) -> (index, index, index) ! CHECK: %[[temp:.*]] = fir.allocmem !fir.array, %[[dim]]#1 ! CHECK: fir.array_merge_store %{{.*}}, %{{.*}} to %[[temp]] -! CHECK: %[[not_contiguous:.*]] = arith.cmpi eq, %[[is_contiguous]], %false{{.*}} : i1 -! CHECK: %[[cast:.*]] = fir.convert %[[addr]] : (!fir.heap>) -> !fir.ref> +! CHECK: %[[cast:.*]] = fir.convert %[[temp]] : (!fir.heap>) -> !fir.ref> ! CHECK: fir.call @_QPbar_intent_inout(%[[cast]]) : (!fir.ref>) -> () call bar_intent_inout(x) -! CHECK: fir.if %[[not_contiguous]] ! CHECK: fir.array_merge_store %{{.*}}, %{{.*}} to %[[x]] -! CHECK: fir.freemem %[[addr]] : !fir.heap> +! CHECK: fir.freemem %[[temp]] : !fir.heap> ! CHECK: return end subroutine @@ -196,10 +162,6 @@ end subroutine ! CHECK-SAME: %[[VAL_0:.*]]: !fir.box>>{{.*}}) { subroutine test_char(x) ! CHECK: %[[VAL_1:.*]] = arith.constant 10 : index - ! CHECK: %[[box_none:.*]] = fir.convert %[[VAL_0]] : (!fir.box>>) -> !fir.box - ! CHECK: %[[is_contiguous:.*]] = fir.call @_FortranAIsContiguous(%[[box_none]]) : (!fir.box) -> i1 - ! CHECK: %[[addr:.*]] = fir.if %[[is_contiguous]] - ! CHECK: } else { ! CHECK: %[[VAL_2:.*]] = arith.constant 0 : index ! CHECK: %[[VAL_3:.*]]:3 = fir.box_dims %[[VAL_0]], %[[VAL_2]] : (!fir.box>>, index) -> (index, index, index) ! CHECK: %[[VAL_4:.*]] = fir.allocmem !fir.array>, %[[VAL_3]]#1 {uniq_name = ".copyinout"} @@ -224,15 +186,14 @@ subroutine test_char(x) ! CHECK: fir.result %[[VAL_23]] : !fir.array> ! CHECK: } ! CHECK: fir.array_merge_store %[[VAL_6]], %[[VAL_24:.*]] to %[[VAL_4]] : !fir.array>, !fir.array>, !fir.heap>> - ! CHECK: %[[dim:.*]]:3 = fir.box_dims %[[VAL_0]], %c0{{.*}} : (!fir.box>>, index) -> (index, index, index) - ! CHECK: %[[VAL_25:.*]] = fir.convert %[[addr]] : (!fir.heap>>) -> !fir.ref> + ! CHECK: %[[VAL_25:.*]] = fir.convert %[[VAL_4]] : (!fir.heap>>) -> !fir.ref> ! CHECK: %[[VAL_26:.*]] = fir.emboxchar %[[VAL_25]], %[[VAL_1]] : (!fir.ref>, index) -> !fir.boxchar<1> ! CHECK: fir.call @_QPbar_char(%[[VAL_26]]) : (!fir.boxchar<1>) -> () ! CHECK: %[[VAL_27:.*]] = fir.array_load %[[VAL_0]] : (!fir.box>>) -> !fir.array> ! CHECK: %[[VAL_28:.*]] = arith.constant 0 : index ! CHECK: %[[VAL_29:.*]]:3 = fir.box_dims %[[VAL_0]], %[[VAL_28]] : (!fir.box>>, index) -> (index, index, index) - ! CHECK: %[[VAL_30:.*]] = fir.shape %[[dim]]#1 : (index) -> !fir.shape<1> - ! CHECK: %[[VAL_31:.*]] = fir.array_load %[[addr]](%[[VAL_30]]) : (!fir.heap>>, !fir.shape<1>) -> !fir.array> + ! CHECK: %[[VAL_30:.*]] = fir.shape %[[VAL_3]]#1 : (index) -> !fir.shape<1> + ! CHECK: %[[VAL_31:.*]] = fir.array_load %[[VAL_4]](%[[VAL_30]]) : (!fir.heap>>, !fir.shape<1>) -> !fir.array> ! CHECK: %[[VAL_32:.*]] = arith.constant 1 : index ! CHECK: %[[VAL_33:.*]] = arith.constant 0 : index ! CHECK: %[[VAL_34:.*]] = arith.subi %[[VAL_29]]#1, %[[VAL_32]] : index @@ -251,7 +212,7 @@ subroutine test_char(x) ! CHECK: fir.result %[[VAL_47]] : !fir.array> ! CHECK: } ! CHECK: fir.array_merge_store %[[VAL_27]], %[[VAL_48:.*]] to %[[VAL_0]] : !fir.array>, !fir.array>, !fir.box>> - ! CHECK: fir.freemem %[[addr]] : !fir.heap>> + ! CHECK: fir.freemem %[[VAL_4]] : !fir.heap>> character(10) :: x(:) call bar_char(x) diff --git a/flang/test/Lower/dummy-argument-optional-2.f90 b/flang/test/Lower/dummy-argument-optional-2.f90 index c260bef4352c..73d346c10fab 100644 --- a/flang/test/Lower/dummy-argument-optional-2.f90 +++ b/flang/test/Lower/dummy-argument-optional-2.f90 @@ -99,17 +99,11 @@ subroutine pass_pointer_array(i) ! CHECK: %[[VAL_3:.*]] = fir.convert %[[VAL_2]] : (!fir.ptr>) -> i64 ! CHECK: %[[VAL_4:.*]] = arith.constant 0 : i64 ! CHECK: %[[VAL_5:.*]] = arith.cmpi ne, %[[VAL_3]], %[[VAL_4]] : i64 -! CHECK: %[[box:.*]] = fir.load %[[VAL_0]] : !fir.ref>>> +! CHECK: %[[VAL_6:.*]] = fir.load %[[VAL_0]] : !fir.ref>>> ! CHECK: %[[VAL_7:.*]] = arith.constant 0 : index -! CHECK: %[[box_none:.*]] = fir.convert %[[box]] : (!fir.box>>) -> !fir.box -! CHECK: %[[is_contiguous:.*]] = fir.call @_FortranAIsContiguous(%[[box_none]]) : (!fir.box) -> i1 ! CHECK: %[[VAL_9:.*]] = fir.if %[[VAL_5]] -> (!fir.heap>) { -! CHECK: %[[addr:.*]] = fir.if %[[is_contiguous]] -> (!fir.heap>) { -! CHECK: %[[box_addr:.*]] = fir.box_addr %[[box]] : (!fir.box>>) -> !fir.heap> -! CHECK: fir.result %[[box_addr]] : !fir.heap> -! CHECK: } else { ! CHECK: %[[VAL_10:.*]] = arith.constant 0 : index -! CHECK: %[[VAL_11:.*]]:3 = fir.box_dims %[[box]], %[[VAL_10]] : (!fir.box>>, index) -> (index, index, index) +! CHECK: %[[VAL_11:.*]]:3 = fir.box_dims %[[VAL_6]], %[[VAL_10]] : (!fir.box>>, index) -> (index, index, index) ! CHECK: %[[VAL_12:.*]] = fir.allocmem !fir.array, %[[VAL_11]]#1 {uniq_name = ".copyinout"} ! CHECK: %[[VAL_20:.*]] = fir.do_loop {{.*}} { ! CHECK: } @@ -119,14 +113,12 @@ subroutine pass_pointer_array(i) ! CHECK: %[[VAL_26:.*]] = fir.zero_bits !fir.heap> ! CHECK: fir.result %[[VAL_26]] : !fir.heap> ! CHECK: } -! CHECK: %[[not_contiguous:.*]] = arith.cmpi eq, %[[is_contiguous]], %false : i1 -! CHECK: %[[and:.*]] = arith.andi %[[VAL_5]], %[[not_contiguous]] : i1 ! CHECK: %[[VAL_29:.*]] = fir.convert %[[VAL_9]] : (!fir.heap>) -> !fir.ref> ! CHECK: fir.call @_QPtakes_opt_explicit_shape(%[[VAL_29]]) : (!fir.ref>) -> () -! CHECK: fir.if %[[and]] { +! CHECK: fir.if %[[VAL_5]] { ! CHECK: %[[VAL_40:.*]] = fir.do_loop {{.*}} { ! CHECK: } -! CHECK: fir.array_merge_store %{{.*}}, %[[VAL_40]] to %[[box]] : !fir.array, !fir.array, !fir.box>> +! CHECK: fir.array_merge_store %{{.*}}, %[[VAL_40]] to %[[VAL_6]] : !fir.array, !fir.array, !fir.box>> ! CHECK: fir.freemem %[[VAL_9]] : !fir.heap> ! CHECK: } end subroutine @@ -142,8 +134,6 @@ subroutine pass_pointer_array_char(c) ! CHECK: %[[VAL_4:.*]] = arith.constant 0 : i64 ! CHECK: %[[VAL_5:.*]] = arith.cmpi ne, %[[VAL_3]], %[[VAL_4]] : i64 ! CHECK: %[[VAL_6:.*]] = fir.load %[[VAL_0]] : !fir.ref>>>> -! CHECK: %[[box_none:.*]] = fir.convert %[[VAL_6]] : (!fir.box>>>) -> !fir.box -! CHECK: %[[is_contiguous:.*]] = fir.call @_FortranAIsContiguous(%[[box_none]]) : (!fir.box) -> i1 ! CHECK: %[[VAL_9:.*]] = fir.if %[[VAL_5]] -> (!fir.heap>>) { ! CHECK: %[[VAL_10:.*]] = arith.constant 0 : index ! CHECK: %[[VAL_11:.*]]:3 = fir.box_dims %[[VAL_6]], %[[VAL_10]] : (!fir.box>>>, index) -> (index, index, index) @@ -158,12 +148,10 @@ subroutine pass_pointer_array_char(c) ! CHECK: fir.result %[[VAL_46]] : !fir.heap>> ! CHECK: } ! CHECK: %[[VAL_47:.*]] = fir.box_elesize %[[VAL_6]] : (!fir.box>>>) -> index -! CHECK: %[[not_contiguous:.*]] = arith.cmpi eq, %[[is_contiguous]], %false : i1 -! CHECK: %[[and:.*]] = arith.andi %[[VAL_5]], %[[not_contiguous]] : i1 ! CHECK: %[[VAL_50:.*]] = fir.convert %[[VAL_9]] : (!fir.heap>>) -> !fir.ref> ! CHECK: %[[VAL_52:.*]] = fir.emboxchar %[[VAL_50]], %[[VAL_47]] : (!fir.ref>, index) -> !fir.boxchar<1> ! CHECK: fir.call @_QPtakes_opt_explicit_shape_char(%[[VAL_52]]) : (!fir.boxchar<1>) -> () -! CHECK: fir.if %[[and]] { +! CHECK: fir.if %[[VAL_5]] { ! CHECK: %[[VAL_62:.*]] = fir.do_loop {{.*}} { ! CHECK: } ! CHECK: fir.array_merge_store %{{.*}}, %[[VAL_62]] to %[[VAL_6]] : !fir.array>, !fir.array>, !fir.box>>> @@ -187,7 +175,6 @@ subroutine forward_pointer_array() ! CHECK: %[[VAL_4:.*]] = fir.convert %[[VAL_3]] : (!fir.ptr>) -> i64 ! CHECK: %[[VAL_5:.*]] = arith.constant 0 : i64 ! CHECK: %[[VAL_6:.*]] = arith.cmpi ne, %[[VAL_4]], %[[VAL_5]] : i64 -! CHECK: %[[is_contiguous:.*]] = fir.call @_FortranAIsContiguous(%{{.*}}) : (!fir.box) -> i1 ! CHECK: %[[VAL_7:.*]] = fir.if %[[VAL_6]] -> (!fir.heap>) { ! CHECK: %[[VAL_10:.*]] = fir.allocmem !fir.array ! CHECK: fir.do_loop {{.*}} { @@ -197,11 +184,9 @@ subroutine forward_pointer_array() ! CHECK: %[[VAL_11:.*]] = fir.zero_bits !fir.heap> ! CHECK: fir.result %[[VAL_11]] : !fir.heap> ! CHECK: } -! CHECK: %[[not_contiguous:.*]] = arith.cmpi eq, %[[is_contiguous]], %false : i1 -! CHECK: %[[and:.*]] = arith.andi %[[VAL_6]], %[[not_contiguous]] : i1 ! CHECK: %[[VAL_14:.*]] = fir.convert %[[VAL_7]] : (!fir.heap>) -> !fir.ref> ! CHECK: fir.call @_QPtakes_opt_explicit_shape(%[[VAL_14]]) : (!fir.ref>) -> () -! CHECK: fir.if %[[and]] { +! CHECK: fir.if %[[VAL_6]] { ! CHECK: fir.do_loop {{.*}} { ! CHECK: } ! CHECK: fir.freemem %[[VAL_7]] : !fir.heap> @@ -226,7 +211,6 @@ subroutine pass_opt_assumed_shape(x) ! CHECK: %[[VAL_4:.*]] = fir.shape %[[VAL_3]] : (index) -> !fir.shape<1> ! CHECK: %[[VAL_5:.*]] = fir.embox %[[VAL_2]](%[[VAL_4]]) : (!fir.ref>, !fir.shape<1>) -> !fir.box> ! CHECK: %[[VAL_6:.*]] = arith.select %[[VAL_1]], %[[VAL_0]], %[[VAL_5]] : !fir.box> -! CHECK: %[[is_contiguous:.*]] = fir.call @_FortranAIsContiguous(%{{.*}}) : (!fir.box) -> i1 ! CHECK: %[[VAL_7:.*]] = fir.if %[[VAL_1]] -> (!fir.heap>) { ! CHECK: %[[VAL_8:.*]] = arith.constant 0 : index ! CHECK: %[[VAL_9:.*]]:3 = fir.box_dims %[[VAL_6]], %[[VAL_8]] : (!fir.box>, index) -> (index, index, index) @@ -239,11 +223,9 @@ subroutine pass_opt_assumed_shape(x) ! CHECK: %[[VAL_23:.*]] = fir.zero_bits !fir.heap> ! CHECK: fir.result %[[VAL_23]] : !fir.heap> ! CHECK: } -! CHECK: %[[not_contiguous:.*]] = arith.cmpi eq, %[[is_contiguous]], %false : i1 -! CHECK: %[[and:.*]] = arith.andi %[[VAL_1]], %[[not_contiguous]] : i1 ! CHECK: %[[VAL_26:.*]] = fir.convert %[[VAL_27:.*]] : (!fir.heap>) -> !fir.ref> ! CHECK: fir.call @_QPtakes_opt_explicit_shape(%[[VAL_26]]) : (!fir.ref>) -> () -! CHECK: fir.if %[[and]] { +! CHECK: fir.if %[[VAL_1]] { ! CHECK: %[[VAL_36:.*]] = fir.do_loop {{.*}} { ! CHECK: } ! CHECK: fir.array_merge_store %{{.*}}, %[[VAL_36]] to %[[VAL_6]] : !fir.array, !fir.array, !fir.box> @@ -263,30 +245,20 @@ subroutine pass_opt_assumed_shape_char(c) ! CHECK: %[[VAL_5:.*]] = arith.constant 0 : index ! CHECK: %[[VAL_6:.*]] = fir.embox %[[VAL_2]](%[[VAL_4]]) typeparams %[[VAL_5]] : (!fir.ref>>, !fir.shape<1>, index) -> !fir.box>> ! CHECK: %[[VAL_7:.*]] = arith.select %[[VAL_1]], %[[VAL_0]], %[[VAL_6]] : !fir.box>> -! CHECK: %[[box_none:.*]] = fir.convert %[[VAL_7]] : (!fir.box>>) -> !fir.box -! CHECK: %[[is_contiguous:.*]] = fir.call @_FortranAIsContiguous(%[[box_none]]) : (!fir.box) -> i1 ! CHECK: %[[VAL_8:.*]] = fir.if %[[VAL_1]] -> (!fir.heap>>) { -! CHECK: %[[addr:.*]] = fir.if %[[is_contiguous]] -> (!fir.heap>>) { -! CHECK: %[[res:.*]] = fir.box_addr %[[VAL_7]] : (!fir.box>>) -> !fir.heap>> -! CHECK: fir.result %[[res]] : !fir.heap>> -! CHECK: } else { -! CHECK: %[[box_elesize:.*]] = fir.box_elesize %[[VAL_7]] : (!fir.box>>) -> index -! CHECK: %[[temp:.*]] = fir.allocmem !fir.array>(%[[box_elesize]] : index), %{{.*}}#1 {uniq_name = ".copyinout"} ! CHECK: %[[VAL_19:.*]] = fir.do_loop {{.*}} { ! CHECK: } -! CHECK: fir.array_merge_store %{{.*}}, %[[VAL_19]] to %[[temp]] typeparams %[[box_elesize]] : !fir.array>, !fir.array>, !fir.heap>>, index +! CHECK: fir.array_merge_store %{{.*}}, %[[VAL_19]] to %[[VAL_12]] typeparams %[[VAL_11]] : !fir.array>, !fir.array>, !fir.heap>>, index ! CHECK: fir.result %[[VAL_12]] : !fir.heap>> ! CHECK: } else { ! CHECK: %[[VAL_44:.*]] = fir.zero_bits !fir.heap>> ! CHECK: fir.result %[[VAL_44]] : !fir.heap>> ! CHECK: } ! CHECK: %[[VAL_45:.*]] = fir.box_elesize %[[VAL_7]] : (!fir.box>>) -> index -! CHECK: %[[not_contiguous:.*]] = arith.cmpi eq, %[[is_contiguous]], %false : i1 -! CHECK: %[[and:.*]] = arith.andi %[[VAL_1]], %[[not_contiguous]] : i1 ! CHECK: %[[VAL_48:.*]] = fir.convert %[[VAL_49:.*]] : (!fir.heap>>) -> !fir.ref> ! CHECK: %[[VAL_50:.*]] = fir.emboxchar %[[VAL_48]], %[[VAL_45]] : (!fir.ref>, index) -> !fir.boxchar<1> ! CHECK: fir.call @_QPtakes_opt_explicit_shape_char(%[[VAL_50]]) : (!fir.boxchar<1>) -> () -! CHECK: fir.if %[[and]] { +! CHECK: fir.if %[[VAL_1]] { ! CHECK: %[[VAL_59:.*]] = fir.do_loop {{.*}} { ! CHECK: fir.array_merge_store %{{.*}}, %[[VAL_59]] to %[[VAL_7]] : !fir.array>, !fir.array>, !fir.box>> ! CHECK: fir.freemem %[[VAL_49]] : !fir.heap>> @@ -407,8 +379,6 @@ subroutine pass_opt_assumed_shape_to_intentin(x) ! CHECK: %[[VAL_4:.*]] = fir.shape %[[VAL_3]] : (index) -> !fir.shape<1> ! CHECK: %[[VAL_5:.*]] = fir.embox %[[VAL_2]](%[[VAL_4]]) : (!fir.ref>, !fir.shape<1>) -> !fir.box> ! CHECK: %[[VAL_6:.*]] = arith.select %[[VAL_1]], %[[VAL_0]], %[[VAL_5]] : !fir.box> -! CHECK: %[[box_none:.*]] = fir.convert %[[VAL_6]] : (!fir.box>) -> !fir.box -! CHECK: %[[is_contiguous:.*]] = fir.call @_FortranAIsContiguous(%[[box_none]]) : (!fir.box) -> i1 ! CHECK: %[[VAL_7:.*]] = fir.if %[[VAL_1]] -> (!fir.heap>) { ! CHECK: %[[VAL_10:.*]] = fir.allocmem !fir.array ! CHECK: fir.do_loop {{.*}} { @@ -418,11 +388,9 @@ subroutine pass_opt_assumed_shape_to_intentin(x) ! CHECK: %[[VAL_23:.*]] = fir.zero_bits !fir.heap> ! CHECK: fir.result %[[VAL_23]] : !fir.heap> ! CHECK: } -! CHECK: %[[not_contiguous:.*]] = arith.cmpi eq, %[[is_contiguous]], %false : i1 -! CHECK: %[[and:.*]] = arith.andi %[[VAL_1]], %[[not_contiguous]] : i1 ! CHECK: %[[VAL_24:.*]] = fir.convert %[[VAL_7]] : (!fir.heap>) -> !fir.ref> ! CHECK: fir.call @_QPtakes_opt_explicit_shape_intentin(%[[VAL_24]]) : (!fir.ref>) -> () -! CHECK: fir.if %[[and]] { +! CHECK: fir.if %[[VAL_1]] { ! CHECK-NOT: fir.do_loop ! CHECK: fir.freemem %[[VAL_7]] : !fir.heap> ! CHECK: } @@ -439,8 +407,6 @@ subroutine pass_opt_assumed_shape_to_intentout(x) ! CHECK: %[[VAL_4:.*]] = fir.shape %[[VAL_3]] : (index) -> !fir.shape<1> ! CHECK: %[[VAL_5:.*]] = fir.embox %[[VAL_2]](%[[VAL_4]]) : (!fir.ref>, !fir.shape<1>) -> !fir.box> ! CHECK: %[[VAL_6:.*]] = arith.select %[[VAL_1]], %[[VAL_0]], %[[VAL_5]] : !fir.box> -! CHECK: %[[box_none:.*]] = fir.convert %[[VAL_6]] : (!fir.box>) -> !fir.box -! CHECK: %[[is_contiguous:.*]] = fir.call @_FortranAIsContiguous(%[[box_none]]) : (!fir.box) -> i1 ! CHECK: %[[VAL_7:.*]] = fir.if %[[VAL_1]] -> (!fir.heap>) { ! CHECK: %[[VAL_10:.*]] = fir.allocmem !fir.array ! CHECK-NOT: fir.do_loop @@ -449,11 +415,9 @@ subroutine pass_opt_assumed_shape_to_intentout(x) ! CHECK: %[[VAL_11:.*]] = fir.zero_bits !fir.heap> ! CHECK: fir.result %[[VAL_11]] : !fir.heap> ! CHECK: } -! CHECK: %[[not_contiguous:.*]] = arith.cmpi eq, %[[is_contiguous]], %false : i1 -! CHECK: %[[and:.*]] = arith.andi %[[VAL_1]], %[[not_contiguous]] : i1 ! CHECK: %[[VAL_14:.*]] = fir.convert %[[VAL_7]] : (!fir.heap>) -> !fir.ref> ! CHECK: fir.call @_QPtakes_opt_explicit_shape_intentout(%[[VAL_14]]) : (!fir.ref>) -> () -! CHECK: fir.if %[[and]] { +! CHECK: fir.if %[[VAL_1]] { ! CHECK: fir.do_loop {{.*}} { ! CHECK: } ! CHECK: fir.freemem %[[VAL_7]] : !fir.heap> diff --git a/flang/test/Lower/optional-value-caller.f90 b/flang/test/Lower/optional-value-caller.f90 index 4b935053a508..72c10dcb5497 100644 --- a/flang/test/Lower/optional-value-caller.f90 +++ b/flang/test/Lower/optional-value-caller.f90 @@ -281,8 +281,6 @@ subroutine test_dyn_array_from_assumed(i, n) ! CHECK: %[[VAL_5:.*]] = fir.shape %[[VAL_4]] : (index) -> !fir.shape<1> ! CHECK: %[[VAL_6:.*]] = fir.embox %[[VAL_3]](%[[VAL_5]]) : (!fir.ref>, !fir.shape<1>) -> !fir.box> ! CHECK: %[[VAL_7:.*]] = arith.select %[[VAL_2]], %[[VAL_0]], %[[VAL_6]] : !fir.box> -! CHECK: %[[box_none:.*]] = fir.convert %[[VAL_7]] : (!fir.box>) -> !fir.box -! CHECK: %[[is_contiguous:.*]] = fir.call @_FortranAIsContiguous(%[[box_none]]) : (!fir.box) -> i1 ! CHECK: %[[VAL_8:.*]] = fir.if %[[VAL_2]] -> (!fir.heap>) { ! CHECK: %[[VAL_9:.*]] = arith.constant 0 : index ! CHECK: %[[VAL_10:.*]]:3 = fir.box_dims %[[VAL_7]], %[[VAL_9]] : (!fir.box>, index) -> (index, index, index) @@ -295,11 +293,9 @@ subroutine test_dyn_array_from_assumed(i, n) ! CHECK: %[[VAL_24:.*]] = fir.zero_bits !fir.heap> ! CHECK: fir.result %[[VAL_24]] : !fir.heap> ! CHECK: } -! CHECK: %[[not_contiguous:.*]] = arith.cmpi eq, %[[is_contiguous]], %false{{.*}} : i1 -! CHECK: %[[and:.*]] = arith.andi %[[VAL_2]], %[[not_contiguous]] : i1 ! CHECK: %[[VAL_25:.*]] = fir.convert %[[VAL_8]] : (!fir.heap>) -> !fir.ref> ! CHECK: fir.call @_QPdyn_array(%[[VAL_25]], %[[VAL_1]]) : (!fir.ref>, !fir.ref) -> () -! CHECK: fir.if %[[and]] { +! CHECK: fir.if %[[VAL_2]] { ! CHECK: fir.freemem %[[VAL_8]] : !fir.heap> ! CHECK: } end subroutine @@ -317,8 +313,6 @@ subroutine test_array_ptr(i) ! CHECK: %[[VAL_6:.*]] = fir.load %[[VAL_0]] : !fir.ref>>> ! CHECK: %[[VAL_7:.*]] = arith.constant 0 : index ! CHECK: %[[VAL_8:.*]]:3 = fir.box_dims %[[VAL_6]], %[[VAL_7]] : (!fir.box>>, index) -> (index, index, index) -! CHECK: %[[box_none:.*]] = fir.convert %[[VAL_6]] : (!fir.box>>) -> !fir.box -! CHECK: %[[is_contiguous:.*]] = fir.call @_FortranAIsContiguous(%[[box_none]]) : (!fir.box) -> i1 ! CHECK: %[[VAL_9:.*]] = fir.if %[[VAL_5]] -> (!fir.heap>) { ! CHECK: %[[VAL_10:.*]] = arith.constant 0 : index ! CHECK: %[[VAL_11:.*]]:3 = fir.box_dims %[[VAL_6]], %[[VAL_10]] : (!fir.box>>, index) -> (index, index, index) @@ -331,10 +325,9 @@ subroutine test_array_ptr(i) ! CHECK: %[[VAL_26:.*]] = fir.zero_bits !fir.heap> ! CHECK: fir.result %[[VAL_26]] : !fir.heap> ! CHECK: } -! CHECK: %[[not_contiguous:.*]] = arith.cmpi eq, %[[is_contiguous]], %false{{.*}} : i1 -! CHECK: %[[and:.*]] = arith.andi %[[VAL_5]], %[[not_contiguous]] : i1 ! CHECK: %[[VAL_27:.*]] = fir.convert %[[VAL_9]] : (!fir.heap>) -> !fir.ref> -! CHECK: fir.if %[[and]] { +! CHECK: fir.call @_QParray(%[[VAL_27]]) : (!fir.ref>) -> () +! CHECK: fir.if %[[VAL_5]] { ! CHECK: fir.freemem %[[VAL_9]] : !fir.heap> ! CHECK: } end subroutine @@ -405,8 +398,6 @@ subroutine test_char_array(c) ! CHECK: %[[VAL_6:.*]] = arith.constant 0 : index ! CHECK: %[[VAL_7:.*]] = fir.embox %[[VAL_3]](%[[VAL_5]]) typeparams %[[VAL_6]] : (!fir.ref>>, !fir.shape<1>, index) -> !fir.box>> ! CHECK: %[[VAL_8:.*]] = arith.select %[[VAL_2]], %[[VAL_0]], %[[VAL_7]] : !fir.box>> -! CHECK: %[[box_none:.*]] = fir.convert %5 : (!fir.box>>) -> !fir.box -! CHECK: %[[is_contiguous:.*]] = fir.call @_FortranAIsContiguous(%[[box_none]]) : (!fir.box) -> i1 ! CHECK: %[[VAL_9:.*]] = fir.if %[[VAL_2]] -> (!fir.heap>>) { ! CHECK: %[[VAL_10:.*]] = arith.constant 0 : index ! CHECK: %[[VAL_11:.*]]:3 = fir.box_dims %[[VAL_8]], %[[VAL_10]] : (!fir.box>>, index) -> (index, index, index) @@ -422,12 +413,10 @@ subroutine test_char_array(c) ! CHECK: fir.result %[[VAL_45]] : !fir.heap>> ! CHECK: } ! CHECK: %[[VAL_46:.*]] = fir.box_elesize %[[VAL_8]] : (!fir.box>>) -> index -! CHECK: %[[not_contiguous:.*]] = arith.cmpi eq, %[[is_contiguous]], %false{{.*}} : i1 -! CHECK: %[[and:.*]] = arith.andi %[[VAL_2]], %[[not_contiguous]] : i1 ! CHECK: %[[VAL_47:.*]] = fir.convert %[[VAL_9]] : (!fir.heap>>) -> !fir.ref> ! CHECK: %[[VAL_49:.*]] = fir.emboxchar %[[VAL_47]], %[[VAL_46]] : (!fir.ref>, index) -> !fir.boxchar<1> ! CHECK: fir.call @_QPdyn_char_array(%[[VAL_49]], %[[VAL_1]]) : (!fir.boxchar<1>, !fir.ref) -> () -! CHECK: fir.if %[[and]] { +! CHECK: fir.if %[[VAL_2]] { ! CHECK: fir.freemem %[[VAL_9]] : !fir.heap>> ! CHECK: } end subroutine