[ConstraintElim] Add support for decomposing gep nuw (#118639)
[llvm-project.git] / flang / test / Lower / global-initialization.f90
blobff208ecc3c897817e273f1f19f4645676b8e8f7b
1 ! RUN: bbc %s -o - | FileCheck %s
3 program bar
4 ! CHECK: fir.address_of(@[[name1:.*]]my_data)
5 integer, save :: my_data = 1
6 print *, my_data
7 call foo()
8 call foo2()
9 call foo3()
10 contains
12 ! CHECK-LABEL: func private @_QFPfoo
13 subroutine foo()
14 ! CHECK: fir.address_of(@[[name2:.*foo.*my_data]])
15 integer, save :: my_data = 2
16 print *, my_data + 1
17 end subroutine
19 ! CHECK-LABEL: func private @_QFPfoo2
20 subroutine foo2()
21 ! CHECK: fir.address_of(@[[name3:.*foo2.*my_data]])
22 integer, save :: my_data
23 my_data = 4
24 print *, my_data
25 end subroutine
27 ! CHECK-LABEL: func private @_QFPfoo3
28 subroutine foo3()
29 ! CHECK-DAG: fir.address_of(@[[name4:.*foo3.*idata]]){{.*}}fir.array<5xi32>
30 ! CHECK-DAG: fir.address_of(@[[name5:.*foo3.*rdata]]){{.*}}fir.array<3xf16>
31 ! CHECK-DAG: fir.address_of(@[[name6:.*foo3.*my_data]]){{.*}}fir.array<2x4xi64>
32 integer*4, dimension(5), save :: idata = (/ (i*i, i=1,5) /)
33 integer*8, dimension(2, 10:13), save :: my_data = reshape((/1,2,3,4,5,6,7,8/), shape(my_data))
34 real*2, dimension(7:9), save :: rdata = (/100., 99., 98./)
35 print *, rdata(9)
36 print *, idata(3)
37 print *, my_data(1,11)
38 end subroutine
39 end program
41 ! CHECK: fir.global internal @[[name1]]
42 ! CHECK: fir.global internal @[[name2]]
43 ! CHECK: fir.global internal @[[name3]]
44 ! CHECK-DAG: fir.global internal @[[name4]]{{.*}}fir.array<5xi32>
45 ! CHECK-DAG: fir.global internal @[[name5]]{{.*}}fir.array<3xf16>
46 ! CHECK-DAG: fir.global internal @[[name6]]{{.*}}fir.array<2x4xi64>