microsoft / DirectXShaderCompiler

This repo hosts the source for the DirectX Shader Compiler which is based on LLVM/Clang.
Other
2.98k stars 665 forks source link

dxc internal error; invalid GEP with initialization of matrix in a struct #6723

Open dneto0 opened 5 days ago

dneto0 commented 5 days ago

DXC throws an internal error when compiling this compute shader:

struct a {
  float b;
  float2x4 c;
};
struct d {
  a c;
};
struct e {
  d c[1];
  d f[1];
};

static e g = (e)0;

[numthreads(1, 1, 1)]
void main() {
  d h = g.f[0];
  return;
}

Steps to Reproduce

[godbolt link](https://godbolt.org/#g:!((g:!((g:!((h:codeEditor,i:(filename:'1',fontScale:14,fontUsePx:'0',j:1,lang:hlsl,selection:(endColumn:2,endLineNumber:19,positionColumn:2,positionLineNumber:19,selectionStartColumn:2,selectionStartLineNumber:19,startColumn:2,startLineNumber:19),source:'struct+a+%7B%0A++float+b%3B%0A++float2x4+c%3B%0A%7D%3B%0Astruct+d+%7B%0A++a+c%3B%0A%7D%3B%0Astruct+e+%7B%0A++d+c%5B1%5D%3B%0A++d+f%5B1%5D%3B%0A%7D%3B%0A%0Astatic+e+g+%3D+(e)0%3B%0A%0A%5Bnumthreads(1,+1,+1)%5D%0Avoid+main()+%7B%0A++d+h+%3D+g.f%5B0%5D%3B%0A++return%3B%0A%7D%0A'),l:'5',n:'1',o:'HLSL+source+%231',t:'0')),k:48.13968668407311,l:'4',n:'0',o:'',s:0,t:'0'),(g:!((g:!((h:compiler,i:(compiler:dxc_trunk,filters:(b:'0',binary:'1',binaryObject:'1',commentOnly:'0',debugCalls:'1',demangle:'0',directives:'0',execute:'1',intel:'0',libraryCode:'0',trim:'1',verboseDemangling:'0'),flagsViewOpen:'1',fontScale:14,fontUsePx:'0',j:1,lang:hlsl,libs:!(),options:'-T+cs_6_0',overrides:!(),selection:(endColumn:1,endLineNumber:1,positionColumn:1,positionLineNumber:1,selectionStartColumn:1,selectionStartLineNumber:1,startColumn:1,startLineNumber:1),source:1),l:'5',n:'0',o:'+DXC+(trunk)+(Editor+%231)',t:'0')),k:50,l:'4',m:50,n:'0',o:'',s:0,t:'0'),(g:!((h:output,i:(compilerName:'DXC+1.7.2207',editorid:1,fontScale:14,fontUsePx:'0',j:1,wrap:'1'),l:'5',n:'0',o:'Output+of+DXC+(trunk)+(Compiler+%231)',t:'0')),header:(),l:'4',m:50,n:'0',o:'',s:0,t:'0')),k:51.860313315926895,l:'3',n:'0',o:'',t:'0')),l:'2',n:'0',o:'',t:'0')),version:4)

Actual Behavior

From the command line:

$ dxc -T cs_6_0 x.hlsl
error: cast<X>() argument of incompatible type!

Environment

Initial investigation resulted in #6710 but that doesn't get to root cause.