Repository navigation
[mlir] Recover the behavior of SliceAnaylsis for llvm-project@6a8dde04a07 - #142076
Conversation
In llvm@6a8dde0, it changes the method to return LogicalFailure, so callers can handle the failure instead of crashing, if I read the intention correctly. However, it changes the behavior of the implementation. Before the change, processValue does not treat it as a failure if the check below TODO has a false condition. However, with the new change, it starts treating it as a failure. The revision updates the final `else` branch to return a failure, and return success at the end; the behavior is recovered. ```cpp auto processValue = [&](Value value) { if (auto *definingOp = value.getDefiningOp()) { if (backwardSlice->count(definingOp) == 0) getBackwardSliceImpl(definingOp, backwardSlice, options); } else if (auto blockArg = dyn_cast<BlockArgument>(value)) { if (options.omitBlockArguments) return; Block *block = blockArg.getOwner(); Operation *parentOp = block->getParentOp(); // TODO: determine whether we want to recurse backward into the other // blocks of parentOp, which are not technically backward unless they flow // into us. For now, just bail. if (parentOp && backwardSlice->count(parentOp) == 0) { assert(parentOp->getNumRegions() == 1 && llvm::hasSingleElement(parentOp->getRegion(0).getBlocks())); getBackwardSliceImpl(parentOp, backwardSlice, options); } } else { llvm_unreachable("No definingOp and not a block argument."); } ``` No additional tests are added like the previous commit. This revision is mostly a post-fix for llvm@6a8dde0 Signed-off-by: hanhanW <[email protected]>
|
@llvm/pr-subscribers-mlir Author: Han-Chung Wang (hanhanW) ChangesIn 6a8dde0, it changes the method to return LogicalFailure, so callers can handle the failure instead of crashing, if I read the intention correctly. However, it changes the behavior of the implementation. Before the change, processValue does not treat it as a failure if the check below TODO has a false condition. However, with the new change, it starts treating it as a failure. The revision updates the final auto processValue = [&](Value value) {
if (auto *definingOp = value.getDefiningOp()) {
if (backwardSlice->count(definingOp) == 0)
getBackwardSliceImpl(definingOp, backwardSlice, options);
} else if (auto blockArg = dyn_cast<BlockArgument>(value)) {
if (options.omitBlockArguments)
return;
Block *block = blockArg.getOwner();
Operation *parentOp = block->getParentOp();
// TODO: determine whether we want to recurse backward into the other
// blocks of parentOp, which are not technically backward unless they flow
// into us. For now, just bail.
if (parentOp && backwardSlice->count(parentOp) == 0) {
assert(parentOp->getNumRegions() == 1 &&
llvm::hasSingleElement(parentOp->getRegion(0).getBlocks()));
getBackwardSliceImpl(parentOp, backwardSlice, options);
}
} else {
llvm_unreachable("No definingOp and not a block argument.");
}No additional tests are added, like the previous commit. This revision is mostly a post-fix for 6a8dde0 1 Files Affected:
diff --git a/mlir/lib/Analysis/SliceAnalysis.cpp b/mlir/lib/Analysis/SliceAnalysis.cpp
index c4eda71c42f3e..4cdf47a405c01 100644
--- a/mlir/lib/Analysis/SliceAnalysis.cpp
+++ b/mlir/lib/Analysis/SliceAnalysis.cpp
@@ -111,8 +111,10 @@ static LogicalResult getBackwardSliceImpl(Operation *op,
return getBackwardSliceImpl(parentOp, backwardSlice, options);
}
}
+ } else {
+ return failure();
}
- return failure();
+ return success();
};
bool succeeded = true;
|
|
yeah fair catch -- and yes that should've been a commit which didn't change behavior. |
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/138/builds/13875 Here is the relevant piece of the build log for the reference |
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/35/builds/10510 Here is the relevant piece of the build log for the reference |
| @@ -111,8 +111,10 @@ static LogicalResult getBackwardSliceImpl(Operation *op, | |||
| return getBackwardSliceImpl(parentOp, backwardSlice, options); | |||
| } | |||
There was a problem hiding this comment.
Should this else return a failure? (to reflect the original assert?)
|
Yeah looking at this again this patch is wrong and indeed it should return a failure there |
|
fix in #142223 |
In 6a8dde0, it changes the method to return LogicalFailure, so callers can handle the failure instead of crashing, if I read the intention correctly. However, it changes the behavior of the implementation; it breaks several integratino tests in downstream projects (e.g., IREE).
Before the change, processValue does not treat it as a failure if the check below TODO has a false condition. However, with the new change, it starts treating it as a failure.
The revision updates the final
elsebranch (i.e.,llvm_unreachableline) to return a failure, and return success at the end; the behavior is recovered.No additional tests are added, like the previous commit. This revision is mostly a post-fix for 6a8dde0
Co-authored-by: Ian Wood [email protected]