Skip to content

Commit

Permalink
[mlir][affine] Fix crash in mlir::affine::getForInductionVarOwner() (l…
Browse files Browse the repository at this point in the history
…lvm#102625)

This change fixes a crash when getOwner()->getParent() is a nullptr
  • Loading branch information
DarshanRamakant authored Aug 11, 2024
1 parent 167c71a commit d1bc41f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions mlir/lib/Dialect/Affine/IR/AffineOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2562,10 +2562,10 @@ bool mlir::affine::isAffineInductionVar(Value val) {

AffineForOp mlir::affine::getForInductionVarOwner(Value val) {
auto ivArg = llvm::dyn_cast<BlockArgument>(val);
if (!ivArg || !ivArg.getOwner())
if (!ivArg || !ivArg.getOwner() || !ivArg.getOwner()->getParent())
return AffineForOp();
auto *containingInst = ivArg.getOwner()->getParent()->getParentOp();
if (auto forOp = dyn_cast<AffineForOp>(containingInst))
if (auto forOp =
ivArg.getOwner()->getParent()->getParentOfType<AffineForOp>())
// Check to make sure `val` is the induction variable, not an iter_arg.
return forOp.getInductionVar() == val ? forOp : AffineForOp();
return AffineForOp();
Expand Down

0 comments on commit d1bc41f

Please sign in to comment.