[Mlir-commits] [mlir] 97c60d6 - [MLIR][OpenMP] Check that omp.loop_nest represents at least one loop (#89082)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Thu Apr 18 04:59:01 PDT 2024


Author: Sergio Afonso
Date: 2024-04-18T12:58:58+01:00
New Revision: 97c60d61d043e21da454226619a98bfb2f2194ee

URL: https://github.com/llvm/llvm-project/commit/97c60d61d043e21da454226619a98bfb2f2194ee
DIFF: https://github.com/llvm/llvm-project/commit/97c60d61d043e21da454226619a98bfb2f2194ee.diff

LOG: [MLIR][OpenMP] Check that omp.loop_nest represents at least one loop (#89082)

Added: 
    

Modified: 
    mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
    mlir/test/Dialect/OpenMP/invalid.mlir

Removed: 
    


################################################################################
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


        


More information about the Mlir-commits mailing list