[mlir][Sol] Widen int operand of bytes_cast to match destination#131
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes Solidity-to-MLIR codegen for integer→bytesN casts by ensuring the integer operand is first cast to the exact bit-width required by sol.bytes_cast, and adds regression tests to lock in the behavior.
Changes:
- Adjust
SolidityToMLIRPass::genCastto cast integer operands to the destination byte-width before emittingsol.bytes_cast. - Add new
mlirCodegenandmlirCodegen/EVMlit tests coveringbytes32(uint8)-style widening behavior. - Update
test/mlirSemtestFailures.txtto remove entries that are no longer expected to fail.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| test/mlirSemtestFailures.txt | Removes no-longer-failing semantic tests from the expected-fail list. |
| test/lit/mlirCodegen/EVM/bytes-cast-int-widen.sol | Adds an EVM-lowering regression test for integer widening prior to bytes_cast. |
| test/lit/mlirCodegen/bytes-cast-int-widen.sol | Adds an init-IR regression test for integer widening prior to bytes_cast. |
| libsolidity/codegen/mlir/SolidityToMLIR.cpp | Inserts an integer cast to match bytes_cast’s required operand width for byte/fixedbytes<N> destinations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
90fd667 to
2cdfce9
Compare
7f03134 to
480103b
Compare
2cdfce9 to
8dbebdf
Compare
480103b to
e16453d
Compare
8dbebdf to
7493966
Compare
e16453d to
fc2ff64
Compare
Required by sol.bytes_cast verifier (bitwidth(int) == 8 * size(bytes)); e.g. bytes32(0) where 0 is typed ui8.
7493966 to
c45bf56
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.
Solidity-only; no companion mlir PR.