summaryrefslogtreecommitdiffstats
path: root/mlir/lib/IR
diff options
context:
space:
mode:
authorSean Silva <silvasean@google.com>2019-12-03 11:23:48 -0800
committerA. Unique TensorFlower <gardener@tensorflow.org>2019-12-03 11:24:31 -0800
commit67515e8d7a3bf5bcaa8475890eea3c63d7ea732c (patch)
treec9637b99a96aa2b57c81b813c04f1847b1be8cd9 /mlir/lib/IR
parent4741ec6af0d49cec5fb49a370244657c27ca033c (diff)
downloadbcm5719-llvm-67515e8d7a3bf5bcaa8475890eea3c63d7ea732c.tar.gz
bcm5719-llvm-67515e8d7a3bf5bcaa8475890eea3c63d7ea732c.zip
Verifier: Better error message in case of successor operand mismatch.
In particular, print the successor number in the diagnostic. PiperOrigin-RevId: 283585084
Diffstat (limited to 'mlir/lib/IR')
-rw-r--r--mlir/lib/IR/Operation.cpp15
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();
OpenPOWER on IntegriCloud