Skip to content

[mlir] Add tests for the array deep-copy lowering#91

Merged
PavelKopyl merged 1 commit intomainfrom
kpv-deep-copy-array
Mar 30, 2026
Merged

[mlir] Add tests for the array deep-copy lowering#91
PavelKopyl merged 1 commit intomainfrom
kpv-deep-copy-array

Conversation

@PavelKopyl
Copy link
Copy Markdown
Contributor

@PavelKopyl PavelKopyl commented Mar 26, 2026

Fix array::push to deep-copy reference-type elements instead of emitting a plain StoreOp.
solx-llvm

Copy link
Copy Markdown

Copilot AI left a comment

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 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 through genAssign, 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.

@PavelKopyl PavelKopyl requested a review from abinavpp March 26, 2026 18:42
Copy link
Copy Markdown
Contributor

@abinavpp abinavpp left a comment

Choose a reason for hiding this comment

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

Thank you!

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.
@PavelKopyl PavelKopyl force-pushed the kpv-deep-copy-array branch from 5d8d763 to fba7ec4 Compare March 30, 2026 10:48
@PavelKopyl PavelKopyl merged commit 3d16336 into main Mar 30, 2026
2 checks passed
@PavelKopyl PavelKopyl deleted the kpv-deep-copy-array branch March 30, 2026 10:51
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