[flang][NFC] Add IO lowering tests

These tests were left behind or only partially upstreamed during
the lower code upstreaming.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D128634

Co-authored-by: Kiran Chandramohan <kiran.chandramohan@arm.com>
Co-authored-by: Jean Perier <jperier@nvidia.com>
This commit is contained in:
Valentin Clement 2022-06-27 15:00:07 +02:00
parent 69ae441e4c
commit bd90155df4
No known key found for this signature in database
GPG Key ID: 086D54783C928776
5 changed files with 390 additions and 5 deletions

View File

@ -0,0 +1,49 @@
! RUN: bbc -emit-fir %s -o - | FileCheck %s
! UNSUPPORTED: system-windows
! CHECK-LABEL: func @_QPido1
! CHECK: %[[J_REF_ADDR:.*]] = fir.alloca !fir.ptr<i32> {uniq_name = "_QFido1Eiptr.addr"}
! CHECK: %[[J_ADDR:.*]] = fir.load %[[J_REF_ADDR]] : !fir.ref<!fir.ptr<i32>>
! CHECK: %[[J_VAL_FINAL:.*]] = fir.do_loop %[[J_VAL:.*]] = %{{.*}} to %{{.*}} step %{{.*}} -> index {
! CHECK: %[[J_VAL_CVT1:.*]] = fir.convert %[[J_VAL]] : (index) -> i32
! CHECK: fir.store %[[J_VAL_CVT1]] to %[[J_ADDR]] : !fir.ptr<i32>
! CHECK: }
! CHECK: %[[J_VAL_CVT2:.*]] = fir.convert %[[J_VAL_FINAL]] : (index) -> i32
! CHECK: fir.store %[[J_VAL_CVT2]] to %[[J_ADDR]] : !fir.ptr<i32>
subroutine ido1
integer, pointer :: iptr
integer, target :: itgt
iptr => itgt
print *, (iptr,iptr=1,10)
end subroutine
! CHECK-LABEL: func @_QPido2
! CHECK: %[[J_REF_ADDR:.*]] = fir.alloca !fir.heap<i32> {uniq_name = "_QFido2Eiptr.addr"}
! CHECK: %[[J_ADDR:.*]] = fir.load %[[J_REF_ADDR]] : !fir.ref<!fir.heap<i32>>
! CHECK: %[[J_VAL_FINAL:.*]] = fir.do_loop %[[J_VAL:.*]] = %{{.*}} to %{{.*}} step %{{.*}} -> index {
! CHECK: %[[J_VAL_CVT1:.*]] = fir.convert %[[J_VAL]] : (index) -> i32
! CHECK: fir.store %[[J_VAL_CVT1]] to %[[J_ADDR]] : !fir.heap<i32>
! CHECK: }
! CHECK: %[[J_VAL_CVT2:.*]] = fir.convert %[[J_VAL_FINAL]] : (index) -> i32
! CHECK: fir.store %[[J_VAL_CVT2]] to %[[J_ADDR]] : !fir.heap<i32>
subroutine ido2
integer, allocatable :: iptr
allocate(iptr)
print *, (iptr,iptr=1,10)
end subroutine
! CHECK-LABEL: func @_QPido3
! CHECK: %[[J_REF_ADDR:.*]] = fir.alloca !fir.heap<i32> {uniq_name = "_QFido3Ej.addr"}
! CHECK: %[[J_ADDR:.*]] = fir.load %[[J_REF_ADDR]] : !fir.ref<!fir.heap<i32>>
! CHECK: %[[J_VAL_FINAL:.*]]:2 = fir.iterate_while (%[[J_VAL:.*]] = %{{.*}} to %{{.*}} step %{{.*}}) and ({{.*}}) -> (index, i1) {
! CHECK: %[[J_VAL_CVT1:.*]] = fir.convert %[[J_VAL]] : (index) -> i32
! CHECK: fir.store %[[J_VAL_CVT1]] to %[[J_ADDR]] : !fir.heap<i32>
! CHECK: }
! CHECK: %[[J_VAL_CVT2:.*]] = fir.convert %[[J_VAL_FINAL]]#0 : (index) -> i32
! CHECK: fir.store %[[J_VAL_CVT2]] to %[[J_ADDR]] : !fir.heap<i32
subroutine ido3
integer, allocatable :: j
allocate(j)
write(*,*,err=404) (j,j=1,10)
404 continue
end subroutine

View File

@ -104,6 +104,6 @@ subroutine pass_vector_subscript_write(x, j)
! CHECK: %[[embox:.*]] = fir.embox %[[temp]](%{{.*}}) : (!fir.heap<!fir.array<10xf32>>, !fir.shape<1>) -> !fir.box<!fir.array<10xf32>>
! CHECK: %[[boxCast:.*]] = fir.convert %[[embox]] : (!fir.box<!fir.array<10xf32>>) -> !fir.box<none>
! CHECK: fir.call @_FortranAioOutputDescriptor(%{{.*}}, %[[boxCast]]) : (!fir.ref<i8>, !fir.box<none>) -> i1
! CHECK: fir.freemem %[[temp]]
! CHECK: fir.freemem %[[temp]] : !fir.heap<!fir.array<10xf32>>
write(1, rec=1) x(j)
end

View File

@ -67,12 +67,26 @@
inquire (iolength=length) existsvar, length, a
end
! Tests the 3 basic inquire formats
! CHECK-LABEL: internalnamelistio
subroutine internalNamelistIO()
! CHECK: %[[internal:[0-9]+]] = fir.alloca !fir.char<1,12> {bindc_name = "internal"
character(12) :: internal
integer :: x = 123
namelist /nml/x
! CHECK: %[[internal_:[0-9]+]] = fir.convert %[[internal]] : (!fir.ref<!fir.char<1,12>>) -> !fir.ref<i8>
! CHECK: %[[cookie:[0-9]+]] = fir.call @_FortranAioBeginInternalListOutput(%[[internal_]]
! CHECK: fir.call @_FortranAioOutputNamelist(%[[cookie]]
! CHECK: fir.call @_FortranAioEndIoStatement(%[[cookie]]
write(internal,nml=nml)
end
! Tests the 4 basic inquire formats
! CHECK-LABEL: func @_QPinquire_test
subroutine inquire_test(ch, i, b)
character(80) :: ch
integer :: i
logical :: b
integer :: id_func
! CHARACTER
! CHECK: %[[sugar:.*]] = fir.call {{.*}}BeginInquireUnit
@ -91,6 +105,13 @@ subroutine inquire_test(ch, i, b)
! CHECK: call @_FortranAioInquireLogical(%[[snicker]], %c{{.*}}, %[[b:.*]]) : (!fir.ref<i8>, i64, !fir.ref<i1>) -> i1
! CHECK: call {{.*}}EndIoStatement
inquire(90, opened=b)
! PENDING with ID
! CHECK-DAG: %[[chip:.*]] = fir.call {{.*}}BeginInquireUnit
! CHECK-DAG: fir.call @_QPid_func
! CHECK: call @_FortranAioInquirePendingId(%[[chip]], %{{.*}}, %{{.*}}) : (!fir.ref<i8>, i64, !fir.ref<i1>) -> i1
! CHECK: call {{.*}}EndIoStatement
inquire(91, id=id_func(), pending=b)
end subroutine inquire_test
! CHECK-LABEL: @_QPboz

View File

@ -0,0 +1,315 @@
! Test lowering of IO statement involving INTEGER(8) and INTEGER(16) external
! unit number that may turn out at runtime to be too large to fit in a default
! integer. Unit numbers must fit on default integers. This file tests that the
! related generated runtime checks and error recovery code.
! RUN: bbc -emit-fir %s -o - | FileCheck %s
! -----------------------------------------------------------------------------
! Test that runtime checks are not emitted when not needed
! -----------------------------------------------------------------------------
! CHECK-LABEL: func @_QPopen_4
subroutine open_4(n4)
integer(4) :: n4
! CHECK-NOT: CheckUnitNumberInRange
! CHECK-NOT: fir.if
open(n4)
end subroutine
! CHECK-LABEL: func @_QPwrite_4
subroutine write_4(n4)
integer(4) :: n4
! CHECK-NOT: CheckUnitNumberInRange
! CHECK-NOT: fir.if
write(n4, *) "hello"
end subroutine
! CHECK-LABEL: func @_QPwrite_4_recovery
subroutine write_4_recovery(n4, ios)
integer(4) :: n4, ios
! CHECK-NOT: CheckUnitNumberInRange
write(n4, *, iostat=ios) "hello"
end subroutine
! -----------------------------------------------------------------------------
! Test that runtime checks are emitted for integer(8/16) when there is
! no user error recovery.
! -----------------------------------------------------------------------------
! CHECK-LABEL: func @_QPopen_8(
! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i64>
subroutine open_8(n)
integer(8) :: n
! CHECK: %[[VAL_1:.*]] = fir.load %[[VAL_0]] : !fir.ref<i64>
! CHECK: %[[VAL_2:.*]] = arith.constant false
! CHECK: %[[VAL_3:.*]] = fir.zero_bits !fir.ref<i8>
! CHECK: %[[VAL_4:.*]] = arith.constant 0 : i64
! CHECK: %[[VAL_8:.*]] = fir.call @_FortranAioCheckUnitNumberInRange64(%[[VAL_1]], %[[VAL_2]], %[[VAL_3]], %[[VAL_4]], %{{.*}}, %{{.*}}) : (i64, i1, !fir.ref<i8>, i64, !fir.ref<i8>, i32) -> i32
! CHECK-NOT: fir.if
! CHECK: %[[VAL_9:.*]] = fir.convert %[[VAL_1]] : (i64) -> i32
! CHECK: %[[VAL_13:.*]] = fir.call @_FortranAioBeginOpenUnit(%[[VAL_9]], %{{.*}}, %{{.*}}) : (i32, !fir.ref<i8>, i32) -> !fir.ref<i8>
! CHECK: %[[VAL_14:.*]] = fir.call @_FortranAioEndIoStatement(%[[VAL_13]]) : (!fir.ref<i8>) -> i32
open(n)
end subroutine
! CHECK-LABEL: func @_QPclose_8(
! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i64>
subroutine close_8(n)
integer(8) :: n
! CHECK: %[[VAL_1:.*]] = fir.load %[[VAL_0]] : !fir.ref<i64>
! CHECK: %[[VAL_2:.*]] = arith.constant false
! CHECK: %[[VAL_3:.*]] = fir.zero_bits !fir.ref<i8>
! CHECK: %[[VAL_4:.*]] = arith.constant 0 : i64
! CHECK: %[[VAL_8:.*]] = fir.call @_FortranAioCheckUnitNumberInRange64(%[[VAL_1]], %[[VAL_2]], %[[VAL_3]], %[[VAL_4]], %{{.*}}, %{{.*}}) : (i64, i1, !fir.ref<i8>, i64, !fir.ref<i8>, i32) -> i32
! CHECK-NOT: fir.if
! CHECK: BeginClose
close(n)
end subroutine
! CHECK-LABEL: func @_QPrewind_8(
! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i64>
subroutine rewind_8(n)
integer(8) :: n
! CHECK: %[[VAL_1:.*]] = fir.load %[[VAL_0]] : !fir.ref<i64>
! CHECK: %[[VAL_2:.*]] = arith.constant false
! CHECK: %[[VAL_3:.*]] = fir.zero_bits !fir.ref<i8>
! CHECK: %[[VAL_4:.*]] = arith.constant 0 : i64
! CHECK: %[[VAL_8:.*]] = fir.call @_FortranAioCheckUnitNumberInRange64(%[[VAL_1]], %[[VAL_2]], %[[VAL_3]], %[[VAL_4]], %{{.*}}, %{{.*}}) : (i64, i1, !fir.ref<i8>, i64, !fir.ref<i8>, i32) -> i32
! CHECK-NOT: fir.if
! CHECK: BeginRewind
rewind(n)
end subroutine
! CHECK-LABEL: func @_QPbackspace_8(
! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i64>
subroutine backspace_8(n)
integer(8) :: n
backspace(n)
! CHECK: %[[VAL_1:.*]] = fir.load %[[VAL_0]] : !fir.ref<i64>
! CHECK: %[[VAL_2:.*]] = arith.constant false
! CHECK: %[[VAL_3:.*]] = fir.zero_bits !fir.ref<i8>
! CHECK: %[[VAL_4:.*]] = arith.constant 0 : i64
! CHECK: %[[VAL_8:.*]] = fir.call @_FortranAioCheckUnitNumberInRange64(%[[VAL_1]], %[[VAL_2]], %[[VAL_3]], %[[VAL_4]], %{{.*}}, %{{.*}}) : (i64, i1, !fir.ref<i8>, i64, !fir.ref<i8>, i32) -> i32
! CHECK-NOT: fir.if
! CHECK: BeginBackspace
end subroutine
! CHECK-LABEL: func @_QPinquire_8(
! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i64>
subroutine inquire_8(n, fm)
integer(8) :: n
character(*), fm
! CHECK: %[[VAL_1:.*]] = fir.load %[[VAL_0]] : !fir.ref<i64>
! CHECK: %[[VAL_2:.*]] = arith.constant false
! CHECK: %[[VAL_3:.*]] = fir.zero_bits !fir.ref<i8>
! CHECK: %[[VAL_4:.*]] = arith.constant 0 : i64
! CHECK: %[[VAL_8:.*]] = fir.call @_FortranAioCheckUnitNumberInRange64(%[[VAL_1]], %[[VAL_2]], %[[VAL_3]], %[[VAL_4]], %{{.*}}, %{{.*}}) : (i64, i1, !fir.ref<i8>, i64, !fir.ref<i8>, i32) -> i32
! CHECK-NOT: fir.if
! CHECK: BeginInquire
inquire(n, formatted=fm)
end subroutine
! CHECK-LABEL: func @_QPwrite_8(
! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i64>
subroutine write_8(n)
integer(8) :: n
! CHECK: %[[VAL_1:.*]] = fir.load %[[VAL_0]] : !fir.ref<i64>
! CHECK: %[[VAL_2:.*]] = arith.constant false
! CHECK: %[[VAL_3:.*]] = fir.zero_bits !fir.ref<i8>
! CHECK: %[[VAL_4:.*]] = arith.constant 0 : i64
! CHECK: %[[VAL_8:.*]] = fir.call @_FortranAioCheckUnitNumberInRange64(%[[VAL_1]], %[[VAL_2]], %[[VAL_3]], %[[VAL_4]], %{{.*}}, %{{.*}}) : (i64, i1, !fir.ref<i8>, i64, !fir.ref<i8>, i32) -> i32
! CHECK-NOT: fir.if
! CHECK: BeginExternalListOutput
write(n, *) "hello"
end subroutine
! CHECK-LABEL: func @_QPread_8(
! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i64>
subroutine read_8(n, var)
integer(8) :: n
integer(4) :: var
! CHECK: %[[VAL_1:.*]] = fir.load %[[VAL_0]] : !fir.ref<i64>
! CHECK: %[[VAL_2:.*]] = arith.constant false
! CHECK: %[[VAL_3:.*]] = fir.zero_bits !fir.ref<i8>
! CHECK: %[[VAL_4:.*]] = arith.constant 0 : i64
! CHECK: %[[VAL_8:.*]] = fir.call @_FortranAioCheckUnitNumberInRange64(%[[VAL_1]], %[[VAL_2]], %[[VAL_3]], %[[VAL_4]], %{{.*}}, %{{.*}}) : (i64, i1, !fir.ref<i8>, i64, !fir.ref<i8>, i32) -> i32
! CHECK-NOT: fir.if
! CHECK: BeginExternalListInput
read(n, *) var
end subroutine
! CHECK-LABEL: func @_QPopen_16(
! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i128>
subroutine open_16(n)
integer(16) :: n
! CHECK: %[[VAL_1:.*]] = fir.load %[[VAL_0]] : !fir.ref<i128>
! CHECK: %[[VAL_2:.*]] = arith.constant false
! CHECK: %[[VAL_3:.*]] = fir.zero_bits !fir.ref<i8>
! CHECK: %[[VAL_4:.*]] = arith.constant 0 : i64
! CHECK: %[[VAL_8:.*]] = fir.call @_FortranAioCheckUnitNumberInRange128(%[[VAL_1]], %[[VAL_2]], %[[VAL_3]], %[[VAL_4]], %{{.*}}, %{{.*}}) : (i128, i1, !fir.ref<i8>, i64, !fir.ref<i8>, i32) -> i32
open(n)
end subroutine
! -----------------------------------------------------------------------------
! Test generation of user error recovery if-nests with INTEGER(8/16)
! unit numbers.
! -----------------------------------------------------------------------------
! CHECK-LABEL: func @_QPopen_8_error_recovery_1(
! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i64>
! CHECK-SAME: , %[[VAL_1:.*]]: !fir.ref<i32>
subroutine open_8_error_recovery_1(n, ios)
integer(8) :: n
integer(4) :: ios
! CHECK: %[[VAL_2:.*]] = fir.load %[[VAL_0]] : !fir.ref<i64>
! CHECK: %[[VAL_3:.*]] = arith.constant true
! CHECK: %[[VAL_4:.*]] = fir.zero_bits !fir.ref<i8>
! CHECK: %[[VAL_5:.*]] = arith.constant 0 : i64
! CHECK: %[[VAL_9:.*]] = fir.call @_FortranAioCheckUnitNumberInRange64(%[[VAL_2]], %[[VAL_3]], %[[VAL_4]], %[[VAL_5]], %{{.*}}, %{{.*}}) : (i64, i1, !fir.ref<i8>, i64, !fir.ref<i8>, i32) -> i32
! CHECK: %[[VAL_10:.*]] = arith.constant 0 : i32
! CHECK: %[[VAL_11:.*]] = arith.cmpi eq, %[[VAL_9]], %[[VAL_10]] : i32
! CHECK: %[[VAL_12:.*]] = fir.if %[[VAL_11]] -> (i32) {
! CHECK: %[[VAL_13:.*]] = fir.convert %[[VAL_2]] : (i64) -> i32
! CHECK: %[[VAL_17:.*]] = fir.call @_FortranAioBeginOpenUnit(%[[VAL_13]], %{{.*}}, {{.*}}) : (i32, !fir.ref<i8>, i32) -> !fir.ref<i8>
! CHECK: %[[VAL_18:.*]] = arith.constant true
! CHECK: %[[VAL_19:.*]] = arith.constant false
! CHECK: %[[VAL_20:.*]] = arith.constant false
! CHECK: %[[VAL_21:.*]] = arith.constant false
! CHECK: %[[VAL_22:.*]] = arith.constant false
! CHECK: %[[VAL_23:.*]] = fir.call @_FortranAioEnableHandlers(%[[VAL_17]], %[[VAL_18]], %[[VAL_19]], %[[VAL_20]], %[[VAL_21]], %[[VAL_22]]) : (!fir.ref<i8>, i1, i1, i1, i1, i1) -> none
! CHECK: %[[VAL_24:.*]] = fir.call @_FortranAioEndIoStatement(%[[VAL_17]]) : (!fir.ref<i8>) -> i32
! CHECK: fir.result %[[VAL_24]] : i32
! CHECK: } else {
! CHECK: fir.result %[[VAL_9]] : i32
! CHECK: }
! CHECK: fir.store %[[VAL_25:.*]] to %[[VAL_1]] : !fir.ref<i32>
open(n, iostat=ios)
end subroutine
! CHECK-LABEL: func @_QPopen_8_error_recovery_2(
! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i64>
! CHECK-SAME: , %[[VAL_1:.*]]: !fir.boxchar<1>
subroutine open_8_error_recovery_2(n, msg)
integer(8) :: n
character(*) :: msg
! CHECK: %[[VAL_2:.*]]:2 = fir.unboxchar %[[VAL_1]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
! CHECK: %[[VAL_3:.*]] = fir.load %[[VAL_0]] : !fir.ref<i64>
! CHECK: %[[VAL_4:.*]] = arith.constant true
! CHECK: %[[VAL_5:.*]] = fir.convert %[[VAL_2]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_2]]#1 : (index) -> i64
! CHECK: %[[VAL_10:.*]] = fir.call @_FortranAioCheckUnitNumberInRange64(%[[VAL_3]], %[[VAL_4]], %[[VAL_5]], %[[VAL_6]], %{{.*}}, %{{.*}}) : (i64, i1, !fir.ref<i8>, i64, !fir.ref<i8>, i32) -> i32
! CHECK: %[[VAL_11:.*]] = arith.constant 0 : i32
! CHECK: %[[VAL_12:.*]] = arith.cmpi eq, %[[VAL_10]], %[[VAL_11]] : i32
! CHECK: %[[VAL_13:.*]] = fir.if %[[VAL_12]] -> (i32) {
! CHECK: %[[VAL_14:.*]] = fir.convert %[[VAL_3]] : (i64) -> i32
! CHECK: %[[VAL_18:.*]] = fir.call @_FortranAioBeginOpenUnit(%[[VAL_14]], %{{.*}}, %{{.*}}) : (i32, !fir.ref<i8>, i32) -> !fir.ref<i8>
! CHECK: %[[VAL_19:.*]] = arith.constant false
! CHECK: %[[VAL_20:.*]] = arith.constant true
! CHECK: %[[VAL_21:.*]] = arith.constant false
! CHECK: %[[VAL_22:.*]] = arith.constant false
! CHECK: %[[VAL_23:.*]] = arith.constant true
! CHECK: %[[VAL_24:.*]] = fir.call @_FortranAioEnableHandlers(%[[VAL_18]], %[[VAL_19]], %[[VAL_20]], %[[VAL_21]], %[[VAL_22]], %[[VAL_23]]) : (!fir.ref<i8>, i1, i1, i1, i1, i1) -> none
! CHECK: %[[VAL_25:.*]] = fir.convert %[[VAL_2]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
! CHECK: %[[VAL_26:.*]] = fir.convert %[[VAL_2]]#1 : (index) -> i64
! CHECK: %[[VAL_27:.*]] = fir.call @_FortranAioGetIoMsg(%[[VAL_18]], %[[VAL_25]], %[[VAL_26]]) : (!fir.ref<i8>, !fir.ref<i8>, i64) -> none
! CHECK: %[[VAL_28:.*]] = fir.call @_FortranAioEndIoStatement(%[[VAL_18]]) : (!fir.ref<i8>) -> i32
! CHECK: fir.result %[[VAL_28]] : i32
! CHECK: } else {
! CHECK: fir.result %[[VAL_10]] : i32
! CHECK: }
! CHECK: %[[VAL_29:.*]] = fir.convert %[[VAL_30:.*]] : (i32) -> index
! CHECK: fir.select %[[VAL_29]] : index [0, ^bb1, unit, ^bb2]
! CHECK: ^bb1:
! CHECK: br ^bb3
! CHECK: ^bb2:
! CHECK: fir.call @_QPi_failed() : () -> ()
! CHECK: br ^bb3
! CHECK: ^bb3:
! CHECK: return
open(n, err=30, iomsg=msg)
return
30 call i_failed()
end subroutine
! Torture test for temp clean-ups when user recovery is enabled.
! Checks that temps are cleaned-up in the right nests.
subroutine temp_cleanup(n, msg, ios)
interface
function make_temp0()
integer, allocatable :: make_temp0
end function
function make_temp1()
integer, allocatable :: make_temp1
end function
function make_temp2()
integer, allocatable :: make_temp2
end function
function make_temp3()
integer, allocatable :: make_temp3
end function
function make_temp4()
integer, allocatable :: make_temp4
end function
function make_temp5()
integer, allocatable :: make_temp5
end function
end interface
integer(8) :: n(2)
character(80) :: msg
Integer ios(2)
write(n(make_temp0()), iostat=ios(make_temp1()), iomsg=msg(make_temp2():make_temp3())) make_temp4(), make_temp5()
! CHECK-LABEL: func @_QPtemp_cleanup(
! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<2xi64>> {fir.bindc_name = "n"},
! CHECK-SAME: %[[VAL_1:.*]]: !fir.boxchar<1> {fir.bindc_name = "msg"},
! CHECK-SAME: %[[VAL_2:.*]]: !fir.ref<!fir.array<2xi32>> {fir.bindc_name = "ios"}) {
! CHECK: %[[VAL_10:.*]] = fir.call @_QPmake_temp2() : () -> !fir.box<!fir.heap<i32>>
! CHECK: fir.save_result %[[VAL_10]] to %[[VAL_8:.*]] : !fir.box<!fir.heap<i32>>, !fir.ref<!fir.box<!fir.heap<i32>>>
! CHECK: %[[VAL_15:.*]] = fir.call @_QPmake_temp3() : () -> !fir.box<!fir.heap<i32>>
! CHECK: fir.save_result %[[VAL_15]] to %[[VAL_7:.*]] : !fir.box<!fir.heap<i32>>, !fir.ref<!fir.box<!fir.heap<i32>>>
! CHECK: fir.load %[[VAL_7]]
! CHECK: %[[VAL_32:.*]] = fir.load %[[VAL_7]] : !fir.ref<!fir.box<!fir.heap<i32>>>
! CHECK: %[[VAL_33:.*]] = fir.box_addr %[[VAL_32]] : (!fir.box<!fir.heap<i32>>) -> !fir.heap<i32>
! CHECK: fir.freemem %[[VAL_33]] : !fir.heap<i32>
! CHECK: %[[VAL_37:.*]] = fir.load %[[VAL_8]] : !fir.ref<!fir.box<!fir.heap<i32>>>
! CHECK: %[[VAL_38:.*]] = fir.box_addr %[[VAL_37]] : (!fir.box<!fir.heap<i32>>) -> !fir.heap<i32>
! CHECK: fir.freemem %[[VAL_38]] : !fir.heap<i32>
! CHECK: %[[VAL_42:.*]] = fir.call @_QPmake_temp0() : () -> !fir.box<!fir.heap<i32>>
! CHECK: fir.save_result %[[VAL_42]] to %[[VAL_6:.*]] : !fir.box<!fir.heap<i32>>, !fir.ref<!fir.box<!fir.heap<i32>>>
! CHECK: %[[VAL_57:.*]] = fir.call @_FortranAioCheckUnitNumberInRange64(
! CHECK: %[[VAL_58:.*]] = arith.constant 0 : i32
! CHECK: %[[VAL_59:.*]] = arith.cmpi eq, %[[VAL_57]], %[[VAL_58]] : i32
! CHECK: %[[VAL_60:.*]] = fir.if %[[VAL_59]] -> (i32) {
! CHECK: fir.call @_FortranAioBeginUnformattedOutput(
! CHECK: fir.call @_FortranAioEnableHandlers(
! CHECK: %[[VAL_72:.*]] = fir.call @_QPmake_temp4() : () -> !fir.box<!fir.heap<i32>>
! CHECK: fir.save_result %[[VAL_72]] to %[[VAL_5:.*]] : !fir.box<!fir.heap<i32>>, !fir.ref<!fir.box<!fir.heap<i32>>>
! CHECK: %[[VAL_77:.*]] = fir.call @_FortranAioOutputDescriptor(
! CHECK: %[[VAL_77_1:.*]] = fir.load %[[VAL_5]] : !fir.ref<!fir.box<!fir.heap<i32>>>
! CHECK: %[[VAL_77_2:.*]] = fir.box_addr %[[VAL_77_1]] : (!fir.box<!fir.heap<i32>>) -> !fir.heap<i32>
! CHECK: fir.freemem %[[VAL_77_2]] : !fir.heap<i32>
! CHECK: fir.if %[[VAL_77]] {
! CHECK: %[[VAL_78:.*]] = fir.call @_QPmake_temp5() : () -> !fir.box<!fir.heap<i32>>
! CHECK: fir.save_result %[[VAL_78]] to %[[VAL_4:.*]] : !fir.box<!fir.heap<i32>>, !fir.ref<!fir.box<!fir.heap<i32>>>
! CHECK: fir.call @_FortranAioOutputDescriptor(
! CHECK: %[[VAL_84:.*]] = fir.load %[[VAL_4]] : !fir.ref<!fir.box<!fir.heap<i32>>>
! CHECK: %[[VAL_85:.*]] = fir.box_addr %[[VAL_84]] : (!fir.box<!fir.heap<i32>>) -> !fir.heap<i32>
! CHECK: fir.freemem %[[VAL_85]] : !fir.heap<i32>
! CHECK: }
! CHECK-NOT: fir.call @_QPmake_temp3
! CHECK: fir.call @_FortranAioGetIoMsg(
! CHECK: %[[VAL_97:.*]] = fir.call @_FortranAioEndIoStatement(
! CHECK: fir.result %[[VAL_97]] : i32
! CHECK: } else {
! CHECK: fir.result %[[VAL_57]] : i32
! CHECK: }
! CHECK: %[[VAL_98:.*]] = fir.call @_QPmake_temp1() : () -> !fir.box<!fir.heap<i32>>
! CHECK: fir.save_result %[[VAL_98]] to %[[VAL_3:.*]] : !fir.box<!fir.heap<i32>>, !fir.ref<!fir.box<!fir.heap<i32>>>
! CHECK: fir.load %[[VAL_3]]
! CHECK: %[[VAL_107:.*]] = fir.load %[[VAL_3]] : !fir.ref<!fir.box<!fir.heap<i32>>>
! CHECK: %[[VAL_108:.*]] = fir.box_addr %[[VAL_107]] : (!fir.box<!fir.heap<i32>>) -> !fir.heap<i32>
! CHECK: fir.freemem %[[VAL_108]] : !fir.heap<i32>
! CHECK: %[[VAL_112:.*]] = fir.load %[[VAL_6]] : !fir.ref<!fir.box<!fir.heap<i32>>>
! CHECK: %[[VAL_113:.*]] = fir.box_addr %[[VAL_112]] : (!fir.box<!fir.heap<i32>>) -> !fir.heap<i32>
! CHECK: fir.freemem %[[VAL_113]] : !fir.heap<i32>
end

View File

@ -22,21 +22,21 @@ subroutine test_temp_io_options(status)
! CHECK: %[[VAL_21:.*]] = fir.call @_FortranAioSetEncoding
! CHECK: %[[VAL_22:.*]] = fir.load %[[VAL_3]] : !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>
! CHECK: %[[VAL_23:.*]] = fir.box_addr %[[VAL_22]] : (!fir.box<!fir.heap<!fir.char<1,?>>>) -> !fir.heap<!fir.char<1,?>>
! CHECK: fir.freemem %[[VAL_23]]
! CHECK: fir.freemem %[[VAL_23]] : !fir.heap<!fir.char<1,?>>
! CHECK: fir.if %[[VAL_21]] {
! CHECK: %[[VAL_27:.*]] = fir.call @_QPgen_temp_character() : () -> !fir.box<!fir.heap<!fir.char<1,?>>>
! CHECK: fir.save_result %[[VAL_27]] to %[[VAL_2]] : !fir.box<!fir.heap<!fir.char<1,?>>>, !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>
! CHECK: %[[VAL_33:.*]] = fir.call @_FortranAioSetFile
! CHECK: %[[VAL_34:.*]] = fir.load %[[VAL_2]] : !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>
! CHECK: %[[VAL_35:.*]] = fir.box_addr %[[VAL_34]] : (!fir.box<!fir.heap<!fir.char<1,?>>>) -> !fir.heap<!fir.char<1,?>>
! CHECK: fir.freemem %[[VAL_35]]
! CHECK: fir.freemem %[[VAL_35]] : !fir.heap<!fir.char<1,?>>
! CHECK: fir.if %[[VAL_33]] {
! CHECK: %[[VAL_39:.*]] = fir.call @_QPgen_temp_character() : () -> !fir.box<!fir.heap<!fir.char<1,?>>>
! CHECK: fir.save_result %[[VAL_39]] to %[[VAL_1]] : !fir.box<!fir.heap<!fir.char<1,?>>>, !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>
! CHECK: fir.call @_FortranAioSetPad
! CHECK: %[[VAL_46:.*]] = fir.load %[[VAL_1]] : !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>
! CHECK: %[[VAL_47:.*]] = fir.box_addr %[[VAL_46]] : (!fir.box<!fir.heap<!fir.char<1,?>>>) -> !fir.heap<!fir.char<1,?>>
! CHECK: fir.freemem %[[VAL_47]]
! CHECK: fir.freemem %[[VAL_47]] : !fir.heap<!fir.char<1,?>>
! CHECK: }
! CHECK: }
! CHECK: fir.call @_FortranAioEndIoStatement