julia
6a3f5434 - inference: Alias-aware union splitting for identical arguments (#61041)

Commit
61 days ago
inference: Alias-aware union splitting for identical arguments (#61041) When the same IR variable (`SlotNumber`/`SSAValue`) is passed to multiple argument positions of a call, the union-split algorithm previously generated the full cartesian product of `Union` types. For example, `f(a, a, a)` where `a::Union{A,B}` produced 8 splits when only 2 diagonal combinations are actually reachable, causing wasted inference on impossible type combinations. This commit uses `fargs` from `ArgInfo` and `MustAlias` information from `argtypes` to detect argument aliasing via `compute_alias_groups`, which builds a leader/follower mapping. Aliasing is detected from two sources: IR identity (same `SlotNumber`/`SSAValue` in `fargs`) and `MustAlias` lattice elements with matching `(slot, ssadef, fldidx)`, which covers cases like `f(a.x, a.x)` where distinct SSAValues refer to the same field. In cost calculation, each alias group is counted once. In split generation, only leaders iterate over union types and propagate the chosen type to their followers. --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Author
Parents
Loading