Skip to content

feat(vcr-ra): flag-gated range re-allocation pass — first consequential allocator step (wiring 3a) - #288

Merged
avrabe merged 1 commit into
mainfrom
feat/vcr-ra-realloc-pass
Jun 10, 2026
Merged

avrabe merged 1 commit into
mainfrom
feat/vcr-ra-realloc-pass

Conversation

@avrabe

@avrabe avrabe commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

What

The first consequential VCR-RA-001 step: reallocate_function re-colours each maximal straight-line segment with value ranges as the allocation unit, wired behind SYNTH_RANGE_REALLOC=1 (default off — fixtures bit-identical, verified).

Soundness by construction:

  • Conservative pinning — segment inputs (def==0) and per-register live-outs keep their original registers, so segments are independently sound with no cross-segment liveness; reserved registers (R9–R12/SP) identity-assigned outside the colouring.
  • Renames only — never adds/removes/reorders instructions; labels and branch offsets unaffected.
  • Defense-in-depth — every interference edge re-checked against the final assignment (independent of the colourer) before accepting a rewrite; declines pass through untouched.

Flag-ON evidence (the gate that matters)

check result
control_step differential 13/13 → 0x00210A55 PASS
flight_seam inlined + flat 0x07FDF307 MATCH
div_const 338/338 PASS
control_step / div_const bytes flag-on byte-identical to flag-off — the conservative pass re-derives the greedy assignment exactly
flat_flight 1/1 segment re-allocated, .text 1244 → 1240 B (−4) — re-colouring enables more 16-bit Thumb forms, result unchanged

Flag-OFF: all fixtures cmp-bit-identical to v0.11.35. 338/338 lib tests, clippy clean.

Why the flag stays off

Bytes ≠ cycles (lesson #277: the mla fusion removed instructions and still regressed on-target). The flip is gated on gale's on-target cycle confirmation. Step-4 spill insertion and the slack-aware assignment policy (the const-CSE residency unlock) build directly on this pass.

Falsification

Wrong if any flag-on module's result diverges from wasmtime — i.e. the pinning rules missed a cross-segment dependency or the interference convention let simultaneous values share a register. Watched by the four differentials (all green above) and the per-segment defense-in-depth check.

Traceability: VCR-RA-001 (epic #242, release-v0.11.37).

🤖 Generated with Claude Code

…ential allocator step (#209/#242, wiring step 3a)

reallocate_function(instrs, pool): re-colour each maximal straight-line
segment over the pool with VALUE RANGES as the allocation unit. Conservative
pinning makes every segment independently sound with no cross-segment
liveness: inputs (def==0) and per-register last-opened ranges (live-outs)
keep their original registers; reserved-register ranges (R9-R12/SP) are
identity-assigned outside the colouring. Renames only — never adds, removes,
or reorders instructions, so labels and branch offsets are unaffected.
Defense-in-depth: every interference edge is re-checked against the final
assignment before a segment's rewrite is accepted; any decline passes the
segment through untouched.

Wired in arm_backend behind SYNTH_RANGE_REALLOC=1 (default OFF — every
fixture stays bit-identical, verified by cmp).

FLAG-ON evidence (the consequential gate):
  - differentials ALL RESULT-IDENTICAL: control_step 13/13 0x00210A55,
    flight_seam inlined+flat 0x07FDF307, div_const 338/338
  - control_step + div_const: flag-on output is BYTE-identical to flag-off —
    the conservative pass re-derives the greedy assignment exactly (the
    strongest no-regression evidence)
  - flat_flight: 1/1 segment re-allocated, .text 1244 -> 1240 B (-4): the
    re-colouring enables more 16-bit Thumb encodings, result unchanged
  - stats per function: control_step 2/5 segments re-allocated, flight_seam
    1/2, flat_flight 1/1

The flag stays default-off pending gale's on-target cycle confirmation
(bytes != cycles, lesson #277). Step-4 spill insertion and the slack-aware
assignment policy (const-CSE residency) build on this pass.

Tests: pins honoured (inputs/live-outs/reserved identity), control flow
verbatim, soundness on packed greedy code (output's own range interference
conflict-free), structure preservation. 338/338 lib tests, clippy clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@codecov

codecov Bot commented Jun 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.13483% with 21 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/synth-synthesis/src/liveness.rs 93.12% 18 Missing ⚠️
crates/synth-backend/src/arm_backend.rs 40.00% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

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.

1 participant