97 lines · plain
1// Use --mlir-disable-threading so that the AA queries are serialized2// 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 %s4 5// Fortran source code:6//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 )11// p(1) = a(1)12// !$omp end target13// !$omp target map(to: b )14// p(1) = b(1)15// !$omp end target16// !$omp end target data17// end subroutine18 19// CHECK-LABEL: Testing : "_QPTestTargetData"20 21// CHECK-DAG: targetArrayA#0 <-> targetArrayP#0: NoAlias22// CHECK-DAG: targetArrayA#0 <-> targetArrayB#0: NoAlias23// CHECK-DAG: targetArrayP#0 <-> targetArrayB#0: NoAlias24 25func.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.dscope27 %c10 = arith.constant 10 : index28 %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 : index31 %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 : index34 %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 : index37 %c0 = arith.constant 0 : index38 %7 = arith.subi %c10_1, %c1 : index39 %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 : index43 %c0_3 = arith.constant 0 : index44 %10 = arith.subi %c10, %c1_2 : index45 %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 : index48 %c0_5 = arith.constant 0 : index49 %13 = arith.subi %c10_1, %c1_4 : index50 %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 : index54 %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 : index57 %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 : index60 %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 : index63 %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>65 omp.terminator66 }67 %c1_6 = arith.constant 1 : index68 %c0_7 = arith.constant 0 : index69 %16 = arith.subi %c10_0, %c1_6 : index70 %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 : index73 %c0_9 = arith.constant 0 : index74 %19 = arith.subi %c10_1, %c1_8 : index75 %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 : index79 %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 : index82 %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 : index85 %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 : index88 %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>90 omp.terminator91 }92 omp.terminator93 }94 return95}96 97