-
Notifications
You must be signed in to change notification settings - Fork 14.4k
[mlir][transform] Fix crash in transform.get_parent_op. #66492
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
Merged
ingomueller-net
merged 2 commits into
llvm:main
from
ingomueller-net:fix-transform-get-parent-op
Sep 15, 2023
Merged
[mlir][transform] Fix crash in transform.get_parent_op. #66492
ingomueller-net
merged 2 commits into
llvm:main
from
ingomueller-net:fix-transform-get-parent-op
Sep 15, 2023
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The previous implementation crashed if run on a `builtin.module` using an `op_name` filter (because the initial value of `parent` in the while loop was a `nullptr`). This PR fixes the crash and adds a test.
@llvm/pr-subscribers-mlir-core @llvm/pr-subscribers-mlir ChangesThe previous implementation crashed if run on a `builtin.module` using an `op_name` filter (because the initial value of `parent` in the while loop was a `nullptr`). This PR fixes the crash and adds a test. -- Full diff: https://github.com//pull/66492.diff2 Files Affected:
diff --git a/mlir/lib/Dialect/Transform/IR/TransformOps.cpp b/mlir/lib/Dialect/Transform/IR/TransformOps.cpp index de3cd1b28e435bc..f1d07b85adb7576 100644 --- a/mlir/lib/Dialect/Transform/IR/TransformOps.cpp +++ b/mlir/lib/Dialect/Transform/IR/TransformOps.cpp @@ -1233,7 +1233,7 @@ transform::GetParentOp::apply(transform::TransformRewriter &rewriter, DenseSet<Operation *> resultSet; for (Operation *target : state.getPayloadOps(getTarget())) { Operation *parent = target->getParentOp(); - do { + while (parent) { bool checkIsolatedFromAbove = !getIsolatedFromAbove() || parent->hasTrait<OpTrait::IsIsolatedFromAbove>(); @@ -1241,7 +1241,8 @@ transform::GetParentOp::apply(transform::TransformRewriter &rewriter, parent->getName().getStringRef() == *getOpName(); if (checkIsolatedFromAbove && checkOpName) break; - } while ((parent = parent->getParentOp())); + parent = parent->getParentOp(); + } if (!parent) { DiagnosedSilenceableFailure diag = emitSilenceableError() diff --git a/mlir/test/Dialect/Transform/test-interpreter.mlir b/mlir/test/Dialect/Transform/test-interpreter.mlir index 68e3a4851539690..91a283c799941bb 100644 --- a/mlir/test/Dialect/Transform/test-interpreter.mlir +++ b/mlir/test/Dialect/Transform/test-interpreter.mlir @@ -1891,6 +1891,18 @@ transform.sequence failures(propagate) { test_print_number_of_associated_payload_ir_ops %4 : !transform.any_op } + +// ----- + +// expected-note @below {{target op}} +module { + transform.sequence failures(propagate) { + ^bb0(%arg0: !pdl.operation): + // expected-error @below{{could not find a parent op that matches all requirements}} + %3 = get_parent_op %arg0 {op_name = "builtin.module"} : (!pdl.operation) -> !transform.any_op + } +} + // ----- func.func @cast(%arg0: f32) -> f64 { |
ftynse
reviewed
Sep 15, 2023
Comment on lines
1900
to
1902
^bb0(%arg0: !pdl.operation): | ||
// expected-error @below{{could not find a parent op that matches all requirements}} | ||
%3 = get_parent_op %arg0 {op_name = "builtin.module"} : (!pdl.operation) -> !transform.any_op |
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.
Nit: s/pdl.operation/transform.any_op
ftynse
approved these changes
Sep 15, 2023
ZijunZhaoCCK
pushed a commit
to ZijunZhaoCCK/llvm-project
that referenced
this pull request
Sep 19, 2023
The previous implementation crashed if run on a `builtin.module` using an `op_name` filter (because the initial value of `parent` in the while loop was a `nullptr`). This PR fixes the crash and adds a test.
zahiraam
pushed a commit
to tahonermann/llvm-project
that referenced
this pull request
Oct 24, 2023
The previous implementation crashed if run on a `builtin.module` using an `op_name` filter (because the initial value of `parent` in the while loop was a `nullptr`). This PR fixes the crash and adds a test.
zahiraam
pushed a commit
to tahonermann/llvm-project
that referenced
this pull request
Oct 24, 2023
The previous implementation crashed if run on a `builtin.module` using an `op_name` filter (because the initial value of `parent` in the while loop was a `nullptr`). This PR fixes the crash and adds a test.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The previous implementation crashed if run on a
builtin.module
using anop_name
filter (because the initial value ofparent
in the while loop was anullptr
). This PR fixes the crash and adds a test.