From: Hanhan Wang Date: Thu, 3 Nov 2022 01:09:46 +0000 (-0700) Subject: [mlir] Move the assertion to a valid place. X-Git-Tag: upstream/17.0.6~28483 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8c33639aa65d0771472abb28718f178d0ffa923d;p=platform%2Fupstream%2Fllvm.git [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 --- diff --git a/mlir/lib/Analysis/SliceAnalysis.cpp b/mlir/lib/Analysis/SliceAnalysis.cpp index e343c47..4684ccf 100644 --- a/mlir/lib/Analysis/SliceAnalysis.cpp +++ b/mlir/lib/Analysis/SliceAnalysis.cpp @@ -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."); }