brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.1 KiB · 181c6b7 Raw
61 lines · plain
1! Test HLFIR lowering of user defined elemental procedure references2! with finalizable results. Verify that the elemental results3! are not destroyed inside hlfir.elemental.4! RUN: bbc -emit-hlfir -o - -I nowhere %s 2>&1 | FileCheck %s5 6module types7  type t8   contains9     final :: finalize10  end type t11contains12  pure subroutine finalize(x)13    type(t), intent(inout) :: x14  end subroutine finalize15end module types16 17subroutine test1(x)18  use types19  interface20     elemental function elem(x)21       use types22       type(t), intent(in) :: x23       type(t) :: elem24     end function elem25  end interface26  type(t) :: x(:)27  x = elem(x)28end subroutine test129! CHECK-LABEL:   func.func @_QPtest1(30! CHECK:           %[[VAL_6:.*]] = hlfir.elemental %{{.*}} : (!fir.shape<1>) -> !hlfir.expr<?x!fir.type<_QMtypesTt>> {31! CHECK-NOT: fir.call @_FortranADestroy32! CHECK:           hlfir.destroy %[[VAL_6]] finalize : !hlfir.expr<?x!fir.type<_QMtypesTt>>33 34subroutine test2(x)35  use types36  interface37     elemental function elem(x)38       use types39       type(t), intent(in) :: x40       type(t) :: elem41     end function elem42     elemental function elem2(x, y)43       use types44       type(t), intent(in) :: x, y45       type(t) :: elem246     end function elem247  end interface48  type(t) :: x(:)49  x = elem2(elem(x), elem(x))50end subroutine test251! CHECK-LABEL:   func.func @_QPtest2(52! CHECK:           %[[VAL_8:.*]] = hlfir.elemental %{{.*}} : (!fir.shape<1>) -> !hlfir.expr<?x!fir.type<_QMtypesTt>> {53! CHECK-NOT: fir.call @_FortranADestroy54! CHECK:           %[[VAL_16:.*]] = hlfir.elemental %{{.*}} : (!fir.shape<1>) -> !hlfir.expr<?x!fir.type<_QMtypesTt>> {55! CHECK-NOT: fir.call @_FortranADestroy56! CHECK:           %[[VAL_23:.*]] = hlfir.elemental %{{.*}} : (!fir.shape<1>) -> !hlfir.expr<?x!fir.type<_QMtypesTt>> {57! CHECK-NOT: fir.call @_FortranADestroy58! CHECK:           hlfir.destroy %[[VAL_23]] finalize : !hlfir.expr<?x!fir.type<_QMtypesTt>>59! CHECK:           hlfir.destroy %[[VAL_16]] finalize : !hlfir.expr<?x!fir.type<_QMtypesTt>>60! CHECK:           hlfir.destroy %[[VAL_8]] finalize : !hlfir.expr<?x!fir.type<_QMtypesTt>>61