[LLVM UPDATE] Refactor MLIR operations to use static creation methods#2416
Merged
Conversation
Contributor
Author
paul0403
approved these changes
Jan 29, 2026
paul0403
left a comment
Member
There was a problem hiding this comment.
I like how this 1700 line PR is the easiest to review lol
**Context:** Summary MLIR has updated [Value type](llvm/llvm-project@31536e6#diff-acfa9a5ea4439eae3f3e5a57ccbb8e72944842f6ae7816624c1d75e2908f3e62) to be generic in the type of the value it holds and now the generated dialect bindings emit `Value[Type] / OpResult[Type]` annotations. This would crash Catalyst when importing the generated python files because JAX's LLVM version is older and doesn’t expose `__class_getitem__` which causes an error complaining about indexing. **Description of the Change:** patched `mlir/llvm-project/mlir/tools/mlir-tblgen/OpPythonBindingGen.cpp` to postpone evaluation of type hints to avoid the crash while import. Thanks @rniczh for the idea! **Benefits:** **Possible Drawbacks:** **Related GitHub Issues:**
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## update-llvm-Q1-2026 #2416 +/- ##
=======================================================
+ Coverage 96.63% 97.31% +0.67%
=======================================================
Files 36 107 +71
Lines 4071 12978 +8907
Branches 0 1074 +1074
=======================================================
+ Hits 3934 12629 +8695
- Misses 137 288 +151
- Partials 0 61 +61 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
mehrdad2m
added a commit
that referenced
this pull request
Feb 4, 2026
**Context:** Updating LLVM related dependencies for Q1 2025. After the update we will point the following versions: ``` jax=0.7.1 (no change) stablehlo=v1.13.7 -> llvm=8f264586d7521b0e305ca7bb78825aa3382ffef7 enzyme=v0.0.238 ``` **Description of the Change:** - Replaced rewriter/builder.create<Op>() with Op::create(rewriter/builder, ...) for operations. (#2416) - Updated the "how to write a pass" tutorial to use the updated creation method. (#2416) - Changed integer literals in `InsertValueOp::create` calls to `SmallVector<int64_t>` because MLIR introduced `DenseI64ArrayAttr` overloads, creating ambiguity between `ArrayRef<int64_t>` and `DenseI64ArrayAttr` when passing integer literals. (#2416) - Patched `mlir/llvm-project/mlir/tools/mlir-tblgen/OpPythonBindingGen.cpp` to avoid the crash when importing the generated python files because JAX's LLVM version is older and doesn’t expose `__class_getitem__` which causes an error complaining about indexing. see #2444 - Remove the xfail for a vmap+grad test that is passing now with the update and move another two xfails inside the tests since they are now segfaulting at runtime. see #2445 - Changed `std::nullopt` to `{}` for `ValueRange` default arguments because MLIR removed the `ArrayRef(std::nullopt_t)` constructor, requiring empty initializer lists instead. (6b4f790) - Added `exactNone` argument to `Arith_DivSIOp` pattern because the operation now requires an explicit `fastmath` attribute parameter in tablegen. (279cefc) - Fixed `BufferizableOpInterfaceImpl.cpp`: Added explicit cast from `TensorType` to `TensorLikeType` and `BaseMemRefType` to `BufferLikeType` because MLIR's bufferization framework now uses the `TensorLikeType` and `BufferLikeType` interface to support generic tensor/buffer types. (35b5690) - Fixed `StringSwitch::Cases` usage in to use `std::initializer_list` syntax because LLVM deprecated the old `Cases` method that took multiple string arguments in favor of a single `std::initializer_list` parameter. (48f97d8) - Fixed `inferCanonicalRankReducedResultType` call from 5 arguments to 3 arguments (87cf94b) - Added `StablehloBroadcastLowering` to `CMakeLists.txt` because StableHLO split broadcast lowering functionality into a separate library (fad13a8) **Benefits:** **Possible Drawbacks:** **Related GitHub Issues:** [sc-107552] [sc-107551]
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
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.
Context:
llvm/llvm-project#147168 in LLVM adds concrete static methods for operation creation that are attached to the operation instead of the builder.
Recently the old
rewriter.create<Op>()method is deprecated.This PR updates operations to utilize static creation methods instead of the deprecated version.
Description of the Change:
rewriter/builder.create<Op>()withOp::create(rewriter/builder, ...)for operations.InsertValueOp::createcalls toSmallVector<int64_t>because MLIR introducedDenseI64ArrayAttroverloads, creating ambiguity betweenArrayRef<int64_t>andDenseI64ArrayAttrwhen passing integer literals.Benefits:
Better autocomplete
Possible Drawbacks:
Related GitHub Issues:
[sc-107551]