Problem
Generated names in the IR — CSE binders ($cseN), uniquification and uncurry suffixes — are minted from one supply that spans the whole uber-module compilation, so any change to how many names an earlier pass or an earlier binding mints renumbers everything after it. The committed golden.ir files print these names verbatim, which turns every optimizer change into corpus-wide index churn: PR #327 touched 45 golden.ir files, and some of them contain nothing but renumbering — Golden.CasePruning.Test/golden.ir's entire diff is $cse249 → $cse244 and $cse248 → $cse243, alpha-equivalent IR with zero semantic change. The noise buries the diffs a reviewer actually needs to read. The Lua goldens do not have this problem: Lua codegen renumbers locals per scope (x_S_0, _S_cse0 restart within each function), so a change in one binding cannot rename anything in another.
Approach
Normalize in the golden harness only, before pretty-printing: alpha-rename generated names deterministically with a counter that resets per top-level binding, assigning numbers in first-occurrence order within the binding. Post-uniquification, generated locals are referenced only within their own binding (cross-binding references go by qualified name), so per-binding renumbering preserves alpha-equivalence and contains any churn to the binding that genuinely changed — the IR analogue of the Lua _S_N behavior. The compiler pipeline keeps its globally unique names untouched; only the golden representation stabilizes. One final re-acceptance of all golden.ir files lands the normalized baseline.
Prerequisites / Relations
Motivated by the churn in PR #327; independent of the directive machinery. Touches only the golden Spec's dump path.
Verification / Measurement
A deliberate inlining perturbation in one golden module leaves every other module's golden.ir byte-identical (today it renumbers them); re-running the suite twice over the normalized goldens is stable; a unit test pins the normalizer on a two-binding module where the first binding's name count changes.
Problem
Generated names in the IR — CSE binders (
$cseN), uniquification and uncurry suffixes — are minted from one supply that spans the whole uber-module compilation, so any change to how many names an earlier pass or an earlier binding mints renumbers everything after it. The committedgolden.irfiles print these names verbatim, which turns every optimizer change into corpus-wide index churn: PR #327 touched 45 golden.ir files, and some of them contain nothing but renumbering —Golden.CasePruning.Test/golden.ir's entire diff is$cse249 → $cse244and$cse248 → $cse243, alpha-equivalent IR with zero semantic change. The noise buries the diffs a reviewer actually needs to read. The Lua goldens do not have this problem: Lua codegen renumbers locals per scope (x_S_0,_S_cse0restart within each function), so a change in one binding cannot rename anything in another.Approach
Normalize in the golden harness only, before pretty-printing: alpha-rename generated names deterministically with a counter that resets per top-level binding, assigning numbers in first-occurrence order within the binding. Post-uniquification, generated locals are referenced only within their own binding (cross-binding references go by qualified name), so per-binding renumbering preserves alpha-equivalence and contains any churn to the binding that genuinely changed — the IR analogue of the Lua
_S_Nbehavior. The compiler pipeline keeps its globally unique names untouched; only the golden representation stabilizes. One final re-acceptance of all golden.ir files lands the normalized baseline.Prerequisites / Relations
Motivated by the churn in PR #327; independent of the directive machinery. Touches only the golden Spec's dump path.
Verification / Measurement
A deliberate inlining perturbation in one golden module leaves every other module's golden.ir byte-identical (today it renumbers them); re-running the suite twice over the normalized goldens is stable; a unit test pins the normalizer on a two-binding module where the first binding's name count changes.