llvm / llvm/llvm-project

[HLSL][SPIRV] ByteAddressBuffer InterlockedXYZ methods hit unreachable: Unsupported ptrcast user. Please fix.

Open
#221,370 0 comments 0 reactions 1 assignee Claimed by @bob80905 View on GitHub
backend:SPIR-V clang:HLSL:SPIRV HLSL
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Using most ByteAddressBuffer Interlocked methods hits an unreachable in SPIRVLegalizePointerCast ([godbolt](https://hlsl.godbolt.org/z/P89vx3dYY)):
```hlsl
RWByteAddressBuffer Buf : register(u0);

[numthreads(1, 1, 1)]
void main(uint3 GTID : SV_GroupThreadID) {
Buf.InterlockedAnd(0, 1);
}
```

This errors:
```
Unsupported ptrcast user. Please fix.
UNREACHABLE executed at /root/llvm-project/llvm/lib/Target/SPIRV/SPIRVLegalizePointerCast.cpp:818!
```

Backtrace:
```
frame #3: 0x00000001035d898c clang-dxc`llvm::llvm_unreachable_internal(char const*, char const*, unsigned int) + 552
frame #4: 0x00000001018e3c40 clang-dxc`(anonymous namespace)::SPIRVLegalizePointerCastImpl::legalizePointerCast(this=0x000000016fdf2e58, II=0x00000008cf128160) at SPIRVLegalizePointerCast.cpp:818:7
frame #5: 0x00000001018e2f4c clang-dxc`(anonymous namespace)::SPIRVLegalizePointerCastImpl::run(this=0x000000016fdf2e58, F=0x00000008ced7c468) at SPIRVLegalizePointerCast.cpp:842:7
frame #6: 0x00000001018f3bd8 clang-dxc`(anonymous namespace)::SPIRVLegalizePointerCastLegacy::runOnFunction(this=0x00000008cf804930, F=0x00000008ced7c468) at SPIRVLegalizePointerCast.cpp:863:45
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.