Skip to content

Commit fbaf2c6

Browse files
committed
[OpenMP][Flang] Add "IsolatedFromAbove" trait to omp.target
This patch adds the PFT lowering changes required for adding the IsolatedFromAbove trait to omp.target. Key Changes: - Add IsolatedFromAbove trait to target op in MLIR. - Main reason for this change is to prevent CSE and other similar optimisations from crossing region boundaries for target operations. The link below has the discourse discussion surrounding this issue. - Move implicit operand capturing to the PFT lowering stage. - Implicit operands are first added as implicitly captured map_operands with their map_types set accordingly to indicate this. Later, all map_operands including implicit ones are added as block arguments. - Remove `implicit` attribute from the `MapInfoOp`. This information is already captured by the `map_type`. - The custom printer and parser for the map_types have been updated to show the `implicit` and `literal` map_types. - Update related tests. - This fixes #63555. - This fixes #70488.
1 parent 0a22a80 commit fbaf2c6

File tree

11 files changed

+676
-169
lines changed

11 files changed

+676
-169
lines changed

flang/lib/Lower/OpenMP.cpp

Lines changed: 261 additions & 37 deletions
Large diffs are not rendered by default.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
!RUN: %flang_fc1 -emit-llvm -fopenmp %s -o - | FileCheck %s
2+
3+
!===============================================================================
4+
! Check MapTypes for target implicit captures
5+
!===============================================================================
6+
7+
!CHECK: @.offload_sizes = private unnamed_addr constant [1 x i64] [i64 4]
8+
!CHECK: @.offload_maptypes = private unnamed_addr constant [1 x i64] [i64 800]
9+
subroutine mapType_scalar
10+
integer :: a
11+
!$omp target
12+
a = 10
13+
!$omp end target
14+
end subroutine mapType_scalar
15+
16+
!CHECK: @.offload_sizes{{.*}} = private unnamed_addr constant [1 x i64] [i64 4096]
17+
!CHECK: @.offload_maptypes{{.*}} = private unnamed_addr constant [1 x i64] [i64 547]
18+
subroutine mapType_array
19+
integer :: a(1024)
20+
!$omp target
21+
a(10) = 20
22+
!$omp end target
23+
end subroutine mapType_array
24+
25+
!CHECK: @.offload_sizes{{.*}} = private unnamed_addr constant [1 x i64] [i64 8]
26+
!CHECK: @.offload_maptypes{{.*}} = private unnamed_addr constant [1 x i64] [i64 547]
27+
subroutine mapType_ptr
28+
integer, pointer :: a
29+
!$omp target
30+
a = 10
31+
!$omp end target
32+
end subroutine mapType_ptr
33+
34+
!CHECK: @.offload_sizes{{.*}} = private unnamed_addr constant [2 x i64] [i64 8, i64 4]
35+
!CHECK: @.offload_maptypes{{.*}} = private unnamed_addr constant [2 x i64] [i64 544, i64 800]
36+
subroutine mapType_c_ptr
37+
use iso_c_binding, only : c_ptr, c_loc
38+
type(c_ptr) :: a
39+
integer, target :: b
40+
!$omp target
41+
a = c_loc(b)
42+
!$omp end target
43+
end subroutine mapType_c_ptr
44+
45+
!CHECK: @.offload_sizes{{.*}} = private unnamed_addr constant [1 x i64] [i64 1]
46+
!CHECK: @.offload_maptypes{{.*}} = private unnamed_addr constant [1 x i64] [i64 800]
47+
subroutine mapType_char
48+
character :: a
49+
!$omp target
50+
a = 'b'
51+
!$omp end target
52+
end subroutine mapType_char

flang/test/Fir/convert-to-llvm-openmp-and-fir.fir

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -433,12 +433,13 @@ func.func @_QPomp_target() {
433433
%1 = arith.subi %c512, %c1 : index
434434
%2 = omp.bounds lower_bound(%c0 : index) upper_bound(%1 : index) extent(%c512 : index) stride(%c1 : index) start_idx(%c1 : index)
435435
%3 = omp.map_info var_ptr(%0 : !fir.ref<!fir.array<512xi32>>, !fir.array<512xi32>) map_clauses(tofrom) capture(ByRef) bounds(%2) -> !fir.ref<!fir.array<512xi32>> {name = "a"}
436-
omp.target thread_limit(%c64_i32 : i32) map_entries(%3 : !fir.ref<!fir.array<512xi32>>) {
436+
omp.target thread_limit(%c64_i32 : i32) map_entries(%3 -> %arg0 : !fir.ref<!fir.array<512xi32>>) {
437+
^bb0(%arg0: !fir.ref<!fir.array<512xi32>>):
437438
%c10_i32 = arith.constant 10 : i32
438439
%c1_i64 = arith.constant 1 : i64
439440
%c1_i64_0 = arith.constant 1 : i64
440441
%4 = arith.subi %c1_i64, %c1_i64_0 : i64
441-
%5 = fir.coordinate_of %0, %4 : (!fir.ref<!fir.array<512xi32>>, i64) -> !fir.ref<i32>
442+
%5 = fir.coordinate_of %arg0, %4 : (!fir.ref<!fir.array<512xi32>>, i64) -> !fir.ref<i32>
442443
fir.store %c10_i32 to %5 : !fir.ref<i32>
443444
omp.terminator
444445
}
@@ -455,12 +456,13 @@ func.func @_QPomp_target() {
455456
// CHECK: %[[UPPER:.*]] = llvm.mlir.constant(511 : index) : i64
456457
// CHECK: %[[BOUNDS:.*]] = omp.bounds lower_bound(%[[LOWER]] : i64) upper_bound(%[[UPPER]] : i64) extent(%[[EXTENT]] : i64) stride(%[[STRIDE]] : i64) start_idx(%[[STRIDE]] : i64)
457458
// CHECK: %[[MAP:.*]] = omp.map_info var_ptr(%2 : !llvm.ptr, !llvm.array<512 x i32>) map_clauses(tofrom) capture(ByRef) bounds(%[[BOUNDS]]) -> !llvm.ptr {name = "a"}
458-
// CHECK: omp.target thread_limit(%[[VAL_2]] : i32) map_entries(%[[MAP]] : !llvm.ptr) {
459+
// CHECK: omp.target thread_limit(%[[VAL_2]] : i32) map_entries(%[[MAP]] -> %[[ARG_0:.*]] : !llvm.ptr) {
460+
// CHECK: ^bb0(%[[ARG_0]]: !llvm.ptr):
459461
// CHECK: %[[VAL_3:.*]] = llvm.mlir.constant(10 : i32) : i32
460462
// CHECK: %[[VAL_4:.*]] = llvm.mlir.constant(1 : i64) : i64
461463
// CHECK: %[[VAL_5:.*]] = llvm.mlir.constant(1 : i64) : i64
462464
// CHECK: %[[VAL_6:.*]] = llvm.mlir.constant(0 : i64) : i64
463-
// CHECK: %[[VAL_7:.*]] = llvm.getelementptr %[[VAL_1]][0, %[[VAL_6]]] : (!llvm.ptr, i64) -> !llvm.ptr
465+
// CHECK: %[[VAL_7:.*]] = llvm.getelementptr %[[ARG_0]][0, %[[VAL_6]]] : (!llvm.ptr, i64) -> !llvm.ptr
464466
// CHECK: llvm.store %[[VAL_3]], %[[VAL_7]] : i32, !llvm.ptr
465467
// CHECK: omp.terminator
466468
// CHECK: }

flang/test/Lower/OpenMP/FIR/array-bounds.f90

Lines changed: 43 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,22 @@
1-
!RUN: %flang_fc1 -emit-fir -fopenmp %s -o - | FileCheck %s --check-prefixes HOST
2-
!RUN: %flang_fc1 -emit-fir -fopenmp -fopenmp-is-target-device %s -o - | FileCheck %s --check-prefixes DEVICE
1+
!RUN: %flang_fc1 -emit-fir -fopenmp %s -o - | FileCheck %s --check-prefixes=HOST,ALL
2+
!RUN: %flang_fc1 -emit-fir -fopenmp -fopenmp-is-target-device %s -o - | FileCheck %s --check-prefixes=DEVICE,ALL
33

4-
!DEVICE-LABEL: func.func @_QPread_write_section_omp_outline_0(
5-
!DEVICE-SAME: %[[ARG0:.*]]: !fir.ref<i32>, %[[ARG1:.*]]: !fir.ref<!fir.array<10xi32>>, %[[ARG2:.*]]: !fir.ref<!fir.array<10xi32>>) attributes {omp.declare_target = #omp.declaretarget<device_type = (host), capture_clause = (to)>, omp.outline_parent_name = "_QPread_write_section"} {
6-
!DEVICE: %[[C1:.*]] = arith.constant 1 : index
7-
!DEVICE: %[[C2:.*]] = arith.constant 4 : index
8-
!DEVICE: %[[C3:.*]] = arith.constant 1 : index
9-
!DEVICE: %[[C4:.*]] = arith.constant 1 : index
10-
!DEVICE: %[[BOUNDS0:.*]] = omp.bounds lower_bound(%[[C1]] : index) upper_bound(%[[C2]] : index) stride(%[[C4]] : index) start_idx(%[[C4]] : index)
11-
!DEVICE: %[[MAP0:.*]] = omp.map_info var_ptr(%[[ARG1]] : !fir.ref<!fir.array<10xi32>>, !fir.array<10xi32>) map_clauses(tofrom) capture(ByRef) bounds(%[[BOUNDS0]]) -> !fir.ref<!fir.array<10xi32>> {name = "sp_read(2:5)"}
12-
!DEVICE: %[[C5:.*]] = arith.constant 1 : index
13-
!DEVICE: %[[C6:.*]] = arith.constant 4 : index
14-
!DEVICE: %[[C7:.*]] = arith.constant 1 : index
15-
!DEVICE: %[[C8:.*]] = arith.constant 1 : index
16-
!DEVICE: %[[BOUNDS1:.*]] = omp.bounds lower_bound(%[[C5]] : index) upper_bound(%[[C6]] : index) stride(%[[C8]] : index) start_idx(%[[C8]] : index)
17-
!DEVICE: %[[MAP1:.*]] = omp.map_info var_ptr(%[[ARG2]] : !fir.ref<!fir.array<10xi32>>, !fir.array<10xi32>) map_clauses(tofrom) capture(ByRef) bounds(%[[BOUNDS1]]) -> !fir.ref<!fir.array<10xi32>> {name = "sp_write(2:5)"}
18-
!DEVICE: omp.target map_entries(%[[MAP0]], %[[MAP1]] : !fir.ref<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>) {
19-
20-
!HOST-LABEL: func.func @_QPread_write_section() {
21-
!HOST: %0 = fir.alloca i32 {bindc_name = "i", uniq_name = "_QFread_write_sectionEi"}
22-
!HOST: %[[READ:.*]] = fir.address_of(@_QFread_write_sectionEsp_read) : !fir.ref<!fir.array<10xi32>>
23-
!HOST: %[[WRITE:.*]] = fir.address_of(@_QFread_write_sectionEsp_write) : !fir.ref<!fir.array<10xi32>>
24-
!HOST: %[[C1:.*]] = arith.constant 1 : index
25-
!HOST: %[[C2:.*]] = arith.constant 1 : index
26-
!HOST: %[[C3:.*]] = arith.constant 4 : index
27-
!HOST: %[[BOUNDS0:.*]] = omp.bounds lower_bound(%[[C2]] : index) upper_bound(%[[C3]] : index) stride(%[[C1]] : index) start_idx(%[[C1]] : index)
28-
!HOST: %[[MAP0:.*]] = omp.map_info var_ptr(%[[READ]] : !fir.ref<!fir.array<10xi32>>, !fir.array<10xi32>) map_clauses(tofrom) capture(ByRef) bounds(%[[BOUNDS0]]) -> !fir.ref<!fir.array<10xi32>> {name = "sp_read(2:5)"}
29-
!HOST: %[[C4:.*]] = arith.constant 1 : index
30-
!HOST: %[[C5:.*]] = arith.constant 1 : index
31-
!HOST: %[[C6:.*]] = arith.constant 4 : index
32-
!HOST: %[[BOUNDS1:.*]] = omp.bounds lower_bound(%[[C5]] : index) upper_bound(%[[C6]] : index) stride(%[[C4]] : index) start_idx(%[[C4]] : index)
33-
!HOST: %[[MAP1:.*]] = omp.map_info var_ptr(%[[WRITE]] : !fir.ref<!fir.array<10xi32>>, !fir.array<10xi32>) map_clauses(tofrom) capture(ByRef) bounds(%[[BOUNDS1]]) -> !fir.ref<!fir.array<10xi32>> {name = "sp_write(2:5)"}
34-
!HOST: omp.target map_entries(%[[MAP0]], %[[MAP1]] : !fir.ref<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>) {
4+
!ALL-LABEL: func.func @_QPread_write_section(
5+
!ALL: %[[ITER:.*]] = fir.alloca i32 {bindc_name = "i", uniq_name = "_QFread_write_sectionEi"}
6+
!ALL: %[[READ:.*]] = fir.address_of(@_QFread_write_sectionEsp_read) : !fir.ref<!fir.array<10xi32>>
7+
!ALL: %[[WRITE:.*]] = fir.address_of(@_QFread_write_sectionEsp_write) : !fir.ref<!fir.array<10xi32>>
8+
!ALL: %[[C1:.*]] = arith.constant 1 : index
9+
!ALL: %[[C2:.*]] = arith.constant 1 : index
10+
!ALL: %[[C3:.*]] = arith.constant 4 : index
11+
!ALL: %[[BOUNDS0:.*]] = omp.bounds lower_bound(%[[C2]] : index) upper_bound(%[[C3]] : index) stride(%[[C1]] : index) start_idx(%[[C1]] : index)
12+
!ALL: %[[MAP0:.*]] = omp.map_info var_ptr(%[[READ]] : !fir.ref<!fir.array<10xi32>>, !fir.array<10xi32>) map_clauses(tofrom) capture(ByRef) bounds(%[[BOUNDS0]]) -> !fir.ref<!fir.array<10xi32>> {name = "sp_read(2:5)"}
13+
!ALL: %[[C4:.*]] = arith.constant 1 : index
14+
!ALL: %[[C5:.*]] = arith.constant 1 : index
15+
!ALL: %[[C6:.*]] = arith.constant 4 : index
16+
!ALL: %[[BOUNDS1:.*]] = omp.bounds lower_bound(%[[C5]] : index) upper_bound(%[[C6]] : index) stride(%[[C4]] : index) start_idx(%[[C4]] : index)
17+
!ALL: %[[MAP1:.*]] = omp.map_info var_ptr(%[[WRITE]] : !fir.ref<!fir.array<10xi32>>, !fir.array<10xi32>) map_clauses(tofrom) capture(ByRef) bounds(%[[BOUNDS1]]) -> !fir.ref<!fir.array<10xi32>> {name = "sp_write(2:5)"}
18+
!ALL: %[[MAP2:.*]] = omp.map_info var_ptr(%[[ITER]] : !fir.ref<i32>, i32) map_clauses(implicit, exit_release_or_enter_alloc) capture(ByCopy) -> !fir.ref<i32> {name = "i"}
19+
!ALL: omp.target map_entries(%[[MAP0]] -> %{{.*}}, %[[MAP1]] -> %{{.*}}, %[[MAP2]] -> %{{.*}}, %{{.*}} -> %{{.*}}, %{{.*}} -> %{{.*}} : !fir.ref<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>, !fir.ref<i32>, index, index) {
3520

3621
subroutine read_write_section()
3722
integer :: sp_read(10) = (/1,2,3,4,5,6,7,8,9,10/)
@@ -44,33 +29,22 @@ subroutine read_write_section()
4429
!$omp end target
4530
end subroutine read_write_section
4631

47-
4832
module assumed_array_routines
49-
contains
50-
!DEVICE-LABEL: func.func @_QMassumed_array_routinesPassumed_shape_array_omp_outline_0(
51-
!DEVICE-SAME: %[[ARG0:.*]]: !fir.ref<i32>, %[[ARG1:.*]]: !fir.box<!fir.array<?xi32>>, %[[ARG2:.*]]: !fir.ref<!fir.array<?xi32>>) attributes {omp.declare_target = #omp.declaretarget<device_type = (host), capture_clause = (to)>, omp.outline_parent_name = "_QMassumed_array_routinesPassumed_shape_array"} {
52-
!DEVICE: %[[C0:.*]] = arith.constant 1 : index
53-
!DEVICE: %[[C1:.*]] = arith.constant 4 : index
54-
!DEVICE: %[[C2:.*]] = arith.constant 0 : index
55-
!DEVICE: %[[C3:.*]]:3 = fir.box_dims %[[ARG1]], %[[C2]] : (!fir.box<!fir.array<?xi32>>, index) -> (index, index, index)
56-
!DEVICE: %[[C4:.*]] = arith.constant 1 : index
57-
!DEVICE: %[[BOUNDS:.*]] = omp.bounds lower_bound(%[[C0]] : index) upper_bound(%[[C1]] : index) stride(%[[C3]]#2 : index) start_idx(%[[C4]] : index) {stride_in_bytes = true}
58-
!DEVICE: %[[ARGADDR:.*]] = fir.box_addr %[[ARG1]] : (!fir.box<!fir.array<?xi32>>) -> !fir.ref<!fir.array<?xi32>>
59-
!DEVICE: %[[MAP:.*]] = omp.map_info var_ptr(%[[ARGADDR]] : !fir.ref<!fir.array<?xi32>>, !fir.array<?xi32>) map_clauses(tofrom) capture(ByRef) bounds(%[[BOUNDS]]) -> !fir.ref<!fir.array<?xi32>> {name = "arr_read_write(2:5)"}
60-
!DEVICE: omp.target map_entries(%[[MAP]] : !fir.ref<!fir.array<?xi32>>) {
33+
contains
34+
!ALL-LABEL: func.func @_QMassumed_array_routinesPassumed_shape_array(
35+
!ALL-SAME: %[[ARG0:.*]]: !fir.box<!fir.array<?xi32>> {fir.bindc_name = "arr_read_write"}) {
36+
!ALL: %[[ALLOCA:.*]] = fir.alloca i32 {bindc_name = "i", uniq_name = "_QMassumed_array_routinesFassumed_shape_arrayEi"}
37+
!ALL: %[[C0:.*]] = arith.constant 1 : index
38+
!ALL: %[[C1:.*]] = arith.constant 0 : index
39+
!ALL: %[[C2:.*]]:3 = fir.box_dims %arg0, %[[C1]] : (!fir.box<!fir.array<?xi32>>, index) -> (index, index, index)
40+
!ALL: %[[C3:.*]] = arith.constant 1 : index
41+
!ALL: %[[C4:.*]] = arith.constant 4 : index
42+
!ALL: %[[BOUNDS:.*]] = omp.bounds lower_bound(%[[C3]] : index) upper_bound(%[[C4]] : index) stride(%[[C2]]#2 : index) start_idx(%[[C0]] : index) {stride_in_bytes = true}
43+
!ALL: %[[ADDROF:.*]] = fir.box_addr %arg0 : (!fir.box<!fir.array<?xi32>>) -> !fir.ref<!fir.array<?xi32>>
44+
!ALL: %[[MAP:.*]] = omp.map_info var_ptr(%[[ADDROF]] : !fir.ref<!fir.array<?xi32>>, !fir.array<?xi32>) map_clauses(tofrom) capture(ByRef) bounds(%[[BOUNDS]]) -> !fir.ref<!fir.array<?xi32>> {name = "arr_read_write(2:5)"}
45+
!ALL: %[[MAP2:.*]] = omp.map_info var_ptr(%[[ALLOCA]] : !fir.ref<i32>, i32) map_clauses(implicit, exit_release_or_enter_alloc) capture(ByCopy) -> !fir.ref<i32> {name = "i"}
46+
!ALL: omp.target map_entries(%[[MAP]] -> %{{.*}}, %[[MAP2]] -> %{{.*}} : !fir.ref<!fir.array<?xi32>>, !fir.ref<i32>) {
6147

62-
!HOST-LABEL: func.func @_QMassumed_array_routinesPassumed_shape_array(
63-
!HOST-SAME: %[[ARG0:.*]]: !fir.box<!fir.array<?xi32>> {fir.bindc_name = "arr_read_write"}) {
64-
!HOST: %[[ALLOCA:.*]] = fir.alloca i32 {bindc_name = "i", uniq_name = "_QMassumed_array_routinesFassumed_shape_arrayEi"}
65-
!HOST: %[[C0:.*]] = arith.constant 1 : index
66-
!HOST: %[[C1:.*]] = arith.constant 0 : index
67-
!HOST: %[[C2:.*]]:3 = fir.box_dims %arg0, %[[C1]] : (!fir.box<!fir.array<?xi32>>, index) -> (index, index, index)
68-
!HOST: %[[C3:.*]] = arith.constant 1 : index
69-
!HOST: %[[C4:.*]] = arith.constant 4 : index
70-
!HOST: %[[BOUNDS:.*]] = omp.bounds lower_bound(%[[C3]] : index) upper_bound(%[[C4]] : index) stride(%[[C2]]#2 : index) start_idx(%[[C0]] : index) {stride_in_bytes = true}
71-
!HOST: %[[ADDROF:.*]] = fir.box_addr %arg0 : (!fir.box<!fir.array<?xi32>>) -> !fir.ref<!fir.array<?xi32>>
72-
!HOST: %[[MAP:.*]] = omp.map_info var_ptr(%[[ADDROF]] : !fir.ref<!fir.array<?xi32>>, !fir.array<?xi32>) map_clauses(tofrom) capture(ByRef) bounds(%[[BOUNDS]]) -> !fir.ref<!fir.array<?xi32>> {name = "arr_read_write(2:5)"}
73-
!HOST: omp.target map_entries(%[[MAP]] : !fir.ref<!fir.array<?xi32>>) {
7448
subroutine assumed_shape_array(arr_read_write)
7549
integer, intent(inout) :: arr_read_write(:)
7650

@@ -81,25 +55,17 @@ subroutine assumed_shape_array(arr_read_write)
8155
!$omp end target
8256
end subroutine assumed_shape_array
8357

84-
!DEVICE-LABEL: func.func @_QMassumed_array_routinesPassumed_size_array_omp_outline_0(
85-
!DEVICE-SAME: %[[ARG0:.*]]: !fir.ref<i32>, %[[ARG1:.*]]: !fir.ref<!fir.array<?xi32>>) attributes {omp.declare_target = #omp.declaretarget<device_type = (host), capture_clause = (to)>, omp.outline_parent_name = "_QMassumed_array_routinesPassumed_size_array"} {
86-
!DEVICE: %[[C0:.*]] = arith.constant 1 : index
87-
!DEVICE: %[[C1:.*]] = arith.constant 4 : index
88-
!DEVICE: %[[C2:.*]] = arith.constant 1 : index
89-
!DEVICE: %[[C3:.*]] = arith.constant 1 : index
90-
!DEVICE: %[[BOUNDS:.*]] = omp.bounds lower_bound(%[[C0]] : index) upper_bound(%[[C1]] : index) stride(%[[C3]] : index) start_idx(%[[C3]] : index)
91-
!DEVICE: %[[MAP:.*]] = omp.map_info var_ptr(%[[ARG1]] : !fir.ref<!fir.array<?xi32>>, !fir.array<?xi32>) map_clauses(tofrom) capture(ByRef) bounds(%[[BOUNDS]]) -> !fir.ref<!fir.array<?xi32>> {name = "arr_read_write(2:5)"}
92-
!DEVICE: omp.target map_entries(%[[MAP]] : !fir.ref<!fir.array<?xi32>>) {
58+
!ALL-LABEL: func.func @_QMassumed_array_routinesPassumed_size_array(
59+
!ALL-SAME: %[[ARG0:.*]]: !fir.ref<!fir.array<?xi32>> {fir.bindc_name = "arr_read_write"}) {
60+
!ALL: %[[ALLOCA:.*]] = fir.alloca i32 {bindc_name = "i", uniq_name = "_QMassumed_array_routinesFassumed_size_arrayEi"}
61+
!ALL: %[[C0:.*]] = arith.constant 1 : index
62+
!ALL: %[[C1:.*]] = arith.constant 1 : index
63+
!ALL: %[[C2:.*]] = arith.constant 4 : index
64+
!ALL: %[[BOUNDS:.*]] = omp.bounds lower_bound(%[[C1]] : index) upper_bound(%[[C2]] : index) stride(%[[C0]] : index) start_idx(%[[C0]] : index)
65+
!ALL: %[[MAP:.*]] = omp.map_info var_ptr(%[[ARG0]] : !fir.ref<!fir.array<?xi32>>, !fir.array<?xi32>) map_clauses(tofrom) capture(ByRef) bounds(%[[BOUNDS]]) -> !fir.ref<!fir.array<?xi32>> {name = "arr_read_write(2:5)"}
66+
!ALL: %[[MAP2:.*]] = omp.map_info var_ptr(%[[ALLOCA]] : !fir.ref<i32>, i32) map_clauses(implicit, exit_release_or_enter_alloc) capture(ByCopy) -> !fir.ref<i32> {name = "i"}
67+
!ALL: omp.target map_entries(%[[MAP]] -> %{{.*}}, %[[MAP2]] -> %{{.*}}, %{{.*}} -> %{{.*}} : !fir.ref<!fir.array<?xi32>>, !fir.ref<i32>, index) {
9368

94-
!HOST-LABEL: func.func @_QMassumed_array_routinesPassumed_size_array(
95-
!HOST-SAME: %[[ARG0:.*]]: !fir.ref<!fir.array<?xi32>> {fir.bindc_name = "arr_read_write"}) {
96-
!HOST: %[[ALLOCA:.*]] = fir.alloca i32 {bindc_name = "i", uniq_name = "_QMassumed_array_routinesFassumed_size_arrayEi"}
97-
!HOST: %[[C0:.*]] = arith.constant 1 : index
98-
!HOST: %[[C1:.*]] = arith.constant 1 : index
99-
!HOST: %[[C2:.*]] = arith.constant 4 : index
100-
!HOST: %[[BOUNDS:.*]] = omp.bounds lower_bound(%[[C1]] : index) upper_bound(%[[C2]] : index) stride(%[[C0]] : index) start_idx(%[[C0]] : index)
101-
!HOST: %[[MAP:.*]] = omp.map_info var_ptr(%[[ARG0]] : !fir.ref<!fir.array<?xi32>>, !fir.array<?xi32>) map_clauses(tofrom) capture(ByRef) bounds(%[[BOUNDS]]) -> !fir.ref<!fir.array<?xi32>> {name = "arr_read_write(2:5)"}
102-
!HOST: omp.target map_entries(%[[MAP]] : !fir.ref<!fir.array<?xi32>>) {
10369
subroutine assumed_size_array(arr_read_write)
10470
integer, intent(inout) :: arr_read_write(*)
10571

@@ -111,6 +77,7 @@ subroutine assumed_size_array(arr_read_write)
11177
end subroutine assumed_size_array
11278
end module assumed_array_routines
11379

80+
!DEVICE-NOT:func.func @_QPcall_assumed_shape_and_size_array() {
11481

11582
!HOST-LABEL:func.func @_QPcall_assumed_shape_and_size_array() {
11683
!HOST:%{{.*}} = arith.constant 20 : index

flang/test/Lower/OpenMP/FIR/location.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ subroutine sub_parallel()
1717
!CHECK-LABEL: sub_target
1818
subroutine sub_target()
1919
print *, x
20-
!CHECK: omp.target {
20+
!CHECK: omp.target {{.*}} {
2121
!$omp target
2222
print *, x
2323
!CHECK: omp.terminator loc(#[[TAR_LOC:.*]])

0 commit comments

Comments
 (0)