Issue 135745
Summary [DirectX] DXIL Bitcode Writer hits llvm_unreachable
Labels new issue
Assignees farzonl
Reporter Icohedron
    Many (3938) DML shaders fail to compile under clang-dxc with the `-Fo` command-line option supplied due to hitting an llvm_unreachable https://github.com/llvm/llvm-project/blob/9cdc3aab3eae55be30003cb486f290f3ee3df3a8/llvm/lib/Target/DirectX/DXILWriter/DXILBitcodeWriter.cpp#L1025

Example stack trace:
```
In file included from AdamOptimizerMoment_float_256_16.hlsl:7:

AdamOptimizerMoment.hlsl:7:10: warning: non-portable path to file '"DataTypeDefsOld.hlsl"'; specified path differs in case from file name on disk [-Wnonportable-include-path]

    7 | #include "DatatypeDefsOld.hlsl"

      | ^~~~~~~~~~~~~~~~~~~~~~

      | "DataTypeDefsOld.hlsl"

AdamOptimizerMoment.hlsl:26:2: warning: unknown attribute 'RootSignature' ignored [-Wunknown-attributes]

   26 | [RootSignature(ROOT_SIG_DEF)]

      |  ^~~~~~~~~~~~~

These should never be used!!!

UNREACHABLE executed at D:/ClangDML/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: clang-dxc.exe -enable-16bit-types -O3 -D DXC_COMPILER=1 -D __SHADER_TARGET_MAJOR=6 -D __SHADER_TARGET_MINOR=2 -T cs_6_2 -E CSMain -DJIT_COMPILED=1 -I Shaders AdamOptimizerMoment_float_256_16.hlsl -Fo AdamOptimizerMoment_float_256_16.dat -Vd

1.	<eof> parser at end of file

2.	Code generation

3.	Running pass 'DXIL Embedder' on module 'AdamOptimizerMoment_float_256_16.hlsl'.

Exception Code: 0xC000001D

 #0 0x00007ff63843c64c HandleAbort D:\ClangDML\llvm-project\llvm\lib\Support\Windows\Signals.inc:429:0

 #1 0x00007ffbf73c9ea7 (C:\Windows\SYSTEM32\ucrtbased.dll+0x99ea7)

 #2 0x00007ffbf73cbae9 (C:\Windows\SYSTEM32\ucrtbased.dll+0x9bae9)

 #3 0x00007ff6384af76e llvm::llvm_unreachable_internal(char const *, char const *, unsigned int) D:\ClangDML\llvm-project\llvm\lib\Support\ErrorHandling.cpp:214:0

 #4 0x00007ff63b1a0429 llvm::dxil::DXILBitcodeWriter::writeTypeTable(void) D:\ClangDML\llvm-project\llvm\lib\Target\DirectX\DXILWriter\DXILBitcodeWriter.cpp:1028:0

 #5 0x00007ff63b19e3e9 llvm::dxil::DXILBitcodeWriter::write(void) D:\ClangDML\llvm-project\llvm\lib\Target\DirectX\DXILWriter\DXILBitcodeWriter.cpp:2888:0

 #6 0x00007ff63b19e1b6 llvm::dxil::BitcodeWriter::writeModule(class llvm::Module const &) D:\ClangDML\llvm-project\llvm\lib\Target\DirectX\DXILWriter\DXILBitcodeWriter.cpp:437:0

 #7 0x00007ff63b19e081 llvm::dxil::WriteDXILToFile(class llvm::Module const &, class llvm::raw_ostream &) D:\ClangDML\llvm-project\llvm\lib\Target\DirectX\DXILWriter\DXILBitcodeWriter.cpp:409:0

 #8 0x00007ff638f88d74 `anonymous namespace'::EmbedDXILPass::runOnModule D:\ClangDML\llvm-project\llvm\lib\Target\DirectX\DXILWriter\DXILWriterPass.cpp:76:0

 #9 0x00007ff6380a0715 `anonymous namespace'::MPPassManager::runOnModule D:\ClangDML\llvm-project\llvm\lib\IR\LegacyPassManager.cpp:1521:0

#10 0x00007ff6380a0224 llvm::legacy::PassManagerImpl::run(class llvm::Module &) D:\ClangDML\llvm-project\llvm\lib\IR\LegacyPassManager.cpp:539:0

#11 0x00007ff6380a4951 llvm::legacy::PassManager::run(class llvm::Module &) D:\ClangDML\llvm-project\llvm\lib\IR\LegacyPassManager.cpp:1648:0

#12 0x00007ff639e85cfb `anonymous namespace'::EmitAssemblyHelper::RunCodegenPipeline D:\ClangDML\llvm-project\clang\lib\CodeGen\BackendUtil.cpp:1244:0

#13 0x00007ff639e7fc2c `anonymous namespace'::EmitAssemblyHelper::emitAssembly D:\ClangDML\llvm-project\clang\lib\CodeGen\BackendUtil.cpp:1270:0

#14 0x00007ff639e7f04e 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 *) D:\ClangDML\llvm-project\clang\lib\CodeGen\BackendUtil.cpp:1437:0

#15 0x00007ff63a663889 clang::BackendConsumer::HandleTranslationUnit(class clang::ASTContext &) D:\ClangDML\llvm-project\clang\lib\CodeGen\CodeGenAction.cpp:320:0

#16 0x00007ff63d380d21 clang::ParseAST(class clang::Sema &, bool, bool) D:\ClangDML\llvm-project\clang\lib\Parse\ParseAST.cpp:191:0

#17 0x00007ff63a54e09d clang::ASTFrontendAction::ExecuteAction(void) D:\ClangDML\llvm-project\clang\lib\Frontend\FrontendAction.cpp:1347:0

#18 0x00007ff63a667a9d clang::CodeGenAction::ExecuteAction(void) D:\ClangDML\llvm-project\clang\lib\CodeGen\CodeGenAction.cpp:1112:0

#19 0x00007ff63a54da69 clang::FrontendAction::Execute(void) D:\ClangDML\llvm-project\clang\lib\Frontend\FrontendAction.cpp:1231:0

#20 0x00007ff6386e0fe7 clang::CompilerInstance::ExecuteAction(class clang::FrontendAction &) D:\ClangDML\llvm-project\clang\lib\Frontend\CompilerInstance.cpp:1055:0

#21 0x00007ff6387e498c clang::ExecuteCompilerInvocation(class clang::CompilerInstance *) D:\ClangDML\llvm-project\clang\lib\FrontendTool\ExecuteCompilerInvocation.cpp:300:0

#22 0x00007ff637c70296 cc1_main(class llvm::ArrayRef<char const *>, char const *, void *) D:\ClangDML\llvm-project\clang\tools\driver\cc1_main.cpp:294:0

#23 0x00007ff637c626d6 ExecuteCC1Tool D:\ClangDML\llvm-project\clang\tools\driver\driver.cpp:218:0

#24 0x00007ff637c63360 clang_main::<lambda_0>::operator() D:\ClangDML\llvm-project\clang\tools\driver\driver.cpp:364:0

#25 0x00007ff637c6332d llvm::function_ref<int (llvm::SmallVectorImpl<const char *> &)>::callback_fn<`lambda at D:\ClangDML\llvm-project\clang\tools\driver\driver.cpp:363:7'> D:\ClangDML\llvm-project\llvm\include\llvm\ADT\STLFunctionalExtras.h:46:0

#26 0x00007ff63a1cead1 llvm::function_ref<(class llvm::SmallVectorImpl<char const *> &)>::operator()(class llvm::SmallVectorImpl<char const *> &) const D:\ClangDML\llvm-project\llvm\include\llvm\ADT\STLFunctionalExtras.h:69:0

#27 0x00007ff63a1caf87 clang::driver::CC1Command::Execute::<lambda_1>::operator() D:\ClangDML\llvm-project\clang\lib\Driver\Job.cpp:435:0

#28 0x00007ff63a1caf53 llvm::function_ref<void ()>::callback_fn<`lambda at D:\ClangDML\llvm-project\clang\lib\Driver\Job.cpp:435:22'> D:\ClangDML\llvm-project\llvm\include\llvm\ADT\STLFunctionalExtras.h:46:0

#29 0x00007ff638403447 llvm::function_ref<(void)>::operator()(void) const D:\ClangDML\llvm-project\llvm\include\llvm\ADT\STLFunctionalExtras.h:69:0

#30 0x00007ff638436148 llvm::CrashRecoveryContext::RunSafely(class llvm::function_ref<(void)>) D:\ClangDML\llvm-project\llvm\lib\Support\CrashRecoveryContext.cpp:235:0

#31 0x00007ff63a1caa92 clang::driver::CC1Command::Execute(class llvm::ArrayRef<class std::optional<class llvm::StringRef>>, class std::basic_string<char, struct std::char_traits<char>, class std::allocator<char>> *, bool *) const D:\ClangDML\llvm-project\clang\lib\Driver\Job.cpp:435:0

#32 0x00007ff6386c30a1 clang::driver::Compilation::ExecuteCommand(class clang::driver::Command const &, class clang::driver::Command const *&, bool) const D:\ClangDML\llvm-project\clang\lib\Driver\Compilation.cpp:196:0

#33 0x00007ff6386c3285 clang::driver::Compilation::ExecuteJobs(class clang::driver::JobList const &, class llvm::SmallVectorImpl<struct std::pair<int, class clang::driver::Command const *>> &, bool) const D:\ClangDML\llvm-project\clang\lib\Driver\Compilation.cpp:251:0

#34 0x00007ff6386798fb clang::driver::Driver::ExecuteCompilation(class clang::driver::Compilation &, class llvm::SmallVectorImpl<struct std::pair<int, class clang::driver::Command const *>> &) D:\ClangDML\llvm-project\clang\lib\Driver\Driver.cpp:2223:0

#35 0x00007ff637c621a0 clang_main(int, char **, struct llvm::ToolContext const &) D:\ClangDML\llvm-project\clang\tools\driver\driver.cpp:402:0

#36 0x00007ff637c95cb8 main D:\ClangDML\llvm-project\build\tools\clang\tools\driver\clang-driver.cpp:17:0

#37 0x00007ff6408c1149 invoke_main D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:79:0

#38 0x00007ff6408c1282 __scrt_common_main_seh D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288:0

#39 0x00007ff6408c130e __scrt_common_main D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:331:0

#40 0x00007ff6408c132e mainCRTStartup D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_main.cpp:17:0

#41 0x00007ffc56c3e8d7 (C:\Windows\System32\KERNEL32.DLL+0x2e8d7)

#42 0x00007ffc58d514fc (C:\Windows\SYSTEM32\ntdll.dll+0xb14fc)

clang-dxc: error: clang frontend command failed due to signal (use -v to see invocation)

clang version 21.0.0git (https://github.com/llvm/llvm-project.git f5c5f9f926cb93c58e8cc6302f788474909606b0)

Target: dxilv1.2-unknown-shadermodel6.2-compute

Thread model: posix

InstalledDir: D:\ClangDML\llvm-project\build\bin

Build config: +unoptimized, +assertions

clang-dxc: note: diagnostic msg: 
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to