Repository navigation
Conversation
There was a problem hiding this comment.
🔵 Needs a closer look
The central SolToYul.cpp lowering diff is missing, preventing reliable review of semantic preservation and LLVM IR/debug-info equivalence.
No open issues 🎉
What changed in this PR
Refactors MLIR’s Sol-to-Yul lowering from staged dialect conversions to a single contract walk, aiming to reduce compilation overhead while preserving generated LLVM IR and debug information.
Changes:
- Uses direct type mapping and Yul functions for helpers and internal dispatch.
- Removes the staged conversion driver, type converter, and
sol.conv_castoperation. - Updates inline-assembly checks for pointer casts emitted at each use.
| File | Description |
|---|---|
mlir/test/Conversion/SolToYul/inline-asm.mlir |
Updates pointer-cast placement expectations. |
mlir/lib/Dialect/Sol/SolOps.cpp |
Removes the obsolete conversion-cast folder. |
mlir/lib/Conversion/SolToYul/TypeConverter.cpp |
Deletes the materializing type converter. |
mlir/lib/Conversion/SolToYul/SolToYulPass.cpp |
Deletes the staged conversion driver. |
mlir/lib/Conversion/SolToYul/InternalDispatch.cpp |
Tracks Yul function targets and their IDs directly. |
mlir/lib/Conversion/SolToYul/EVMUtil.cpp |
Adds direct type mapping and generates helpers as Yul functions. |
mlir/lib/Conversion/SolToYul/CMakeLists.txt |
Removes deleted sources and conversion dependencies. |
mlir/include/mlir/Dialect/Sol/SolOps.td |
Removes the sol.conv_cast definition. |
mlir/include/mlir/Conversion/SolToYul/Util.h |
Adds signedness-aware 256-bit constant generation. |
mlir/include/mlir/Conversion/SolToYul/SolToYul.h |
Updates dispatch state and removes conversion-pattern APIs. |
mlir/include/mlir/Conversion/SolToYul/EVMUtil.h |
Exposes direct lowering utilities and simplifies decoding APIs. |
Review effort: Balanced
abinavpp
force-pushed
the
app-sol-to-yul-direct
branch
from
November 17, 2026 22:11
7989305 to
ab57e54
Compare
abinavpp
marked this pull request as ready for review
November 17, 2026 22:15
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.
Lowers Sol to Yul in one walk over the contract, replacing the staged dialect conversions. The LLVM IR, debug info included, is unchanged.
Companion: NomicFoundation/solx#947
Improvements:
yul.funcis now declared up front and the contract is lowered after its bodies, so one walk suffices.yul.funcdirectly, no longer as asol.funcwithsol.call/sol.returnthat existed only to be converted to Yul in a later stage.sol.trybuilds its control flow and allocas directly, instead of emitting Sol ops to be lowered later, and maps its clause arguments instead of replacing them behind the rewriter's back.!yul.ptr(see the open question).sol.ext_icallcalls the external call lowering directly, instead of building a temporarysol.ext_calland lowering that.convert-sol-to-yultakes about 60% less time, but a whole compile only about 3% less, since LLVM dominates it. Each op is built once, in place, with no rewrite log or rollback.sol.conv_castis deleted from the Sol dialect.loweroverload over the already-lowered operands (anIRMapping), in place of theOpConversionPatternstructs, theCleanedOperandsLoweringtemplate dispatch and thepopulate*Patssets. Shared state (the string literal pool, the internal dispatch) is a member, no longer threaded through every pattern's constructor.Open questions
!yul.ptrvs!llvm.ptr. A lowered Sol stack slot is an!llvm.ptr(llvm.alloca,llvm.getelementptr), while inline assembly'syul.load/yul.storetake a!yul.ptr. The lowering bridges them with anunrealized_conversion_castat each use, which the Yul translation reads through. Either:yul.alloca,yul.loadandyul.storework on!llvm.ptrand!yul.ptrgoes away, or!yul.ptr.The first is a small change (the Yul op definitions, the translation's cast handling, and solx's pointer type) and works as is: with it, the LLVM IR is unchanged and the solx tests pass.
Location tracking. The lit tests barely check the locations the lowering gives its ops, so a change can move one unnoticed. How should this be tested? A lit test can pin each lowered op to its Sol op's line (
-mlir-print-debuginfowithloc({{.*}}:[[@LINE+1]]:<col>)), but the relative line numbers need the CHECK lines interleaved with the input.