[Mlir-commits] [mlir] [MLIR][OpenMP] Check that omp.loop_nest represents at least one loop (PR #89082)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Wed Apr 17 07:49:31 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir-openmp
@llvm/pr-subscribers-mlir
Author: Sergio Afonso (skatrak)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/89082.diff
2 Files Affected:
- (modified) mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp (+3)
- (modified) mlir/test/Dialect/OpenMP/invalid.mlir (+14)
``````````diff
diff --git a/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp b/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
index 5d2281ce6094fd..1e480d6471cbce 100644
--- a/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
+++ b/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
@@ -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";
diff --git a/mlir/test/Dialect/OpenMP/invalid.mlir b/mlir/test/Dialect/OpenMP/invalid.mlir
index 9323beadf45499..1f04f457068709 100644
--- a/mlir/test/Dialect/OpenMP/invalid.mlir
+++ b/mlir/test/Dialect/OpenMP/invalid.mlir
@@ -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 at +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
``````````
</details>
https://github.com/llvm/llvm-project/pull/89082
More information about the Mlir-commits
mailing list