Skip to content

[mlir][Sol] genMemAlloc: zero-init StringType data area for new bytes(N)#84

Merged
PavelKopyl merged 1 commit into
mainfrom
kpv-mem-cleanup-bytes
Jun 4, 2026
Merged

[mlir][Sol] genMemAlloc: zero-init StringType data area for new bytes(N)#84
PavelKopyl merged 1 commit into
mainfrom
kpv-mem-cleanup-bytes

Conversation

@PavelKopyl

@PavelKopyl PavelKopyl commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

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 Sol-to-Yul lowering’s memory allocation helper so that when allocating a memory StringType/bytes with zeroInit=true (e.g., new bytes(N)), the newly allocated data area is explicitly zero-initialized (including padding up to 32-byte alignment).

Changes:

  • In evm::Builder::genMemAlloc’s StringType path, round the requested byte length up to a 32-byte multiple for allocation sizing.
  • When zeroInit is set, zero the allocated data region via CALLDATACOPY from CALLDATASIZE (out-of-range reads yield zeros).
  • Preserve existing behavior for calldata strings ({0,0} null reference) and for the sizeVar-absent case (return zero pointer sentinel).

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

@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.

thank you!

@PavelKopyl PavelKopyl merged commit 35fdf47 into main Jun 4, 2026
9 of 10 checks passed
@PavelKopyl PavelKopyl deleted the kpv-mem-cleanup-bytes branch June 4, 2026 09:58
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