Repository navigation
fix(mir-lower): support packed address-space 3 aggregates across the internal device ABI - #1001
Merged
nihalpasham merged 3 commits intoAug 19, 2026
Merged
Conversation
Signed-off-by: Raul Estrada <[email protected]>
Signed-off-by: Raul Estrada <[email protected]>
Collaborator
|
nihalpasham
approved these changes
Aug 19, 2026
This was referenced Aug 20, 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 #1000
Summary
Adds support for the first packed aggregate shape containing an AS3/shared-memory pointer across the internal device ABI.
The implementation keeps the packed aggregate's semantic representation unchanged inside device-function SSA, but uses a target-stable packed carrier containing a generic pointer when the value crosses an internal return boundary.
This extends the aggregate ABI work from #867, the scalar AS3 representation strategy from #884, and the packed aggregate support from #941.
Problem
#941 intentionally kept packed aggregates containing shared-memory pointers unsupported by value because their physical representation depends on the selected NVPTX target mode.
That restriction is still correct for:
It is unnecessarily restrictive for an internal device-function return, where the compiler controls both sides of the ABI boundary.
A packed semantic value such as:
<{ i8, ptr addrspace(3) }>can cross that boundary through a target-stable carrier:
<{ i8, ptr }>and be reconstructed back to the semantic AS3 representation at the caller.
Design
The new internal return path is:
The AS3 ↔ generic conversion is represented explicitly with
addrspacecast.The function body itself continues to use the semantic packed AS3 type.
Target-stable aggregate storage
This PR factors the recursive physical-storage rewrite previously used by enum payload storage into a shared helper.
The helper supports:
i1↔i8canonicalization;Enum payload storage retains its existing bounded-array and bool-canonicalization policy on top of the shared implementation.
Packed AS3 internal ABI classification
The new packed-AS3 ABI path is intentionally narrow.
It accepts only:
It rejects:
The target-stable carrier must preserve the recorded aggregate size.
Arguments and returns
Internal aggregate arguments already use the existing flattened field ABI path, so no new aggregate argument carrier is required.
For eligible packed-AS3 returns:
llvm.return;Kernel entry returns and parameters are unchanged.
Memory behavior
Whole-value packed AS3 loads and stores remain fail closed.
This PR does not make the target-dependent packed memory image legal.
The new exception applies only to semantic SSA construction and the controlled internal device ABI boundary.
End-to-end coverage
packed_aggregate_abinow includes a device-only packed shared-pointer case:The value crosses internal device-function boundaries while remaining in SSA.
The shared pointer is created on device and is never exposed through the host/kernel parameter ABI.
Runtime validation confirms that the shared-memory pointer survives the round trip.
Validation
Results:
End-to-end:
Results:
Out of scope
This PR intentionally does not support: