From c114dba3f3e1ccd342bf249b08c94caceb7b776b Mon Sep 17 00:00:00 2001 From: Mehdi Amini Date: Wed, 18 Jan 2023 14:14:33 +0000 Subject: [PATCH] Harden -slice-analysis-test MLIR testing pass to check for some invariants 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 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mlir/test/lib/IR/TestSlicing.cpp b/mlir/test/lib/IR/TestSlicing.cpp index 78c8ff7d46015d..3388b972880e31 100644 --- a/mlir/test/lib/IR/TestSlicing.cpp +++ b/mlir/test/lib/IR/TestSlicing.cpp @@ -64,6 +64,11 @@ void SliceAnalysisTestPass::runOnOperation() { auto funcOps = module.getOps(); 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) {