Summary
Fixes #390.
The same dynamic-array grow helper was duplicated across four files in
native/zero-c/src:
ir_grow_items(ir.c),lower_grow_items(program_graph_lower.c), andchecker_grow_items(checker.c) shared an identical body.ir_grow_tracked_items(the variant that also accountsir->mir_bytes) was defined verbatim in bothir.candprogram_graph_mir.c.
As the issue notes, the duplicated mir_bytes accounting can silently diverge
if one copy is edited without the others.
Change
Hoist both helpers into include/zero.h as shared static inline functions
(z_grow_items and ir_grow_tracked_items), placed right after the
IrProgram definition so the tracked variant can reference ir->mir_bytes.
The five local definitions are removed and their call sites repointed at the
shared helpers.
Pure refactor — the helper bodies are byte-for-byte the originals, so there is
no behavior change. Net +61 / -81 lines across 5 files.
Validation
make -C native/zero-cbuilds clean under-Wall -Wextra -Wpedantic.- Host-target end-to-end works:
zero build --emit exe --target linux-x64onconformance/run/pass/hello.graphproduces an exe that runs and prints the expected output. - All
conformance/check/pass/*.graphfixtures passzero check(this is the path that exercises the modifiedchecker.candir.clowering).
Transparency per
AGENTS.md: I developed this on Linux (Ubuntu via WSL) where thelinux-x64host target is fully runnable, butpnpm run agent:checkscould not complete because thelinux-musl-x64build steps require a musl-capable C compiler that isn't installed in my environment. That step fails identically on a clean checkout (BLD003: cross target 'linux-musl-x64' requires a target-capable C compiler ... install the bundled-toolchain default), so it is pre-existing and unrelated to this change. CI (with the musl toolchain) should exercise the full matrix.
Activity
3Pull request overview
NOTE
Copilot was unable to run its full agentic suite in this review.
Refactors dynamic array growth helpers by centralizing them into shared inline functions, reducing duplicated logic across several C source files.
Changes:
- Removed per-file
*_grow_itemshelpers inir.c,program_graph_lower.c,checker.c, andprogram_graph_mir.c. - Introduced shared
z_grow_items(andir_grow_tracked_items) helpers ininclude/zero.h. - Updated call sites to use
z_grow_items.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| native/zero-c/src/program_graph_mir.c | Removes local tracked grow helper in favor of shared header implementation. |
| native/zero-c/src/program_graph_lower.c | Replaces local grow helper usage with z_grow_items. |
| native/zero-c/src/ir.c | Removes local grow helpers and switches call sites to z_grow_items. |
| native/zero-c/src/checker.c | Removes local grow helper and switches call sites to z_grow_items. |
| native/zero-c/include/zero.h | Adds shared inline grow helpers (z_grow_items, ir_grow_tracked_items). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
@Osamaali313 is attempting to deploy a commit to the Vercel Labs Team on Vercel.
A member of the Team first needs to authorize it.