File: modref-call-locals.f90

package info (click to toggle)
llvm-toolchain-20 1%3A20.1.8-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,111,696 kB
  • sloc: cpp: 7,438,781; ansic: 1,393,871; asm: 1,012,926; python: 241,771; f90: 86,635; objc: 75,411; lisp: 42,144; pascal: 17,286; sh: 8,596; ml: 5,082; perl: 4,730; makefile: 3,591; awk: 3,523; javascript: 2,251; xml: 892; fortran: 672
file content (52 lines) | stat: -rw-r--r-- 1,586 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
! RUN: bbc -emit-hlfir %s -o - | %python %S/gen_mod_ref_test.py | \
! RUN:  fir-opt -pass-pipeline='builtin.module(func.func(test-fir-alias-analysis-modref))' \
! RUN:  --mlir-disable-threading -o /dev/null 2>&1 | FileCheck %s

! Test fir.call modref for local variables.

module somemod
  interface
    subroutine may_capture(x)
      real, target :: x
    end subroutine
    subroutine set_pointer(x)
      real, pointer :: x
    end subroutine
  end interface
end module

subroutine test_local
  use somemod, only : may_capture
  implicit none
  real :: test_var_x
  ! Capture is invalid after the call because test_var_xsaved does not have the
  ! target attribute.
  call may_capture(test_var_x)
  call test_effect_external()
end subroutine
! CHECK-LABEL: Testing : "_QPtest_local"
! CHECK: test_effect_external -> test_var_x#0: NoModRef

subroutine test_local_target
  use somemod, only : may_capture
  implicit none
  real, target :: test_var_x_target
  call may_capture(test_var_x_target)
  call test_effect_external()
end subroutine
! CHECK-LABEL: Testing : "_QPtest_local_target"
! CHECK: test_effect_external -> test_var_x_target#0: ModRef

subroutine test_local_pointer
  use somemod, only : set_pointer
  implicit none
  real, pointer :: p
  call set_pointer(p)
  ! Use associated to test the pointer target address, no the
  ! address of the pointer descriptor.
  associate(test_var_p_target  => p)
    call test_effect_external()
  end associate
end subroutine
! CHECK-LABEL: Testing : "_QPtest_local_pointer"
! CHECK: test_effect_external -> test_var_p_target#0: ModRef