[mlir] Add tests for the array deep-copy lowering#91
Merged
PavelKopyl merged 1 commit intomainfrom Mar 30, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes MLIR lowering for array::push(value) so that pushing reference-type elements performs a deep copy (via sol.copy) instead of emitting a plain sol.store, and adds regression tests to cover array copying / clearing behavior.
Changes:
- Update
array::push(value)lowering to route throughgenAssign, enabling deep-copy semantics for storage reference types and inserting casts for pointer stores. - Refresh FileCheck expectations for storage array/struct codegen (MLIR + EVM) to match the new lowering behavior.
- Add new MLIR semantic regression tests for 1D/2D array copy semantics, array tail clearing, and narrow-element array literal zero-extension.
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| libsolidity/codegen/mlir/SolidityToMLIR.cpp | Switch array::push(value) from StoreOp to genAssign (deep-copy + casts); minor SmallVector cleanup. |
| test/lit/mlirCodegen/storage-array.sol | Update checks to expect casting before storing into ui256 slots after push(1). |
| test/lit/mlirCodegen/storage-struct.sol | Update checks to expect cast+store for push into ui256 array field and SSA renumbering. |
| test/lit/mlirCodegen/array-copy.sol | New MLIR codegen test covering sol.copy for arrays/strings across locations. |
| test/lit/mlirCodegen/EVM/storage-array.sol | Update EVM-lowering checks reflecting full-slot writes for ui256-typed stores. |
| test/lit/mlirCodegen/EVM/storage-struct.sol | Update EVM-lowering checks reflecting full-slot writes for ui256-typed stores. |
| test/libsolidity/semanticTests/mlir/array_copy_1d.sol | New semantic regression tests for deep-copy behavior across data locations for 1D uint arrays. |
| test/libsolidity/semanticTests/mlir/array_copy_1d_string.sol | New semantic regression tests for deep-copy behavior across data locations for 1D string arrays. |
| test/libsolidity/semanticTests/mlir/array_copy_2d.sol | New semantic regression tests for deep-copy/aliasing across data locations for multiple 2D array shapes. |
| test/libsolidity/semanticTests/mlir/array_clear.sol | New semantic tests asserting storage tail-clearing behavior for arrays (including nested + strings). |
| test/libsolidity/semanticTests/mlir/array_lit_narrow_elt.sol | New regression test ensuring narrow element literals are zero-extended before MStore. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
d75067f to
204b6b2
Compare
204b6b2 to
5d8d763
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 12 out of 13 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Fix array::push to deep-copy reference-type elements instead of emitting a plain StoreOp.
5d8d763 to
fba7ec4
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.
Fix array::push to deep-copy reference-type elements instead of emitting a plain StoreOp.
solx-llvm