-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[MLIR][SliceAnalysis] Add comment and restore failure condition #142223
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
base: main
Are you sure you want to change the base?
Conversation
@llvm/pr-subscribers-mlir Author: William Moses (wsmoses) ChangesFull diff: https://github.com/llvm/llvm-project/pull/142223.diff 2 Files Affected:
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 {
|
You can test this locally with the following command:git-clang-format --diff HEAD~1 HEAD --extensions h,cpp -- mlir/include/mlir/Analysis/SliceAnalysis.h mlir/lib/Analysis/SliceAnalysis.cpp View the diff from clang-format here.diff --git a/mlir/include/mlir/Analysis/SliceAnalysis.h b/mlir/include/mlir/Analysis/SliceAnalysis.h
index b6efdcee3..2f9ed1cba 100644
--- a/mlir/include/mlir/Analysis/SliceAnalysis.h
+++ b/mlir/include/mlir/Analysis/SliceAnalysis.h
@@ -140,8 +140,9 @@ 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 one region, or a region with more than one block.
+/// This function will presently return failure if a value to process is a
+/// blockargument whose parent op has more than one region, or a region with
+/// more than one block.
LogicalResult getBackwardSlice(Operation *op,
SetVector<Operation *> *backwardSlice,
const BackwardSliceOptions &options = {});
|
Thanks! |
@@ -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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be tested?
Co-authored-by: Mehdi Amini <joker.eph@gmail.com>
I just noticed a warning in this code that would be worth checking here, as I think this is still broken:
The error handing in getBackwardSliceImpl's processValue is totally ignored it seems? |
Restores the failure accidentally removed in #142076 and adds the comment requested in #140961 (comment)