Repository navigation
fix(mir-lower): legalize address-space 3 slice fat-pointer casts in SSA - #1061
Merged
Merged
Conversation
Signed-off-by: Raul Estrada <[email protected]>
uurl
force-pushed
the
fix/as3-fat-pointer-casts
branch
from
August 20, 2026 01:37
5e58abd to
e30d8c4
Compare
Collaborator
|
nihalpasham
approved these changes
Aug 20, 2026
This was referenced Aug 24, 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 #1060
Summary
Legalize semantic slice fat-pointer casts in SSA, including casts involving shared-memory
addrspace(3)pointers, without round-tripping the aggregate through memory.Instead of treating the fat pointer as raw bytes, the lowering now handles its two semantic components independently:
This implements the sound fat-pointer bridge described in #883.
Why
The generic aggregate cast fallback uses an
alloca+store+loadround-trip.That is unsafe for aggregates containing shared-memory pointers because the physical representation of an
addrspace(3)pointer is target-mode dependent and its raw shared-memory value is not the Rust-visible generic address.A slice fat pointer does not require byte reinterpretation. Its data pointer can be converted semantically with
addrspacecast, while its length metadata can be copied unchanged.Implementation
emit_pointer_castnow recognizes the narrow LLVM representation used by slice fat pointers:When both source and destination match that shape and their metadata types match, the lowering:
addrspacecastfor the data pointer when the address spaces differinsertvalueNo temporary memory representation is created.
Other aggregate casts continue to use the existing fallback behavior.
The legalization is intentionally restricted to the slice-shaped
{ pointer, integer metadata }representation within the semantic pointer-cast path.It does not extend to:
{ ptr, ptr }aggregatesTransmuteaddrspace(7)Tests
Added
mir-lowercoverage for:alloca,store, andloadaddrspacecastbehaviorExtended
shared_ptr_transmutewith an end-to-end GPU regression that checks:Validation performed:
Refs #883