Skip to content
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

Internal llvm::cast<X> due to particular combination of class fields and methods #4629

Open
siliconvoodoo opened this issue Aug 31, 2022 · 3 comments
Labels
bug Bug, regression, crash crash DXC crashing or hitting an assert
Milestone

Comments

@siliconvoodoo
Copy link

siliconvoodoo commented Aug 31, 2022

(reduced to minimum crashing example) code:

struct PSInput
{
};

class SurfaceData_BasePBR
{
    float3 albedo;
};

interface ISpecRough
{
    void ApplySpecularAA();
};

class SurfaceData_NewPBR : SurfaceData_BasePBR, ISpecRough
{
    float3 emissiveLighting;

    void ApplySpecularAA()
    {
    } 
};

float4 PSMain( PSInput input ) : SV_TARGET
{
    SurfaceData_NewPBR obj ;
    obj . albedo . x = 1 ;
    return float4 ( obj . albedo , 1 ) ;
} 

Example command line:

-T ps_6_5 -E PSMain -HV 2021

Effect:

Internal Compiler error: llvm::cast() argument of incompatible type!

@damyanp
Copy link
Member

damyanp commented Jul 31, 2024

Stil reproduces: https://godbolt.org/z/zv4WKPjdn

@damyanp damyanp added this to the Dormant milestone Jul 31, 2024
@llvm-beanz
Copy link
Collaborator

Callstack for the bad cast:

* thread #1, name = 'dxc', stop reason = signal SIGILL: illegal instruction operand
  * frame #0: 0x00007ffff0e036cd libdxcompiler.so ::llvm_assert(const char *, const char *, unsigned int, const char *):`::llvm_assert(Message="false && \"expected struct bitcast to only be used by lifetime intrinsics\"", File="/home/cbieneman/dev/DirectXShaderCompiler/lib/Transforms/Scalar/ScalarReplAggregatesHLSL.cpp", Line=2578 0x00000a12, Function="RewriteBitCast") + 429 at assert.cpp:33
    frame #1: 0x00007ffff0c36d2b libdxcompiler.so (anonymous namespace)::SROA_Helper::RewriteBitCast:`(anonymous namespace)::SROA_Helper::RewriteBitCast(this=0x00007fffffff5c60, BCI=0x00005555570f1f08) + 859 at ScalarReplAggregatesHLSL.cpp:2577
    frame #2: 0x00007ffff0c30ca8 libdxcompiler.so (anonymous namespace)::SROA_Helper::RewriteForScalarRepl:`(anonymous namespace)::SROA_Helper::RewriteForScalarRepl(this=0x00007fffffff5c60, V=0x00005555570efbf8, Builder=0x00007fffffff6938) + 984 at ScalarReplAggregatesHLSL.cpp:2899
    frame #3: 0x00007ffff0c280ae libdxcompiler.so (anonymous namespace)::SROA_Helper::DoScalarReplacement:`(anonymous namespace)::SROA_Helper::DoScalarReplacement(V=0x00005555570efbf8, Elts=size=1, BrokenUpTy=0x00007fffffff6928, NumInstances=0x00007fffffff6920, Builder=0x00007fffffff6938, bFlatVector=true, hasPrecise=false, typeSys=0x000055555709b340, DL=0x00005555570860e0, DeadInsts=0x00007fffffff6aa0, DT=0x0000555557153508) + 6542 at ScalarReplAggregatesHLSL.cpp:3060
    frame #4: 0x00007ffff0c16c21 libdxcompiler.so (anonymous namespace)::SROAGlobalAndAllocas:`(anonymous namespace)::SROAGlobalAndAllocas(HLM=0x000055555708d680, bHasDbgInfo=false) + 6321 at ScalarReplAggregatesHLSL.cpp:1879
    frame #5: 0x00007ffff0c0d5a5 libdxcompiler.so (anonymous namespace)::SROA_Parameter_HLSL::runOnModule:`(anonymous namespace)::SROA_Parameter_HLSL::runOnModule(this=0x00005555570fe350, M=0x0000555557085fe0) + 4613 at ScalarReplAggregatesHLSL.cpp:4370
    frame #6: 0x00007fffefdc37b5 libdxcompiler.so (anonymous namespace)::MPPassManager::runOnModule:`(anonymous namespace)::MPPassManager::runOnModule(this=0x0000555557079a90, M=0x0000555557085fe0) + 1797 at LegacyPassManager.cpp:1669
    frame #7: 0x00007fffefdc2c28 libdxcompiler.so llvm::legacy::PassManagerImpl::run:`llvm::legacy::PassManagerImpl::run(this=0x00005555570f7cc0, M=0x0000555557085fe0) + 776 at LegacyPassManager.cpp:1771
    frame #8: 0x00007fffefdc469a libdxcompiler.so llvm::legacy::PassManager::run:`llvm::legacy::PassManager::run(this=0x00005555570f7c30, M=0x0000555557085fe0) + 138 at LegacyPassManager.cpp:1814
    frame #9: 0x00007ffff0ffc781 libdxcompiler.so (anonymous namespace)::EmitAssemblyHelper::EmitAssembly:`(anonymous namespace)::EmitAssemblyHelper::EmitAssembly(this=0x00007fffffff8048, Action=Backend_EmitBC, OS=0x0000555557085440) + 3761 at BackendUtil.cpp:760
    frame #10: 0x00007ffff0ffb09b libdxcompiler.so clang::EmitBackendOutput:`clang::EmitBackendOutput(Diags=0x00005555570496a0, CGOpts=0x0000555557048150, TOpts=0x0000555557048d80, LOpts=0x0000555557048c00, TDesc=(Data = "e-m:e-p:32:32-i1:32-i8:32-i16:32-i32:32-i64:64-f16:32-f32:32-f64:64-n8:16:32:64", Length = 79), M=0x0000555557085fe0, Action=Backend_EmitBC, OS=0x0000555557085440) + 411 at BackendUtil.cpp:783
    frame #11: 0x00007ffff0ff28d6 libdxcompiler.so clang::BackendConsumer::HandleTranslationUnit:`clang::BackendConsumer::HandleTranslationUnit(this=0x0000555557085610, C=0x000055555706f5c0) + 2150 at CodeGenAction.cpp:191
    frame #12: 0x00007ffff39a0ec3 libdxcompiler.so clang::ParseAST:`clang::ParseAST(S=0x00005555570862a0, PrintStats=false, SkipFunctionBodies=false) + 2547 at ParseAST.cpp:164
    frame #13: 0x00007ffff1780315 libdxcompiler.so clang::ASTFrontendAction::ExecuteAction:`clang::ASTFrontendAction::ExecuteAction(this=0x00007fffffffa5d0) + 725 at FrontendAction.cpp:554
    frame #14: 0x00007ffff0feed07 libdxcompiler.so clang::CodeGenAction::ExecuteAction:`clang::CodeGenAction::ExecuteAction(this=0x00007fffffffa5d0) + 3703 at CodeGenAction.cpp:807
    frame #15: 0x00007ffff177f7ff libdxcompiler.so clang::FrontendAction::Execute:`clang::FrontendAction::Execute(this=0x00007fffffffa5d0) + 303 at FrontendAction.cpp:455
    frame #16: 0x00007fffef74f0b3 libdxcompiler.so DxcCompiler::Compile:`DxcCompiler::Compile(this=0x00005555570458a0, pSource=0x00007fffffffcd60, pArguments=0x00005555570460f0, argCount=5 0x00000005, pIncludeHandler=0x0000555557045570, riid=0x0000555555ae6d10, ppResult=0x00007fffffffc250) + 22435 at dxcompilerobj.cpp:984
    frame #17: 0x00007fffef73ade0 libdxcompiler.so hlsl::DxcCompilerAdapter::WrapCompile:`hlsl::DxcCompilerAdapter::WrapCompile(this=0x0000555557045cc0, bPreprocess=NO, pSource=0x0000555557045d70, pSourceName=L"./4629.hlsl", pEntryPoint=L"main", pTargetProfile=L"ps_6_6", pArguments=0x0000555557045550, argCount=2 0x00000002, pDefines=0x00007fffffffdbe0, defineCount=0 0x00000000, pIncludeHandler=0x0000555557045570, ppResult=0x00007fffffffd710, ppDebugBlobName=0x0000000000000000, ppDebugBlob=0x0000000000000000) + 4288 at dxcompilerobj.cpp:1845
    frame #18: 0x00007fffef73c938 libdxcompiler.so hlsl::DxcCompilerAdapter::CompileWithDebug:`hlsl::DxcCompilerAdapter::CompileWithDebug(this=0x0000555557045cc0, pSource=0x0000555557045d70, pSourceName=L"./4629.hlsl", pEntryPoint=L"main", pTargetProfile=L"ps_6_6", pArguments=0x0000555557045550, argCount=2 0x00000002, pDefines=0x00007fffffffdbe0, defineCount=0 0x00000000, pIncludeHandler=0x0000555557045570, ppResult=0x00007fffffffd710, ppDebugBlobName=0x0000000000000000, ppDebugBlob=0x0000000000000000) + 360 at dxcompilerobj.cpp:1748
    frame #19: 0x00007fffef743e18 libdxcompiler.so hlsl::DxcCompilerAdapter::Compile:`hlsl::DxcCompilerAdapter::Compile(this=0x0000555557045cc0, pSource=0x0000555557045d70, pSourceName=L"./4629.hlsl", pEntryPoint=L"main", pTargetProfile=L"ps_6_6", pArguments=0x0000555557045550, argCount=2 0x00000002, pDefines=0x00007fffffffdbe0, defineCount=0 0x00000000, pIncludeHandler=0x0000555557045570, ppResult=0x00007fffffffd710) + 184 at dxcompileradapter.h:75
    frame #20: 0x0000555555df6490 dxc DxcContext::Compile:`DxcContext::Compile(this=0x00007fffffffda40) + 5344 at dxc.cpp:874
    frame #21: 0x0000555555dfc738 dxc dxc::main:`dxc::main(argc=4 0x00000004, argv_=0x00007fffffffe728) + 2744 at dxc.cpp:1502
    frame #22: 0x0000555555deb722 dxc main:`main(argc=4 0x00000004, argv_=0x00007fffffffe728) + 34 at dxcmain.cpp:19
    frame #23: 0x00007fffe6a9bd90 libc.so.6 __libc_start_call_main:`__libc_start_call_main(main=(dxc`main at dxcmain.cpp:18), argc=4 0x00000004, argv=0x00007fffffffe728) + 128 at libc_start_call_main.h:58
    frame #24: 0x00007fffe6a9be40 libc.so.6 __libc_start_main_impl:`__libc_start_main_impl(main=(dxc`main at dxcmain.cpp:18), argc=4 0x00000004, argv=0x00007fffffffe728, init=0x00007ffff7ffd040, fini=<unavailable>, rtld_fini=<unavailable>, stack_end=0x00007fffffffe718) + 128 at libc-start.c:392
    frame #25: 0x0000555555dc30b5 dxc _start:`_start + 37

@llvm-beanz
Copy link
Collaborator

I've also filed an issue to track removing interfaces in a future version of HLSL. They are broken and can't be used in many of the contexts that would make them interesting (see: microsoft/hlsl-specs#291).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug, regression, crash crash DXC crashing or hitting an assert
Projects
Status: Triaged
Development

No branches or pull requests

3 participants