Wave icon indicating copy to clipboard operation
Wave copied to clipboard

Diagnose oversized variant payload layout before a u32 conversion panic

Open LunaStev opened this issue 3 weeks ago • 0 comments

Problem

An accepted variant payload can exceed the byte-array storage representation used by the LLVM variant layout builder. The size conversion is an expect rather than a source-level diagnostic.

Reproduction and evidence

Audited canonical master 69a67c6e0fb700f37ee6114f5a66d37ee13771a5 (0.0.1-alpha-dev). Matching checkout-built compiler/std were used for compiler probes on Linux amd64 with Rust 1.89.0 and LLVM 21.1.8. Artifact inspection, mocked/projection checks and foreign-target object emission are identified below and are not native execution on those operating systems.

variant V { More(array<u64, 536870912>) } fun main() {}
target/debug/wavec --std-root "$PWD/std" build repro.wave --emit=check
target/debug/wavec --std-root "$PWD/std" build repro.wave --emit=ir --out-dir out

Observed: check succeeds; IR generation exits 1/E9001, variant payload exceeds LLVM array capacity: TryFromIntError. This uses a layout-only declaration; no 4 GiB data allocation or runtime execution is needed.

Scope

Check selected-target layout capacity at a diagnosable boundary and preserve existing variant tag/alignment representation for supported sizes.

Starting points: llvm/src/codegen/variants.rs:140.

Completion criteria

  • [ ] Oversized payloads produce a useful declaration/payload diagnostic without an ICE.
  • [ ] Cover just-inside/outside representability with target-appropriate layout fixtures.
  • [ ] Unused declarations and existing output preservation are covered.

Related: #347, #409. Related broad trackers or completed implementations are context, not claims that their entire scope is unfinished.

LunaStev avatar Nov 12 '26 12:11 LunaStev