56 lines · plain
1!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s2!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-is-device %s -o - | FileCheck %s3!RUN: bbc -emit-hlfir -fopenmp %s -o - | FileCheck %s4!RUN: bbc -emit-hlfir -fopenmp -fopenmp-is-target-device %s -o - | FileCheck %s5 6program test_link7 8 integer :: test_int = 19 !$omp declare target link(test_int)10 11 integer :: test_array_1d(3) = (/1,2,3/)12 !$omp declare target link(test_array_1d)13 14 integer, pointer :: test_ptr115 !$omp declare target link(test_ptr1)16 17 integer, target :: test_target = 118 !$omp declare target link(test_target)19 20 integer, pointer :: test_ptr221 !$omp declare target link(test_ptr2)22 23 !CHECK-DAG: {{%.*}} = omp.map.info var_ptr({{%.*}} : !fir.ref<i32>, i32) map_clauses(implicit, tofrom) capture(ByRef) -> !fir.ref<i32> {name = "test_int"}24 !$omp target25 test_int = test_int + 126 !$omp end target27 28 29 !CHECK-DAG: {{%.*}} = omp.map.info var_ptr({{%.*}} : !fir.ref<!fir.array<3xi32>>, !fir.array<3xi32>) map_clauses(implicit, tofrom) capture(ByRef) bounds({{%.*}}) -> !fir.ref<!fir.array<3xi32>> {name = "test_array_1d"}30 !$omp target31 do i = 1,332 test_array_1d(i) = i * 233 end do34 !$omp end target35 36 allocate(test_ptr1)37 test_ptr1 = 138 !CHECK-DAG: {{%.*}} = omp.map.info var_ptr({{%.*}} : !fir.ref<!fir.box<!fir.ptr<i32>>>, !fir.box<!fir.ptr<i32>>) map_clauses(always, implicit, to) capture(ByRef) members({{%.*}} : !fir.llvm_ptr<!fir.ref<i32>>) -> !fir.ref<!fir.box<!fir.ptr<i32>>> {name = "test_ptr1"}39 !$omp target40 test_ptr1 = test_ptr1 + 141 !$omp end target42 43 !CHECK-DAG: {{%.*}} = omp.map.info var_ptr({{%.*}} : !fir.ref<i32>, i32) map_clauses(implicit, tofrom) capture(ByRef) -> !fir.ref<i32> {name = "test_target"}44 !$omp target45 test_target = test_target + 146 !$omp end target47 48 49 !CHECK-DAG: {{%.*}} = omp.map.info var_ptr({{%.*}} : !fir.ref<!fir.box<!fir.ptr<i32>>>, !fir.box<!fir.ptr<i32>>) map_clauses(always, implicit, to) capture(ByRef) members({{%.*}} : !fir.llvm_ptr<!fir.ref<i32>>) -> !fir.ref<!fir.box<!fir.ptr<i32>>> {name = "test_ptr2"}50 test_ptr2 => test_target51 !$omp target52 test_ptr2 = test_ptr2 + 153 !$omp end target54 55end56