Skip to content

Commit 8c33639

Browse files
committed
[mlir] Move the assertion to a valid place.
The defining Op may live in an unlinked block so its parent Op may be null. Only assert it when the parent Op is not null. Reviewed By: mravishankar Differential Revision: https://reviews.llvm.org/D137306
1 parent 6edb49e commit 8c33639

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

mlir/lib/Analysis/SliceAnalysis.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,11 @@ static void getBackwardSliceImpl(Operation *op,
9898
// TODO: determine whether we want to recurse backward into the other
9999
// blocks of parentOp, which are not technically backward unless they flow
100100
// into us. For now, just bail.
101-
assert(parentOp->getNumRegions() == 1 &&
102-
parentOp->getRegion(0).getBlocks().size() == 1);
103-
if (backwardSlice->count(parentOp) == 0)
101+
if (parentOp && backwardSlice->count(parentOp) == 0) {
102+
assert(parentOp->getNumRegions() == 1 &&
103+
parentOp->getRegion(0).getBlocks().size() == 1);
104104
getBackwardSliceImpl(parentOp, backwardSlice, filter);
105+
}
105106
} else {
106107
llvm_unreachable("No definingOp and not a block argument.");
107108
}

0 commit comments

Comments
 (0)