Skip to content

Commit 97c60d6

Browse files
authored
[MLIR][OpenMP] Check that omp.loop_nest represents at least one loop (#89082)
1 parent af7a82f commit 97c60d6

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1898,6 +1898,9 @@ void LoopNestOp::build(OpBuilder &builder, OperationState &state,
18981898
}
18991899

19001900
LogicalResult LoopNestOp::verify() {
1901+
if (getLowerBound().empty())
1902+
return emitOpError() << "must represent at least one loop";
1903+
19011904
if (getLowerBound().size() != getIVs().size())
19021905
return emitOpError() << "number of range arguments and IVs do not match";
19031906

mlir/test/Dialect/OpenMP/invalid.mlir

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,20 @@ func.func @iv_number_mismatch(%lb : index, %ub : index, %step : index) {
138138

139139
// -----
140140

141+
func.func @no_loops(%lb : index, %ub : index, %step : index) {
142+
// TODO Remove induction variables from omp.wsloop.
143+
omp.wsloop for (%iv) : index = (%lb) to (%ub) step (%step) {
144+
// expected-error@+1 {{op must represent at least one loop}}
145+
"omp.loop_nest" () ({
146+
^bb0():
147+
omp.yield
148+
}) : () -> ()
149+
omp.terminator
150+
}
151+
}
152+
153+
// -----
154+
141155
func.func @inclusive_not_a_clause(%lb : index, %ub : index, %step : index) {
142156
// expected-error @below {{expected 'for'}}
143157
omp.wsloop nowait inclusive

0 commit comments

Comments
 (0)