Skip to content

[mlir] Lower delete of storage references via sol.delete#149

Open
PavelKopyl wants to merge 1 commit into
mainfrom
kpv-delete-skip-maps
Open

[mlir] Lower delete of storage references via sol.delete#149
PavelKopyl wants to merge 1 commit into
mainfrom
kpv-delete-skip-maps

Conversation

@PavelKopyl

Copy link
Copy Markdown
Contributor

No description provided.

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

This PR updates the MLIR lowering of Solidity delete so that deletes of storage reference types (arrays/structs/strings) are lowered via sol.delete rather than the previous “allocate zero value in memory + copy” approach, and expands the lit tests to cover more storage-reference delete patterns (including structs/arrays containing mappings).

Changes:

  • Emit sol.delete for delete applied to non-pointer storage reference types in SolidityToMLIRPass::genDeleteExpr.
  • Extend delete.sol lit tests (init + EVM) with additional reference-type state variables and corresponding delete functions.
  • Regenerate/update FileCheck expectations to match the new lowering and updated symbol/loc numbering.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
test/lit/mlirCodegen/EVM/delete.sol Adds new delete cases (structs/arrays/mappings) and updates EVM-lowering FileCheck output for sol.delete.
test/lit/mlirCodegen/delete.sol Adds the same new delete cases and updates init-MLIR FileCheck output to expect sol.delete for storage reference deletes.
libsolidity/codegen/mlir/SolidityToMLIR.cpp Changes genDeleteExpr to use sol.delete for non-pointer storage reference types.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +913 to +917
// Storage references clear in place via sol.delete, which recursively
// zeroes every occupied slot. Unlike the allocate-empty-and-copy approach
// below, this never attempts to copy uncopyable members (e.g. mappings) and
// matches the legacy codegen's `delete` semantics.
if (mlir::sol::getDataLocation(addrTy) ==

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It looks that all such cases are rejected by the FE, but despite that I added a defensive check.

@PavelKopyl PavelKopyl force-pushed the kpv-delete-skip-maps branch from aa3db0f to 9076c7c Compare June 23, 2026 16:07
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.

2 participants