[Mlir-commits] [mlir] [MLIR] Change getBackwardSlice to return a logicalresult rather than crash (PR #140961)

Han-Chung Wang llvmlistbot at llvm.org
Thu May 29 11:49:30 PDT 2025


================
@@ -125,36 +127,41 @@ static void getBackwardSliceImpl(Operation *op,
       region.walk([&](Operation *op) {
         for (OpOperand &operand : op->getOpOperands()) {
           if (!descendents.contains(operand.get().getParentRegion()))
-            processValue(operand.get());
+            if (!processValue(operand.get()).succeeded()) {
+              return WalkResult::interrupt();
+            }
         }
+        return WalkResult::advance();
----------------
hanhanW wrote:

This breaks some integration tests in a downstream project, and I think you should not interrupt when there is a failure. The below patch fixes our issue. I don't have a clean repro now, but I'd like to share this information first.

```patch
--- a/mlir/lib/Analysis/SliceAnalysis.cpp
+++ b/mlir/lib/Analysis/SliceAnalysis.cpp
@@ -127,11 +127,8 @@ static LogicalResult getBackwardSliceImpl(Operation *op,
       region.walk([&](Operation *op) {
         for (OpOperand &operand : op->getOpOperands()) {
           if (!descendents.contains(operand.get().getParentRegion()))
-            if (!processValue(operand.get()).succeeded()) {
-              return WalkResult::interrupt();
-            }
+            (void)processValue(operand.get());
         }
-        return WalkResult::advance();
       });
     });
   }
```

I don't fully follow what the PR is doing, and I'll follow up when I have cycles.

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


More information about the Mlir-commits mailing list