brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.6 KiB · c9dd03c Raw
46 lines · plain
1// RUN:  fir-opt -pass-pipeline='builtin.module(func.func(test-fir-alias-analysis-modref))' \2// RUN:  --mlir-disable-threading %s -o /dev/null 2>&1 | FileCheck %s3 4// Test fir.call modref with internal procedures after the host function has been inlined in5// some other function. This checks that the last hlfir.declare "internal_assoc" flags that6// marks a variable that was captured is still considered even though there is no such flags7// on the declare at the top of the chain.8//9// In other words, in the following Fortran example, "x" should be considered10// modified by "call internal_proc" after "call inline_me" was inlined into11// "test".12//13//    subroutine test()14//      real :: x(10)15//      call inline_me(x)16//    end subroutine17//    18//    subroutine inline_me(x)19//      real :: x(10)20//      call internal_proc()21//    contains22//      subroutine internal_proc()23//        call some_external(x)24//      end subroutine25//    end subroutine26 27func.func @_QPtest() {                                                                 28  %c0_i32 = arith.constant 0 : i32                                                     29  %c10 = arith.constant 10 : index                                                     30  %0 = fir.alloca !fir.array<10xf32> {bindc_name = "x", uniq_name = "_QFtestEx"}       31  %1 = fir.shape %c10 : (index) -> !fir.shape<1>                                       32  %2:2 = hlfir.declare %0(%1) {uniq_name = "_QFtestEx"} : (!fir.ref<!fir.array<10xf32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<10xf32>>, !fir.ref<!fir.array<10xf32>>)33  %3 = fir.dummy_scope : !fir.dscope34  %4:2 = hlfir.declare %2#1(%1) dummy_scope %3 {test.ptr = "x", fortran_attrs = #fir.var_attrs<internal_assoc>, uniq_name = "_QFinline_meEx"} : (!fir.ref<!fir.array<10xf32>>, !fir.shape<1>, !fir.dscope) -> (!fir.ref<!fir.array<10xf32>>, !fir.ref<!fir.array<10xf32>>)35  %5 = fir.alloca tuple<!fir.box<!fir.array<10xf32>>>36  %6 = fir.coordinate_of %5, %c0_i32 : (!fir.ref<tuple<!fir.box<!fir.array<10xf32>>>>, i32) -> !fir.ref<!fir.box<!fir.array<10xf32>>>37  %7 = fir.embox %4#1(%1) : (!fir.ref<!fir.array<10xf32>>, !fir.shape<1>) -> !fir.box<!fir.array<10xf32>>38  fir.store %7 to %6 : !fir.ref<!fir.box<!fir.array<10xf32>>>                          39  fir.call @_QFinline_mePinternal_proc(%5) {test.ptr="internal_proc"} : (!fir.ref<tuple<!fir.box<!fir.array<10xf32>>>>) -> ()40  return41} 42func.func private @_QFinline_mePinternal_proc(!fir.ref<tuple<!fir.box<!fir.array<10xf32>>>> {fir.host_assoc}) attributes {fir.host_symbol = @_QPinline_me}43 44// CHECK-LABEL: Testing : "_QPtest"45// CHECK: internal_proc -> x#0: ModRef46