llvm / llvm/llvm-project

[DirectX] Assert in DXIL Resource Binding Analysis Pass with -O0.

Open
#167,936 2 comments 0 reactions 0 assignees View on GitHub
backend:DirectX
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

https://godbolt.org/z/WTereG6Tx

This issue needs to be triaged. The problem is because the resource analysis expects intermediate stores of the resource pointer to have all been removed by the time it runs.

## Example HLSL

```hlsl
// clang-dxc -T cs_6_7 -E main -O0
RWBuffer In : register(u0);
RWBuffer Out : register(u1);

[numthreads(1,1,1)]
void main(uint GI : SV_GroupIndex) {
Out[GI] = In[GI];
}

```
## Crash stack
```gdb
clang: warning: argument unused during compilation: '-Qembed_debug' [-Wunused-command-line-argument]
error: Load of "" is not a global resource handle
error: Load of "" is not a global resource handle
error: Load of "this1.i3" is not a global resource handle
error: Load of "this1.i" is not a global resource handle
clang: /root/llvm-project/llvm/include/llvm/Support/Casting.h:572: decltype(auto) llvm::cast(From*) [with To = llvm::ConstantInt; From = llvm::Value]: Assertion `isa(Val) && "cast() argument of incompatible type!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang --driver-mode=dxc -Zi -Qembed_debug -Fc /app/output.s -fcolor-diagnostics -fno-crash-diagnostics -T cs_6_7 -E main -O0
1. parser at end of file
2. Code generation
3. Running pass 'DXIL Resource Binding Analysis' on module ''.
#0 0x0000000004260d08 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4260d08)
#1 0x000000000425e134 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x425e134)
#2 0x00000000041a2398 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x0000782011c42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x0000782011c969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x0000782011c42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x0000782011c287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x0000782011c2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#8 0x0000782011c39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#9 0x000000000306e04b llvm::DXILResourceBindingInfo::populate(llvm::Module&, llvm::DXILResourceTypeMap&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x306e04b)
#10 0x000000000306e40b llvm::DXILResourceBindingWrapperPass::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x306e40b)
#11 0x0000000003b598af llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3b598af)
#12 0x00000000045224b6 clang::emitBackendOutput(clang::CompilerInstance&, clang::CodeGenOptions&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr, std::unique_ptr>, clang::BackendConsumer*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x45224b6)
#13 0x0000000004badad7 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4badad7)
#14 0x000000000695fe7c clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x695fe7c)
#15 0x0000000004badf38 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4badf38)
#16 0x0000000004ebe3ad clang::HLSLFrontendAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4ebe3ad)
#17 0x0000000004e9aff5 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4e9aff5)
#18 0x0000000004e1be2e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4e1be2e)
#19 0x0000000004f9313d clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4f9313d)
#20 0x0000000000dd2780 cc1_main(llvm::ArrayRef, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xdd2780)
#21 0x0000000000dc92fa ExecuteCC1Tool(llvm::SmallVectorImpl&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr) driver.cpp:0:0
#22 0x0000000000dc947d int llvm::function_ref&)>::callback_fn&)>(long, llvm::SmallVectorImpl&) driver.cpp:0:0
#23 0x0000000004c17ab9 void llvm::function_ref::callback_fn>, std::__cxx11::basic_string, std::allocator>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#24 0x00000000041a2834 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x41a2834)
#25 0x0000000004c180cf clang::driver::CC1Command::Execute(llvm::ArrayRef>, std::__cxx11::basic_string, std::allocator>*, bool*) const (.part.0) Job.cpp:0:0
#26 0x0000000004bd8e22 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4bd8e22)
#27 0x0000000004bd9dce clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4bd9dce)
#28 0x0000000004be1525 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4be1525)
#29 0x0000000000dceca1 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xdceca1)
#30 0x0000000000c7d434 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xc7d434)
#31 0x0000782011c29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#32 0x0000782011c29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#33 0x0000000000dc8d95 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xdc8d95)
clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
```

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.