You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(nvvm): keep address-space-qualified pointers out of the generic space
Every access to an `#[address_space(shared)]` (or `constant`) static was
emitted as a *generic* access behind an `addrspacecast`, because `load`,
`volatile_load`, `gep`, `inbounds_gep` and `check_store` all cast their
pointer operand through `type_ptr_to`, which always yields an addrspace 0
pointer.
Correctness then rests entirely on libNVVM's `InferAddressSpaces` pass
folding the cast back into the access. It usually does, which is why this
mostly works. When it does not, the access is emitted as a generic `ld`/`st`
against the raw shared window offset -- an out-of-bounds access at runtime,
with no error or warning at compile time, and only on the warps whose data
reaches the affected branch.
Cast the pointer operand in the address space it already points into
instead. For the kernel added in this commit the emitted NVVM IR goes from
%22 = getelementptr inbounds i32,
i32* addrspacecast (i32 addrspace(3)* ... @sh ... to i32*), i64 %18
store i32 %1, i32* %22, align 4
to
%22 = getelementptr inbounds i32, i32 addrspace(3)* ... @sh ..., i64 %18
store i32 %1, i32 addrspace(3)* %22, align 4
`raw_eq`'s integer-compare fast path had the same defect and is fixed with
it. Casts that are *semantically* required -- a pointer passed to a callee
whose parameter is generic, or to `memcmp` -- are left alone; those still go
through `bitcast`, which addrspacecasts to generic as before.
Add a `dis` compiletest pinning the shared-memory codegen shape: the kernel
must use `st.shared`/`ld.shared` on the raw symbol offset and needs no
`cvta.shared`.
Refs #402
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
0 commit comments