Skip to content

[mlir] Lower addr.code.length and the inline-assembly clz builtin - #165

Merged
abinavpp merged 2 commits into
mainfrom
app-lowering-fixes
Jul 28, 2026
Merged

[mlir] Lower addr.code.length and the inline-assembly clz builtin#165
abinavpp merged 2 commits into
mainfrom
app-lowering-fixes

Conversation

@abinavpp

@abinavpp abinavpp commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 the clz builtin in YulToMLIR.
  • Lower addr.code.length directly 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.

Comment thread libsolidity/codegen/mlir/SolidityToMLIR.cpp Outdated
@abinavpp abinavpp changed the title [mlir] Small lowering additions and fixes [mlir] Lower addr.code.length and the inline-assembly clz builtin Jul 23, 2026
@abinavpp
abinavpp force-pushed the app-lowering-fixes branch from ff216be to e43f945 Compare July 23, 2026 07:52
@abinavpp
abinavpp marked this pull request as ready for review July 23, 2026 08:31
@abinavpp
abinavpp force-pushed the app-lowering-fixes branch from e43f945 to dcf2b2d Compare July 27, 2026 18:43
@abinavpp
abinavpp force-pushed the app-lib-delegatecalls branch from 8806d5b to 7202dab Compare July 27, 2026 18:45

@PavelKopyl PavelKopyl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@abinavpp
abinavpp force-pushed the app-lowering-fixes branch from dcf2b2d to 6bc4c24 Compare July 28, 2026 12:45
@abinavpp
abinavpp force-pushed the app-lib-delegatecalls branch from 7202dab to 59b76fd Compare July 28, 2026 12:45
@abinavpp
abinavpp changed the base branch from app-lib-delegatecalls to main July 28, 2026 12:46
@abinavpp
abinavpp force-pushed the app-lowering-fixes branch 3 times, most recently from 3c8ff09 to a3eb929 Compare July 28, 2026 12:51
abinavpp added 2 commits July 28, 2026 14:52
Materializing the code bytes just to read the length would allocate
memory via-IR doesn't; extcodesize reads the size directly.
@abinavpp
abinavpp force-pushed the app-lowering-fixes branch from a3eb929 to e61dec2 Compare July 28, 2026 12:52
@abinavpp
abinavpp merged commit 0bd1f80 into main Jul 28, 2026
2 checks passed
@abinavpp
abinavpp deleted the app-lowering-fixes branch July 28, 2026 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants