Repository navigation
[mlir][Sol][Yul] Canonicalize the Yul module before its lowering - #202
Merged
Merged
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Entry-function fallthrough still uses caller-dependent return semantics instead of halting safely.
1 open issue
What changed in this PR
Prepares Sol and Yul intermediate representations for optimization before lowering, with explicit object entry functions and expanded regression coverage.
Changes:
- Adds arithmetic folding, comparison canonicalization, and redundant-check elimination.
- Moves object code into
__entryfunctions and removes unreachable code after halting operations. - Updates conversion tests and adds folding and control-flow regressions.
| File | Description |
|---|---|
| mlir/test/Dialect/Yul/ops-invalid.mlir | Tests object structure validation. |
| mlir/test/Dialect/Yul/object.mlir | Updates object round-trip tests. |
| mlir/test/Dialect/Yul/fold.mlir | Adds arithmetic and builtin folding tests. |
| mlir/test/Dialect/Yul/canonicalize.mlir | Tests comparison inversion. |
| mlir/test/Dialect/Sol/canonicalize.mlir | Tests checked and unchecked arithmetic folding. |
| mlir/test/Conversion/YulToStandard/unreachable-location.mlir | Removes obsolete wrapper-location test. |
| mlir/test/Conversion/YulToStandard/switch.mlir | Updates entry and halting-branch expectations. |
| mlir/test/Conversion/YulToStandard/stop.mlir | Tests direct unreachable termination. |
| mlir/test/Conversion/YulToStandard/selfdestruct.mlir | Updates termination expectation. |
| mlir/test/Conversion/YulToStandard/revert.mlir | Updates entry and revert lowering tests. |
| mlir/test/Conversion/YulToStandard/returndata.mlir | Wraps object code in entry functions. |
| mlir/test/Conversion/YulToStandard/pop.mlir | Updates entry fallthrough expectation. |
| mlir/test/Conversion/YulToStandard/obj.mlir | Tests explicit object entry functions. |
| mlir/test/Conversion/YulToStandard/noreturn.mlir | Adds halting and continuation-removal tests. |
| mlir/test/Conversion/YulToStandard/memory.mlir | Updates entry and byte-operation inputs. |
| mlir/test/Conversion/YulToStandard/log.mlir | Wraps logging code in entry functions. |
| mlir/test/Conversion/YulToStandard/llvm-global.mlir | Separates globals from entry code. |
| mlir/test/Conversion/YulToStandard/invalid.mlir | Updates invalid-op termination tests. |
| mlir/test/Conversion/YulToStandard/if.mlir | Moves conditional code into entry functions. |
| mlir/test/Conversion/YulToStandard/function.mlir | Separates entry code from helper functions. |
| mlir/test/Conversion/YulToStandard/entry-function.mlir | Checks entry and helper attributes. |
| mlir/test/Conversion/YulToStandard/empty-block.mlir | Updates empty-entry expectation. |
| mlir/test/Conversion/YulToStandard/dead-loop-regions.mlir | Tests removal of unreachable loop regions. |
| mlir/test/Conversion/YulToStandard/data.mlir | Updates data-copy entry structure. |
| mlir/test/Conversion/YulToStandard/data-in-code.mlir | Updates embedded-data object structure. |
| mlir/test/Conversion/YulToStandard/calldata.mlir | Wraps calldata code in entry functions. |
| mlir/test/Conversion/SolToYul/unsafe-asm-effects.mlir | Updates memory-guard checks for entry functions. |
| mlir/test/Conversion/SolToYul/malloc.mlir | Expects constant cleanup elimination. |
| mlir/test/Conversion/SolToYul/immutable.mlir | Updates constant immutable-store expectations. |
| mlir/test/Conversion/SolToYul/ext-call.mlir | Checks simplified return-data size validation. |
| mlir/test/Conversion/SolToYul/empty-contract.mlir | Checks generated entry-function structure. |
| mlir/test/Conversion/SolToYul/dispatch-locations.mlir | Tests artificial entry debug information. |
| mlir/test/Conversion/SolToYul/ctor-diamond-args.mlir | Updates tuple-size calculation expectations. |
| mlir/test/Conversion/SolToYul/constant-divisor.mlir | Tests omitted constant-divisor checks. |
| mlir/test/Conversion/SolToYul/constant-cleanup.mlir | Tests constant range handling. |
| mlir/test/Conversion/SolToYul/cmp.mlir | Updates boolean constant cleanup expectations. |
| mlir/test/Conversion/SolToYul/abi-decode-storage.mlir | Checks direct tuple-size reuse. |
| mlir/lib/Dialect/Yul/YulOps.cpp | Implements folding, canonicalization, and object validation. |
| mlir/lib/Dialect/Sol/SolOps.cpp | Implements arithmetic folding and division simplification. |
| mlir/lib/Conversion/YulToStandard/YulToStandard.cpp | Lowers explicit entries and removes unreachable code. |
| mlir/lib/Conversion/SolToYul/SolToYul.cpp | Generates entry functions and simplifies checks. |
| mlir/lib/Conversion/SolToYul/EVMUtil.cpp | Skips redundant cleanup and runtime checks. |
| mlir/include/mlir/Dialect/Yul/YulOps.td | Declares folding hooks and entry conventions. |
| mlir/include/mlir/Dialect/Yul/YulBase.td | Declares the halting-operation trait. |
| mlir/include/mlir/Dialect/Yul/Yul.h | Defines the halting-operation trait. |
| mlir/include/mlir/Dialect/Yul/Folders.h | Adds shared integer-folding helpers. |
| mlir/include/mlir/Dialect/Sol/SolOps.td | Enables arithmetic folding and canonicalization. |
| mlir/include/mlir/Conversion/SolToYul/EVMUtil.h | Declares constant-aware division checking. |
Review effort: Balanced
abinavpp
force-pushed
the
app-yul-canon
branch
from
October 26, 2026 19:56
ac81c89 to
07122c6
Compare
abinavpp
marked this pull request as ready for review
October 27, 2026 10:15
abinavpp
force-pushed
the
app-yul-canon
branch
from
October 28, 2026 15:17
07122c6 to
a02af37
Compare
abinavpp
force-pushed
the
app-yul-canon
branch
from
October 30, 2026 10:39
a02af37 to
c6dbbe7
Compare
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
vladimirradosavljevic
approved these changes
Nov 2, 2026
vladimirradosavljevic
left a comment
Contributor
There was a problem hiding this comment.
LGTM, with comments addressed.
abinavpp
force-pushed
the
app-yul-canon
branch
5 times, most recently
from
November 3, 2026 12:10
bc68dcd to
6f0aa17
Compare
PavelKopyl
approved these changes
Nov 3, 2026
Every op in an object then sits in a yul.func, so a pass anchored on functions covers the entry code too.
abinavpp
force-pushed
the
app-yul-canon
branch
from
November 4, 2026 07:32
6f0aa17 to
5015e6b
Compare
abinavpp
force-pushed
the
app-yul-canon
branch
from
November 4, 2026 07:43
5015e6b to
678bbe1
Compare
abinavpp
force-pushed
the
app-yul-canon
branch
from
November 4, 2026 08:07
678bbe1 to
5b4b4b8
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.

Companion: NomicFoundation/solx#850