[Mlir-commits] [mlir] [MLIR][OpenMP] Check that omp.loop_nest represents at least one loop (PR #89082)
Sergio Afonso
llvmlistbot at llvm.org
Wed Apr 17 07:49:01 PDT 2024
https://github.com/skatrak created https://github.com/llvm/llvm-project/pull/89082
None
>From 473de371e3e67cabbf81a49645b8305390957d83 Mon Sep 17 00:00:00 2001
From: Sergio Afonso <safonsof at amd.com>
Date: Wed, 17 Apr 2024 15:46:46 +0100
Subject: [PATCH] [MLIR][OpenMP] Check that omp.loop_nest represents at least
one loop
---
mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp | 3 +++
mlir/test/Dialect/OpenMP/invalid.mlir | 14 ++++++++++++++
2 files changed, 17 insertions(+)
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