[mlir] Add tests for the struct deep-copy support#132
Merged
Conversation
2615755 to
2bdd630
Compare
There was a problem hiding this comment.
Pull request overview
Adds MLIR codegen and semantic tests to validate deep-copy behavior for structs across storage/memory/calldata, and introduces cycle detection when materializing MLIR struct types to prevent infinite recursion.
Changes:
- Added new lit + semantic tests covering struct copies (sto→sto, sto→mem, mem→sto, cd→mem, cd→sto) with assertions for packing/sign-extension/bytesN alignment.
- Updated existing MLIR EVM lit checks for array copy codegen to reflect new generated IR (incl. additional cleanup/revert paths).
- Added recursive-struct cycle detection in
SolidityToMLIRPass::getTypeand removed several entries from the MLIR semantic-test failure allowlist.
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/mlirSemtestFailures.txt | Removes many previously-known failing upstream semantic tests related to struct/array copying. |
| test/lit/mlirCodegen/struct-copy.sol | New lit test asserting sol.copy/location-cast behavior for large nested structs. |
| test/lit/mlirCodegen/EVM/array-copy-widen.sol | Updates FileCheck expectations for widened packed array copy codegen. |
| test/lit/mlirCodegen/EVM/array-copy-packed.sol | Updates FileCheck expectations for packed array copy codegen (incl. masking/revert paths). |
| test/lit/mlirCodegen/EVM/array-copy-packed-widen.sol | Updates FileCheck expectations for packed+widen array copy codegen. |
| test/libsolidity/semanticTests/mlir/struct_copy_sto_to_sto.sol | New semantic test validating storage→storage struct copy preserves packed slot layout. |
| test/libsolidity/semanticTests/mlir/struct_copy_sto_to_mem.sol | New semantic test validating storage→memory copy applies read-side cleanup in memory. |
| test/libsolidity/semanticTests/mlir/struct_copy_mem_to_storage.sol | New semantic test validating memory→storage copy preserves packed slot bit layout. |
| test/libsolidity/semanticTests/mlir/struct_copy_cd_to_storage.sol | New semantic test validating calldata→storage struct copy and packing. |
| test/libsolidity/semanticTests/mlir/struct_copy_cd_to_mem.sol | New semantic test validating calldata→memory copy cleanup/alignment via raw mload checks. |
| libsolidity/codegen/mlir/SolidityToMLIR.cpp | Adds in-progress struct tracking to detect recursive struct type conversion cycles. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
2bdd630 to
cdeea20
Compare
cdeea20 to
07390d9
Compare
07390d9 to
e9c35a4
Compare
abinavpp
approved these changes
May 23, 2026
abinavpp
left a comment
Contributor
There was a problem hiding this comment.
amazing! thank you!
let's discuss recursive structs next week.
Also add cycle detection for recursive struct types in getType.
e9c35a4 to
b6e8a7b
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.
Also add cycle detection for recursive struct types in getType.
llvm