From 8c33639aa65d0771472abb28718f178d0ffa923d Mon Sep 17 00:00:00 2001 From: Hanhan Wang Date: Wed, 2 Nov 2022 18:09:46 -0700 Subject: [PATCH] [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 --- mlir/lib/Analysis/SliceAnalysis.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mlir/lib/Analysis/SliceAnalysis.cpp b/mlir/lib/Analysis/SliceAnalysis.cpp index e343c47bb0f0..4684ccfa21b8 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."); }