[mlir] Lower delete of storage references via sol.delete#149
Open
PavelKopyl wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
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.deletefordeleteapplied to non-pointer storage reference types inSolidityToMLIRPass::genDeleteExpr. - Extend
delete.sollit tests (init + EVM) with additional reference-type state variables and correspondingdeletefunctions. - 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) == |
Contributor
Author
There was a problem hiding this comment.
It looks that all such cases are rejected by the FE, but despite that I added a defensive check.
aa3db0f to
9076c7c
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.
No description provided.