You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit f53e5fc
Browse filesBrowse the repository at this point in the historyBrowse files
A global whose initializer branches becomes a constructor (#462) (#474)
`let g: Node | null | undefined = mkU()`, with mkU returning `Node | undefined`, failed in every
model with "'ts.Global' op expects region #0 to have 0 or 1 blocks", and so did any conditional
global initializer (`let x = on() ? 1 : 2`). The optional's widening into the union, like a
conditional, is a ts.If; the affine lowering turns it into blocks, and ts.Global's
SingleBlockImplicitTerminator trait rejected them.
The trait is dropped (MLIRGen still builds one block ending in ts.GlobalResult, and nothing reads
the initializer as one block after the affine lowering), and GlobalOpLowering makes a global
whose initializer has more than one block a constructor: only a function can hold the branches.
Under rc the widened optional then lost its object: the call runs before the ts.If, and the
branch yields it through views (ts.Value, a cast, ts.OptionalValue), so the global never took its
reference over and the call's was given back at the end of the initializer. claimGlobalInitializers
now follows a ts.If whose branches all yield one owned producer from before it through views, or
a value that holds nothing (the empty optional, null, undefined), and the global takes the count.
Test: 00global_initializer_branches (compile and JIT, and in the rc/none corpus): an optional
widened into a union (set and empty), and conditional number, string and object globals. It failed
to compile before the change. The own corpus is unchanged.
Fixes#462.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
0 commit comments