[Mlir-commits] [mlir] [MLIR][SliceAnalysis] Add comment and restore failure condition (PR #142223)

William Moses llvmlistbot at llvm.org
Fri May 30 15:24:32 PDT 2025


https://github.com/wsmoses created https://github.com/llvm/llvm-project/pull/142223

None

>From 90167b53edc46a32fbd3cb7dd9bf79617ffd2026 Mon Sep 17 00:00:00 2001
From: "William S. Moses" <gh at wsmoses.com>
Date: Fri, 30 May 2025 18:24:19 -0400
Subject: [PATCH] [MLIR][SliceAnalysis] Add comment and restore failure
 condition

---
 mlir/include/mlir/Analysis/SliceAnalysis.h | 2 ++
 mlir/lib/Analysis/SliceAnalysis.cpp        | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/mlir/include/mlir/Analysis/SliceAnalysis.h b/mlir/include/mlir/Analysis/SliceAnalysis.h
index d082d2d9f758b..dc0d56d6b753d 100644
--- a/mlir/include/mlir/Analysis/SliceAnalysis.h
+++ b/mlir/include/mlir/Analysis/SliceAnalysis.h
@@ -140,6 +140,8 @@ void getForwardSlice(Value root, SetVector<Operation *> *forwardSlice,
 ///
 /// This function returns whether the backwards slice was able to be
 /// successfully computed, and failure if it was unable to determine the slice.
+/// This function will presently return failure if a value to process is a blockargument
+/// whose parent op has more than region or more than one block.
 LogicalResult getBackwardSlice(Operation *op,
                                SetVector<Operation *> *backwardSlice,
                                const BackwardSliceOptions &options = {});
diff --git a/mlir/lib/Analysis/SliceAnalysis.cpp b/mlir/lib/Analysis/SliceAnalysis.cpp
index 4cdf47a405c01..20ba558507f4e 100644
--- a/mlir/lib/Analysis/SliceAnalysis.cpp
+++ b/mlir/lib/Analysis/SliceAnalysis.cpp
@@ -109,6 +109,8 @@ static LogicalResult getBackwardSliceImpl(Operation *op,
         if (parentOp->getNumRegions() == 1 &&
             llvm::hasSingleElement(parentOp->getRegion(0).getBlocks())) {
           return getBackwardSliceImpl(parentOp, backwardSlice, options);
+        } else {
+          return failure();
         }
       }
     } else {



More information about the Mlir-commits mailing list