Repository navigation
fix(mir-importer): refuse device statics with a nested SharedArray or Barrier (#1727) - #1750
Open
arpanpathak wants to merge 1 commit into
Open
arpanpathak wants to merge 1 commit into
arpanpathak wants to merge 1 commit into
Conversation
… Barrier (NVIDIA#1727) A static such as `static mut WRAPPED: (Barrier, u32)` was placed in global memory while `&raw mut WRAPPED.0` is typed as a shared-memory pointer, so the importer emitted an addrspace(1) -> addrspace(3) cast and the PTX read an unassigned register. The build succeeded silently. Refuse such a static where it is materialized as a global. The check walks only inline storage (struct/enum fields with generic arguments substituted, arrays, slices, tuples), reusing the nested-union walker, which now takes a predicate. Whole-type `Barrier`/`SharedArray` statics, pointer statics such as `*mut Barrier`, and `PhantomData<Barrier>` stay legal. `[Barrier; N]` is now refused, since it had the same bug. Add the `error_static_nested_shared` fixture, pinned in smoketest.sh and listed in STATUS.md. Signed-off-by: Arpan Pathak <arpan.pathak47@gmail.com>
arpanpathak
marked this pull request as ready for review
November 5, 2026 21:54
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.
A static like
static mut WRAPPED: (Barrier, u32)was placed in global memory, but&raw mut WRAPPED.0is a shared-memory pointer. The importer cast the global address toaddrspace(3), which LLVM treats as undefined, and the PTX read an unassigned register. The build succeeded.The importer now refuses such a static when it materializes the global, with:
device static `WRAPPED` contains a `Barrier` inside another type; shared-memory types are only supported as the whole type of a static.The check walks only inline storage (struct and enum fields with generic arguments substituted, arrays, slices, tuples). It reuses the walker behind the nested-union check, which now takes a predicate.
Still accepted:
static mut BAR: Barrier,static mut S: SharedArray<T, N>, pointer statics such asstatic mut P: *mut Barrier, and zero-sized markers likePhantomData<Barrier>.Now refused as well:
static mut BARS: [Barrier; 4]. It had the same bug, since&raw mut BARS[i]is also a shared-memory pointer into a global.Tested: a new
error_static_nested_sharedfixture with the issue's reproducer, pinned insmoketest.shand listed inSTATUS.md. It fails the smoketest without this change and passes with it.cargo test -p mir-importer -p mir-lowerpasses.barrier,clusterandaddressof_sharedarraystill build.Fixes #1727