Skip to content

Commit

Permalink
[mlir][affine] Fix crash in lir::affine::getForInductionVarOwner()
Browse files Browse the repository at this point in the history
This change fixes a crash when getOwner()->getParent() is
a nullptr
  • Loading branch information
DarshanRamakant committed Aug 11, 2024
1 parent f070f61 commit ec02871
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 ec02871

Please sign in to comment.