Skip to content

[mlir][affine] Fix crash in mlir::affine::getForInductionVarOwner() #102625

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 11, 2024

Conversation

DarshanRamakant
Copy link
Contributor

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

@llvmbot
Copy link
Member

llvmbot commented Aug 9, 2024

@llvm/pr-subscribers-mlir

@llvm/pr-subscribers-mlir-affine

Author: None (DarshanRamakant)

Changes

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


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

1 Files Affected:

  • (modified) mlir/lib/Dialect/Affine/IR/AffineOps.cpp (+1-1)
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))

@joker-eph joker-eph changed the title [mlir][affine] Fix crash in lir::affine::getForInductionVarOwner() [mlir][affine] Fix crash in mlir::affine::getForInductionVarOwner() Aug 11, 2024
This change fixes a crash when getOwner()->getParent() is
a nullptr
@joker-eph joker-eph merged commit d1bc41f into llvm:main Aug 11, 2024
6 of 8 checks passed
@DarshanRamakant DarshanRamakant deleted the dev/AffineCrashFixNew branch August 12, 2024 03:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants