[Mlir-commits] [mlir] Fix affine for fold detached block (PR #209111)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon Jul 13 02:10:53 PDT 2026


https://github.com/LouisLu060211 updated https://github.com/llvm/llvm-project/pull/209111

>From 3a9b774ca84ccb1395764dac6683a553c6e751e8 Mon Sep 17 00:00:00 2001
From: LouisLu0602 <yaolu0602 at gmail.com>
Date: Tue, 23 Jun 2026 18:02:12 +0800
Subject: [PATCH] [mlir][memref] Avoid mem2reg crash on element count overflow

Avoid crash in test alias analysis operand printing

Fix AffineForOP creash

remove

fix

fix issue
---
 mlir/lib/Dialect/Affine/IR/AffineOps.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
index f095500495f18..544715e6a169d 100644
--- a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
+++ b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
@@ -2596,6 +2596,9 @@ static SmallVector<OpFoldResult> AffineForEmptyLoopFolder(AffineForOp forOp) {
       return {};
     if (iterArgIt == iterArgs.end()) {
       // `val` is defined outside of the loop.
+      if(!val.getParentRegion()){
+        return{};
+      }
       assert(forOp.isDefinedOutsideOfLoop(val) &&
              "must be defined outside of the loop");
       hasValDefinedOutsideLoop = true;



More information about the Mlir-commits mailing list