Issue |
156550
|
Summary |
[HLSL][DirectX] Resource lowering bug when using structs with `select`
|
Labels |
|
Assignees |
|
Reporter |
kmpeng
|
https://godbolt.org/z/Pdc3r35nz
```hlsl
struct S {
float a;
};
StructuredBuffer<bool> Cond : register(t0);
StructuredBuffer<S> TrueVal : register(t1);
StructuredBuffer<S> FalseVal : register(t2);
RWStructuredBuffer<S> Out : register(u3);
[numthreads(1,1,1)]
void main() {
Out[0] = select(Cond[0], TrueVal[0], FalseVal[0]);
}
```
This code, when compiled, produces this error:
```
# .---command stderr------------
# | error: Cannot create RawBufferStore operation: Invalid overload type
# | These should never be used!!!
# | UNREACHABLE executed at E:/llvm-project/llvm/lib/Target/DirectX/DXILWriter/DXILBitcodeWriter.cpp:1025!
# | 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: E:\\llvm-build\\bin\\clang-dxc.exe -cc1 -triple dxilv1.5-unknown-shadermodel6.5-compute -O3 -emit-obj -dumpdir a- -disable-free -clear-ast-before-backend -main-file-name source.hlsl -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -debugger-tuning=gdb -fdebug-compilation-dir=E:\\llvm-build\\tools\\OffloadTest\\test\\clang-d3d12\\Feature\\HLSLLib -fcoverage-compilation-dir=E:\\llvm-build\\tools\\OffloadTest\\test\\clang-d3d12\\Feature\\HLSLLib -resource-dir E:\\llvm-build\\lib\\clang\\22 -ferror-limit 19 -O3 -finclude-default-header -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -vectorize-loops -vectorize-slp -o C:\\Users\\KAITLI~1\\AppData\\Local\\Temp\\lit-tmp-_e066qn7\\source-5b6f96.obj -x hlsl E:\\llvm-build\\tools\\OffloadTest\\test\\clang-d3d12\\Feature\\HLSLLib\\Output\\select.struct.test.tmp/source.hlsl
# | 1. <eof> parser at end of file
# | 2. Code generation
# | 3. Running pass 'DXIL Embedder' on module 'E:\llvm-build\tools\OffloadTest\test\clang-d3d12\Feature\HLSLLib\Output\select.struct.test.tmp/source.hlsl'.
# | Exception Code: 0xC000001D
# | #0 0x00007ff73dee5fd6 HandleAbort E:\llvm-project\llvm\lib\Support\Windows\Signals.inc:372:0
# | #1 0x00007ffd4ecc1989 (C:\Windows\System32\ucrtbase.dll+0xc1989)
# | #2 0x00007ffd4eca4ab1 (C:\Windows\System32\ucrtbase.dll+0xa4ab1)
# | #3 0x00007ff73df30665 llvm::llvm_unreachable_internal(char const *, char const *, unsigned int) E:\llvm-project\llvm\lib\Support\ErrorHandling.cpp:244:0
# | #4 0x00007ff73fe029a7 llvm::dxil::DXILBitcodeWriter::writeTypeTable(void) E:\llvm-project\llvm\lib\Target\DirectX\DXILWriter\DXILBitcodeWriter.cpp:1025:0
# | #5 0x00007ff73fdfe8ce llvm::dxil::DXILBitcodeWriter::write(void) E:\llvm-project\llvm\lib\Target\DirectX\DXILWriter\DXILBitcodeWriter.cpp:2890:0
# | #6 0x00007ff73fdfe294 llvm::DenseMap<const llvm::Value *,llvm::Type *,llvm::DenseMapInfo<const llvm::Value *,void>,llvm::detail::DenseMapPair<const llvm::Value *,llvm::Type *> >::getNumBuckets E:\llvm-project\llvm\include\llvm\ADT\DenseMap.h:858:0
# | #7 0x00007ff73fdfe294 llvm::DenseMapBase<llvm::DenseMap<const llvm::Value *,llvm::Type *,llvm::DenseMapInfo<const llvm::Value *,void>,llvm::detail::DenseMapPair<const llvm::Value *,llvm::Type *> >,const llvm::Value *,llvm::Type *,llvm::DenseMapInfo<const llvm::Value *,void>,llvm::detail::DenseMapPair<const llvm::Value *,llvm::Type *> >::getNumBuckets E:\llvm-project\llvm\include\llvm\ADT\DenseMap.h:545:0
# | #8 0x00007ff73fdfe294 llvm::DenseMapBase<llvm::DenseMap<const llvm::Value *,llvm::Type *,llvm::DenseMapInfo<const llvm::Value *,void>,llvm::detail::DenseMapPair<const llvm::Value *,llvm::Type *> >,const llvm::Value *,llvm::Type *,llvm::DenseMapInfo<const llvm::Value *,void>,llvm::detail::DenseMapPair<const llvm::Value *,llvm::Type *> >::destroyAll E:\llvm-project\llvm\include\llvm\ADT\DenseMap.h:362:0
# | #9 0x00007ff73fdfe294 llvm::DenseMap<const llvm::Value *,llvm::Type *,llvm::DenseMapInfo<const llvm::Value *,void>,llvm::detail::DenseMapPair<const llvm::Value *,llvm::Type *> >::~DenseMap E:\llvm-project\llvm\include\llvm\ADT\DenseMap.h:770:0
# | #10 0x00007ff73fdfe294 llvm::dxil::DXILBitcodeWriter::~DXILBitcodeWriter E:\llvm-project\llvm\lib\Target\DirectX\DXILWriter\DXILBitcodeWriter.cpp:65:0
# | #11 0x00007ff73fdfe294 llvm::dxil::BitcodeWriter::writeModule(class llvm::Module const &) E:\llvm-project\llvm\lib\Target\DirectX\DXILWriter\DXILBitcodeWriter.cpp:437:0
# | #12 0x00007ff73fdfe112 llvm::SmallVectorBase<unsigned long long>::empty E:\llvm-project\llvm\include\llvm\ADT\SmallVector.h:82:0
# | #13 0x00007ff73fdfe112 llvm::dxil::WriteDXILToFile(class llvm::Module const &, class llvm::raw_ostream &) E:\llvm-project\llvm\lib\Target\DirectX\DXILWriter\DXILBitcodeWriter.cpp:409:0
# | #14 0x00007ff73e655416 `anonymous namespace'::EmbedDXILPass::runOnModule E:\llvm-project\llvm\lib\Target\DirectX\DXILWriter\DXILWriterPass.cpp:166:0
# | #15 0x00007ff73dc5f7af `anonymous namespace'::MPPassManager::runOnModule E:\llvm-project\llvm\lib\IR\LegacyPassManager.cpp:1513:0
# | #16 0x00007ff73dc5f3be llvm::legacy::PassManagerImpl::run(class llvm::Module &) E:\llvm-project\llvm\lib\IR\LegacyPassManager.cpp:531:0
# | #17 0x00007ff73efeb6f4 `anonymous namespace'::EmitAssemblyHelper::RunCodegenPipeline E:\llvm-project\clang\lib\CodeGen\BackendUtil.cpp:1254:0
# | #18 0x00007ff73efe2791 std::unique_ptr<llvm::ToolOutputFile,std::default_delete<llvm::ToolOutputFile> >::operator bool C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.44.35207\include\memory:3461:0
# | #19 0x00007ff73efe2791 `anonymous namespace'::EmitAssemblyHelper::emitAssembly E:\llvm-project\clang\lib\CodeGen\BackendUtil.cpp:1279:0
# | #20 0x00007ff73efe14a2 std::unique_ptr<llvm::TargetMachine,std::default_delete<llvm::TargetMachine> >::operator bool C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.44.35207\include\memory:3461:0
# | #21 0x00007ff73efe14a2 clang::emitBackendOutput(class clang::CompilerInstance &, class clang::CodeGenOptions &, class llvm::StringRef, class llvm::Module *, enum clang::BackendAction, class llvm::IntrusiveRefCntPtr<class llvm::vfs::FileSystem>, class std::unique_ptr<class llvm::raw_pwrite_stream, struct std::default_delete<class llvm::raw_pwrite_stream>>, class clang::BackendConsumer *) E:\llvm-project\clang\lib\CodeGen\BackendUtil.cpp:1446:0
# | #22 0x00007ff73f5ea4b4 clang::BackendConsumer::HandleTranslationUnit(class clang::ASTContext &) E:\llvm-project\clang\lib\CodeGen\CodeGenAction.cpp:316:0
# | #23 0x00007ff74167c407 clang::ParseAST(class clang::Sema &, bool, bool) E:\llvm-project\clang\lib\Parse\ParseAST.cpp:183:0
# | #24 0x00007ff73f576b1c clang::HLSLFrontendAction::ExecuteAction(void) E:\llvm-project\clang\lib\Frontend\FrontendActions.cpp:1321:0
# | #25 0x00007ff73f50fda1 clang::FrontendAction::Execute(void) E:\llvm-project\clang\lib\Frontend\FrontendAction.cpp:1312:0
# | #26 0x00007ff73e04528b llvm::Error::getPtr E:\llvm-project\llvm\include\llvm\Support\Error.h:277:0
# | #27 0x00007ff73e04528b llvm::Error::operator bool E:\llvm-project\llvm\include\llvm\Support\Error.h:241:0
# | #28 0x00007ff73e04528b clang::CompilerInstance::ExecuteAction(class clang::FrontendAction &) E:\llvm-project\clang\lib\Frontend\CompilerInstance.cpp:1066:0
# | #29 0x00007ff73e0f9edd clang::ExecuteCompilerInvocation(class clang::CompilerInstance *) E:\llvm-project\clang\lib\FrontendTool\ExecuteCompilerInvocation.cpp:302:0
# | #30 0x00007ff73d9c7552 cc1_main(class llvm::ArrayRef<char const *>, char const *, void *) E:\llvm-project\clang\tools\driver\cc1_main.cpp:297:0
# | #31 0x00007ff73d9c31c1 ExecuteCC1Tool E:\llvm-project\clang\tools\driver\driver.cpp:223:0
# | #32 0x00007ff73d9c23d4 clang_main(int, char **, struct llvm::ToolContext const &) E:\llvm-project\clang\tools\driver\driver.cpp:264:0
# | #33 0x00007ff73d9d7bb7 main E:\llvm-build\tools\clang\tools\driver\clang-driver.cpp:17:0
# | #34 0x00007ff743aed304 invoke_main D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78:0
# | #35 0x00007ff743aed304 __scrt_common_main_seh D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288:0
# | #36 0x00007ffd4fdee8d7 (C:\Windows\System32\KERNEL32.DLL+0x2e8d7)
# | #37 0x00007ffd512bc34c (C:\Windows\SYSTEM32\ntdll.dll+0x3c34c)
# | clang-dxc: error: clang frontend command failed due to signal (use -v to see invocation)
# | clang version 22.0.0git (https://github.com/llvm/llvm-project.git fda67dc5b7c0dddf0b2d1a0d81345b211b4ed0dc)
# | Target: dxilv1.5-unknown-shadermodel6.5-compute
# | Thread model: posix
# | InstalledDir: E:\llvm-build\bin
# | Build config: +assertions
# | clang-dxc: note: diagnostic msg: Error generating preprocessed source(s).
# `-----------------------------
# error: command failed with exit status: 1
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs