1 // Test alias analysis queries for host associated accesses.
2 // RUN: fir-opt %s --test-fir-alias-analysis -split-input-file --mlir-disable-threading 2>&1 | FileCheck %s
10 // end subroutine inner
11 // end subroutine test1
14 // CHECK: test1_y(1)#0 <-> test1_x(1)#0: NoAlias
15 func.func @_QFtest1Pinner(%arg0: !fir.ref<!fir.array<10xi32>> {fir.bindc_name = "y"}, %arg1: !fir.ref<tuple<!fir.box<!fir.array<10xi32>>>> {fir.host_assoc}) attributes {fir.internal_proc} {
16 %c0_i32 = arith.constant 0 : i32
17 %0 = fir.coordinate_of %arg1, %c0_i32 : (!fir.ref<tuple<!fir.box<!fir.array<10xi32>>>>, i32) -> !fir.ref<!fir.box<!fir.array<10xi32>>>
18 %1 = fir.load %0 : !fir.ref<!fir.box<!fir.array<10xi32>>>
19 %2 = fir.box_addr %1 : (!fir.box<!fir.array<10xi32>>) -> !fir.ref<!fir.array<10xi32>>
20 %c0 = arith.constant 0 : index
21 %3:3 = fir.box_dims %1, %c0 : (!fir.box<!fir.array<10xi32>>, index) -> (index, index, index)
22 %4 = fir.shape %3#1 : (index) -> !fir.shape<1>
23 %5:2 = hlfir.declare %2(%4) {fortran_attrs = #fir.var_attrs<host_assoc>, uniq_name = "_QFtest1Ex"} : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>)
24 %c10 = arith.constant 10 : index
25 %6 = fir.shape %c10 : (index) -> !fir.shape<1>
26 %7:2 = hlfir.declare %arg0(%6) {uniq_name = "_QFtest1FinnerEy"} : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>)
27 %c1 = arith.constant 1 : index
28 %8 = hlfir.designate %7#0 (%c1) {test.ptr = "test1_y(1)"} : (!fir.ref<!fir.array<10xi32>>, index) -> !fir.ref<i32>
29 %9 = fir.load %8 : !fir.ref<i32>
30 %c1_0 = arith.constant 1 : index
31 %10 = hlfir.designate %5#0 (%c1_0) {test.ptr = "test1_x(1)"} : (!fir.ref<!fir.array<10xi32>>, index) -> !fir.ref<i32>
32 hlfir.assign %9 to %10 : i32, !fir.ref<i32>
39 // integer, target :: x(10)
42 // subroutine inner(y)
43 // integer, pointer, intent(in) :: y(:)
45 // end subroutine inner
46 // end subroutine test2
48 // F18 15.5.2.13 (4) (a):
49 // CHECK: test2_y(1)#0 <-> test2_x(1)#0: MayAlias
50 func.func @_QFtest2Pinner(%arg0: !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>> {fir.bindc_name = "y"}, %arg1: !fir.ref<tuple<!fir.box<!fir.array<10xi32>>>> {fir.host_assoc}) attributes {fir.internal_proc} {
51 %c0_i32 = arith.constant 0 : i32
52 %0 = fir.coordinate_of %arg1, %c0_i32 : (!fir.ref<tuple<!fir.box<!fir.array<10xi32>>>>, i32) -> !fir.ref<!fir.box<!fir.array<10xi32>>>
53 %1 = fir.load %0 : !fir.ref<!fir.box<!fir.array<10xi32>>>
54 %2 = fir.box_addr %1 : (!fir.box<!fir.array<10xi32>>) -> !fir.ref<!fir.array<10xi32>>
55 %c0 = arith.constant 0 : index
56 %3:3 = fir.box_dims %1, %c0 : (!fir.box<!fir.array<10xi32>>, index) -> (index, index, index)
57 %4 = fir.shape %3#1 : (index) -> !fir.shape<1>
58 %5:2 = hlfir.declare %2(%4) {fortran_attrs = #fir.var_attrs<target, host_assoc>, uniq_name = "_QFtest2Ex"} : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>)
59 %6:2 = hlfir.declare %arg0 {fortran_attrs = #fir.var_attrs<intent_in, pointer>, uniq_name = "_QFtest2FinnerEy"} : (!fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>) -> (!fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>, !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>)
60 %7 = fir.load %6#0 : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>
61 %c1 = arith.constant 1 : index
62 %8 = hlfir.designate %7 (%c1) {test.ptr = "test2_y(1)"} : (!fir.box<!fir.ptr<!fir.array<?xi32>>>, index) -> !fir.ref<i32>
63 %9 = fir.load %8 : !fir.ref<i32>
64 %c1_0 = arith.constant 1 : index
65 %10 = hlfir.designate %5#0 (%c1_0) {test.ptr = "test2_x(1)"} : (!fir.ref<!fir.array<10xi32>>, index) -> !fir.ref<i32>
66 hlfir.assign %9 to %10 : i32, !fir.ref<i32>
76 // subroutine inner(y)
77 // integer, target :: y(:)
79 // end subroutine inner
80 // end subroutine test3
82 // F18 15.5.2.13 (4) (b):
83 // CHECK: test3_y(1)#0 <-> test3_x(1)#0: MayAlias
84 func.func @_QFtest3Pinner(%arg0: !fir.box<!fir.array<?xi32>> {fir.bindc_name = "y", fir.target}, %arg1: !fir.ref<tuple<!fir.box<!fir.array<10xi32>>>> {fir.host_assoc}) attributes {fir.internal_proc} {
85 %c0_i32 = arith.constant 0 : i32
86 %0 = fir.coordinate_of %arg1, %c0_i32 : (!fir.ref<tuple<!fir.box<!fir.array<10xi32>>>>, i32) -> !fir.ref<!fir.box<!fir.array<10xi32>>>
87 %1 = fir.load %0 : !fir.ref<!fir.box<!fir.array<10xi32>>>
88 %2 = fir.box_addr %1 : (!fir.box<!fir.array<10xi32>>) -> !fir.ref<!fir.array<10xi32>>
89 %c0 = arith.constant 0 : index
90 %3:3 = fir.box_dims %1, %c0 : (!fir.box<!fir.array<10xi32>>, index) -> (index, index, index)
91 %4 = fir.shape %3#1 : (index) -> !fir.shape<1>
92 %5:2 = hlfir.declare %2(%4) {fortran_attrs = #fir.var_attrs<host_assoc>, uniq_name = "_QFtest3Ex"} : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>)
93 %6:2 = hlfir.declare %arg0 {fortran_attrs = #fir.var_attrs<target>, uniq_name = "_QFtest3FinnerEy"} : (!fir.box<!fir.array<?xi32>>) -> (!fir.box<!fir.array<?xi32>>, !fir.box<!fir.array<?xi32>>)
94 %c1 = arith.constant 1 : index
95 %7 = hlfir.designate %6#0 (%c1) {test.ptr = "test3_y(1)"} : (!fir.box<!fir.array<?xi32>>, index) -> !fir.ref<i32>
96 %8 = fir.load %7 : !fir.ref<i32>
97 %c1_0 = arith.constant 1 : index
98 %9 = hlfir.designate %5#0 (%c1_0) {test.ptr = "test3_x(1)"} : (!fir.ref<!fir.array<10xi32>>, index) -> !fir.ref<i32>
99 hlfir.assign %8 to %9 : i32, !fir.ref<i32>
106 // integer :: n(10), m(10)
107 // equivalence (n, m)
109 // subroutine inner()
111 // end subroutine inner
112 // end subroutine test4
114 // CHECK: test4_m(1)#0 <-> test4_n(1)#0: MayAlias
115 func.func @_QFtest4Pinner(%arg0: !fir.ref<tuple<!fir.box<!fir.array<10xi32>>, !fir.box<!fir.array<10xi32>>>> {fir.host_assoc}) attributes {fir.internal_proc} {
116 %c0_i32 = arith.constant 0 : i32
117 %0 = fir.coordinate_of %arg0, %c0_i32 : (!fir.ref<tuple<!fir.box<!fir.array<10xi32>>, !fir.box<!fir.array<10xi32>>>>, i32) -> !fir.ref<!fir.box<!fir.array<10xi32>>>
118 %1 = fir.load %0 : !fir.ref<!fir.box<!fir.array<10xi32>>>
119 %2 = fir.box_addr %1 : (!fir.box<!fir.array<10xi32>>) -> !fir.ref<!fir.array<10xi32>>
120 %c0 = arith.constant 0 : index
121 %3:3 = fir.box_dims %1, %c0 : (!fir.box<!fir.array<10xi32>>, index) -> (index, index, index)
122 %4 = fir.shape %3#1 : (index) -> !fir.shape<1>
123 %5:2 = hlfir.declare %2(%4) {fortran_attrs = #fir.var_attrs<host_assoc>, uniq_name = "_QFtest4En"} : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>)
124 %c1_i32 = arith.constant 1 : i32
125 %6 = fir.coordinate_of %arg0, %c1_i32 : (!fir.ref<tuple<!fir.box<!fir.array<10xi32>>, !fir.box<!fir.array<10xi32>>>>, i32) -> !fir.ref<!fir.box<!fir.array<10xi32>>>
126 %7 = fir.load %6 : !fir.ref<!fir.box<!fir.array<10xi32>>>
127 %8 = fir.box_addr %7 : (!fir.box<!fir.array<10xi32>>) -> !fir.ref<!fir.array<10xi32>>
128 %c0_0 = arith.constant 0 : index
129 %9:3 = fir.box_dims %7, %c0_0 : (!fir.box<!fir.array<10xi32>>, index) -> (index, index, index)
130 %10 = fir.shape %9#1 : (index) -> !fir.shape<1>
131 %11:2 = hlfir.declare %8(%10) {fortran_attrs = #fir.var_attrs<host_assoc>, uniq_name = "_QFtest4Em"} : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>)
132 %12 = fir.alloca !fir.array<40xi8> {uniq_name = "_QFtest4Em"}
133 %c1 = arith.constant 1 : index
134 %13 = hlfir.designate %11#0 (%c1) {test.ptr = "test4_m(1)"} : (!fir.ref<!fir.array<10xi32>>, index) -> !fir.ref<i32>
135 %14 = fir.load %13 : !fir.ref<i32>
136 %c1_1 = arith.constant 1 : index
137 %15 = hlfir.designate %5#0 (%c1_1) {test.ptr = "test4_n(1)"} : (!fir.ref<!fir.array<10xi32>>, index) -> !fir.ref<i32>
138 hlfir.assign %14 to %15 : i32, !fir.ref<i32>
145 // integer, target :: x(10)
147 // subroutine inner(y)
150 // end subroutine inner
151 // end subroutine test5
153 // F18 15.5.2.13 (4):
154 // CHECK: test5_y(1)#0 <-> test5_x(1)#0: NoAlias
155 func.func @_QFtest5Pinner(%arg0: !fir.ref<!fir.array<10xi32>> {fir.bindc_name = "y"}, %arg1: !fir.ref<tuple<!fir.box<!fir.array<10xi32>>>> {fir.host_assoc}) attributes {fir.internal_proc} {
156 %c0_i32 = arith.constant 0 : i32
157 %0 = fir.coordinate_of %arg1, %c0_i32 : (!fir.ref<tuple<!fir.box<!fir.array<10xi32>>>>, i32) -> !fir.ref<!fir.box<!fir.array<10xi32>>>
158 %1 = fir.load %0 : !fir.ref<!fir.box<!fir.array<10xi32>>>
159 %2 = fir.box_addr %1 : (!fir.box<!fir.array<10xi32>>) -> !fir.ref<!fir.array<10xi32>>
160 %c0 = arith.constant 0 : index
161 %3:3 = fir.box_dims %1, %c0 : (!fir.box<!fir.array<10xi32>>, index) -> (index, index, index)
162 %4 = fir.shape %3#1 : (index) -> !fir.shape<1>
163 %5:2 = hlfir.declare %2(%4) {fortran_attrs = #fir.var_attrs<target, host_assoc>, uniq_name = "_QFtest5Ex"} : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>)
164 %c10 = arith.constant 10 : index
165 %6 = fir.shape %c10 : (index) -> !fir.shape<1>
166 %7:2 = hlfir.declare %arg0(%6) {uniq_name = "_QFtest5FinnerEy"} : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>)
167 %c1 = arith.constant 1 : index
168 %8 = hlfir.designate %7#0 (%c1) {test.ptr = "test5_y(1)"} : (!fir.ref<!fir.array<10xi32>>, index) -> !fir.ref<i32>
169 %9 = fir.load %8 : !fir.ref<i32>
170 %c1_0 = arith.constant 1 : index
171 %10 = hlfir.designate %5#0 (%c1_0) {test.ptr = "test5_x(1)"} : (!fir.ref<!fir.array<10xi32>>, index) -> !fir.ref<i32>
172 hlfir.assign %9 to %10 : i32, !fir.ref<i32>
179 // integer, pointer :: x(:)
181 // subroutine inner(y)
184 // end subroutine inner
185 // end subroutine test6
187 // F18 15.5.2.13 (4):
188 // FIXME: 'x' is classified as Indirect access leading to a conservative reply:
189 // CHECK: test6_y(1)#0 <-> test6_x(1)#0: MayAlias
190 func.func @_QFtest6Pinner(%arg0: !fir.ref<!fir.array<10xi32>> {fir.bindc_name = "y"}, %arg1: !fir.ref<tuple<!fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>>> {fir.host_assoc}) attributes {fir.internal_proc} {
191 %c0_i32 = arith.constant 0 : i32
192 %0 = fir.coordinate_of %arg1, %c0_i32 : (!fir.ref<tuple<!fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>>>, i32) -> !fir.llvm_ptr<!fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>>
193 %1 = fir.load %0 : !fir.llvm_ptr<!fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>>
194 %2:2 = hlfir.declare %1 {fortran_attrs = #fir.var_attrs<pointer, host_assoc>, uniq_name = "_QFtest6Ex"} : (!fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>) -> (!fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>, !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>)
195 %c10 = arith.constant 10 : index
196 %3 = fir.shape %c10 : (index) -> !fir.shape<1>
197 %4:2 = hlfir.declare %arg0(%3) {uniq_name = "_QFtest6FinnerEy"} : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>)
198 %c1 = arith.constant 1 : index
199 %5 = hlfir.designate %4#0 (%c1) {test.ptr = "test6_y(1)"} : (!fir.ref<!fir.array<10xi32>>, index) -> !fir.ref<i32>
200 %6 = fir.load %5 : !fir.ref<i32>
201 %7 = fir.load %2#0 : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>
202 %c1_0 = arith.constant 1 : index
203 %8 = hlfir.designate %7 (%c1_0) {test.ptr = "test6_x(1)"} : (!fir.box<!fir.ptr<!fir.array<?xi32>>>, index) -> !fir.ref<i32>
204 hlfir.assign %6 to %8 : i32, !fir.ref<i32>
212 // end module globals
217 // subroutine inner()
219 // end subroutine inner
220 // end subroutine test7
222 // CHECK: test7_g(1)#0 <-> test7_x(1)#0: NoAlias
223 func.func @_QFtest7Pinner(%arg0: !fir.ref<tuple<!fir.box<!fir.array<10xi32>>>> {fir.host_assoc}) attributes {fir.internal_proc} {
224 %0 = fir.address_of(@_QMglobalsEg) : !fir.ref<!fir.array<10xi32>>
225 %c10 = arith.constant 10 : index
226 %1 = fir.shape %c10 : (index) -> !fir.shape<1>
227 %2:2 = hlfir.declare %0(%1) {uniq_name = "_QMglobalsEg"} : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>)
228 %c0_i32 = arith.constant 0 : i32
229 %3 = fir.coordinate_of %arg0, %c0_i32 : (!fir.ref<tuple<!fir.box<!fir.array<10xi32>>>>, i32) -> !fir.ref<!fir.box<!fir.array<10xi32>>>
230 %4 = fir.load %3 : !fir.ref<!fir.box<!fir.array<10xi32>>>
231 %5 = fir.box_addr %4 : (!fir.box<!fir.array<10xi32>>) -> !fir.ref<!fir.array<10xi32>>
232 %c0 = arith.constant 0 : index
233 %6:3 = fir.box_dims %4, %c0 : (!fir.box<!fir.array<10xi32>>, index) -> (index, index, index)
234 %7 = fir.shape %6#1 : (index) -> !fir.shape<1>
235 %8:2 = hlfir.declare %5(%7) {fortran_attrs = #fir.var_attrs<host_assoc>, uniq_name = "_QFtest7Ex"} : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>)
236 %c1 = arith.constant 1 : index
237 %9 = hlfir.designate %2#0 (%c1) {test.ptr = "test7_g(1)"} : (!fir.ref<!fir.array<10xi32>>, index) -> !fir.ref<i32>
238 %10 = fir.load %9 : !fir.ref<i32>
239 %c1_0 = arith.constant 1 : index
240 %11 = hlfir.designate %8#0 (%c1_0) {test.ptr = "test7_x(1)"} : (!fir.ref<!fir.array<10xi32>>, index) -> !fir.ref<i32>
241 hlfir.assign %10 to %11 : i32, !fir.ref<i32>
244 fir.global @_QMglobalsEg : !fir.array<10xi32> {
245 %0 = fir.undefined !fir.array<10xi32>
246 fir.has_value %0 : !fir.array<10xi32>
252 // integer, target :: g(10)
253 // end module globals
258 // subroutine inner()
260 // end subroutine inner
261 // end subroutine test8
263 // CHECK: test8_g(1)#0 <-> test8_x(1)#0: NoAlias
264 func.func @_QFtest8Pinner(%arg0: !fir.ref<tuple<!fir.box<!fir.array<10xi32>>>> {fir.host_assoc}) attributes {fir.internal_proc} {
265 %0 = fir.address_of(@_QMglobalsEg) : !fir.ref<!fir.array<10xi32>>
266 %c10 = arith.constant 10 : index
267 %1 = fir.shape %c10 : (index) -> !fir.shape<1>
268 %2:2 = hlfir.declare %0(%1) {fortran_attrs = #fir.var_attrs<target>, uniq_name = "_QMglobalsEg"} : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>)
269 %c0_i32 = arith.constant 0 : i32
270 %3 = fir.coordinate_of %arg0, %c0_i32 : (!fir.ref<tuple<!fir.box<!fir.array<10xi32>>>>, i32) -> !fir.ref<!fir.box<!fir.array<10xi32>>>
271 %4 = fir.load %3 : !fir.ref<!fir.box<!fir.array<10xi32>>>
272 %5 = fir.box_addr %4 : (!fir.box<!fir.array<10xi32>>) -> !fir.ref<!fir.array<10xi32>>
273 %c0 = arith.constant 0 : index
274 %6:3 = fir.box_dims %4, %c0 : (!fir.box<!fir.array<10xi32>>, index) -> (index, index, index)
275 %7 = fir.shape %6#1 : (index) -> !fir.shape<1>
276 %8:2 = hlfir.declare %5(%7) {fortran_attrs = #fir.var_attrs<host_assoc>, uniq_name = "_QFtest8Ex"} : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>)
277 %c1 = arith.constant 1 : index
278 %9 = hlfir.designate %2#0 (%c1) {test.ptr = "test8_g(1)"} : (!fir.ref<!fir.array<10xi32>>, index) -> !fir.ref<i32>
279 %10 = fir.load %9 : !fir.ref<i32>
280 %c1_0 = arith.constant 1 : index
281 %11 = hlfir.designate %8#0 (%c1_0) {test.ptr = "test8_x(1)"} : (!fir.ref<!fir.array<10xi32>>, index) -> !fir.ref<i32>
282 hlfir.assign %10 to %11 : i32, !fir.ref<i32>
289 // integer, pointer :: g(:)
290 // end module globals
295 // subroutine inner()
297 // end subroutine inner
298 // end subroutine test9
300 // CHECK: test9_g(1)#0 <-> test9_x(1)#0: NoAlias
301 func.func @_QFtest9Pinner(%arg0: !fir.ref<tuple<!fir.box<!fir.array<10xi32>>>> {fir.host_assoc}) attributes {fir.internal_proc} {
302 %0 = fir.address_of(@_QMglobalsEg) : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>
303 %1:2 = hlfir.declare %0 {fortran_attrs = #fir.var_attrs<pointer>, uniq_name = "_QMglobalsEg"} : (!fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>) -> (!fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>, !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>)
304 %c0_i32 = arith.constant 0 : i32
305 %2 = fir.coordinate_of %arg0, %c0_i32 : (!fir.ref<tuple<!fir.box<!fir.array<10xi32>>>>, i32) -> !fir.ref<!fir.box<!fir.array<10xi32>>>
306 %3 = fir.load %2 : !fir.ref<!fir.box<!fir.array<10xi32>>>
307 %4 = fir.box_addr %3 : (!fir.box<!fir.array<10xi32>>) -> !fir.ref<!fir.array<10xi32>>
308 %c0 = arith.constant 0 : index
309 %5:3 = fir.box_dims %3, %c0 : (!fir.box<!fir.array<10xi32>>, index) -> (index, index, index)
310 %6 = fir.shape %5#1 : (index) -> !fir.shape<1>
311 %7:2 = hlfir.declare %4(%6) {fortran_attrs = #fir.var_attrs<host_assoc>, uniq_name = "_QFtest9Ex"} : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>)
312 %8 = fir.load %1#0 : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>
313 %c1 = arith.constant 1 : index
314 %9 = hlfir.designate %8 (%c1) {test.ptr = "test9_g(1)"} : (!fir.box<!fir.ptr<!fir.array<?xi32>>>, index) -> !fir.ref<i32>
315 %10 = fir.load %9 : !fir.ref<i32>
316 %c1_0 = arith.constant 1 : index
317 %11 = hlfir.designate %7#0 (%c1_0) {test.ptr = "test9_x(1)"} : (!fir.ref<!fir.array<10xi32>>, index) -> !fir.ref<i32>
318 hlfir.assign %10 to %11 : i32, !fir.ref<i32>
321 fir.global @_QMglobalsEg : !fir.box<!fir.ptr<!fir.array<?xi32>>> {
322 %0 = fir.zero_bits !fir.ptr<!fir.array<?xi32>>
323 %c0 = arith.constant 0 : index
324 %1 = fir.shape %c0 : (index) -> !fir.shape<1>
325 %2 = fir.embox %0(%1) : (!fir.ptr<!fir.array<?xi32>>, !fir.shape<1>) -> !fir.box<!fir.ptr<!fir.array<?xi32>>>
326 fir.has_value %2 : !fir.box<!fir.ptr<!fir.array<?xi32>>>
332 // integer, pointer :: g(:)
333 // end module globals
336 // integer, target :: x(10)
338 // subroutine inner()
340 // end subroutine inner
341 // end subroutine test10
343 // CHECK: test10_g(1)#0 <-> test10_x(1)#0: MayAlias
344 func.func @_QFtest10Pinner(%arg0: !fir.ref<tuple<!fir.box<!fir.array<10xi32>>>> {fir.host_assoc}) attributes {fir.internal_proc} {
345 %0 = fir.address_of(@_QMglobalsEg) : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>
346 %1:2 = hlfir.declare %0 {fortran_attrs = #fir.var_attrs<pointer>, uniq_name = "_QMglobalsEg"} : (!fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>) -> (!fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>, !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>)
347 %c0_i32 = arith.constant 0 : i32
348 %2 = fir.coordinate_of %arg0, %c0_i32 : (!fir.ref<tuple<!fir.box<!fir.array<10xi32>>>>, i32) -> !fir.ref<!fir.box<!fir.array<10xi32>>>
349 %3 = fir.load %2 : !fir.ref<!fir.box<!fir.array<10xi32>>>
350 %4 = fir.box_addr %3 : (!fir.box<!fir.array<10xi32>>) -> !fir.ref<!fir.array<10xi32>>
351 %c0 = arith.constant 0 : index
352 %5:3 = fir.box_dims %3, %c0 : (!fir.box<!fir.array<10xi32>>, index) -> (index, index, index)
353 %6 = fir.shape %5#1 : (index) -> !fir.shape<1>
354 %7:2 = hlfir.declare %4(%6) {fortran_attrs = #fir.var_attrs<target, host_assoc>, uniq_name = "_QFtest10Ex"} : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>)
355 %8 = fir.load %1#0 : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>
356 %c1 = arith.constant 1 : index
357 %9 = hlfir.designate %8 (%c1) {test.ptr = "test10_g(1)"} : (!fir.box<!fir.ptr<!fir.array<?xi32>>>, index) -> !fir.ref<i32>
358 %10 = fir.load %9 : !fir.ref<i32>
359 %c1_0 = arith.constant 1 : index
360 %11 = hlfir.designate %7#0 (%c1_0) {test.ptr = "test10_x(1)"} : (!fir.ref<!fir.array<10xi32>>, index) -> !fir.ref<i32>
361 hlfir.assign %10 to %11 : i32, !fir.ref<i32>
364 fir.global @_QMglobalsEg : !fir.box<!fir.ptr<!fir.array<?xi32>>> {
365 %0 = fir.zero_bits !fir.ptr<!fir.array<?xi32>>
366 %c0 = arith.constant 0 : index
367 %1 = fir.shape %c0 : (index) -> !fir.shape<1>
368 %2 = fir.embox %0(%1) : (!fir.ptr<!fir.array<?xi32>>, !fir.shape<1>) -> !fir.box<!fir.ptr<!fir.array<?xi32>>>
369 fir.has_value %2 : !fir.box<!fir.ptr<!fir.array<?xi32>>>
375 // integer, target :: g(10)
376 // end module globals
379 // integer, pointer :: x(:)
381 // subroutine inner()
383 // end subroutine inner
384 // end subroutine test11
386 // CHECK: test11_g(1)#0 <-> test11_x(1)#0: MayAlias
387 func.func @_QFtest11Pinner(%arg0: !fir.ref<tuple<!fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>>> {fir.host_assoc}) attributes {fir.internal_proc} {
388 %0 = fir.address_of(@_QMglobalsEg) : !fir.ref<!fir.array<10xi32>>
389 %c10 = arith.constant 10 : index
390 %1 = fir.shape %c10 : (index) -> !fir.shape<1>
391 %2:2 = hlfir.declare %0(%1) {fortran_attrs = #fir.var_attrs<target>, uniq_name = "_QMglobalsEg"} : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>)
392 %c0_i32 = arith.constant 0 : i32
393 %3 = fir.coordinate_of %arg0, %c0_i32 : (!fir.ref<tuple<!fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>>>, i32) -> !fir.llvm_ptr<!fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>>
394 %4 = fir.load %3 : !fir.llvm_ptr<!fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>>
395 %5:2 = hlfir.declare %4 {fortran_attrs = #fir.var_attrs<pointer, host_assoc>, uniq_name = "_QFtest11Ex"} : (!fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>) -> (!fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>, !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>)
396 %c1 = arith.constant 1 : index
397 %6 = hlfir.designate %2#0 (%c1) {test.ptr = "test11_g(1)"} : (!fir.ref<!fir.array<10xi32>>, index) -> !fir.ref<i32>
398 %7 = fir.load %6 : !fir.ref<i32>
399 %8 = fir.load %5#0 : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>
400 %c1_0 = arith.constant 1 : index
401 %9 = hlfir.designate %8 (%c1_0) {test.ptr = "test11_x(1)"} : (!fir.box<!fir.ptr<!fir.array<?xi32>>>, index) -> !fir.ref<i32>
402 hlfir.assign %7 to %9 : i32, !fir.ref<i32>
405 fir.global @_QMglobalsEg target : !fir.array<10xi32> {
406 %0 = fir.undefined !fir.array<10xi32>
407 fir.has_value %0 : !fir.array<10xi32>