[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
This commit is contained in:
Hanhan Wang 2022-11-02 18:09:46 -07:00
parent 6edb49eee2
commit 8c33639aa6
1 changed files with 4 additions and 3 deletions

View File

@ -98,10 +98,11 @@ static void getBackwardSliceImpl(Operation *op,
// TODO: determine whether we want to recurse backward into the other
// blocks of parentOp, which are not technically backward unless they flow
// into us. For now, just bail.
assert(parentOp->getNumRegions() == 1 &&
parentOp->getRegion(0).getBlocks().size() == 1);
if (backwardSlice->count(parentOp) == 0)
if (parentOp && backwardSlice->count(parentOp) == 0) {
assert(parentOp->getNumRegions() == 1 &&
parentOp->getRegion(0).getBlocks().size() == 1);
getBackwardSliceImpl(parentOp, backwardSlice, filter);
}
} else {
llvm_unreachable("No definingOp and not a block argument.");
}