494 lines · plain
1// Check aliasing with the address *in* (not *of*) a pointer component2// (hlfir.designate).3//4// Throughout this test, the ".fir" suffix on symbols indicates a version of the5// MLIR after convert-hlfir-to-fir. A key difference is that component access6// is via fir.coordinate_of instead of hlfir.designate. We would like alias7// analysis results to be the same in both versions.8 9// RUN: fir-opt %s -split-input-file -o /dev/null --mlir-disable-threading \10// RUN: -pass-pipeline='builtin.module(func.func(test-fir-alias-analysis))' \11// RUN: 2>&1 | FileCheck -match-full-lines %s12 13// module m14// type :: ty15// real, pointer :: p0, p116// real :: arr(2)17// real, allocatable :: alloc18// ! target attribute on components is not supported19// end type ty20// end module m21// subroutine test()22// use m23// real, target :: t24// real :: v25// type(ty) :: obj26// type(ty), target :: t_obj27// end subroutine test28 29// CHECK-LABEL: Testing : "_QPtest"30 31// The address in a pointer can alias the address in another pointer or the32// address of a target but not the address of other variables.33// CHECK-DAG: obj%p0.tgt#0 <-> obj%p1.tgt#0: MayAlias34// CHECK-DAG: t#0 <-> obj%p0.tgt#0: MayAlias35// CHECK-DAG: t#0 <-> obj%p1.tgt#0: MayAlias36// CHECK-DAG: v#0 <-> obj%p0.tgt#0: NoAlias37// CHECK-DAG: v#0 <-> obj%p1.tgt#0: NoAlias38// CHECK-DAG: obj%p0.tgt.fir#0 <-> obj%p1.tgt.fir#0: MayAlias39// CHECK-DAG: t.fir#0 <-> obj%p0.tgt.fir#0: MayAlias40// CHECK-DAG: t.fir#0 <-> obj%p1.tgt.fir#0: MayAlias41// CHECK-DAG: v.fir#0 <-> obj%p0.tgt.fir#0: NoAlias42// CHECK-DAG: v.fir#0 <-> obj%p1.tgt.fir#0: NoAlias43 44// The address in a pointer cannot alias the address of a pointer.45// CHECK-DAG: obj%p0#0 <-> obj%p0.tgt#0: NoAlias46// CHECK-DAG: obj%p0#0 <-> obj%p1.tgt#0: NoAlias47// CHECK-DAG: obj%p0.tgt#0 <-> obj%p1#0: NoAlias48// CHECK-DAG: obj%p1#0 <-> obj%p1.tgt#0: NoAlias49// CHECK-DAG: obj%p0.fir#0 <-> obj%p0.tgt.fir#0: NoAlias50// CHECK-DAG: obj%p0.fir#0 <-> obj%p1.tgt.fir#0: NoAlias51// CHECK-DAG: obj%p0.tgt.fir#0 <-> obj%p1.fir#0: NoAlias52// CHECK-DAG: obj%p1.fir#0 <-> obj%p1.tgt.fir#0: NoAlias53 54// For some cases, AliasAnalysis analyzes hlfir.designate like fir.box_addr, so55// make sure it doesn't mistakenly see the address of obj%arr(1) as an address56// that was loaded from a pointer and that could alias something. However,57// t_obj%arr is a target.58// TODO: Thus, we expect the first case (and corresponding .fir case) below to59// be NoAlias. However, the addresses obj%p0.tgt and obj%arr(1) are analyzed as60// MayAlias because they have the same source and both are data.61// CHECK-DAG: obj%p0.tgt#0 <-> obj%arr(1)#0: MayAlias62// CHECK-DAG: obj%p0.tgt#0 <-> t_obj%arr(1)#0: MayAlias63// CHECK-DAG: obj%p0.tgt.fir#0 <-> obj%arr(1).fir#0: MayAlias64// CHECK-DAG: obj%p0.tgt.fir#0 <-> t_obj%arr(1).fir#0: MayAlias65 66// Like a pointer, an allocatable contains an address, but an allocatable is not67// a pointer and so cannot alias pointers. However, t_obj%alloc is a target.68// TODO: Thus, we expect the first case (and corresponding .fir case) below to69// be NoAlias. However, the addresses obj%p0.tgt and obj%alloc.tgt are analyzed70// as MayAlias because they have the same source and both are data.71// CHECK-DAG: obj%p0.tgt#0 <-> obj%alloc.tgt#0: MayAlias72// CHECK-DAG: obj%p0.tgt#0 <-> t_obj%alloc.tgt#0: MayAlias73// CHECK-DAG: obj%p0.tgt.fir#0 <-> obj%alloc.tgt.fir#0: MayAlias74// CHECK-DAG: obj%p0.tgt.fir#0 <-> t_obj%alloc.tgt.fir#0: MayAlias75 76// The address in an allocatable cannot alias the address of that allocatable.77// CHECK-DAG: obj%alloc#0 <-> obj%alloc.tgt#0: NoAlias78// CHECK-DAG: t_obj%alloc#0 <-> t_obj%alloc.tgt#0: NoAlias79// CHECK-DAG: obj%alloc.fir#0 <-> obj%alloc.tgt.fir#0: NoAlias80// CHECK-DAG: t_obj%alloc.fir#0 <-> t_obj%alloc.tgt.fir#0: NoAlias81 82// The address of a composite aliases the address of any component but not the83// address in a pointer or allocatable component.84// TODO: Thus, we expect the obj%*.tgt cases below to be NoAlias. However, the85// addresses obj and obj%*.tgt are analyzed as MayAlias because they have the86// same source and both are data.87// CHECK-DAG: obj#0 <-> obj%p0#0: MayAlias88// CHECK-DAG: obj#0 <-> obj%alloc#0: MayAlias89// CHECK-DAG: obj#0 <-> obj%p0.tgt#0: MayAlias90// CHECK-DAG: obj#0 <-> obj%alloc.tgt#0: MayAlias91// CHECK-DAG: obj.fir#0 <-> obj%p0.fir#0: MayAlias92// CHECK-DAG: obj.fir#0 <-> obj%alloc.fir#0: MayAlias93// CHECK-DAG: obj.fir#0 <-> obj%p0.tgt.fir#0: MayAlias94// CHECK-DAG: obj.fir#0 <-> obj%alloc.tgt.fir#0: MayAlias95 96// The addresses obtained via multiple load instructions from the same97// allocatable can alias.98// CHECK-DAG: obj%alloc.tgt#0 <-> obj%alloc.tgt2#0: MayAlias99// CHECK-DAG: obj%alloc.tgt.fir#0 <-> obj%alloc.tgt2.fir#0: MayAlias100 101func.func @_QPtest() {102 %0 = fir.alloca !fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}> {bindc_name = "obj", uniq_name = "_QFtestEobj"}103 %1:2 = hlfir.declare %0 {test.ptr="obj", uniq_name = "_QFtestEobj"} : (!fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>) -> (!fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>, !fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>)104 %2 = fir.alloca f32 {bindc_name = "t", fir.target, uniq_name = "_QFtestEt"}105 %3:2 = hlfir.declare %2 {test.ptr="t", fortran_attrs = #fir.var_attrs<target>, uniq_name = "_QFtestEt"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)106 %4 = fir.alloca !fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}> {bindc_name = "t_obj", fir.target, uniq_name = "_QFtestEt_obj"}107 %5:2 = hlfir.declare %4 {test.ptr="t_obj", fortran_attrs = #fir.var_attrs<target>, uniq_name = "_QFtestEt_obj"} : (!fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>) -> (!fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>, !fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>)108 %6 = fir.alloca f32 {bindc_name = "v", uniq_name = "_QFtestEv"}109 %7:2 = hlfir.declare %6 {test.ptr="v", uniq_name = "_QFtestEv"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)110 %8 = hlfir.designate %1#0{"p0"} {test.ptr="obj%p0", fortran_attrs = #fir.var_attrs<pointer>} : (!fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>) -> !fir.ref<!fir.box<!fir.ptr<f32>>>111 %9 = fir.load %8 : !fir.ref<!fir.box<!fir.ptr<f32>>>112 %10 = fir.box_addr %9 {test.ptr="obj%p0.tgt"} : (!fir.box<!fir.ptr<f32>>) -> !fir.ptr<f32>113 %11 = hlfir.designate %1#0{"p1"} {test.ptr="obj%p1", fortran_attrs = #fir.var_attrs<pointer>} : (!fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>) -> !fir.ref<!fir.box<!fir.ptr<f32>>>114 %12 = fir.load %11 : !fir.ref<!fir.box<!fir.ptr<f32>>>115 %13 = fir.box_addr %12 {test.ptr="obj%p1.tgt"}: (!fir.box<!fir.ptr<f32>>) -> !fir.ptr<f32>116 %c2 = arith.constant 2 : index117 %14 = fir.shape %c2 : (index) -> !fir.shape<1>118 %c1 = arith.constant 1 : index119 %15 = hlfir.designate %1#0{"arr"} <%14> (%c1) {test.ptr="obj%arr(1)"} : (!fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>, !fir.shape<1>, index) -> !fir.ref<f32>120 %16 = hlfir.designate %1#0{"alloc"} {test.ptr="obj%alloc", fortran_attrs = #fir.var_attrs<allocatable>} : (!fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>) -> !fir.ref<!fir.box<!fir.heap<f32>>>121 %17 = fir.load %16 : !fir.ref<!fir.box<!fir.heap<f32>>>122 %repeat17 = fir.load %16 : !fir.ref<!fir.box<!fir.heap<f32>>>123 %18 = fir.box_addr %17 {test.ptr="obj%alloc.tgt"}: (!fir.box<!fir.heap<f32>>) -> !fir.heap<f32>124 %repeat18 = fir.box_addr %repeat17 {test.ptr="obj%alloc.tgt2"}: (!fir.box<!fir.heap<f32>>) -> !fir.heap<f32>125 %c2_1 = arith.constant 2 : index126 %19 = fir.shape %c2_1 : (index) -> !fir.shape<1>127 %c1_2 = arith.constant 1 : index128 %20 = hlfir.designate %5#0{"arr"} <%19> (%c1_2) {test.ptr="t_obj%arr(1)"} : (!fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>, !fir.shape<1>, index) -> !fir.ref<f32>129 %21 = hlfir.designate %5#0{"alloc"} {test.ptr="t_obj%alloc", fortran_attrs = #fir.var_attrs<allocatable>} : (!fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>) -> !fir.ref<!fir.box<!fir.heap<f32>>>130 %22 = fir.load %21 : !fir.ref<!fir.box<!fir.heap<f32>>>131 %23 = fir.box_addr %22 {test.ptr="t_obj%alloc.tgt"} : (!fir.box<!fir.heap<f32>>) -> !fir.heap<f32>132 return133}134 135func.func @_QPtest.fir() {136 %0 = fir.alloca !fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}> {bindc_name = "obj", uniq_name = "_QFtestEobj"}137 %1 = fir.declare %0 {test.ptr="obj.fir", uniq_name = "_QFtestEobj"} : (!fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>) -> !fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>138 %2 = fir.alloca f32 {bindc_name = "t", fir.target, uniq_name = "_QFtestEt"}139 %3 = fir.declare %2 {test.ptr = "t.fir", fortran_attrs = #fir.var_attrs<target>, uniq_name = "_QFtestEt"} : (!fir.ref<f32>) -> !fir.ref<f32>140 %4 = fir.alloca !fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}> {bindc_name = "t_obj", fir.target, uniq_name = "_QFtestEt_obj"}141 %5 = fir.declare %4 {test.ptr="t_obj.fir", fortran_attrs = #fir.var_attrs<target>, uniq_name = "_QFtestEt_obj"} : (!fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>) -> !fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>142 %6 = fir.alloca f32 {bindc_name = "v", uniq_name = "_QFtestEv"}143 %7 = fir.declare %6 {test.ptr = "v.fir", uniq_name = "_QFtestEv"} : (!fir.ref<f32>) -> !fir.ref<f32>144 %9 = fir.coordinate_of %1, p0 {test.ptr="obj%p0.fir"} : (!fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>) -> !fir.ref<!fir.box<!fir.ptr<f32>>>145 %10 = fir.load %9 : !fir.ref<!fir.box<!fir.ptr<f32>>>146 %11 = fir.box_addr %10 {test.ptr = "obj%p0.tgt.fir"} : (!fir.box<!fir.ptr<f32>>) -> !fir.ptr<f32>147 %13 = fir.coordinate_of %1, p1 {test.ptr="obj%p1.fir"} : (!fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>) -> !fir.ref<!fir.box<!fir.ptr<f32>>>148 %14 = fir.load %13 : !fir.ref<!fir.box<!fir.ptr<f32>>>149 %15 = fir.box_addr %14 {test.ptr = "obj%p1.tgt.fir"} : (!fir.box<!fir.ptr<f32>>) -> !fir.ptr<f32>150 %c2 = arith.constant 2 : index151 %16 = fir.shape %c2 : (index) -> !fir.shape<1>152 %c1 = arith.constant 1 : index153 %18 = fir.coordinate_of %1, arr : (!fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>) -> !fir.ref<!fir.array<2xf32>>154 %19 = fir.array_coor %18(%16) %c1 {test.ptr="obj%arr(1).fir"} : (!fir.ref<!fir.array<2xf32>>, !fir.shape<1>, index) -> !fir.ref<f32>155 %21 = fir.coordinate_of %1, alloc {test.ptr="obj%alloc.fir"} : (!fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>) -> !fir.ref<!fir.box<!fir.heap<f32>>>156 %22 = fir.load %21 : !fir.ref<!fir.box<!fir.heap<f32>>>157 %repeat22 = fir.load %21 : !fir.ref<!fir.box<!fir.heap<f32>>>158 %23 = fir.box_addr %22 {test.ptr = "obj%alloc.tgt.fir"} : (!fir.box<!fir.heap<f32>>) -> !fir.heap<f32>159 %repeat23 = fir.box_addr %repeat22 {test.ptr = "obj%alloc.tgt2.fir"} : (!fir.box<!fir.heap<f32>>) -> !fir.heap<f32>160 %c2_0 = arith.constant 2 : index161 %24 = fir.shape %c2_0 : (index) -> !fir.shape<1>162 %c1_1 = arith.constant 1 : index163 %26 = fir.coordinate_of %5, arr : (!fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>) -> !fir.ref<!fir.array<2xf32>>164 %27 = fir.array_coor %26(%24) %c1_1 {test.ptr="t_obj%arr(1).fir"} : (!fir.ref<!fir.array<2xf32>>, !fir.shape<1>, index) -> !fir.ref<f32>165 %29 = fir.coordinate_of %5, alloc {test.ptr="t_obj%alloc.fir"} : (!fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>) -> !fir.ref<!fir.box<!fir.heap<f32>>>166 %30 = fir.load %29 : !fir.ref<!fir.box<!fir.heap<f32>>>167 %31 = fir.box_addr %30 {test.ptr = "t_obj%alloc.tgt.fir"} : (!fir.box<!fir.heap<f32>>) -> !fir.heap<f32>168 return169}170 171// -----172 173// Repeat above test except composites are dummy args instead of locals.174 175// module m176// type :: ty177// real, pointer :: p0, p1178// real :: arr(2)179// real, allocatable :: alloc180// ! target attribute on components is not supported181// end type ty182// end module m183// subroutine test(obj, t_obj)184// use m185// type(ty) :: obj186// type(ty), target :: t_obj187// real, target :: t188// real :: v189// end subroutine test190 191// CHECK-LABEL: Testing : "_QPtest"192 193// The address in a pointer can alias the address in another pointer or the194// address of a target but not the address of other variables.195// CHECK-DAG: obj%p0.tgt#0 <-> obj%p1.tgt#0: MayAlias196// CHECK-DAG: t#0 <-> obj%p0.tgt#0: MayAlias197// CHECK-DAG: t#0 <-> obj%p1.tgt#0: MayAlias198// CHECK-DAG: v#0 <-> obj%p0.tgt#0: NoAlias199// CHECK-DAG: v#0 <-> obj%p1.tgt#0: NoAlias200// CHECK-DAG: obj%p0.tgt.fir#0 <-> obj%p1.tgt.fir#0: MayAlias201// CHECK-DAG: t.fir#0 <-> obj%p0.tgt.fir#0: MayAlias202// CHECK-DAG: t.fir#0 <-> obj%p1.tgt.fir#0: MayAlias203// CHECK-DAG: v.fir#0 <-> obj%p0.tgt.fir#0: NoAlias204// CHECK-DAG: v.fir#0 <-> obj%p1.tgt.fir#0: NoAlias205 206// The address in a pointer cannot alias the address of a pointer.207// CHECK-DAG: obj%p0#0 <-> obj%p0.tgt#0: NoAlias208// CHECK-DAG: obj%p0#0 <-> obj%p1.tgt#0: NoAlias209// CHECK-DAG: obj%p0.tgt#0 <-> obj%p1#0: NoAlias210// CHECK-DAG: obj%p1#0 <-> obj%p1.tgt#0: NoAlias211// CHECK-DAG: obj%p0.fir#0 <-> obj%p0.tgt.fir#0: NoAlias212// CHECK-DAG: obj%p0.fir#0 <-> obj%p1.tgt.fir#0: NoAlias213// CHECK-DAG: obj%p0.tgt.fir#0 <-> obj%p1.fir#0: NoAlias214// CHECK-DAG: obj%p1.fir#0 <-> obj%p1.tgt.fir#0: NoAlias215 216// For some cases, AliasAnalysis analyzes hlfir.designate like fir.box_addr, so217// make sure it doesn't mistakenly see the address of obj%arr(1) as an address218// that was loaded from a pointer and that could alias something. However,219// t_obj%arr is a target.220// TODO: Thus, we expect the first case (and corresponding .fir case) below to221// be NoAlias. However, the addresses obj%p0.tgt and obj%arr(1) are analyzed as222// MayAlias because they have the same source and both are data.223// CHECK-DAG: obj%p0.tgt#0 <-> obj%arr(1)#0: MayAlias224// CHECK-DAG: obj%p0.tgt#0 <-> t_obj%arr(1)#0: MayAlias225// CHECK-DAG: obj%p0.tgt.fir#0 <-> obj%arr(1).fir#0: MayAlias226// CHECK-DAG: obj%p0.tgt.fir#0 <-> t_obj%arr(1).fir#0: MayAlias227 228// Like a pointer, an allocatable contains an address, but an allocatable is not229// a pointer and so cannot alias pointers. However, t_obj%alloc is a target.230// TODO: Thus, we expect the first case (and corresponding .fir case) below to231// be NoAlias. However, the addresses obj%p0.tgt and obj%alloc.tgt are analyzed232// as MayAlias because they have the same source and both are data.233// CHECK-DAG: obj%p0.tgt#0 <-> obj%alloc.tgt#0: MayAlias234// CHECK-DAG: obj%p0.tgt#0 <-> t_obj%alloc.tgt#0: MayAlias235// CHECK-DAG: obj%p0.tgt.fir#0 <-> obj%alloc.tgt.fir#0: MayAlias236// CHECK-DAG: obj%p0.tgt.fir#0 <-> t_obj%alloc.tgt.fir#0: MayAlias237 238// The address in an allocatable cannot alias the address of that allocatable.239// TODO: Thus, we expect all cases below to be NoAlias. However, target dummy240// args are currently indiscrimnately analyzed as MayAlias.241// CHECK-DAG: obj%alloc#0 <-> obj%alloc.tgt#0: NoAlias242// CHECK-DAG: t_obj%alloc#0 <-> t_obj%alloc.tgt#0: MayAlias243// CHECK-DAG: obj%alloc.fir#0 <-> obj%alloc.tgt.fir#0: NoAlias244// CHECK-DAG: t_obj%alloc.fir#0 <-> t_obj%alloc.tgt.fir#0: MayAlias245 246// The address of a composite aliases the address of any component but not the247// address in a pointer or allocatable component.248// TODO: Thus, we expect the obj%*.tgt cases below to be NoAlias. However, the249// addresses obj and obj%*.tgt are analyzed as MayAlias because they have the250// same source and both are data.251// CHECK-DAG: obj#0 <-> obj%p0#0: MayAlias252// CHECK-DAG: obj#0 <-> obj%alloc#0: MayAlias253// CHECK-DAG: obj#0 <-> obj%p0.tgt#0: MayAlias254// CHECK-DAG: obj#0 <-> obj%alloc.tgt#0: MayAlias255// CHECK-DAG: obj.fir#0 <-> obj%p0.fir#0: MayAlias256// CHECK-DAG: obj.fir#0 <-> obj%alloc.fir#0: MayAlias257// CHECK-DAG: obj.fir#0 <-> obj%p0.tgt.fir#0: MayAlias258// CHECK-DAG: obj.fir#0 <-> obj%alloc.tgt.fir#0: MayAlias259 260// The addresses obtained via multiple load instructions from the same261// allocatable can alias.262// CHECK-DAG: obj%alloc.tgt#0 <-> obj%alloc.tgt2#0: MayAlias263// CHECK-DAG: obj%alloc.tgt.fir#0 <-> obj%alloc.tgt2.fir#0: MayAlias264 265func.func @_QPtest(%arg0: !fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>> {fir.bindc_name = "obj"}, %arg1: !fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>> {fir.bindc_name = "t_obj", fir.target}) {266 %0 = fir.dummy_scope : !fir.dscope267 %1:2 = hlfir.declare %arg0 dummy_scope %0 {test.ptr="obj", uniq_name = "_QFtestEobj"} : (!fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>, !fir.dscope) -> (!fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>, !fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>)268 %2 = fir.alloca f32 {bindc_name = "t", fir.target, uniq_name = "_QFtestEt"}269 %3:2 = hlfir.declare %2 {test.ptr="t", fortran_attrs = #fir.var_attrs<target>, uniq_name = "_QFtestEt"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)270 %4:2 = hlfir.declare %arg1 dummy_scope %0 {test.ptr="t_obj", fortran_attrs = #fir.var_attrs<target>, uniq_name = "_QFtestEt_obj"} : (!fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>, !fir.dscope) -> (!fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>, !fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>)271 %5 = fir.alloca f32 {bindc_name = "v", uniq_name = "_QFtestEv"}272 %6:2 = hlfir.declare %5 {test.ptr="v", uniq_name = "_QFtestEv"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)273 %7 = hlfir.designate %1#0{"p0"} {test.ptr="obj%p0", fortran_attrs = #fir.var_attrs<pointer>} : (!fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>) -> !fir.ref<!fir.box<!fir.ptr<f32>>>274 %8 = fir.load %7 : !fir.ref<!fir.box<!fir.ptr<f32>>>275 %9 = fir.box_addr %8 {test.ptr="obj%p0.tgt"} : (!fir.box<!fir.ptr<f32>>) -> !fir.ptr<f32>276 %10 = hlfir.designate %1#0{"p1"} {test.ptr="obj%p1", fortran_attrs = #fir.var_attrs<pointer>} : (!fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>) -> !fir.ref<!fir.box<!fir.ptr<f32>>>277 %11 = fir.load %10 : !fir.ref<!fir.box<!fir.ptr<f32>>>278 %12 = fir.box_addr %11 {test.ptr="obj%p1.tgt"} : (!fir.box<!fir.ptr<f32>>) -> !fir.ptr<f32>279 %c2 = arith.constant 2 : index280 %13 = fir.shape %c2 : (index) -> !fir.shape<1>281 %c1 = arith.constant 1 : index282 %14 = hlfir.designate %1#0{"arr"} <%13> (%c1) {test.ptr="obj%arr(1)"} : (!fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>, !fir.shape<1>, index) -> !fir.ref<f32>283 %15 = hlfir.designate %1#0{"alloc"} {test.ptr="obj%alloc", fortran_attrs = #fir.var_attrs<allocatable>} : (!fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>) -> !fir.ref<!fir.box<!fir.heap<f32>>>284 %16 = fir.load %15 : !fir.ref<!fir.box<!fir.heap<f32>>>285 %repeat16 = fir.load %15 : !fir.ref<!fir.box<!fir.heap<f32>>>286 %17 = fir.box_addr %16 {test.ptr="obj%alloc.tgt"} : (!fir.box<!fir.heap<f32>>) -> !fir.heap<f32>287 %repeat17 = fir.box_addr %repeat16 {test.ptr="obj%alloc.tgt2"} : (!fir.box<!fir.heap<f32>>) -> !fir.heap<f32>288 %c2_0 = arith.constant 2 : index289 %18 = fir.shape %c2_0 : (index) -> !fir.shape<1>290 %c1_1 = arith.constant 1 : index291 %19 = hlfir.designate %4#0{"arr"} <%18> (%c1_1) {test.ptr="t_obj%arr(1)"} : (!fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>, !fir.shape<1>, index) -> !fir.ref<f32>292 %20 = hlfir.designate %4#0{"alloc"} {test.ptr="t_obj%alloc", fortran_attrs = #fir.var_attrs<allocatable>} : (!fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>) -> !fir.ref<!fir.box<!fir.heap<f32>>>293 %21 = fir.load %20 : !fir.ref<!fir.box<!fir.heap<f32>>>294 %22 = fir.box_addr %21 {test.ptr="t_obj%alloc.tgt"} : (!fir.box<!fir.heap<f32>>) -> !fir.heap<f32>295 return296}297 298func.func @_QPtest.fir(%arg0: !fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>> {fir.bindc_name = "obj"}, %arg1: !fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>> {fir.bindc_name = "t_obj", fir.target}) {299 %0 = fir.dummy_scope : !fir.dscope300 %1 = fir.declare %arg0 dummy_scope %0 {test.ptr="obj.fir", uniq_name = "_QFtestEobj"} : (!fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>, !fir.dscope) -> !fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>301 %2 = fir.alloca f32 {bindc_name = "t", fir.target, uniq_name = "_QFtestEt"}302 %3 = fir.declare %2 {test.ptr = "t.fir", fortran_attrs = #fir.var_attrs<target>, uniq_name = "_QFtestEt"} : (!fir.ref<f32>) -> !fir.ref<f32>303 %4 = fir.declare %arg1 dummy_scope %0 {test.ptr="t_obj.fir", fortran_attrs = #fir.var_attrs<target>, uniq_name = "_QFtestEt_obj"} : (!fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>, !fir.dscope) -> !fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>304 %5 = fir.alloca f32 {bindc_name = "v", uniq_name = "_QFtestEv"}305 %6 = fir.declare %5 {test.ptr = "v.fir", uniq_name = "_QFtestEv"} : (!fir.ref<f32>) -> !fir.ref<f32>306 %8 = fir.coordinate_of %1, p0 {test.ptr="obj%p0.fir"} : (!fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>) -> !fir.ref<!fir.box<!fir.ptr<f32>>>307 %9 = fir.load %8 : !fir.ref<!fir.box<!fir.ptr<f32>>>308 %10 = fir.box_addr %9 {test.ptr = "obj%p0.tgt.fir"} : (!fir.box<!fir.ptr<f32>>) -> !fir.ptr<f32>309 %12 = fir.coordinate_of %1, p1 {test.ptr="obj%p1.fir"} : (!fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>) -> !fir.ref<!fir.box<!fir.ptr<f32>>>310 %13 = fir.load %12 : !fir.ref<!fir.box<!fir.ptr<f32>>>311 %14 = fir.box_addr %13 {test.ptr = "obj%p1.tgt.fir"} : (!fir.box<!fir.ptr<f32>>) -> !fir.ptr<f32>312 %c2 = arith.constant 2 : index313 %15 = fir.shape %c2 : (index) -> !fir.shape<1>314 %c1 = arith.constant 1 : index315 %17 = fir.coordinate_of %1, arr : (!fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>) -> !fir.ref<!fir.array<2xf32>>316 %18 = fir.array_coor %17(%15) %c1 {test.ptr="obj%arr(1).fir"} : (!fir.ref<!fir.array<2xf32>>, !fir.shape<1>, index) -> !fir.ref<f32>317 %20 = fir.coordinate_of %1, alloc {test.ptr="obj%alloc.fir"} : (!fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>) -> !fir.ref<!fir.box<!fir.heap<f32>>>318 %21 = fir.load %20 : !fir.ref<!fir.box<!fir.heap<f32>>>319 %repeat21 = fir.load %20 : !fir.ref<!fir.box<!fir.heap<f32>>>320 %22 = fir.box_addr %21 {test.ptr = "obj%alloc.tgt.fir"} : (!fir.box<!fir.heap<f32>>) -> !fir.heap<f32>321 %repeat22 = fir.box_addr %repeat21 {test.ptr = "obj%alloc.tgt2.fir"} : (!fir.box<!fir.heap<f32>>) -> !fir.heap<f32>322 %c2_0 = arith.constant 2 : index323 %23 = fir.shape %c2_0 : (index) -> !fir.shape<1>324 %c1_1 = arith.constant 1 : index325 %25 = fir.coordinate_of %4, arr : (!fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>) -> !fir.ref<!fir.array<2xf32>>326 %26 = fir.array_coor %25(%23) %c1_1 {test.ptr="t_obj%arr(1).fir"} : (!fir.ref<!fir.array<2xf32>>, !fir.shape<1>, index) -> !fir.ref<f32>327 %28 = fir.coordinate_of %4, alloc {test.ptr="t_obj%alloc.fir"} : (!fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>) -> !fir.ref<!fir.box<!fir.heap<f32>>>328 %29 = fir.load %28 : !fir.ref<!fir.box<!fir.heap<f32>>>329 %30 = fir.box_addr %29 {test.ptr = "t_obj%alloc.tgt.fir"} : (!fir.box<!fir.heap<f32>>) -> !fir.heap<f32>330 return331}332 333// -----334 335// Repeat above test except composites are globals.336 337// module m338// type :: ty339// real, pointer :: p0, p1340// real :: arr(2)341// real, allocatable :: alloc342// ! target attribute on components is not supported343// end type ty344// type(ty) :: obj345// type(ty), target :: t_obj346// end module m347// subroutine test()348// use m349// real, target :: t350// real :: v351// end subroutine test352 353// CHECK-LABEL: Testing : "_QPtest"354 355// The address in a pointer can alias the address in another pointer or the356// address of a target but not the address of other variables.357// CHECK-DAG: obj%p0.tgt#0 <-> obj%p1.tgt#0: MayAlias358// CHECK-DAG: t#0 <-> obj%p0.tgt#0: MayAlias359// CHECK-DAG: t#0 <-> obj%p1.tgt#0: MayAlias360// CHECK-DAG: v#0 <-> obj%p0.tgt#0: NoAlias361// CHECK-DAG: v#0 <-> obj%p1.tgt#0: NoAlias362// CHECK-DAG: obj%p0.tgt.fir#0 <-> obj%p1.tgt.fir#0: MayAlias363// CHECK-DAG: t.fir#0 <-> obj%p0.tgt.fir#0: MayAlias364// CHECK-DAG: t.fir#0 <-> obj%p1.tgt.fir#0: MayAlias365// CHECK-DAG: v.fir#0 <-> obj%p0.tgt.fir#0: NoAlias366// CHECK-DAG: v.fir#0 <-> obj%p1.tgt.fir#0: NoAlias367 368// The address in a pointer cannot alias the address of a pointer.369// CHECK-DAG: obj%p0#0 <-> obj%p0.tgt#0: NoAlias370// CHECK-DAG: obj%p0#0 <-> obj%p1.tgt#0: NoAlias371// CHECK-DAG: obj%p0.tgt#0 <-> obj%p1#0: NoAlias372// CHECK-DAG: obj%p1#0 <-> obj%p1.tgt#0: NoAlias373// CHECK-DAG: obj%p0.fir#0 <-> obj%p0.tgt.fir#0: NoAlias374// CHECK-DAG: obj%p0.fir#0 <-> obj%p1.tgt.fir#0: NoAlias375// CHECK-DAG: obj%p0.tgt.fir#0 <-> obj%p1.fir#0: NoAlias376// CHECK-DAG: obj%p1.fir#0 <-> obj%p1.tgt.fir#0: NoAlias377 378// For some cases, AliasAnalysis analyzes hlfir.designate like fir.box_addr, so379// make sure it doesn't mistakenly see the address of obj%arr(1) as an address380// that was loaded from a pointer and that could alias something. However,381// t_obj%arr is a target.382// TODO: Thus, we expect the first case (and corresponding .fir case) below to383// be NoAlias. However, the addresses obj%p0.tgt and obj%arr(1) are analyzed as384// MayAlias because they have the same source and both are data.385// CHECK-DAG: obj%p0.tgt#0 <-> obj%arr(1)#0: MayAlias386// CHECK-DAG: obj%p0.tgt#0 <-> t_obj%arr(1)#0: MayAlias387// CHECK-DAG: obj%p0.tgt.fir#0 <-> obj%arr(1).fir#0: MayAlias388// CHECK-DAG: obj%p0.tgt.fir#0 <-> t_obj%arr(1).fir#0: MayAlias389 390// Like a pointer, an allocatable contains an address, but an allocatable is not391// a pointer and so cannot alias pointers. However, t_obj%alloc is a target.392// TODO: Thus, we expect the first case (and corresponding .fir case) below to393// be NoAlias. However, the addresses obj%p0.tgt and obj%alloc.tgt are analyzed394// as MayAlias because they have the same source and both are data.395// CHECK-DAG: obj%p0.tgt#0 <-> obj%alloc.tgt#0: MayAlias396// CHECK-DAG: obj%p0.tgt#0 <-> t_obj%alloc.tgt#0: MayAlias397// CHECK-DAG: obj%p0.tgt.fir#0 <-> obj%alloc.tgt.fir#0: MayAlias398// CHECK-DAG: obj%p0.tgt.fir#0 <-> t_obj%alloc.tgt.fir#0: MayAlias399 400// The address in an allocatable cannot alias the address of that allocatable.401// CHECK-DAG: obj%alloc#0 <-> obj%alloc.tgt#0: NoAlias402// CHECK-DAG: t_obj%alloc#0 <-> t_obj%alloc.tgt#0: NoAlias403// CHECK-DAG: obj%alloc.fir#0 <-> obj%alloc.tgt.fir#0: NoAlias404// CHECK-DAG: t_obj%alloc.fir#0 <-> t_obj%alloc.tgt.fir#0: NoAlias405 406// The address of a composite aliases the address of any component but not the407// address in a pointer or allocatable component.408// TODO: Thus, we expect the obj%*.tgt cases below to be NoAlias. However, the409// addresses obj and obj%*.tgt are analyzed as MayAlias because they have the410// same source and both are data.411// CHECK-DAG: obj#0 <-> obj%p0#0: MayAlias412// CHECK-DAG: obj#0 <-> obj%alloc#0: MayAlias413// CHECK-DAG: obj#0 <-> obj%p0.tgt#0: MayAlias414// CHECK-DAG: obj#0 <-> obj%alloc.tgt#0: MayAlias415// CHECK-DAG: obj.fir#0 <-> obj%p0.fir#0: MayAlias416// CHECK-DAG: obj.fir#0 <-> obj%alloc.fir#0: MayAlias417// CHECK-DAG: obj.fir#0 <-> obj%p0.tgt.fir#0: MayAlias418// CHECK-DAG: obj.fir#0 <-> obj%alloc.tgt.fir#0: MayAlias419 420// The addresses obtained via multiple load instructions from the same421// allocatable can alias.422// CHECK-DAG: obj%alloc.tgt#0 <-> obj%alloc.tgt2#0: MayAlias423// CHECK-DAG: obj%alloc.tgt.fir#0 <-> obj%alloc.tgt2.fir#0: MayAlias424 425func.func @_QPtest() {426 %0 = fir.address_of(@_QMmEobj) : !fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>427 %1:2 = hlfir.declare %0 {test.ptr="obj", uniq_name = "_QMmEobj"} : (!fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>) -> (!fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>, !fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>)428 %2 = fir.alloca f32 {bindc_name = "t", fir.target, uniq_name = "_QFtestEt"}429 %3:2 = hlfir.declare %2 {test.ptr="t", fortran_attrs = #fir.var_attrs<target>, uniq_name = "_QFtestEt"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)430 %4 = fir.address_of(@_QMmEt_obj) : !fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>431 %5:2 = hlfir.declare %4 {test.ptr="t_obj", fortran_attrs = #fir.var_attrs<target>, uniq_name = "_QMmEt_obj"} : (!fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>) -> (!fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>, !fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>)432 %6 = fir.alloca f32 {bindc_name = "v", uniq_name = "_QFtestEv"}433 %7:2 = hlfir.declare %6 {test.ptr="v", uniq_name = "_QFtestEv"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)434 %8 = hlfir.designate %1#0{"p0"} {test.ptr="obj%p0", fortran_attrs = #fir.var_attrs<pointer>} : (!fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>) -> !fir.ref<!fir.box<!fir.ptr<f32>>>435 %9 = fir.load %8 : !fir.ref<!fir.box<!fir.ptr<f32>>>436 %10 = fir.box_addr %9 {test.ptr="obj%p0.tgt"} : (!fir.box<!fir.ptr<f32>>) -> !fir.ptr<f32>437 %12 = hlfir.designate %1#0{"p1"} {test.ptr="obj%p1", fortran_attrs = #fir.var_attrs<pointer>} : (!fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>) -> !fir.ref<!fir.box<!fir.ptr<f32>>>438 %13 = fir.load %12 : !fir.ref<!fir.box<!fir.ptr<f32>>>439 %14 = fir.box_addr %13 {test.ptr="obj%p1.tgt"} : (!fir.box<!fir.ptr<f32>>) -> !fir.ptr<f32>440 %c2 = arith.constant 2 : index441 %16 = fir.shape %c2 : (index) -> !fir.shape<1>442 %c1 = arith.constant 1 : index443 %17 = hlfir.designate %1#0{"arr"} <%16> (%c1) {test.ptr="obj%arr(1)"} : (!fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>, !fir.shape<1>, index) -> !fir.ref<f32>444 %19 = hlfir.designate %1#0{"alloc"} {test.ptr="obj%alloc", fortran_attrs = #fir.var_attrs<allocatable>} : (!fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>) -> !fir.ref<!fir.box<!fir.heap<f32>>>445 %20 = fir.load %19 : !fir.ref<!fir.box<!fir.heap<f32>>>446 %repeat20 = fir.load %19 : !fir.ref<!fir.box<!fir.heap<f32>>>447 %21 = fir.box_addr %20 {test.ptr="obj%alloc.tgt"} : (!fir.box<!fir.heap<f32>>) -> !fir.heap<f32>448 %repeat21 = fir.box_addr %repeat20 {test.ptr="obj%alloc.tgt2"} : (!fir.box<!fir.heap<f32>>) -> !fir.heap<f32>449 %c2_0 = arith.constant 2 : index450 %23 = fir.shape %c2_0 : (index) -> !fir.shape<1>451 %c1_1 = arith.constant 1 : index452 %24 = hlfir.designate %5#0{"arr"} <%23> (%c1_1) {test.ptr="t_obj%arr(1)"} : (!fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>, !fir.shape<1>, index) -> !fir.ref<f32>453 %26 = hlfir.designate %5#0{"alloc"} {test.ptr="t_obj%alloc", fortran_attrs = #fir.var_attrs<allocatable>} : (!fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>) -> !fir.ref<!fir.box<!fir.heap<f32>>>454 %27 = fir.load %26 : !fir.ref<!fir.box<!fir.heap<f32>>>455 %28 = fir.box_addr %27 {test.ptr="t_obj%alloc.tgt"} : (!fir.box<!fir.heap<f32>>) -> !fir.heap<f32>456 return457}458 459func.func @_QPtest.fir() {460 %0 = fir.address_of(@_QMmEobj) : !fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>461 %1 = fir.declare %0 {test.ptr="obj.fir", uniq_name = "_QMmEobj"} : (!fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>) -> !fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>462 %2 = fir.alloca f32 {bindc_name = "t", fir.target, uniq_name = "_QFtestEt"}463 %3 = fir.declare %2 {test.ptr = "t.fir", fortran_attrs = #fir.var_attrs<target>, uniq_name = "_QFtestEt"} : (!fir.ref<f32>) -> !fir.ref<f32>464 %4 = fir.address_of(@_QMmEt_obj) : !fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>465 %5 = fir.declare %4 {test.ptr="t_obj.fir", fortran_attrs = #fir.var_attrs<target>, uniq_name = "_QMmEt_obj"} : (!fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>) -> !fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>466 %6 = fir.alloca f32 {bindc_name = "v", uniq_name = "_QFtestEv"}467 %7 = fir.declare %6 {test.ptr = "v.fir", uniq_name = "_QFtestEv"} : (!fir.ref<f32>) -> !fir.ref<f32>468 %9 = fir.coordinate_of %1, p0 {test.ptr="obj%p0.fir"} : (!fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>) -> !fir.ref<!fir.box<!fir.ptr<f32>>>469 %10 = fir.load %9 : !fir.ref<!fir.box<!fir.ptr<f32>>>470 %11 = fir.box_addr %10 {test.ptr = "obj%p0.tgt.fir"} : (!fir.box<!fir.ptr<f32>>) -> !fir.ptr<f32>471 %13 = fir.coordinate_of %1, p1 {test.ptr="obj%p1.fir"} : (!fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>) -> !fir.ref<!fir.box<!fir.ptr<f32>>>472 %14 = fir.load %13 : !fir.ref<!fir.box<!fir.ptr<f32>>>473 %15 = fir.box_addr %14 {test.ptr = "obj%p1.tgt.fir"} : (!fir.box<!fir.ptr<f32>>) -> !fir.ptr<f32>474 %c2 = arith.constant 2 : index475 %16 = fir.shape %c2 : (index) -> !fir.shape<1>476 %c1 = arith.constant 1 : index477 %18 = fir.coordinate_of %1, arr : (!fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>) -> !fir.ref<!fir.array<2xf32>>478 %19 = fir.array_coor %18(%16) %c1 {test.ptr="obj%arr(1).fir"} : (!fir.ref<!fir.array<2xf32>>, !fir.shape<1>, index) -> !fir.ref<f32>479 %21 = fir.coordinate_of %1, alloc {test.ptr="obj%alloc.fir"} : (!fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>) -> !fir.ref<!fir.box<!fir.heap<f32>>>480 %22 = fir.load %21 : !fir.ref<!fir.box<!fir.heap<f32>>>481 %repeat22 = fir.load %21 : !fir.ref<!fir.box<!fir.heap<f32>>>482 %23 = fir.box_addr %22 {test.ptr = "obj%alloc.tgt.fir"} : (!fir.box<!fir.heap<f32>>) -> !fir.heap<f32>483 %repeat23 = fir.box_addr %repeat22 {test.ptr = "obj%alloc.tgt2.fir"} : (!fir.box<!fir.heap<f32>>) -> !fir.heap<f32>484 %c2_0 = arith.constant 2 : index485 %24 = fir.shape %c2_0 : (index) -> !fir.shape<1>486 %c1_1 = arith.constant 1 : index487 %26 = fir.coordinate_of %5, arr : (!fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>) -> !fir.ref<!fir.array<2xf32>>488 %27 = fir.array_coor %26(%24) %c1_1 {test.ptr="t_obj%arr(1).fir"} : (!fir.ref<!fir.array<2xf32>>, !fir.shape<1>, index) -> !fir.ref<f32>489 %29 = fir.coordinate_of %5, alloc {test.ptr="t_obj%alloc.fir"} : (!fir.ref<!fir.type<_QMmTty{p0:!fir.box<!fir.ptr<f32>>,p1:!fir.box<!fir.ptr<f32>>,arr:!fir.array<2xf32>,alloc:!fir.box<!fir.heap<f32>>}>>) -> !fir.ref<!fir.box<!fir.heap<f32>>>490 %30 = fir.load %29 : !fir.ref<!fir.box<!fir.heap<f32>>>491 %31 = fir.box_addr %30 {test.ptr = "t_obj%alloc.tgt.fir"} : (!fir.box<!fir.heap<f32>>) -> !fir.heap<f32>492 return493}494