Skip to content

[MLIR] Fix: cast were meant to be dyn_cast. #110518

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
merged 1 commit into from
Sep 30, 2024
Merged

Conversation

bjacob
Copy link
Contributor

@bjacob bjacob commented Sep 30, 2024

This fixes cast's that were introduced in #108450.

Signed-off-by: Benoit Jacob <[email protected]>
@bjacob bjacob changed the title [MLIR] Fix after #108450: cast were meant to be dyn_cast. [MLIR] Fix: cast were meant to be dyn_cast. Sep 30, 2024
@bjacob bjacob marked this pull request as ready for review September 30, 2024 15:04
@llvmbot
Copy link
Member

llvmbot commented Sep 30, 2024

@llvm/pr-subscribers-mlir-affine

@llvm/pr-subscribers-mlir

Author: Benoit Jacob (bjacob)

Changes

This fixes cast's that were introduced in #108450.


Full diff: https://github.com/llvm/llvm-project/pull/110518.diff

1 Files Affected:

  • (modified) mlir/lib/Dialect/Affine/IR/AffineOps.cpp (+2-2)
diff --git a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
index 1ccff7324f514d..5e7a6b6ca883c3 100644
--- a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
+++ b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
@@ -4612,12 +4612,12 @@ struct DropDelinearizeOfSingleLoop
       return failure();
 
     // Check that the `linear_index` is an induction variable.
-    auto inductionVar = cast<BlockArgument>(delinearizeOp.getLinearIndex());
+    auto inductionVar = dyn_cast<BlockArgument>(delinearizeOp.getLinearIndex());
     if (!inductionVar)
       return failure();
 
     // Check that the parent is a `LoopLikeOpInterface`.
-    auto loopLikeOp = cast<LoopLikeOpInterface>(
+    auto loopLikeOp = dyn_cast<LoopLikeOpInterface>(
         inductionVar.getParentRegion()->getParentOp());
     if (!loopLikeOp)
       return failure();

@bjacob bjacob merged commit f3ebf22 into llvm:main Sep 30, 2024
10 of 12 checks passed
bjacob added a commit to iree-org/iree that referenced this pull request Sep 30, 2024
Cherry-picks:
1. Cherry-picking llvm/llvm-project#110518

Carrying two local reverts:
1. Revert llvm/llvm-project#100667)
- As noted by @hanhanW on #18619,
that PR "breaks the stablehlo build. We need to wait stablehlo bumping
LLVM ahead of it and fix the issue. Then we can bump stablehlo and drop
the local commit together."
2. Revert llvm/llvm-project#110170)
   - That is just the Bazel change accompanying 1.

Signed-off-by: Benoit Jacob <[email protected]>
@joker-eph
Copy link
Collaborator

joker-eph commented Sep 30, 2024

Can we have a test that fails these?
If these are reachable and not dead code, then we're missing the test coverage it seems.

@bjacob
Copy link
Contributor Author

bjacob commented Sep 30, 2024

Correct, this was caught by IREE tests, so we are missing that coverage upstream. I'll send something.

@bjacob
Copy link
Contributor Author

bjacob commented Sep 30, 2024

@joker-eph #110563

bjacob added a commit that referenced this pull request Oct 1, 2024
#110518 fixed assertion
failures in `cast` introduced in
#108450.

Signed-off-by: Benoit Jacob <[email protected]>
puja2196 pushed a commit to puja2196/LLVM-tutorial that referenced this pull request Oct 2, 2024
Sterling-Augustine pushed a commit to Sterling-Augustine/llvm-project that referenced this pull request Oct 3, 2024
llvm#110518 fixed assertion
failures in `cast` introduced in
llvm#108450.

Signed-off-by: Benoit Jacob <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants