Harden -slice-analysis-test MLIR testing pass to check for some invariants
authorMehdi Amini <joker.eph@gmail.com>
Wed, 18 Jan 2023 14:14:33 +0000 (14:14 +0000)
committerMehdi Amini <joker.eph@gmail.com>
Wed, 18 Jan 2023 14:16:40 +0000 (14:16 +0000)
The pass would assert on some input IR that it didn't expect. Instead
signal a pass failure and properly interupt the flow.

Fixes #60022

mlir/test/lib/IR/TestSlicing.cpp

index 78c8ff7..3388b97 100644 (file)
@@ -64,6 +64,11 @@ void SliceAnalysisTestPass::runOnOperation() {
   auto funcOps = module.getOps<func::FuncOp>();
   unsigned opNum = 0;
   for (auto funcOp : funcOps) {
+    if (!llvm::hasSingleElement(funcOp.getBody())) {
+      funcOp->emitOpError("Does not support functions with multiple blocks");
+      signalPassFailure();
+      return;
+    }
     // TODO: For now this is just looking for Linalg ops. It can be generalized
     // to look for other ops using flags.
     funcOp.walk([&](Operation *op) {