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

Mehdi Amini llvmlistbot at llvm.org
Sun Aug 11 05:26:24 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))
----------------
joker-eph wrote:

```suggestion
  if (!ivArg || !ivArg.getOwner())
    return AffineForOp();
  if (auto forOp = ivArg.getOwner()->getParentOfType<AffineForOp()))
```

This seems like the most straightforward fix to me.

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


More information about the Mlir-commits mailing list