diff options
author | Mehdi Amini <joker.eph@gmail.com> | 2022-12-13 09:41:13 +0000 |
---|---|---|
committer | Mehdi Amini <joker.eph@gmail.com> | 2022-12-13 09:42:34 +0000 |
commit | cffd7b144b6df9ced6f4d6f477a63516dbdf3c4b (patch) | |
tree | 01f78c6a6e038142dfdc3415292dc9ce9e90481a /mlir/lib/Dialect | |
parent | 899739cdbd6646fa48b4b7ad251eb52143d909ba (diff) | |
download | llvm-cffd7b144b6df9ced6f4d6f477a63516dbdf3c4b.tar.gz |
[mlir][scf] Fixes IndexSwitchOp verifier crash
Fixes #59460
Diffstat (limited to 'mlir/lib/Dialect')
-rw-r--r-- | mlir/lib/Dialect/SCF/IR/SCF.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/mlir/lib/Dialect/SCF/IR/SCF.cpp b/mlir/lib/Dialect/SCF/IR/SCF.cpp index a7ca5783d67d..0ec89c06f77e 100644 --- a/mlir/lib/Dialect/SCF/IR/SCF.cpp +++ b/mlir/lib/Dialect/SCF/IR/SCF.cpp @@ -3477,9 +3477,12 @@ LogicalResult scf::IndexSwitchOp::verify() { for (int64_t value : getCases()) if (!valueSet.insert(value).second) return emitOpError("has duplicate case value: ") << value; - auto verifyRegion = [&](Region ®ion, const Twine &name) -> LogicalResult { - auto yield = cast<YieldOp>(region.front().getTerminator()); + auto yield = dyn_cast<YieldOp>(region.front().back()); + if (!yield) + return emitOpError("expected region to end with scf.yield, but got ") + << region.front().back().getName(); + if (yield.getNumOperands() != getNumResults()) { return (emitOpError("expected each region to return ") << getNumResults() << " values, but " << name << " returns " |