Skip to content

feat(rt): add address allocation model for pointer-to-integer semantics#1003

Draft
Stevengre wants to merge 2 commits intomasterfrom
jh/address-alloc-model
Draft

feat(rt): add address allocation model for pointer-to-integer semantics#1003
Stevengre wants to merge 2 commits intomasterfrom
jh/address-alloc-model

Conversation

@Stevengre
Copy link
Copy Markdown
Contributor

Summary

Implements Miri-style lazy address allocation for pointer-to-integer casts (Issue #1002).

  • Adds <addressMap>, <nextAddress>, <exposedSet> configuration cells
  • Supports castKindTransmute PtrLocal→int and castKindPointerExposeAddress
  • Addresses are lazily assigned, aligned to type requirements, starting from 4096 (non-NULL)
  • Different allocations get unique addresses

Verification

LLVM backend execution confirms correctness:

  • interior-mut3-fail.rs: reaches #EndProgram with addr=4096, alignment check passes
  • Address map correctly populated: allocKey(0, local(1)) |-> addrEntry(4096, 0)

Known issue

Haskell backend (symbolic prove) performance regresses — 3 new configuration cells increase matching state space. Needs optimization before the prove tests can run in reasonable time.

Related

Test plan

  • make build passes
  • LLVM backend: interior-mut3-fail.rs executes to #EndProgram
  • Haskell backend: prove tests (blocked on performance)
  • Regression: full test suite

🤖 Generated with Claude Code

Stevengre and others added 2 commits March 26, 2026 15:33
Implements Miri-style lazy address allocation (Issue #1002):

Configuration:
- `<addressMap>`: maps allocation keys to (base_address, size) pairs
- `<nextAddress>`: next available address (starts at 4096 to avoid NULL)
- `<exposedSet>`: tracks allocations with exposed provenance

Semantics:
- `#allocAddressFor`: lazily assigns aligned base addresses on demand
- `#alignUp`: aligns addresses to type alignment requirements
- `castKindTransmute` PtrLocal→int: computes base + byte_offset
- `castKindPointerExposeAddress`: same as transmute but also exposes provenance

Verified via LLVM backend execution:
- interior-mut3-fail.rs reaches #EndProgram (alignment check passes with addr=4096)
- Address uniqueness: different locals get different base addresses

Note: Haskell backend (prove) performance regresses due to 3 new configuration
cells increasing the matching state space. This needs further optimization
(e.g. cell multiplicity annotations or rule priorities).

Closes #1002
Supersedes #812, #877
Fixes #638

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

feat: add address allocation model for pointer-to-integer semantics Extend pointer emulation to pass alignment check

1 participant