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

llvmlistbot at llvm.org llvmlistbot at llvm.org
Fri Aug 9 07:37:40 PDT 2024


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

This change fixes a crash when getOwner()->getParent() is a nullptr

>From e19ce805fa4d9971f45b1b0127c4a6145b9d8978 Mon Sep 17 00:00:00 2001
From: Darshan Bhat <darshanbhatsirsi at gmail.com>
Date: Thu, 8 Aug 2024 16:30:41 +0530
Subject: [PATCH] [mlir][affine] Fix crash in
 lir::affine::getForInductionVarOwner()

This change fixes a crash when getOwner()->getParent() is
a nullptr
---
 mlir/lib/Dialect/Affine/IR/AffineOps.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
index 35d5f53aad241f..2d4d23ba712bca 100644
--- a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
+++ b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
@@ -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))



More information about the Mlir-commits mailing list