llvm / llvm/llvm-project

[SPIR-V][HLSL] Crash compiling 64-bit InterlockedOr/Xor on typed RWBuffer

Open
#217,823 0 comments 0 reactions 0 assignees View on GitHub
backend:SPIR-V clang:HLSL:SPIRV
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Clang crashes during SPIR-V instruction selection when compiling 64-bit bitwise atomic operations on typed `RWBuffer` resources.

Minimal reproducer:

```hlsl
RWBuffer B : register(u0);

[numthreads(1, 1, 1)]
void main() {
InterlockedXor(B[0], 1ull);
// InterlockedOr(B[0], 1ull) also crashes.
}
```

https://godbolt.org/z/GPYbvEMx3

Command:
`clang-dxc -spirv -fspv-target-env=vulkan1.3 -fspv-extension=DXC -HV 202x -T cs_6_6 source.hlsl`

Both `InterlockedOr` and `InterlockedXor` crash in `InstructionSelect` while targeting `spirv1.6-unknown-vulkan1.3-compute`.

The failure is compile-time and independent of the GPU vendor. It reproduces on an NVIDIA GPU reporting `shaderImageInt64Atomics` and `VK_EXT_shader_image_atomic_int64`. Non-atomic 64-bit typed-resource stores compile successfully.

Contributor guide

Open the contributing guide

Research direction

Reproduce the crash with the provided clang-dxc command and minimal HLSL example, then inspect the failure in InstructionSelect for the SPIR-V Vulkan compute target. Verify the fix by compiling both InterlockedXor and InterlockedOr on the typed 64-bit RWBuffer without a compiler crash.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.