feat(t27b): bench blocks as the reference path handles them (Closes #6179) - #6258
Merged
Merged
Conversation
…6179) t27c's Zig backend emits a bench as `fn bench_<name>() void { ... }` that nothing calls: `zig test` neither runs nor counts it, and lazy analysis does not even type-check it. t27b now lowers each bench body with the test binding rule, compiles it to AArch64 and drops it: never run, never a test. A body it cannot lower rejects the file under the construct it contains, never `BenchBlock`. corpus specs: pass 165 -> 169, pass_vacuous 278 -> 278, fail 2 -> 2, rejected 760 -> 756, mismatch 0. The 4 new passes agree with the reference (15/15, 15/15, 18/18, 3/3). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
6 tasks
This was referenced Oct 4, 2026
Merged
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #6179
Refs #6063
Stacked on #6254 (enums), which is stacked on #6249 and #6247.
FR-001 -- what the reference does with a bench
t27c gen specs/numeric/e8m0.t27emits the bench as a plain fn. Nothing calls it, and the output does not mention its name anywhere else:specs/config/paths.t27gives the same shape:fn bench_paths_join_latency() void { ... }, and so on for each bench.So
zig testneither runs nor counts a bench. Because Zig analyzes lazily, it does not even type-check the body:const bogus: u8 = "not a u8";intobench_e8m0_decode_encode.zig teststill printedAll 18 tests passed.test "reference the bench" { _ = &bench_e8m0_decode_encode; }.zig testthen failed witherror: expected type 'u8', found '*const [8:0]u8'.What t27b now does (FR-002)
gen_bench_blockuses (the first assignment becomes a const).codegen::compile_funcand dropped. It is never run and never counted as a test, so a failing assert in a bench does not fail the file, as in the reference.StmtFor(range)), never underBenchBlock. A codegen refusal rejects the file too.BenchBlockis still named for a bench the front-end only partly parsed, the same wayTestBlockandInvariantBlockare.FR-003
cli/t27b/tests/differential.rs:bench_bodies_compile_but_never_runlowers a spec with two failing benches (a brace bench and a colon bench). Only the one test runs, and JIT and interpreter agree on it. It then renames the same bodies to test/invariant: they run and trap at the same site in both the JIT and the interpreter.bench_unlowerable_body_names_its_constructchecks that an unlowerable bench body is rejected asStmtFor(range)and never asBenchBlock.cargo test -p t27bpasses.Corpus (
t27b corpus specs, macOS arm64, from the worktree root)pass_vacuous gained nothing.
New passes, each checked with
t27c gen+zig test. The reference agrees on all four, with the same test count:New fails: none.
The 112 other former-BenchBlock files now stop on a real construct:
All 22 StmtExpr stops are "empty statement" inside a bench written in the prose form
measure: nanoseconds to .../target: < 100ns. The t27c front-end lowers that form to nothing; its Zig output says// NOT LOWERED: empty statement -- statement rendered to nothing (T43). Under FR-002, t27b rejects such a body rather than passing an empty one.Top first blockers
Reference-side finding: broken bench bodies the reference never checks
For the 116 former-BenchBlock files I ran
t27c gen+zig test, then again with_ = &bench_x;added for every bench:fpga/testbench/gf16_accel_tbhangs intest_add_zero.fpga/boards/arty_a7_integration,fpga/boards/qmtech_a100t_integration, andfpga/testbench/{cts,partition,power,simulator,router}_tb:value of type 'u32' ignored. Example:estimate_latency(...)called as a statement inbench_cts.isa/ternary_gates:unable to resolve comptime value. It indexes a.{...}tuple with a runtime value.These are spec bugs that lazy analysis hides, not t27c miscompiles. I left them for a separate issue.
🤖 Generated with Claude Code