llvm / llvm/llvm-project

[HLSL] DXILOpLowering `cleanupHandleCasts` assertion on uninitialized local resource Store

Open
#192,551 0 comments 0 reactions 0 assignees View on GitHub
crash HLSL
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Compiling an HLSL compute shader that stores through an uninitialized local RWByteAddressBuffer crashes in the DXIL Op Lowering pass with an assertion in cleanupHandleCasts.

Repro:

```hlsl
RWByteAddressBuffer gBuf : register(u0);

[numthreads(1,1,1)]
void main() {
RWByteAddressBuffer buf;
buf.Store(0, 11);
gBuf.Store(0, 42);
}
```

Command: `clang-dxc -T cs_6_0 -Fo out.o input.hlsl`

Stack trace:

```
Assertion failed: isa(Val) && "cast() argument of incompatible type!"
Running pass 'DXIL Op Lowering' on module 'input.hlsl'.

#0 HandleAbort Signals.inc:371
#1 (ucrtbased.dll)
#2 (ucrtbased.dll)
#3 (ucrtbased.dll)
#4 (ucrtbased.dll)
#5 (ucrtbased.dll)
#6 llvm::cast Casting.h:573
#7 OpLowerer::cleanupHandleCasts DXILOpLowering.cpp:181
#8 OpLowerer::lowerIntrinsics DXILOpLowering.cpp:1012
#9 DXILOpLoweringLegacy::runOnModule DXILOpLowering.cpp:1048
#10 MPPassManager::runOnModule LegacyPassManager.cpp:1513
```

Clang version: 23.0.0git (commit 2a2ba99)

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.