diff options
Diffstat (limited to 'mlir/lib/IR/Operation.cpp')
| -rw-r--r-- | mlir/lib/IR/Operation.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/mlir/lib/IR/Operation.cpp b/mlir/lib/IR/Operation.cpp index f0ebd59ab9f..d079033e39b 100644 --- a/mlir/lib/IR/Operation.cpp +++ b/mlir/lib/IR/Operation.cpp @@ -901,18 +901,21 @@ LogicalResult OpTrait::impl::verifySameOperandsAndResultType(Operation *op) { return success(); } -static LogicalResult verifyBBArguments(Operation::operand_range operands, - Block *destBB, Operation *op) { - unsigned operandCount = std::distance(operands.begin(), operands.end()); +static LogicalResult verifySuccessor(Operation *op, unsigned succNo) { + Operation::operand_range operands = op->getSuccessorOperands(succNo); + unsigned operandCount = op->getNumSuccessorOperands(succNo); + Block *destBB = op->getSuccessor(succNo); if (operandCount != destBB->getNumArguments()) return op->emitError() << "branch has " << operandCount - << " operands, but target block has " + << " operands for successor #" << succNo + << ", but target block has " << destBB->getNumArguments(); auto operandIt = operands.begin(); for (unsigned i = 0, e = operandCount; i != e; ++i, ++operandIt) { if ((*operandIt)->getType() != destBB->getArgument(i)->getType()) - return op->emitError() << "type mismatch in bb argument #" << i; + return op->emitError() << "type mismatch for bb argument #" << i + << " of successor #" << succNo; } return success(); @@ -926,7 +929,7 @@ static LogicalResult verifyTerminatorSuccessors(Operation *op) { auto *succ = op->getSuccessor(i); if (succ->getParent() != parent) return op->emitError("reference to block defined in another region"); - if (failed(verifyBBArguments(op->getSuccessorOperands(i), succ, op))) + if (failed(verifySuccessor(op, i))) return failure(); } return success(); |

