[Mlir-commits] [mlir] d1bc41f - [mlir][affine] Fix crash in mlir::affine::getForInductionVarOwner() (#102625)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Sun Aug 11 11:21:41 PDT 2024
Author: DarshanRamakant
Date: 2024-08-11T20:21:37+02:00
New Revision: d1bc41fdd1f531de2a0fdd02de03d43a11de6767
URL: https://github.com/llvm/llvm-project/commit/d1bc41fdd1f531de2a0fdd02de03d43a11de6767
DIFF: https://github.com/llvm/llvm-project/commit/d1bc41fdd1f531de2a0fdd02de03d43a11de6767.diff
LOG: [mlir][affine] Fix crash in mlir::affine::getForInductionVarOwner() (#102625)
This change fixes a crash when getOwner()->getParent() is a nullptr
Added:
Modified:
mlir/lib/Dialect/Affine/IR/AffineOps.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
index 35d5f53aad241f..11b6b7cf5fd5a7 100644
--- a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
+++ b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
@@ -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();
More information about the Mlir-commits
mailing list