Skip to content

Naga output for functions-optimized-by-version.wgsl crashes DXC #7651

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jimblandy opened this issue Apr 30, 2025 · 2 comments
Open

Naga output for functions-optimized-by-version.wgsl crashes DXC #7651

jimblandy opened this issue Apr 30, 2025 · 2 comments
Labels
area: naga back-end Outputs of naga shader conversion external: driver-bug A driver is causing the bug, though we may still want to work around it lang: HLSL D3D Shading Language naga Shader Translator

Comments

@jimblandy
Copy link
Member

DXC built from moz-1.8.2502 crashes on the HLSL Naga generates for naga/tests/in/wgsl/functions-optimized-by-version.wgsl.

naga$ dxc tests/out/hlsl/wgsl-functions-optimized-by-version.hlsl -T cs_6_4 -E main -Wno-parentheses-equality -Zi -Qembed_debug -Od -HV 2018
otherwise, unexpected vector support in high level intrinsic templateError: assert()
File:
(0)
Func:	
Illegal instruction (core dumped)
naga$ 
Crash stack in DXC
#0  (anonymous namespace)::llvm_assert_trap (_Message=0x7ffff6f2fb30 "", _File=0x7ffff6f2fb30 "", _Line=0, _Function=0x7ffff6f2fb30 "")
    at /home/jimb/DirectXShaderCompiler/lib/Support/assert.cpp:18
#1  0x00007ffff518876f in llvm_assert (Message=0x7ffff6f2fb30 "", File=0x7ffff6f2fb30 "", Line=0, Function=0x7ffff6f2fb30 "") at /home/jimb/DirectXShaderCompiler/lib/Support/assert.cpp:41
#2  0x00007ffff4e5a110 in (anonymous namespace)::TranslateDot4AddPacked (CI=0x91f9c8, IOP=hlsl::IntrinsicOp::IOP_dot4add_u8packed, opcode=hlsl::DXIL::OpCode::Dot4AddU8Packed, helper=..., 
    pObjHelper=0x7fffffff8c80, Translated=@0x7fffffff8a6f: true) at /home/jimb/DirectXShaderCompiler/lib/HLSL/HLOperationLower.cpp:5957
#3  0x00007ffff4e5b4d8 in TranslateBuiltinIntrinsic (CI=0x91f9c8, helper=..., pObjHelper=0x7fffffff8c80, Translated=@0x7fffffff8a6f: true)
    at /home/jimb/DirectXShaderCompiler/lib/HLSL/HLOperationLower.cpp:6818
#4  0x00007ffff4e6761a in TranslateHLBuiltinOperation (F=0x8f1d98, helper=..., group=hlsl::HLOpcodeGroup::HLIntrinsic, pObjHelper=0x7fffffff8c80)
    at /home/jimb/DirectXShaderCompiler/lib/HLSL/HLOperationLower.cpp:9010
#5  0x00007ffff4e68244 in hlsl::TranslateBuiltinOperations (HLM=..., extCodegenHelper=0x853a90, UpdateCounterSet=std::unordered_set with 0 elements)
    at /home/jimb/DirectXShaderCompiler/lib/HLSL/HLOperationLower.cpp:9192
#6  0x00007ffff4e21ba6 in (anonymous namespace)::DxilGenerationPass::GenerateDxilOperations (this=0x904cf0, M=..., UpdateCounterSet=std::unordered_set with 0 elements)
    at /home/jimb/DirectXShaderCompiler/lib/HLSL/DxilGenerationPass.cpp:827
#7  0x00007ffff4e1efce in (anonymous namespace)::DxilGenerationPass::runOnModule (this=0x904cf0, M=...) at /home/jimb/DirectXShaderCompiler/lib/HLSL/DxilGenerationPass.cpp:251
#8  0x00007ffff692ace2 in (anonymous namespace)::MPPassManager::runOnModule (this=0x8f5b00, M=...) at /home/jimb/DirectXShaderCompiler/lib/IR/LegacyPassManager.cpp:1669
#9  0x00007ffff692b48d in llvm::legacy::PassManagerImpl::run (this=0x8f56c0, M=...) at /home/jimb/DirectXShaderCompiler/lib/IR/LegacyPassManager.cpp:1771
#10 0x00007ffff692b7fc in llvm::legacy::PassManager::run (this=0x8f5630, M=...) at /home/jimb/DirectXShaderCompiler/lib/IR/LegacyPassManager.cpp:1814
#11 0x00007ffff525d778 in (anonymous namespace)::EmitAssemblyHelper::EmitAssembly (this=0x7fffffff9800, Action=clang::Backend_EmitBC, OS=0x88ec40)
    at /home/jimb/DirectXShaderCompiler/tools/clang/lib/CodeGen/BackendUtil.cpp:760
#12 0x00007ffff525d95d in clang::EmitBackendOutput (Diags=..., CGOpts=..., TOpts=..., LOpts=..., TDesc=..., M=0x88f900, Action=clang::Backend_EmitBC, OS=0x88ec40)
    at /home/jimb/DirectXShaderCompiler/tools/clang/lib/CodeGen/BackendUtil.cpp:783
#13 0x00007ffff5239b91 in clang::BackendConsumer::HandleTranslationUnit (this=0x88edf0, C=...) at /home/jimb/DirectXShaderCompiler/tools/clang/lib/CodeGen/CodeGenAction.cpp:192
#14 0x00007ffff64f4def in clang::ParseAST (S=..., PrintStats=false, SkipFunctionBodies=false) at /home/jimb/DirectXShaderCompiler/tools/clang/lib/Parse/ParseAST.cpp:164
#15 0x00007ffff5570a0b in clang::ASTFrontendAction::ExecuteAction (this=0x7fffffffa090) at /home/jimb/DirectXShaderCompiler/tools/clang/lib/Frontend/FrontendAction.cpp:554
#16 0x00007ffff5237870 in clang::CodeGenAction::ExecuteAction (this=0x7fffffffa090) at /home/jimb/DirectXShaderCompiler/tools/clang/lib/CodeGen/CodeGenAction.cpp:808
#17 0x00007ffff5570503 in clang::FrontendAction::Execute (this=0x7fffffffa090) at /home/jimb/DirectXShaderCompiler/tools/clang/lib/Frontend/FrontendAction.cpp:455
#18 0x00007ffff4a21bf4 in DxcCompiler::Compile (this=0x84d430, pSource=0x7fffffffc3d0, pArguments=0x84cf10, argCount=11, pIncludeHandler=0x84caf0, riid=..., ppResult=0x7fffffffc398)
    at /home/jimb/DirectXShaderCompiler/tools/clang/tools/dxcompiler/dxcompilerobj.cpp:974
#19 0x00007ffff4a14b87 in hlsl::DxcCompilerAdapter::WrapCompile (this=0x84d850, bPreprocess=false, pSource=0x84d870, 
    pSourceName=0x84d8b0 L"tests/out/hlsl/wgsl-functions-optimized-by-version.hlsl", pEntryPoint=0x84dcc0 L"main", pTargetProfile=0x84d9a0 L"cs_6_4", pArguments=0x84d3a0, argCount=10, 
    pDefines=0x7fffffffccd8, defineCount=0, pIncludeHandler=0x84caf0, ppResult=0x7fffffffc7e0, ppDebugBlobName=0x0, ppDebugBlob=0x0)
    at /home/jimb/DirectXShaderCompiler/tools/clang/tools/dxcompiler/dxcompilerobj.cpp:1851
#20 0x00007ffff4a1437c in hlsl::DxcCompilerAdapter::CompileWithDebug (this=0x84d850, pSource=0x84d870, pSourceName=0x84d8b0 L"tests/out/hlsl/wgsl-functions-optimized-by-version.hlsl", 
    pEntryPoint=0x84dcc0 L"main", pTargetProfile=0x84d9a0 L"cs_6_4", pArguments=0x84d3a0, argCount=10, pDefines=0x7fffffffccd8, defineCount=0, pIncludeHandler=0x84caf0, 
    ppResult=0x7fffffffc7e0, ppDebugBlobName=0x0, ppDebugBlob=0x0) at /home/jimb/DirectXShaderCompiler/tools/clang/tools/dxcompiler/dxcompilerobj.cpp:1754
#21 0x00007ffff4a1bde7 in hlsl::DxcCompilerAdapter::Compile (this=0x84d850, pSource=0x84d870, pSourceName=0x84d8b0 L"tests/out/hlsl/wgsl-functions-optimized-by-version.hlsl", 
    pEntryPoint=0x84dcc0 L"main", pTargetProfile=0x84d9a0 L"cs_6_4", pArguments=0x84d3a0, argCount=10, pDefines=0x7fffffffccd8, defineCount=0, pIncludeHandler=0x84caf0, 
    ppResult=0x7fffffffc7e0) at /home/jimb/DirectXShaderCompiler/tools/clang/tools/dxcompiler/dxcompileradapter.h:75
#22 0x000000000040805d in DxcContext::Compile (this=0x7fffffffd580) at /home/jimb/DirectXShaderCompiler/tools/clang/tools/dxclib/dxc.cpp:874
#23 0x000000000040b321 in dxc::main (argc=12, argv_=0x7fffffffd768) at /home/jimb/DirectXShaderCompiler/tools/clang/tools/dxclib/dxc.cpp:1502
#24 0x0000000000402406 in main (argc=12, argv_=0x7fffffffd768) at /home/jimb/DirectXShaderCompiler/tools/clang/tools/dxc/dxcmain.cpp:19
@jimblandy
Copy link
Member Author

Reduced test case:

[numthreads(1, 1, 1)]
void main()
{
    uint c_6_ = dot4add_i8packed(0, 0, 0);
    dot4add_i8packed(0, 0, c_6_);
}

@jimblandy
Copy link
Member Author

Filed upstream as microsoft/DirectXShaderCompiler#7400.
My shot-in-the-dark PR: microsoft/DirectXShaderCompiler#7401.
The same PR, rebased on Firefox's DXC branch: FirefoxGraphics/DirectXShaderCompiler#5

@cwfitzgerald cwfitzgerald added external: driver-bug A driver is causing the bug, though we may still want to work around it area: naga back-end Outputs of naga shader conversion lang: HLSL D3D Shading Language naga Shader Translator labels Apr 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: naga back-end Outputs of naga shader conversion external: driver-bug A driver is causing the bug, though we may still want to work around it lang: HLSL D3D Shading Language naga Shader Translator
Projects
Status: Todo
Development

No branches or pull requests

2 participants