Skip to content

Commit

Permalink
[MLIR][OpenMP] Check that omp.loop_nest represents at least one loop (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
skatrak authored Apr 18, 2024
1 parent af7a82f commit 97c60d6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1898,6 +1898,9 @@ void LoopNestOp::build(OpBuilder &builder, OperationState &state,
}

LogicalResult LoopNestOp::verify() {
if (getLowerBound().empty())
return emitOpError() << "must represent at least one loop";

if (getLowerBound().size() != getIVs().size())
return emitOpError() << "number of range arguments and IVs do not match";

Expand Down
14 changes: 14 additions & 0 deletions mlir/test/Dialect/OpenMP/invalid.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,20 @@ func.func @iv_number_mismatch(%lb : index, %ub : index, %step : index) {

// -----

func.func @no_loops(%lb : index, %ub : index, %step : index) {
// TODO Remove induction variables from omp.wsloop.
omp.wsloop for (%iv) : index = (%lb) to (%ub) step (%step) {
// expected-error@+1 {{op must represent at least one loop}}
"omp.loop_nest" () ({
^bb0():
omp.yield
}) : () -> ()
omp.terminator
}
}

// -----

func.func @inclusive_not_a_clause(%lb : index, %ub : index, %step : index) {
// expected-error @below {{expected 'for'}}
omp.wsloop nowait inclusive
Expand Down

0 comments on commit 97c60d6

Please sign in to comment.