[mlir] Lower addr.code.length and the inline-assembly clz builtin - #165
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR extends the Solidity→MLIR lowering pipeline with a couple of small but meaningful feature additions (Yul leave, Yul clz, and a special-case for addr.code.length) and updates the MLIR FileCheck fixtures accordingly, also removing several items from the semtest failure allowlist.
Changes:
- Add Yul lowering support for
leave(early return) and theclzbuiltin inYulToMLIR. - Lower
addr.code.lengthdirectly to a code-size operation (avoids materializing code bytes just to read length). - Update MLIR codegen tests / EVM FileCheck expectations and reduce the semtest failure list.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/mlirSemtestFailures.txt | Removes multiple tests from the known-fail list as the lowering now supports them. |
| test/lit/mlirCodegen/inline-asm.sol | Adds a Solidity wrapper calling Yul clz and updates MLIR checks. |
| test/lit/mlirCodegen/inline-asm-functions.sol | Adds an inline-asm nested function using leave and updates MLIR checks. |
| test/lit/mlirCodegen/EVM/load-store-memory-cleanup.sol | Reorders/updates constants in expected EVM MLIR output. |
| test/lit/mlirCodegen/EVM/load-calldata-cleanup.sol | Reorders/updates constants in expected EVM MLIR output. |
| test/lit/mlirCodegen/EVM/inline-asm.sol | Adds clz case and updates deployed-module and dispatch checks. |
| test/lit/mlirCodegen/EVM/inline-asm-functions.sol | Adds leave case and updates expected EVM MLIR lowering for nested Yul functions. |
| test/lit/mlirCodegen/EVM/fixedbytes-memory-store.sol | Reorders constant emission in expected output. |
| test/lit/mlirCodegen/EVM/code.sol | Adds payable-address .code/.codehash and .code.length tests; expands dispatch + helper function checks. |
| test/lit/mlirCodegen/EVM/bytes-to-storage-cleanup.sol | Reorders/updates constants in expected EVM MLIR output. |
| test/lit/mlirCodegen/EVM/array.sol | Reorders constant emission in expected output for multiple functions. |
| test/lit/mlirCodegen/code.sol | Adds .code.length test and updates non-EVM MLIR checks (sol.code_size). |
| libsolidity/codegen/mlir/YulToMLIR.cpp | Implements lowering for Yul leave and adds clz to builtin generation. |
| libsolidity/codegen/mlir/SolidityToMLIR.cpp | Special-cases addr.code.length to generate a code-size op instead of materializing bytes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
abinavpp
force-pushed
the
app-lowering-fixes
branch
from
July 23, 2026 07:52
ff216be to
e43f945
Compare
abinavpp
marked this pull request as ready for review
July 23, 2026 08:31
abinavpp
force-pushed
the
app-lowering-fixes
branch
from
July 27, 2026 18:43
e43f945 to
dcf2b2d
Compare
abinavpp
force-pushed
the
app-lib-delegatecalls
branch
from
July 27, 2026 18:45
8806d5b to
7202dab
Compare
abinavpp
force-pushed
the
app-lowering-fixes
branch
from
July 28, 2026 12:45
dcf2b2d to
6bc4c24
Compare
abinavpp
force-pushed
the
app-lib-delegatecalls
branch
from
July 28, 2026 12:45
7202dab to
59b76fd
Compare
abinavpp
force-pushed
the
app-lowering-fixes
branch
3 times, most recently
from
July 28, 2026 12:51
3c8ff09 to
a3eb929
Compare
Materializing the code bytes just to read the length would allocate memory via-IR doesn't; extcodesize reads the size directly.
abinavpp
force-pushed
the
app-lowering-fixes
branch
from
July 28, 2026 12:52
a3eb929 to
e61dec2
Compare
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.
NomicFoundation/solx-llvm#121