Repository navigation
Conversation
An enum payload that is a struct or tuple with a pointer niche carrier and
non-pointer leaves (`Option<(f32, f32, &mut T)>`, `Option<{&mut T, u64, u64}>`)
gave only the pointer leaf a typed slot. The other leaves fell into
`[N x i8]` filler bytes, so construct spilled the payload through a slot and
the payload read loaded it back at another width. SROA cannot rebuild
mixed-type slices, and the slot reached PTX as a local depot.
Every leaf of such a payload now claims a typed slot at its rustc offset,
reusing the carrier's slot where the types match, with construct and payload
reads using insertvalue/extractvalue; size, alignment, field offsets and the
niche encoding are unchanged, and a payload the rule cannot prove keeps the
old lowering.
Measured with one device-only probe source against each tree's backend:
parent e027ac3 emits a 16 B `.local` depot in the `smooth_triplets` entry
plus 16 B in the outlined `Cells::next_cell`; this commit emits none.
`lease_borrow` and `lease_raw` emit none on either commit.
Across the 241 examples under rustc-codegen-cuda/examples, only
enum_niche_payload and set_discriminant_niche change PTX, and both lose
their 16 B depot; vectorization and repr_u32_enum_stride are unchanged per
entry.
The NVIDIA#1332 slot-map test now expects the 16 bytes under the carrier as one
i128 slot instead of [2 x i64] filler; alignment stays 16.
Adds the enum_niche_payload example and the leaf-slot unit tests.
Signed-off-by: midagedev <[email protected]>
This branch has not been deployed
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.
Fixes #1590.
A niche enum payload with a pointer carrier and non-pointer leaves gave only the pointer a typed slot. The rest became filler bytes, and the payload went through a
.localdepot.Now every leaf gets a typed slot at its rustc offset. Size, alignment, field offsets and the niche encoding do not change. A payload the rule cannot prove keeps the old lowering.
Evidence (sm_86, ptxas 13.3, llc 21 and 23):
set_discriminant_niche/niche_roundtrip: 16 B.localto 0, stack 16 to 0.enum_niche_payload:smooth_triplets16 B.localto 0.--verify-ptxfails on main and passes here. Value runs pass.vectorization(fix(mir-lower): preserve address spaces through typed enum fillers #1332) andrepr_u32_enum_stride(fix(mir-lower): cap enum alignment anchors #1357) are the same per entry, and their value runs pass.One test changes: #1332's u128 slot-map test now expects one
i128slot under the carrier instead of[2 x i64]filler. Alignment is still 16.I used an AI assistant (Claude) to write and check this change. I reviewed and measured it.