Skip to content
This repository was archived by the owner on Apr 23, 2021. It is now read-only.

Commit d469311

Browse files
jpienaartensorflower-gardener
authored andcommitted
Make isIsolatedAbove robuster to invalid IR
This function is only called from the verifier. PiperOrigin-RevId: 267145495
1 parent 0d78918 commit d469311

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/IR/Region.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,15 @@ static bool isIsolatedAbove(Region &region, Region &limit,
143143
for (Block &block : *pendingRegions.pop_back_val()) {
144144
for (Operation &op : block) {
145145
for (Value *operand : op.getOperands()) {
146+
// operand should be non-null here if the IR is well-formed. But
147+
// we don't assert here as this function is called from the verifier
148+
// and so could be called on invalid IR.
149+
if (!operand) {
150+
if (noteLoc)
151+
op.emitOpError("block's operand not defined").attachNote(noteLoc);
152+
return false;
153+
}
154+
146155
// Check that any value that is used by an operation is defined in the
147156
// same region as either an operation result or a block argument.
148157
if (operand->getParentRegion()->isProperAncestor(&limit)) {

0 commit comments

Comments
 (0)