fix(codegen): faithful Rust/C emit — don't run optimizer on source backends (#1455)#1456
Open
gHashTag wants to merge 1 commit into
Open
fix(codegen): faithful Rust/C emit — don't run optimizer on source backends (#1455)#1456gHashTag wants to merge 1 commit into
gHashTag wants to merge 1 commit into
Conversation
gHashTag
pushed a commit
that referenced
this pull request
Jul 10, 2026
…1457) Second codegen fix after the optimizer removal. Makes the Rust backend emit correct array types and indices so generated modules compile under rustc. t27_type_to_rust: - `[T; N]` (Rust-style, element before `;`) previously took the empty suffix after `]` and emitted `Vec<>` -> E0107. Now emits `[T; N as usize]` (element parsed correctly; length cast to usize as arrays require). - Zig-style `[N]T` still lowers to `Vec<T>`. expr_to_rust (ExprIndex): - Array/Vec indices must be `usize`; t27 index expressions are u32. Non-literal indices now emit `[(idx) as usize]`. Integer literals are left uncast (they infer usize and casting them would trip clippy::unnecessary_cast). Verified: t27c suite unchanged at 1494 passed / 1 failed (the remaining failure is the pre-existing Verilog HIR let-binding test, untouched). Regenerating gHashTag/tri-net with #1456 + this drops the wired-module error count from 400+ to a handful of genuine SPEC bugs (a bool-vs-u32 return type, a Q8.8 fixed-point 256-in-u8 literal, a couple of `let`-that-should-be-`var`), i.e. the codegen itself now produces compiling Rust. FROZEN_HASH re-sealed (M5). phi^2 + phi^-2 = 3
Contributor
|
📓 NotebookLM Notebook linked to this PR
This notebook contains session context, decisions, and artifacts for this work. |
Contributor
Contributor
|
📓 NotebookLM Notebook linked to this PR
This notebook contains session context, decisions, and artifacts for this work. |
Contributor
PR DashboardGenerated at: 2026-07-10 05:01:10 UTC
Summary
Seal Status
|
gHashTag
pushed a commit
that referenced
this pull request
Jul 10, 2026
…ure, wildcard module array bindings, bench-local packed-vector array parameters, 0 UNSUPPORTED_ICARUS placeholders - Host-only namespace calls (module::helper) are now erased from Verilog emission. - Module-scope wildcard 'let _ = ...' bindings emit anonymous ROMs/temporaries correctly. - Bench-local scalar arrays can be passed as packed-vector function parameters. - Icarus strictness fixes: packed-vector slicing for local array params, bench initial-block deduplication. - Resealed NMSE manifests for current compiler.rs hash. - W486 close-out report + W487 cooperation variants. Closes #1456 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
#1455, Refs #1457) Two codegen-correctness fixes for the Rust (and C) source backends, so t27c generates compiling code. 1) compile_rust/compile_c no longer run t27c's AST optimizer before emitting source. Those passes (const-prop + the unconditional copy-prop / dead-store passes) corrupt the source-level output: a reassigned mutable local loses its declaration while its uses remain (E0425), and `let` locals are const-inlined. rustc/cc optimize the emitted code downstream. Fixes the 2609-site E0425 wave seen in gHashTag/tri-net. (Closes #1455.) 2) t27_type_to_rust lowers Rust-style fixed arrays `[T; N]` to `[T; N as usize]` (previously emitted `Vec<>` -> E0107); expr_to_rust casts non-literal array indices to `usize` (literals stay uncast to avoid clippy::unnecessary_cast). (Refs #1457.) Tests: rust/C let-binding regression tests now pass, new test_two_reassigned_locals_survive_1455 passes; suite 1491/3-fail -> 1494/1-fail (the remaining failure is the pre-existing Verilog HIR let-binding test, untouched). FROZEN_HASH re-sealed (M5). docs/NOW.md updated. Downstream gHashTag/tri-net regenerates gen/rust with this: E0425 2609 -> 0. phi^2 + phi^-2 = 3
gHashTag
force-pushed
the
fix/faithful-rust-c-codegen-1455
branch
from
July 10, 2026 05:31
d7f3a73 to
0f7f512
Compare
gHashTag
pushed a commit
that referenced
this pull request
Jul 10, 2026
Refs #1456 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
|
📓 NotebookLM Notebook linked to this PR
This notebook contains session context, decisions, and artifacts for this work. |
Contributor
PR DashboardGenerated at: 2026-07-10 08:49:12 UTC
Summary
Seal Status
|
This was referenced Jul 13, 2026
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.
Fixes #1455. t27c's AST optimizer corrupted source-level Rust/C output (dropped reassigned locals -> E0425; const-inlined
let). compile_rust/compile_c now emit faithfully from the AST; rustc/cc optimize downstream. Suite 1491/3-fail -> 1494/1-fail (+3, remaining failure is the pre-existing Verilog HIR path). Regenerating gHashTag/tri-net gen/rust with this drops the E0425 wave 2609 -> 0. FROZEN_HASH re-sealed (M5). phi^2 + phi^-2 = 3