code wiki / (root) / nx_ir_validate.nx

nx_ir_validate.nx

buildroot/runtime/nx_ir_validate.nx

10488 B271 linesdepth 4pulls 5 transitivereach 8 importersview sourcekind librarytopic ir
docsdependenciesstructsconstsfunctions

about

ir_validate.nx -- structural invariants on the in-memory IR. Mirrors what nxc2/ir_validate.c does for the C anchor, ported to run inside nxc.elf so the sovereign pipeline can self-check. Catches the class of bug that bit us 2026-04-25: * BR / BR_COND op_X references a block id past f.n_blocks (the dangling-label landmine). * BR / BR_COND op_X disagrees with bb.succ0 / bb.succ1 (the stale-pointer landmine). * A block listed in f.blocks has a different .id than its position (the compaction-skew landmine). Designed to run AFTER each opt pass. When an invariant breaks, the validator prints {function name, pass label, block id, invariant code, instr op} to stderr and returns the count of violations. Caller decides whether to abort or continue. Design rule: validator reads f only -- no writes. Safe to invoke between any two passes without altering pipeline behavior.

dependencies 3 imports · 7 importers

nx_types.nx nx_syscalls.nx nx_ir.nx nx_ir_validate.nx ir_validate.nx nx_compile_wat.nx nx_compile_x86.nx nx_dom_oracle_gate.nx nx_nxc.nx nx_vcc_color_wat.nx nx_vcc_probe_wat.nx

imports: nx_types.nxnx_syscalls.nxnx_ir.nx

imported by: ir_validate.nxnx_compile_wat.nxnx_compile_x86.nxnx_dom_oracle_gate.nxnx_nxc.nxnx_vcc_color_wat.nxnx_vcc_probe_wat.nx

structs

none

consts

none

functions

33func iv_putc(c: i64) -> i64
40func iv_puts(s: *u8) -> i64
47func iv_putd(v: i64) -> i64
72func iv_violation(f: *Function, pass_label: *u8) -> i64
89func ir_validate_function(f: *Function, pass_label: *u8) -> i64
261func ir_validate_module(m: *Module, pass_label: *u8) -> i64