Make isIsolatedAbove robuster to invalid IR

This function is only called from the verifier.

PiperOrigin-RevId: 267145495
This commit is contained in:
Jacques Pienaar 2019-09-04 07:02:37 -07:00 committed by A. Unique TensorFlower
parent 8c9dc690eb
commit 636bcbade0
1 changed files with 9 additions and 0 deletions

View File

@ -143,6 +143,15 @@ static bool isIsolatedAbove(Region &region, Region &limit,
for (Block &block : *pendingRegions.pop_back_val()) {
for (Operation &op : block) {
for (Value *operand : op.getOperands()) {
// operand should be non-null here if the IR is well-formed. But
// we don't assert here as this function is called from the verifier
// and so could be called on invalid IR.
if (!operand) {
if (noteLoc)
op.emitOpError("block's operand not defined").attachNote(noteLoc);
return false;
}
// Check that any value that is used by an operation is defined in the
// same region as either an operation result or a block argument.
if (operand->getParentRegion()->isProperAncestor(&limit)) {