[Mlir-commits] [mlir] [mlir][affine] Fix crash in mlir::affine::getForInductionVarOwner() (PR #102625)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Sun Aug 11 07:00:36 PDT 2024


================
@@ -2562,7 +2562,7 @@ 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))
----------------
DarshanRamakant wrote:

Thanks @joker-eph for the suggestion. But "`ivArg.getOwner()`" will be a "`Block*`", and the "`getParentOfType()`" method is not available on that. So we need to access to the "`Region*`" to get that method. 
I have modified my code. 

https://github.com/llvm/llvm-project/pull/102625


More information about the Mlir-commits mailing list