Skip to content

DXC crashes compiling calls to dot4add_u8packed and dot4add_i8packed #7400

Closed

Description

@jimblandy

Using DXC built as described in #7395, and invoked as:

dxc -Od -T cs_6_8 reduced.hlsl

the following causes a crash:

[numthreads(1, 1, 1)]
void main()
{
    uint c_6_ = dot4add_u8packed(0, 0, 0);
    dot4add_u8packed(0, 0, c_6_);
}
Call stack
#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=0x8ec1b8, IOP=hlsl::IntrinsicOp::IOP_dot4add_u8packed, opcode=hlsl::DXIL::OpCode::Dot4AddU8Packed, helper=..., 
    pObjHelper=0x7fffffff8c90, Translated=@0x7fffffff8a7f: true) at /home/jimb/DirectXShaderCompiler/lib/HLSL/HLOperationLower.cpp:5957
#3  0x00007ffff4e5b4d8 in TranslateBuiltinIntrinsic (CI=0x8ec1b8, helper=..., pObjHelper=0x7fffffff8c90, Translated=@0x7fffffff8a7f: true)
    at /home/jimb/DirectXShaderCompiler/lib/HLSL/HLOperationLower.cpp:6818
#4  0x00007ffff4e6761a in TranslateHLBuiltinOperation (F=0x8ec018, helper=..., group=hlsl::HLOpcodeGroup::HLIntrinsic, pObjHelper=0x7fffffff8c90)
    at /home/jimb/DirectXShaderCompiler/lib/HLSL/HLOperationLower.cpp:9010
#5  0x00007ffff4e68244 in hlsl::TranslateBuiltinOperations (HLM=..., extCodegenHelper=0x8535f0, UpdateCounterSet=std::unordered_set with 0 elements)
    at /home/jimb/DirectXShaderCompiler/lib/HLSL/HLOperationLower.cpp:9192
#6  0x00007ffff4e21ba6 in (anonymous namespace)::DxilGenerationPass::GenerateDxilOperations (this=0x8fe630, 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=0x8fe630, M=...) at /home/jimb/DirectXShaderCompiler/lib/HLSL/DxilGenerationPass.cpp:251
#8  0x00007ffff692ace2 in (anonymous namespace)::MPPassManager::runOnModule (this=0x882de0, M=...) at /home/jimb/DirectXShaderCompiler/lib/IR/LegacyPassManager.cpp:1669
#9  0x00007ffff692b48d in llvm::legacy::PassManagerImpl::run (this=0x8ef200, M=...) at /home/jimb/DirectXShaderCompiler/lib/IR/LegacyPassManager.cpp:1771
#10 0x00007ffff692b7fc in llvm::legacy::PassManager::run (this=0x8ef170, M=...) at /home/jimb/DirectXShaderCompiler/lib/IR/LegacyPassManager.cpp:1814
#11 0x00007ffff525d778 in (anonymous namespace)::EmitAssemblyHelper::EmitAssembly (this=0x7fffffff9810, Action=clang::Backend_EmitBC, OS=0x88e6a0)
    at /home/jimb/DirectXShaderCompiler/tools/clang/lib/CodeGen/BackendUtil.cpp:760
#12 0x00007ffff525d95d in clang::EmitBackendOutput (Diags=..., CGOpts=..., TOpts=..., LOpts=..., TDesc=..., M=0x88f360, Action=clang::Backend_EmitBC, OS=0x88e6a0)
    at /home/jimb/DirectXShaderCompiler/tools/clang/lib/CodeGen/BackendUtil.cpp:783
#13 0x00007ffff5239b91 in clang::BackendConsumer::HandleTranslationUnit (this=0x88e850, 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=0x7fffffffa0a0) at /home/jimb/DirectXShaderCompiler/tools/clang/lib/Frontend/FrontendAction.cpp:554
#16 0x00007ffff5237870 in clang::CodeGenAction::ExecuteAction (this=0x7fffffffa0a0) at /home/jimb/DirectXShaderCompiler/tools/clang/lib/CodeGen/CodeGenAction.cpp:808
#17 0x00007ffff5570503 in clang::FrontendAction::Execute (this=0x7fffffffa0a0) at /home/jimb/DirectXShaderCompiler/tools/clang/lib/Frontend/FrontendAction.cpp:455
#18 0x00007ffff4a21bf4 in DxcCompiler::Compile (this=0x84d430, pSource=0x7fffffffc3e0, pArguments=0x84cf10, argCount=11, pIncludeHandler=0x84caf0, riid=..., ppResult=0x7fffffffc3a8)
    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"/home/jimb/naga-crashes-dxc-2/reduced.hlsl", 
    pEntryPoint=0x84db00 L"main", pTargetProfile=0x84d970 L"cs_6_4", pArguments=0x84d3a0, argCount=10, pDefines=0x7fffffffcce8, defineCount=0, pIncludeHandler=0x84caf0, 
    ppResult=0x7fffffffc7f0, 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"/home/jimb/naga-crashes-dxc-2/reduced.hlsl", 
    pEntryPoint=0x84db00 L"main", pTargetProfile=0x84d970 L"cs_6_4", pArguments=0x84d3a0, argCount=10, pDefines=0x7fffffffcce8, defineCount=0, pIncludeHandler=0x84caf0, 
    ppResult=0x7fffffffc7f0, 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"/home/jimb/naga-crashes-dxc-2/reduced.hlsl", 
    pEntryPoint=0x84db00 L"main", pTargetProfile=0x84d970 L"cs_6_4", pArguments=0x84d3a0, argCount=10, pDefines=0x7fffffffcce8, defineCount=0, pIncludeHandler=0x84caf0, 
    ppResult=0x7fffffffc7f0) at /home/jimb/DirectXShaderCompiler/tools/clang/tools/dxcompiler/dxcompileradapter.h:75
#22 0x000000000040805d in DxcContext::Compile (this=0x7fffffffd590) at /home/jimb/DirectXShaderCompiler/tools/clang/tools/dxclib/dxc.cpp:874
#23 0x000000000040b321 in dxc::main (argc=12, argv_=0x7fffffffd778) at /home/jimb/DirectXShaderCompiler/tools/clang/tools/dxclib/dxc.cpp:1502
#24 0x0000000000402406 in main (argc=12, argv_=0x7fffffffd778) at /home/jimb/DirectXShaderCompiler/tools/clang/tools/dxc/dxcmain.cpp:19

Activity

  1. added
    bug
    needs-triage
    on Apr 30, 2025
  2. jimblandy commented on Apr 30, 2025

    @jimblandy
    ContributorAuthor

    I have no idea if I'm barking up the right tree, but when processing the first call to dot4add_u8unpacked, AddOverloadedCallCandidates's call to HLSLExternalSource::MatchArguments leaves functionArgTypes set to
    [literal int, unsigned int, unsigned int, literal int], and we end up with a callee:

    declare i64 @"\01?dot4add_u8packed@hlsl@@YA_JII_J@Z"(i32, i32, i64 signext) #1821 
    

    It seems to me that i64 is wrong as the return type and third argument type, especially since the failing assertion is this one:

      DXASSERT(
          !accTy->isVectorTy() && accTy->isIntegerTy(32),
          "otherwise, unexpected vector support in high level intrinsic template");
    
  3. jimblandy commented on Apr 30, 2025

    @jimblandy
    ContributorAuthor

    This is the code in MatchArguments that sets the other arguments to unsigned int. It skips the third argument, since that's the one that determines the return type.

        if (TypeInfoEltKind == AR_BASIC_LITERAL_INT ||
            TypeInfoEltKind == AR_BASIC_LITERAL_FLOAT) {
          bool affectRetType =
              (iArg != retArgIdx && retTypeIdx == pIntrinsicArg->uComponentTypeId);
          // For literal arg which don't affect return type, find concrete type.
          // For literal arg affect return type,
          //   TryEvalIntrinsic in CGHLSLMS.cpp will take care of cases
          //     where all argumentss are literal.
          //   CombineBasicTypes will cover the rest cases.
          if (!affectRetType) {
            TypeInfoEltKind =
                ConcreteLiteralType(pCallArg, TypeInfoEltKind,
                                    pIntrinsicArg->uLegalComponentTypes, this);
          }
        }
  4. added 5 commits that reference this issue on Apr 30, 2025
    c8bd8bc
    974bdaa
    5f04faf
    553be8c
    f895647
  5. added a commit that references this issue on May 12, 2025
    377c4ca
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugneeds-triage

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions