ReviewOS

home-lang/home

refactor(codegen): choose the AOT backbone and retire unwired backends

#801
Open chris opened this 9 days ago ·
9 days ago

Problem

A lot of backend code is unwired: llvm_codegen.zig / llvm_backend.zig are never called; packages/wasm is not in build.zig and codegen/src/wasm.zig uses the old ArrayList.init API; packages/regalloc is only used by its own tests while native codegen uses a 5-register bitmask allocator; packages/build/src/lto.zig and cross_compilation.zig are referenced nowhere; packages/linker is not wired into the build; the planned split of native_codegen.zig stopped after one extracted module.

Evidence (origin/main @ d4b219507)

Scope

  • Decision record in docs/docs/DECISIONS.md: direct codegen vs. LLVM (vs. both) for user-space AOT, x64 and aarch64.
  • Each listed module is either wired with tests or deleted.
  • If direct codegen stays: adopt packages/regalloc (linear scan) in place of the bitmask allocator.

Acceptance criteria

  • Decision record merged.
  • No backend module remains that is neither built nor tested.
  • Parity-status docs updated to match.

Related: #5 Part of #814.

9 days ago

AOT-backbone cleanup: daa91ed0b closes #822 by deleting codegen’s unwired second HM inference bridge and stale unregistered tests. packages/types/src/type_system.zig is now explicitly documented as the single semantic authority before codegen. The codegen gate passes 16/16 under the memory guard.

9 days ago

Direct-backend decision slice pushed to main in 69658585c (refactor(codegen): select direct AOT backend (#801)).

  • superseded the never-wired Cranelift-primary / optional-LLVM decision with the executable architecture: direct x86-64 and AArch64 Home AOT, separate JavaScriptCore standalone builds
  • deleted the exported but unused 622-line llvm_codegen.zig implementation and removed its public package surface
  • removed LLVM as an advertised active codegen target and corrected parity percentages

Verification: codegen 16/16; full no-JSC CLI build 26/26; zig fmt --check and git diff --check pass. Guarded peaks were 413 MB for codegen and 2,865 MB for the full build. #801 remains open for the other listed unwired modules and direct-backend regalloc/refactor work.

9 days ago

Second direct-backend cleanup pushed in c1ff859b1 (refactor(codegen): remove orphan LLVM backend (#801)).

  • deleted the separate, completely unreferenced 715-line llvm_backend.zig implementation
  • deleted the 472-line Backend Quick Guide, which documented nonexistent ion build --backend=llvm commands and invented LLVM benchmark results
  • corrected the compiler pipeline and TypeScript AOT plan to describe direct x64/arm64 lowering
  • removed the dead guide from the docs index

Static audit finds no remaining Home LLVM backend symbols or links (the decision record retains LLVM only as a rejected option; a vendored Unicode build comment refers to Zig compiler internals). Codegen remains 16/16; diff checks pass. Focused Pickier reached only pre-existing TS_PARITY_PLAN.md lint debt outside the changed lines (3 errors/224 warnings), with no auto-fix or lockfile mutation. #801 remains open for WASM/regalloc/build-package cleanup.

9 days ago

Two more unwired-backend slices are now on main:

  • 18d4c95e0 removes the stale exported codegen/src/wasm.zig emitter and its advertised capability (4 files, 367 deletions).
  • de03bec70 removes the separate unbuilt packages/wasm prototype and makes the Phase 7 plan require build/CLI/runtime admission for any future replacement (4 files, 1,457 deletions).

Both slices pass the 16/16 codegen gate under the serialized memory guard. No active runtime WebAssembly support was removed: neither prototype had a build.zig import or caller. #801 remains open for the standalone regalloc adoption, unused build/linker modules, and native-codegen split.

9 days ago

Pushed 2dc4f5f06 directly to main: fix(linker): restore root test coverage (#801).

This keeps the substantive linker package and fixes the real integration gap instead of deleting it: migrated generator/file I/O to Zig 0.17, modernized the file-generation integration test, and wired both linker unit and integration suites into the root test graph.

Verification:

  • standalone linker build: 67/67 tests passed (350 MB guarded peak)
  • root zig build test -Dfilter=linker -j1: 67/67 tests passed (345 MB guarded peak)
  • zig fmt --check and git diff --check passed

#801 remains open for the native-codegen/register-allocator integration work.

9 days ago

Two register-allocation cleanup slices are now pushed directly to main:

  • 024bedbbc removes the zero-caller standalone packages/regalloc prototype and its root-only self-test wiring (5 files, 980 deletions). Audit showed it was a manual hint/occupancy API, not the linear-scan allocator described in the issue.
  • b5d0737ce removes native codegen’s completely unused five-register bitmask field, gives the actual packages/codegen/src/regalloc.zig graph-coloring allocator a dedicated root test target, and corrects the Phase 7 plan to put allocation after HIR-to-MIR lowering (3 files).

Verification under the serialized memory guard:

  • zig build test -Dfilter=codegen_regalloc -j1: 17/17 passed, 322 MB peak
  • zig build test -Dfilter=codegen -j1: native codegen 16/16 passed; allocator target cached green, 467 MB peak
  • build-file formatting and diff checks passed; native_codegen.zig has pre-existing whole-file format drift, and this change only deletes contiguous code

The honest remaining allocator work is to connect MIR live intervals to the tested graph-coloring allocator and then consume its assignments/spills during machine lowering. #801 stays open for that integration and the remaining native-codegen split.

Sign in to comment on this issue.