Skip to content

Commit bcb94bb

Browse files
committed
Post-merge fixes
1 parent afa84e1 commit bcb94bb

File tree

7 files changed

+72
-15
lines changed

7 files changed

+72
-15
lines changed

flang/lib/Lower/OpenMP/OpenMP.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ extractOmpDirective(const parser::OpenMPConstruct &ompConstruct) {
146146
},
147147
[](const parser::OpenMPCancellationPointConstruct &c) {
148148
return llvm::omp::OMPD_cancellation_point;
149+
},
150+
[](const parser::OpenMPDepobjConstruct &c) {
151+
return llvm::omp::OMPD_depobj;
149152
}},
150153
c.u);
151154
}},

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,8 +1112,7 @@ func.func @omp_allocatable_derived_type_member_map(%arg0 : !fir.ref<!fir.box<!fi
11121112
%c0 = arith.constant 0 : index
11131113
// CHECK: %[[BOUNDS:.*]] = omp.map.bounds lower_bound({{.*}}) upper_bound({{.*}}) extent({{.*}}) stride({{.*}}) start_idx({{.*}}) {stride_in_bytes = true}
11141114
%0 = omp.map.bounds lower_bound(%c0 : index) upper_bound(%c4 : index) extent(%c4 : index) stride(%c1 : index) start_idx(%c0 : index) {stride_in_bytes = true}
1115-
// CHECK: %[[LOAD_DESCRIPTOR:.*]] = llvm.load %[[ARG_0]] : !llvm.ptr -> !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8, ptr, array<1 x i64>)>
1116-
// CHECK: llvm.store %[[LOAD_DESCRIPTOR]], %[[DTYPE_ALLOCATABLE_ALOCA]] : !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8, ptr, array<1 x i64>)>, !llvm.ptr
1115+
// CHECK: "llvm.intr.memcpy"(%[[DTYPE_ALLOCATABLE_ALOCA]], %[[ARG_0]], %{{.*}})
11171116
%1 = fir.load %arg0 : !fir.ref<!fir.box<!fir.heap<!fir.type<_QFtest_allocatable_derived_type_map_operand_and_block_additionTone_layer{i:f32,scalar:!fir.box<!fir.heap<i32>>,array_i:!fir.array<10xi32>,j:f32,array_j:!fir.box<!fir.heap<!fir.array<?xi32>>>,k:i32}>>>>
11181117
// CHECK: %[[GEP_DTYPE_BADDR:.*]] = llvm.getelementptr %[[DTYPE_ALLOCATABLE_ALOCA]][0, 0] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8, ptr, array<1 x i64>)>
11191118
// CHECK: %[[LOAD_DTYPE_BADDR:.*]] = llvm.load %[[GEP_DTYPE_BADDR]] : !llvm.ptr -> !llvm.ptr
@@ -1125,9 +1124,8 @@ func.func @omp_allocatable_derived_type_member_map(%arg0 : !fir.ref<!fir.box<!fi
11251124
%4 = omp.map.info var_ptr(%2 : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>, !fir.array<?xi32>) var_ptr_ptr(%3 : !fir.llvm_ptr<!fir.ref<!fir.array<?xi32>>>) map_clauses(tofrom) capture(ByRef) bounds(%0) -> !fir.llvm_ptr<!fir.ref<!fir.array<?xi32>>> {name = ""}
11261125
// CHECK: %[[MAP_MEMBER_DESC:.*]] = omp.map.info var_ptr(%[[GEP_DTYPE_MEMBER]] : !llvm.ptr, !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>)>) map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = "one_l%array_j"}
11271126
%5 = omp.map.info var_ptr(%2 : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>, !fir.box<!fir.heap<!fir.array<?xi32>>>) map_clauses(tofrom) capture(ByRef) -> !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>> {name = "one_l%array_j"}
1128-
// CHECK: %[[LOAD_DESCRIPTOR:.*]] = llvm.load %[[ARG_0]] : !llvm.ptr -> !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8, ptr, array<1 x i64>)>
1127+
// CHECK: "llvm.intr.memcpy"(%[[DTYPE_ALLOCATABLE_ALOCA_2]], %[[ARG_0]], %{{.*}})
11291128
%6 = fir.load %arg0 : !fir.ref<!fir.box<!fir.heap<!fir.type<_QFtest_allocatable_derived_type_map_operand_and_block_additionTone_layer{i:f32,scalar:!fir.box<!fir.heap<i32>>,array_i:!fir.array<10xi32>,j:f32,array_j:!fir.box<!fir.heap<!fir.array<?xi32>>>,k:i32}>>>>
1130-
// CHECK: llvm.store %[[LOAD_DESCRIPTOR]], %[[DTYPE_ALLOCATABLE_ALOCA_2]] : !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8, ptr, array<1 x i64>)>, !llvm.ptr
11311129
// CHECK: %[[GEP_DTYPE_BADDR:.*]] = llvm.getelementptr %[[DTYPE_ALLOCATABLE_ALOCA_2]][0, 0] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8, ptr, array<1 x i64>)>
11321130
// CHECK: %[[LOAD_DTYPE_BADDR:.*]] = llvm.load %[[GEP_DTYPE_BADDR]] : !llvm.ptr -> !llvm.ptr
11331131
// CHECK: %[[GEP_DTYPE_REGULAR_MEMBER:.*]] = llvm.getelementptr %[[LOAD_DTYPE_BADDR]][0, 5] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<"_QFtest_allocatable_derived_type_map_operand_and_block_additionTone_layer", (f32, struct<(ptr, i64, i32, i8, i8, i8, i8)>, array<10 x i32>, f32, struct<(ptr, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>)>, i32)>
@@ -1162,8 +1160,7 @@ func.func @omp_alloca_nested_derived_type_map(%arg0 : !fir.ref<!fir.box<!fir.hea
11621160
%c0 = arith.constant 0 : index
11631161
// CHECK: %[[BOUNDS:.*]] = omp.map.bounds lower_bound({{.*}}) upper_bound({{.*}}) extent({{.*}}) stride({{.*}}) start_idx({{.*}}) {stride_in_bytes = true}
11641162
%0 = omp.map.bounds lower_bound(%c0 : index) upper_bound(%c4 : index) extent(%c4 : index) stride(%c1 : index) start_idx(%c0 : index) {stride_in_bytes = true}
1165-
// CHECK: %[[LOAD_DESCRIPTOR:.*]] = llvm.load %[[ARG_0]] : !llvm.ptr -> !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8, ptr, array<1 x i64>)>
1166-
// CHECK: llvm.store %[[LOAD_DESCRIPTOR]], %[[DTYPE_ALLOCATABLE_ALOCA]] : !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8, ptr, array<1 x i64>)>, !llvm.ptr
1163+
// CHECK: "llvm.intr.memcpy"(%[[DTYPE_ALLOCATABLE_ALOCA]], %[[ARG_0]], %{{.*}})
11671164
%1 = fir.load %arg0 : !fir.ref<!fir.box<!fir.heap<!fir.type<_QFtest_alloca_nested_derived_type_map_operand_and_block_additionTtop_layer{i:f32,scalar:!fir.box<!fir.heap<i32>>,array_i:!fir.array<10xi32>,j:f32,array_j:!fir.box<!fir.heap<!fir.array<?xi32>>>,k:i32,nest:!fir.type<_QFtest_alloca_nested_derived_type_map_operand_and_block_additionTmiddle_layer{i:f32,array_i:!fir.array<10xi32>,array_k:!fir.box<!fir.heap<!fir.array<?xi32>>>,k:i32}>}>>>>
11681165
// CHECK: %[[GEP_DTYPE_BADDR:.*]] = llvm.getelementptr %[[DTYPE_ALLOCATABLE_ALOCA]][0, 0] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8, ptr, array<1 x i64>)>
11691166
// CHECK: %[[LOAD_GEP_DTYPE_BADDR:.*]] = llvm.load %[[GEP_DTYPE_BADDR]] : !llvm.ptr -> !llvm.ptr
@@ -1177,8 +1174,7 @@ func.func @omp_alloca_nested_derived_type_map(%arg0 : !fir.ref<!fir.box<!fir.hea
11771174
%5 = omp.map.info var_ptr(%3 : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>, !fir.array<?xi32>) var_ptr_ptr(%4 : !fir.llvm_ptr<!fir.ref<!fir.array<?xi32>>>) map_clauses(tofrom) capture(ByRef) bounds(%0) -> !fir.llvm_ptr<!fir.ref<!fir.array<?xi32>>> {name = ""}
11781175
// CHECK: %[[MAP_NESTED_MEMBER_DESC:.*]] = omp.map.info var_ptr(%[[GEP_NESTED_DTYPE_ALLOCATABLE_MEMBER]] : !llvm.ptr, !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>)>) map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = "one_l%nest%array_k"}
11791176
%6 = omp.map.info var_ptr(%3 : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>, !fir.box<!fir.heap<!fir.array<?xi32>>>) map_clauses(tofrom) capture(ByRef) -> !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>> {name = "one_l%nest%array_k"}
1180-
// CHECK: %[[LOAD_DESCRIPTOR:.*]] = llvm.load %[[ARG_0]] : !llvm.ptr -> !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8, ptr, array<1 x i64>)>
1181-
// CHECK: llvm.store %[[LOAD_DESCRIPTOR]], %[[DTYPE_ALLOCATABLE_ALOCA_2]] : !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8, ptr, array<1 x i64>)>, !llvm.ptr
1177+
// CHECK: "llvm.intr.memcpy"(%[[DTYPE_ALLOCATABLE_ALOCA_2]], %[[ARG_0]], %{{.*}})
11821178
// CHECK: %[[GEP_DTYPE_BADDR:.*]] = llvm.getelementptr %[[DTYPE_ALLOCATABLE_ALOCA_2]][0, 0] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8, ptr, array<1 x i64>)>
11831179
// CHECK: %[[LOAD_GEP_DTYPE_BADDR:.*]] = llvm.load %[[GEP_DTYPE_BADDR]] : !llvm.ptr -> !llvm.ptr
11841180
%7 = fir.load %arg0 : !fir.ref<!fir.box<!fir.heap<!fir.type<_QFtest_alloca_nested_derived_type_map_operand_and_block_additionTtop_layer{i:f32,scalar:!fir.box<!fir.heap<i32>>,array_i:!fir.array<10xi32>,j:f32,array_j:!fir.box<!fir.heap<!fir.array<?xi32>>>,k:i32,nest:!fir.type<_QFtest_alloca_nested_derived_type_map_operand_and_block_additionTmiddle_layer{i:f32,array_i:!fir.array<10xi32>,array_k:!fir.box<!fir.heap<!fir.array<?xi32>>>,k:i32}>}>>>>

flang/test/Integration/OpenMP/map-types-and-sizes.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ end subroutine mapType_common_block_members
656656
!CHECK: %[[ALLOCATABLE_MEMBER_SIZE_CALC_1:.*]] = sub i64 %[[ALLOCATABLE_MEMBER_ADDR_LOAD]], 1
657657
!CHECK: %[[NESTED_DTYPE_MEMBER_ACCESS:.*]] = getelementptr %_QFmaptype_nested_derived_type_allocaTtop_layer, ptr %[[ALLOCA]], i32 0, i32 6
658658
!CHECK: %[[NESTED_MEMBER_ACCESS:.*]] = getelementptr %_QFmaptype_nested_derived_type_allocaTmiddle_layer, ptr %[[NESTED_DTYPE_MEMBER_ACCESS]], i32 0, i32 2
659-
!CHECK: %[[NESTED_MEMBER_BASE_ADDR_ACCESS:.*]] = getelementptr { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %20, i32 0, i32 0
659+
!CHECK: %[[NESTED_MEMBER_BASE_ADDR_ACCESS:.*]] = getelementptr { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %[[NESTED_MEMBER_ACCESS]], i32 0, i32 0
660660
!CHECK: %[[ALLOCATABLE_MEMBER_SIZE_CALC_2:.*]] = sub i64 %[[ALLOCATABLE_MEMBER_SIZE_CALC_1]], 0
661661
!CHECK: %[[ALLOCATABLE_MEMBER_SIZE_CALC_3:.*]] = add i64 %[[ALLOCATABLE_MEMBER_SIZE_CALC_2]], 1
662662
!CHECK: %[[ALLOCATABLE_MEMBER_SIZE_CALC_4:.*]] = mul i64 1, %[[ALLOCATABLE_MEMBER_SIZE_CALC_3]]

flang/test/Semantics/OpenMP/ordered01.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
! RUN: %python %S/../test_errors.py %s %flang -fopenmp
1+
! RUN: %python %S/../test_errors.py %s %flang -fopenmp -fopenmp-version=51
22
! OpenMP Version 5.1
33
! Check OpenMP construct validity for the following directives:
44
! 2.19.9 Ordered Construct

flang/test/Semantics/OpenMP/ordered03.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
! RUN: %python %S/../test_errors.py %s %flang -fopenmp
1+
! RUN: %python %S/../test_errors.py %s %flang -fopenmp -fopenmp-version=51
22
! OpenMP Version 5.1
33
! Check OpenMP construct validity for the following directives:
44
! 2.19.9 Ordered Construct

mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@ static LogicalResult checkImplementationStatus(Operation &op) {
164164
if (op.getDevice())
165165
result = todo("device");
166166
};
167+
auto checkDistSchedule = [&todo](auto op, LogicalResult &result) {
168+
if (op.getDistScheduleStatic() || op.getDistScheduleChunkSize())
169+
result = todo("dist_schedule");
170+
};
167171
auto checkHasDeviceAddr = [&todo](auto op, LogicalResult &result) {
168172
if (!op.getHasDeviceAddrVars().empty())
169173
result = todo("has_device_addr");
@@ -277,6 +281,12 @@ static LogicalResult checkImplementationStatus(Operation &op) {
277281
omp::AtomicCaptureOp>([&](auto op) { checkHint(op, result); })
278282
.Case<omp::TargetEnterDataOp, omp::TargetExitDataOp, omp::TargetUpdateOp>(
279283
[&](auto op) { checkDepend(op, result); })
284+
.Case([&](omp::DistributeOp op) {
285+
checkAllocate(op, result);
286+
checkDistSchedule(op, result);
287+
checkOrder(op, result);
288+
checkPrivate(op, result);
289+
})
280290
.Case([&](omp::TargetOp op) {
281291
checkAllocate(op, result);
282292
checkDevice(op, result);
@@ -3723,6 +3733,9 @@ convertOmpDistribute(Operation &opInst, llvm::IRBuilderBase &builder,
37233733
llvm::OpenMPIRBuilder *ompBuilder = moduleTranslation.getOpenMPBuilder();
37243734
// FIXME: This ignores any other nested wrappers (e.g. omp.wsloop, omp.simd).
37253735
auto distributeOp = cast<omp::DistributeOp>(opInst);
3736+
if (failed(checkImplementationStatus(opInst)))
3737+
return failure();
3738+
37263739
auto loopOp = cast<omp::LoopNestOp>(distributeOp.getWrappedLoop());
37273740

37283741
SmallVector<omp::LoopWrapperInterface> loopWrappers;
@@ -3744,7 +3757,7 @@ convertOmpDistribute(Operation &opInst, llvm::IRBuilderBase &builder,
37443757
auto loopNestConversionResult = convertLoopNestHelper(
37453758
*loopOp, builder, moduleTranslation, "omp.distribute.region");
37463759
if (!loopNestConversionResult)
3747-
return llvm::createStringError("failed to translate omp.loop_nest");
3760+
return llvm::make_error<PreviouslyReportedError>();
37483761

37493762
builder.restoreIP(std::get<InsertPointTy>(*loopNestConversionResult));
37503763
} else {

mlir/test/Target/LLVMIR/openmp-todo.mlir

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,55 @@ llvm.func @do_simd(%lb : i32, %ub : i32, %step : i32) {
6666

6767
// -----
6868

69-
llvm.func @distribute(%lb : i32, %ub : i32, %step : i32) {
70-
// expected-error@below {{unsupported OpenMP operation: omp.distribute}}
69+
llvm.func @distribute_allocate(%lb : i32, %ub : i32, %step : i32, %x : !llvm.ptr) {
70+
// expected-error@below {{allocate clause not yet supported}}
71+
// expected-error@below {{LLVM Translation failed for operation: omp.distribute}}
72+
omp.distribute allocate(%x : !llvm.ptr -> %x : !llvm.ptr) {
73+
omp.loop_nest (%iv) : i32 = (%lb) to (%ub) step (%step) {
74+
omp.yield
75+
}
76+
}
77+
llvm.return
78+
}
79+
80+
// -----
81+
82+
llvm.func @distribute_dist_schedule(%lb : i32, %ub : i32, %step : i32, %x : i32) {
83+
// expected-error@below {{dist_schedule clause not yet supported}}
84+
// expected-error@below {{LLVM Translation failed for operation: omp.distribute}}
85+
omp.distribute dist_schedule_static dist_schedule_chunk_size(%x : i32) {
86+
omp.loop_nest (%iv) : i32 = (%lb) to (%ub) step (%step) {
87+
omp.yield
88+
}
89+
}
90+
llvm.return
91+
}
92+
93+
// -----
94+
95+
llvm.func @distribute_order(%lb : i32, %ub : i32, %step : i32) {
96+
// expected-error@below {{order clause not yet supported}}
97+
// expected-error@below {{LLVM Translation failed for operation: omp.distribute}}
98+
omp.distribute order(concurrent) {
99+
omp.loop_nest (%iv) : i32 = (%lb) to (%ub) step (%step) {
100+
omp.yield
101+
}
102+
}
103+
llvm.return
104+
}
105+
106+
// -----
107+
108+
omp.private {type = private} @x.privatizer : !llvm.ptr alloc {
109+
^bb0(%arg0: !llvm.ptr):
110+
%0 = llvm.mlir.constant(1 : i32) : i32
111+
%1 = llvm.alloca %0 x i32 : (i32) -> !llvm.ptr
112+
omp.yield(%1 : !llvm.ptr)
113+
}
114+
llvm.func @distribute_private(%lb : i32, %ub : i32, %step : i32, %x : !llvm.ptr) {
115+
// expected-error@below {{privatization clause not yet supported}}
71116
// expected-error@below {{LLVM Translation failed for operation: omp.distribute}}
72-
omp.distribute {
117+
omp.distribute private(@x.privatizer %x -> %arg0 : !llvm.ptr) {
73118
omp.loop_nest (%iv) : i32 = (%lb) to (%ub) step (%step) {
74119
omp.yield
75120
}

0 commit comments

Comments
 (0)