Repository navigation
Description
Problem
Enum payload lowering currently supports shared-memory pointer leaves directly and through ordinary struct/tuple nesting by using target-stable generic-pointer physical storage and reconstructing the semantic address space at enum construction and extraction boundaries.
Arrays containing shared-memory pointers are still rejected.
This leaves cases such as:
struct SharedPointerArrayWrapper {
pointers: [&'static SharedArray<u32, 1>; 2],
}
Option<SharedPointerArrayWrapper>unsupported even though the existing recursive storage conversion can reconstruct aggregate values element by element.
Why this needs an explicit bound
Array reconstruction is performed in SSA. Each shared-pointer leaf requires aggregate extraction/insertion around an address-space cast, so accepting arbitrary arrays would allow type size to translate directly into unbounded generated code and verifier work.
The support should therefore remain fail-closed unless the recursive array shape stays within an explicit expansion bound.
The bound should count shared-pointer leaves recursively rather than only the outer array length. For example:
[ptr; 2] -> 2 leaves
[[ptr; 2]; 2] -> 4 leaves
[struct { p1, p2 }; 4] -> 8 leaves
[struct { p1, p2 }; 9] -> 18 leaves
Proposed behavior
Use a maximum of 16 shared-pointer leaves for recursive enum-payload array reconstruction.
Within that bound:
- convert address-space-3 pointer leaves to CUDA generic pointers for physical enum storage;
- recursively rebuild arrays and nested structs at construction/extraction boundaries;
- allow bounded pointer arrays to participate in enum pointer-overlap/niche analysis.
Outside that bound:
- reject oversized shared-pointer arrays with a diagnostic reporting the required expansion and supported bound.
Pointer vectors should remain unsupported because they have separate ABI, alignment, and address-space-cast semantics.
Acceptance criteria
[shared_ptr; N]enum payloads are supported when recursive shared-pointer leaf expansion is at most 16.- Nested aggregate shapes use the same recursive leaf-count bound.
- Oversized arrays remain fail-closed.
- Pointer vectors remain fail-closed.
- Physical enum storage contains generic pointers rather than target-dependent address-space-3 pointers.
- Semantic payload types retain their original shared address-space semantics.
Option/niche layouts containing bounded shared-pointer arrays lower correctly.- Construction and extraction round-trip correctly on CUDA hardware.
- Existing enum payload lowering behavior remains unchanged for non-pointer arrays, bool payloads, and existing direct/nested shared-pointer cases.
Activity