Skip to content

[mlir] Add tests for the struct deep-copy support#132

Merged
PavelKopyl merged 1 commit into
mainfrom
kpv-deep-copy-structs
May 26, 2026
Merged

[mlir] Add tests for the struct deep-copy support#132
PavelKopyl merged 1 commit into
mainfrom
kpv-deep-copy-structs

Conversation

@PavelKopyl

@PavelKopyl PavelKopyl commented May 19, 2026

Copy link
Copy Markdown
Contributor

Also add cycle detection for recursive struct types in getType.

llvm

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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::getType and 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.

Comment thread libsolidity/codegen/mlir/SolidityToMLIR.cpp
@PavelKopyl PavelKopyl force-pushed the kpv-deep-copy-structs branch from 2bdd630 to cdeea20 Compare May 20, 2026 18:51
Base automatically changed from kpv-fix-pop-op to main May 20, 2026 22:01
@PavelKopyl PavelKopyl force-pushed the kpv-deep-copy-structs branch from cdeea20 to 07390d9 Compare May 21, 2026 15:40
@PavelKopyl PavelKopyl requested a review from Copilot May 21, 2026 21:49

Copilot AI left a comment

Copy link
Copy Markdown

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 11 out of 12 changed files in this pull request and generated 1 comment.

Comment thread libsolidity/codegen/mlir/SolidityToMLIR.cpp

@abinavpp abinavpp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

amazing! thank you!

let's discuss recursive structs next week.

Comment thread libsolidity/codegen/mlir/SolidityToMLIR.cpp
Also add cycle detection for recursive struct types in getType.
@PavelKopyl PavelKopyl force-pushed the kpv-deep-copy-structs branch from e9c35a4 to b6e8a7b Compare May 25, 2026 11:31
@PavelKopyl PavelKopyl merged commit 1fc123e into main May 26, 2026
2 checks passed
@PavelKopyl PavelKopyl deleted the kpv-deep-copy-structs branch May 26, 2026 10:04
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