Repository navigation
fix(mir-lower): support bounded shared-pointer arrays in enum payloads - #750
Merged
nihalpasham merged 4 commits intoAug 10, 2026
Merged
nihalpasham merged 4 commits into
nihalpasham merged 4 commits into
Conversation
Signed-off-by: Raul Estrada <raulestradaa@gmail.com>
…oad root The 16-leaf bound was checked per array node, so a payload holding several individually in-bound arrays, e.g. struct([&shared; 9], [&shared; 8]), passed the storage gate with 17 conversions in direct layouts while the same shape died in niche layouts inside the overlap walk with an unrelated pointer-provenance error. Count array-expanded shared-pointer leaves through the whole rewrite and compare the total against the bound once, at the payload root, so every layout kind reports the same 'rewrite requires N pointer conversions, supported bound is 16' diagnostic for the same over-bound payload. Struct nesting outside arrays stays unbounded on purpose: its leaf count is proportional to the source text, while [&shared; N] expands from three tokens into N rebuild sequences. This matches what the overlap walk in build_enum_slot_map already budgets. Single oversized arrays keep the exact diagnostic the error_enum_shared_pointer_layout example documents (N = 17).
…eeds it Exhausting the pointer-storage walk's array-expansion budget used to propagate as a generic walk failure, so build_enum_slot_map reported 'refusing to erase LLVM pointer provenance' for a shape whose only problem is the documented 16-leaf bound (for example a generic-pointer array of 17 elements sitting over a niche carrier). Count the array-expanded pointer leaves up front and return a typed rejection, PointerOverlapRejection::OverArrayLeafBound versus ProvenanceLoss, so the slot map surfaces 'rewrite requires N pointer conversions, supported bound is 16' for over-bound arrays while genuine pointer puns keep the provenance diagnostic. Pre-counting also means the walk never allocates a single per-leaf record for a type it is going to refuse, which replaces the previous mid-walk budget threading.
Collaborator
|
Gist: this is the representation clang and I pushed two commits closing the review's consistency gaps:
Verified on an RTX 5090:
Merging. This closes #749. Related to #306 but doesn't close it. |
# Conflicts: # crates/rustc-codegen-cuda/STATUS.md
nihalpasham
approved these changes
Aug 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #749
Summary
Add bounded recursive support for arrays containing shared-memory pointers in enum payloads.
Enum payload lowering already uses CUDA generic pointers as the target-stable physical representation for direct and struct/tuple-nested address-space-3 pointer leaves. This extends the same representation and reconstruction model to arrays when the recursive expansion contains at most 16 shared-pointer leaves.
Changes
Option<SharedPointerArrayWrapper>can be represented correctly.mir-lowercoverage for bounded shared-pointer arrays in niche enum payloads.Optionwith a two-element shared-pointer array.error_enum_shared_pointer_layoutto exercise the oversized-array boundary with 17 shared-pointer leaves.STATUS.mdto document bounded array support and the remaining vector/oversized-array limitation.The bound counts recursive pointer leaves rather than only the outer array length. This keeps generated aggregate reconstruction and verifier work explicitly bounded for nested shapes as well.
Validation
Remaining boundary
Pointer vectors remain unsupported. Their ABI/alignment behavior and address-space-cast semantics should be handled separately rather than implicitly treating them as fixed arrays.