1 // Use --mlir-disable-threading so that the AA queries are serialized
2 // as well as its diagnostic output.
3 // RUN: fir-opt %s -pass-pipeline='builtin.module(func.func(test-fir-alias-analysis))' -split-input-file --mlir-disable-threading 2>&1 | FileCheck %s
5 // Fortran source code:
7 // subroutine TestTargetData(p, a, b)
8 // real :: p(10), a(10), b(10)
9 // !$omp target data map(from: p)
10 // !$omp target map(to: a )
13 // !$omp target map(to: b )
16 // !$omp end target data
19 // CHECK-LABEL: Testing : "_QPTestTargetData"
21 // CHECK-DAG: targetArrayA#0 <-> targetArrayP#0: NoAlias
22 // CHECK-DAG: targetArrayA#0 <-> targetArrayB#0: NoAlias
23 // CHECK-DAG: targetArrayP#0 <-> targetArrayB#0: NoAlias
25 func.func @_QPTestTargetData(%arg0: !fir.ref<!fir.array<10xf32>> {fir.bindc_name = "p"}, %arg1: !fir.ref<!fir.array<10xf32>> {fir.bindc_name = "a"}, %arg2: !fir.ref<!fir.array<10xf32>> {fir.bindc_name = "b"}) {
26 %0 = fir.dummy_scope : !fir.dscope
27 %c10 = arith.constant 10 : index
28 %1 = fir.shape %c10 : (index) -> !fir.shape<1>
29 %2:2 = hlfir.declare %arg1(%1) dummy_scope %0 {uniq_name = "_QFtest_target_dataEa"} : (!fir.ref<!fir.array<10xf32>>, !fir.shape<1>, !fir.dscope) -> (!fir.ref<!fir.array<10xf32>>, !fir.ref<!fir.array<10xf32>>)
30 %c10_0 = arith.constant 10 : index
31 %3 = fir.shape %c10_0 : (index) -> !fir.shape<1>
32 %4:2 = hlfir.declare %arg2(%3) dummy_scope %0 {uniq_name = "_QFtest_target_dataEb"} : (!fir.ref<!fir.array<10xf32>>, !fir.shape<1>, !fir.dscope) -> (!fir.ref<!fir.array<10xf32>>, !fir.ref<!fir.array<10xf32>>)
33 %c10_1 = arith.constant 10 : index
34 %5 = fir.shape %c10_1 : (index) -> !fir.shape<1>
35 %6:2 = hlfir.declare %arg0(%5) dummy_scope %0 {uniq_name = "_QFtest_target_dataEp"} : (!fir.ref<!fir.array<10xf32>>, !fir.shape<1>, !fir.dscope) -> (!fir.ref<!fir.array<10xf32>>, !fir.ref<!fir.array<10xf32>>)
36 %c1 = arith.constant 1 : index
37 %c0 = arith.constant 0 : index
38 %7 = arith.subi %c10_1, %c1 : index
39 %8 = omp.map.bounds lower_bound(%c0 : index) upper_bound(%7 : index) extent(%c10_1 : index) stride(%c1 : index) start_idx(%c1 : index)
40 %9 = omp.map.info var_ptr(%6#1 : !fir.ref<!fir.array<10xf32>>, !fir.array<10xf32>) map_clauses(from) capture(ByRef) bounds(%8) -> !fir.ref<!fir.array<10xf32>> {name = "p"}
41 omp.target_data map_entries(%9 : !fir.ref<!fir.array<10xf32>>) {
42 %c1_2 = arith.constant 1 : index
43 %c0_3 = arith.constant 0 : index
44 %10 = arith.subi %c10, %c1_2 : index
45 %11 = omp.map.bounds lower_bound(%c0_3 : index) upper_bound(%10 : index) extent(%c10 : index) stride(%c1_2 : index) start_idx(%c1_2 : index)
46 %12 = omp.map.info var_ptr(%2#1 : !fir.ref<!fir.array<10xf32>>, !fir.array<10xf32>) map_clauses(to) capture(ByRef) bounds(%11) -> !fir.ref<!fir.array<10xf32>> {name = "a"}
47 %c1_4 = arith.constant 1 : index
48 %c0_5 = arith.constant 0 : index
49 %13 = arith.subi %c10_1, %c1_4 : index
50 %14 = omp.map.bounds lower_bound(%c0_5 : index) upper_bound(%13 : index) extent(%c10_1 : index) stride(%c1_4 : index) start_idx(%c1_4 : index)
51 %15 = omp.map.info var_ptr(%6#1 : !fir.ref<!fir.array<10xf32>>, !fir.array<10xf32>) map_clauses(implicit, tofrom) capture(ByRef) bounds(%14) -> !fir.ref<!fir.array<10xf32>> {name = "p"}
52 omp.target map_entries(%12 -> %arg3, %15 -> %arg4 : !fir.ref<!fir.array<10xf32>>, !fir.ref<!fir.array<10xf32>>) {
53 %c10_10 = arith.constant 10 : index
54 %22 = fir.shape %c10_10 : (index) -> !fir.shape<1>
55 %23:2 = hlfir.declare %arg3(%22) {uniq_name = "_QFtest_target_dataEa"} : (!fir.ref<!fir.array<10xf32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<10xf32>>, !fir.ref<!fir.array<10xf32>>)
56 %c10_11 = arith.constant 10 : index
57 %24 = fir.shape %c10_11 : (index) -> !fir.shape<1>
58 %25:2 = hlfir.declare %arg4(%24) {uniq_name = "_QFtest_target_dataEp"} : (!fir.ref<!fir.array<10xf32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<10xf32>>, !fir.ref<!fir.array<10xf32>>)
59 %c1_12 = arith.constant 1 : index
60 %26 = hlfir.designate %23#0 (%c1_12) {test.ptr = "targetArrayA"} : (!fir.ref<!fir.array<10xf32>>, index) -> !fir.ref<f32>
61 %27 = fir.load %26 : !fir.ref<f32>
62 %c1_13 = arith.constant 1 : index
63 %28 = hlfir.designate %25#0 (%c1_13) {test.ptr = "targetArrayP"} : (!fir.ref<!fir.array<10xf32>>, index) -> !fir.ref<f32>
64 hlfir.assign %27 to %28 : f32, !fir.ref<f32>
67 %c1_6 = arith.constant 1 : index
68 %c0_7 = arith.constant 0 : index
69 %16 = arith.subi %c10_0, %c1_6 : index
70 %17 = omp.map.bounds lower_bound(%c0_7 : index) upper_bound(%16 : index) extent(%c10_0 : index) stride(%c1_6 : index) start_idx(%c1_6 : index)
71 %18 = omp.map.info var_ptr(%4#1 : !fir.ref<!fir.array<10xf32>>, !fir.array<10xf32>) map_clauses(to) capture(ByRef) bounds(%17) -> !fir.ref<!fir.array<10xf32>> {name = "b"}
72 %c1_8 = arith.constant 1 : index
73 %c0_9 = arith.constant 0 : index
74 %19 = arith.subi %c10_1, %c1_8 : index
75 %20 = omp.map.bounds lower_bound(%c0_9 : index) upper_bound(%19 : index) extent(%c10_1 : index) stride(%c1_8 : index) start_idx(%c1_8 : index)
76 %21 = omp.map.info var_ptr(%6#1 : !fir.ref<!fir.array<10xf32>>, !fir.array<10xf32>) map_clauses(implicit, tofrom) capture(ByRef) bounds(%20) -> !fir.ref<!fir.array<10xf32>> {name = "p"}
77 omp.target map_entries(%18 -> %arg3, %21 -> %arg4 : !fir.ref<!fir.array<10xf32>>, !fir.ref<!fir.array<10xf32>>) {
78 %c10_10 = arith.constant 10 : index
79 %22 = fir.shape %c10_10 : (index) -> !fir.shape<1>
80 %23:2 = hlfir.declare %arg3(%22) {uniq_name = "_QFtest_target_dataEb"} : (!fir.ref<!fir.array<10xf32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<10xf32>>, !fir.ref<!fir.array<10xf32>>)
81 %c10_11 = arith.constant 10 : index
82 %24 = fir.shape %c10_11 : (index) -> !fir.shape<1>
83 %25:2 = hlfir.declare %arg4(%24) {uniq_name = "_QFtest_target_dataEp"} : (!fir.ref<!fir.array<10xf32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<10xf32>>, !fir.ref<!fir.array<10xf32>>)
84 %c1_12 = arith.constant 1 : index
85 %26 = hlfir.designate %23#0 (%c1_12) {test.ptr = "targetArrayB"} : (!fir.ref<!fir.array<10xf32>>, index) -> !fir.ref<f32>
86 %27 = fir.load %26 : !fir.ref<f32>
87 %c1_13 = arith.constant 1 : index
88 %28 = hlfir.designate %25#0 (%c1_13) {test.ptr = "targetArrayP"} : (!fir.ref<!fir.array<10xf32>>, index) -> !fir.ref<f32>
89 hlfir.assign %27 to %28 : f32, !fir.ref<f32>