63 lines · plain
1! RUN: bbc -emit-hlfir %s -o - | %python %S/gen_mod_ref_test.py | \2! RUN: fir-opt -pass-pipeline='builtin.module(func.func(test-fir-alias-analysis-modref))' \3! RUN: --mlir-disable-threading -o /dev/null 2>&1 | FileCheck %s4 5! Test fir.call modref when arguments are passed to the call. This focus6! on the possibility of "direct" effects (taken via the arguments, and not7! via some indirect access via global states).8 9subroutine test_simple()10 implicit none11 real :: test_var_x, test_var_y12 call test_effect_external(test_var_x)13end subroutine14! CHECK-LABEL: Testing : "_QPtest_simple"15! CHECK: test_effect_external -> test_var_x#0: ModRef16! CHECK: test_effect_external -> test_var_y#0: NoModRef17 18subroutine test_equivalence()19 implicit none20 real :: test_var_x, test_var_y21 equivalence(test_var_x, test_var_y)22 call test_effect_external(test_var_x)23end subroutine24! CHECK-LABEL: Testing : "_QPtest_equivalence"25! CHECK: test_effect_external -> test_var_x#0: ModRef26! CHECK: test_effect_external -> test_var_y#0: ModRef27 28subroutine test_pointer()29 implicit none30 real, target :: test_var_x, test_var_y31 real, pointer :: p32 p => test_var_x33 call test_effect_external(p)34end subroutine35! CHECK-LABEL: Testing : "_QPtest_pointer"36! CHECK: test_effect_external -> test_var_x#0: ModRef37! TODO: test_var_y should be NoModRef, the alias analysis is currently very38! conservative whenever pointer/allocatable descriptors are involved (mostly39! because it needs to make sure it is dealing descriptors for POINTER/ALLOCATABLE40! from the Fortran source and that it can apply language rules).41! CHECK: test_effect_external -> test_var_y#0: ModRef42 43subroutine test_array_1(test_var_x)44 implicit none45 real :: test_var_x(:), test_var_y46 call test_effect_external(test_var_x(10))47end subroutine48! CHECK-LABEL: Testing : "_QPtest_array_1"49! CHECK: test_effect_external -> test_var_x#0: ModRef50! CHECK: test_effect_external -> test_var_y#0: NoModRef51 52subroutine test_array_copy_in(test_var_x)53 implicit none54 real :: test_var_x(:), test_var_y55 call test_effect_external_2(test_var_x)56end subroutine57! CHECK-LABEL: Testing : "_QPtest_array_copy_in"58! CHECK: test_effect_external_2 -> test_var_x#0: ModRef59! TODO: copy-in/out is currently badly understood by alias analysis, this60! causes the modref analysis to think the argument may alias with anyting.61! test_var_y should obviously be considered NoMoRef in the call.62! CHECK: test_effect_external_2 -> test_var_y#0: ModRef63