Skip to content

codegen: a bundle global whose initializer did not fold is refused where a body reads it, never a zeroed stand-in (#2219) - #2226

Merged
ehartford merged 1 commit into
mainfrom
global-demotion-loud
Oct 7, 2026
Merged

ehartford merged 1 commit into
mainfrom
global-demotion-loud

Conversation

@ehartford

@ehartford ehartford commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

A bundle-owned global whose initializer does not fold to data has no storage in the object and no initializer runs for it; a body reading it got a fresh zeroed alloca from mir_place_ptr and the build exited 0 (a consumer read 0). Now mir_bind_global_locals refuses the body naming the global, the body and the sub-expression the fold stopped at, and mir_place_ptr never invents storage for a global. An unread global stays omitted. Fixtures wi_refuse_global_init / wi_omit_global_init in bundle-interface-tests.

Fixes #2219. Draft until the stack's battery is green.

…ere a body reads it, never a zeroed stand-in (#2219)

A bundle-owned global whose initializer `try_eval_const_llvm` could not
fold has no storage in the object (D38 Level 0 omits it) and no
initializer ever runs for it. A body that read it got a fresh local alloca
from `mir_place_ptr` (`create_base`) — a zeroed local standing in for the
global — and the build exited 0: a consumer calling `limit_x()` over
`pub let LIMITS = Point { x: side(), y: 0 }` printed 0.

Now `mir_bind_global_locals` refuses the body naming the global, the body
and the sub-expression the fold stopped at (`try_eval_const_llvm` records
the innermost failing node in `const_fold_unfolded_node`;
`gen_module_constant` keeps it per global in `unlowered_global_reasons`),
and `mir_place_ptr` never invents storage for a global local. A global
nothing reads is omitted as before.

Fixtures: `wi_refuse_global_init` (refused, no interface written; fails on
the pre-fix compiler with "expected --emit-bundle-interface to refuse") and
`wi_omit_global_init` (omitted with the note and manifest line), in
bundle-interface-tests.
@ehartford
ehartford added this pull request to stack #2228 October 6, 2026 23:28
@ehartford ehartford changed the title global demotion loud codegen: a bundle global whose initializer did not fold is refused where a body reads it, never a zeroed stand-in (#2219) Oct 6, 2026
@ehartford

Copy link
Copy Markdown
Contributor Author

Battery GREEN on stack top bfecc6f (seed-driven, with run tools/battery.w): gate rc=0 399s, uat rc=0 28s, battery-checks rc=0 397s.

@ehartford
ehartford marked this pull request as ready for review October 7, 2026 02:14
@ehartford
ehartford merged commit 66fe4be into main Oct 7, 2026
@ehartford
ehartford deleted the global-demotion-loud branch October 7, 2026 02:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

codegen: a module global demoted to runtime init inside a bundle fails silently (zeroed data or a late ICE)

1 participant