Issue 135719
Summary [DirectX] DXIL Bitcode Writer hits assertion when compiling many of the DML shaders
Labels new issue
Assignees farzonl
Reporter Icohedron
    Many of the DML shaders fail to compile via clang-dxc when the `-Fo` command-line option is provided due to the DXIL bitcode writer hitting an assertion error in https://github.com/llvm/llvm-project/blob/9cdc3aab3eae55be30003cb486f290f3ee3df3a8/llvm/lib/Target/DirectX/DXILWriter/DXILBitcodeWriter.cpp#L2245

In this instance, the instruction `I` hitting the assertion has an opcode of 67, which corresponds to [freeze](https://llvm.org/docs/LangRef.html#freeze-instruction).

```
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 ActivationFunctionHardmax_float16_native_accum16_256_4.hlsl -Fo - -Vd 
In file included from ActivationFunctionHardmax_float16_native_accum16_256_4.hlsl:31:
Shaders\ActivationOperation.hlsl:15:10: warning: non-portable path to file '"DataTypeDefs.hlsl"'; specified path differs in case from file name on disk [-Wnonportable-include-path]
   15 | #include "DatatypeDefs.hlsl"
      |          ^~~~~~~~~~~~~~~~~~~
      | "DataTypeDefs.hlsl"
Shaders\ActivationOperation.hlsl:32:2: warning: unknown attribute 'RootSignature' ignored [-Wunknown-attributes]
 32 | [RootSignature(ROOT_SIG_DEF)]
      |  ^~~~~~~~~~~~~
Assertion failed: isa<BinaryOperator>(I) && "Unknown instruction!", file D:/ClangDML/llvm-project/llvm/lib/Target/DirectX/DXILWriter/DXILBitcodeWriter.cpp, line 2245
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 ActivationFunctionHardmax_float16_native_accum16_256_4.hlsl -Fo - -Vd
1. <eof> parser at end of file
2.      Code generation
3.      Running pass 'DXIL Embedder' on module 'ActivationFunctionHardmax_float16_native_accum16_256_4.hlsl'.
Exception Code: 0xC000001D
 #0 0x00007ff63843c64c HandleAbort D:\ClangDML\llvm-project\llvm\lib\Support\Windows\Signals.inc:429:0
 #1 0x00007ffbf9069ea7 (C:\Windows\SYSTEM32\ucrtbased.dll+0x99ea7)
 #2 0x00007ffbf906bae9 (C:\Windows\SYSTEM32\ucrtbased.dll+0x9bae9)
 #3 0x00007ffbf9071745 (C:\Windows\SYSTEM32\ucrtbased.dll+0xa1745)
 #4 0x00007ffbf90713b7 (C:\Windows\SYSTEM32\ucrtbased.dll+0xa13b7)
 #5 0x00007ffbf906f381 (C:\Windows\SYSTEM32\ucrtbased.dll+0x9f381)
 #6 0x00007ffbf9071caf (C:\Windows\SYSTEM32\ucrtbased.dll+0xa1caf)
 #7 0x00007ff63b1a95cf llvm::dxil::DXILBitcodeWriter::writeInstruction(class llvm::Instruction const &, unsigned int, class llvm::SmallVectorImpl<unsigned int> &) D:\ClangDML\llvm-project\llvm\lib\Target\DirectX\DXILWriter\DXILBitcodeWriter.cpp:2246:0
 #8 0x00007ff63b1abfba llvm::dxil::DXILBitcodeWriter::writeFunction(class llvm::Function const &) D:\ClangDML\llvm-project\llvm\lib\Target\DirectX\DXILWriter\DXILBitcodeWriter.cpp:2650:0
 #9 0x00007ff63b19e4a3 llvm::dxil::DXILBitcodeWriter::write(void) D:\ClangDML\llvm-project\llvm\lib\Target\DirectX\DXILWriter\DXILBitcodeWriter.cpp:2911:0
#10 0x00007ff63b19e1b6 llvm::dxil::BitcodeWriter::writeModule(class llvm::Module const &) D:\ClangDML\llvm-project\llvm\lib\Target\DirectX\DXILWriter\DXILBitcodeWriter.cpp:437:0
#11 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
#12 0x00007ff638f88d74 `anonymous namespace'::EmbedDXILPass::runOnModule D:\ClangDML\llvm-project\llvm\lib\Target\DirectX\DXILWriter\DXILWriterPass.cpp:76:0
#13 0x00007ff6380a0715 `anonymous namespace'::MPPassManager::runOnModule D:\ClangDML\llvm-project\llvm\lib\IR\LegacyPassManager.cpp:1521:0
#14 0x00007ff6380a0224 llvm::legacy::PassManagerImpl::run(class llvm::Module &) D:\ClangDML\llvm-project\llvm\lib\IR\LegacyPassManager.cpp:539:0
#15 0x00007ff6380a4951 llvm::legacy::PassManager::run(class llvm::Module &) D:\ClangDML\llvm-project\llvm\lib\IR\LegacyPassManager.cpp:1648:0
#16 0x00007ff639e85cfb `anonymous namespace'::EmitAssemblyHelper::RunCodegenPipeline D:\ClangDML\llvm-project\clang\lib\CodeGen\BackendUtil.cpp:1244:0
#17 0x00007ff639e7fc2c `anonymous namespace'::EmitAssemblyHelper::emitAssembly D:\ClangDML\llvm-project\clang\lib\CodeGen\BackendUtil.cpp:1270:0
#18 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
#19 0x00007ff63a663889 clang::BackendConsumer::HandleTranslationUnit(class clang::ASTContext &) D:\ClangDML\llvm-project\clang\lib\CodeGen\CodeGenAction.cpp:320:0
#20 0x00007ff63d380d21 clang::ParseAST(class clang::Sema &, bool, bool) D:\ClangDML\llvm-project\clang\lib\Parse\ParseAST.cpp:191:0
#21 0x00007ff63a54e09d clang::ASTFrontendAction::ExecuteAction(void) D:\ClangDML\llvm-project\clang\lib\Frontend\FrontendAction.cpp:1347:0
#22 0x00007ff63a667a9d clang::CodeGenAction::ExecuteAction(void) D:\ClangDML\llvm-project\clang\lib\CodeGen\CodeGenAction.cpp:1112:0
#23 0x00007ff63a54da69 clang::FrontendAction::Execute(void) D:\ClangDML\llvm-project\clang\lib\Frontend\FrontendAction.cpp:1231:0
#24 0x00007ff6386e0fe7 clang::CompilerInstance::ExecuteAction(class clang::FrontendAction &) D:\ClangDML\llvm-project\clang\lib\Frontend\CompilerInstance.cpp:1055:0
#25 0x00007ff6387e498c clang::ExecuteCompilerInvocation(class clang::CompilerInstance *) D:\ClangDML\llvm-project\clang\lib\FrontendTool\ExecuteCompilerInvocation.cpp:300:0
#26 0x00007ff637c70296 cc1_main(class llvm::ArrayRef<char const *>, char const *, void *) D:\ClangDML\llvm-project\clang\tools\driver\cc1_main.cpp:294:0
#27 0x00007ff637c626d6 ExecuteCC1Tool D:\ClangDML\llvm-project\clang\tools\driver\driver.cpp:218:0
#28 0x00007ff637c63360 clang_main::<lambda_0>::operator() D:\ClangDML\llvm-project\clang\tools\driver\driver.cpp:364:0
#29 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
#30 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
#31 0x00007ff63a1caf87 clang::driver::CC1Command::Execute::<lambda_1>::operator() D:\ClangDML\llvm-project\clang\lib\Driver\Job.cpp:435:0
#32 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
#33 0x00007ff638403447 llvm::function_ref<(void)>::operator()(void) const D:\ClangDML\llvm-project\llvm\include\llvm\ADT\STLFunctionalExtras.h:69:0
#34 0x00007ff638436148 llvm::CrashRecoveryContext::RunSafely(class llvm::function_ref<(void)>) D:\ClangDML\llvm-project\llvm\lib\Support\CrashRecoveryContext.cpp:235:0
#35 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
#36 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
#37 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
#38 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
#39 0x00007ff637c621a0 clang_main(int, char **, struct llvm::ToolContext const &) D:\ClangDML\llvm-project\clang\tools\driver\driver.cpp:402:0
#40 0x00007ff637c95cb8 main D:\ClangDML\llvm-project\build\tools\clang\tools\driver\clang-driver.cpp:17:0
#41 0x00007ff6408c1149 invoke_main D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:79:0
#42 0x00007ff6408c1282 __scrt_common_main_seh D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288:0
#43 0x00007ff6408c130e __scrt_common_main D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:331:0
#44 0x00007ff6408c132e mainCRTStartup D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_main.cpp:17:0
#45 0x00007ffc56c3e8d7 (C:\Windows\System32\KERNEL32.DLL+0x2e8d7)
#46 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