<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/114131>114131</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Invalid type description generated in DXIL IR for StructuredBuffer
</td>
</tr>
<tr>
<th>Labels</th>
<td>
bug,
HLSL
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
coopp
</td>
</tr>
</table>
<pre>
An invalid form of a type was being generated in the DXIL IR for the StructuredBuffer type. This form was causing 'opt' to fail with a syntax error while parsing the IR.
godbolt: https://godbolt.org/z/zf7TTWa5q
Shader compiled with -T cs_6_6
```
struct mystruct
{
float4 Color;
};
StructuredBuffer<mystruct> my_buffer : register(t2, space4);
export float4 test()
{
return my_buffer[0].Color;
}
[numthreads(1,1,1)]
void main() {}
```
See `%"class.hlsl::StructuredBuffer" = type { target("dx.RawBuffer", %struct.mystruct = type { <4 x float> }, 0, 0), %struct.mystruct }`
Type section for IR
```
%"class.hlsl::StructuredBuffer" = type { target("dx.RawBuffer", %struct.mystruct = type { <4 x float> }, 0, 0), %struct.mystruct }
%struct.mystruct = type { <4 x float> }
%dx.types.Handle = type { ptr }
%dx.types.ResBind = type { i32, i32, i32, i8 }
%dx.types.ResourceProperties = type { i32, i32 }
```
The part "%struct.mystruct = type" is causing the parsing error.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUVUFvszgQ_TXmMioCG0I4cGiSjb5KPazSSLu3yuABvDKYtU2b7K9fGUjTpF9X2uMnBbCTN2_mPSZjbq1sesSCpBuS7gI-ulabotJ6GIJSi3Px2IPs37iSAmptOtA1cHDnAeGdWyhR9g002KPhDgXIHlyLsPvz6RmeDj5i2r84M1ZuNCg2Y12jmQhCgGMr7UzrySo-Wk9HaKYHR2gGTkPNpYJ36VrgYM-94ydAY7SB91YqhIGbKcZneTqEJNqR6HG-N1qUWjnCHqF1brCEPRK6J3S__BBq0xC6_8dfdXY8_sHTvz_Hv7RcoIFKd4NUKOYiHo5Q2dfV62pBrqLlM23tpBO687xYMNlmXgAA1Epzl8BWK20I21wQu-t6zn1nGGHbD1L2G3Tn13I20qsz2Ejr0BC6dpTQLdiBV5gQmt-x4mnQxl1qcGgdoWsP-1qnQTea_pqIpJuIpLvwa-Gf-Em66cfOtQa5sISuY0K3y5WTdIG-aSmg47Kfc4NP-0Fza-fiBSL4r2hKKK0UtzZslVX-dbKvRlEKhO3mDiXZBhw3Dc46qTiFB_7-AfRWEZrOtoYXf2_DCdsmcJot8877UukWouWWf8eR7e5UHD2jxcpJ3U__i6fDzzX_ajIvVf9v_kugOIUeZ8MfvBcKbwMHZ34OPqDdyF7coiWb1N491t8y6NFU-LvRAxon0X5HBv_doMd2mkMOJrO_NcK_M3mdcq69Tq9poi3DKxAFEznLeYBFnLGIslWaREFbpGlC01KsVtWKlVldlqJaRaws46zKcb0uA1nQiCZxRHMaxynLw3WU8nKV0yTKKpGwmiQRdlyqUKm3zo-_QFo7YhHHScziQPESlZ2OAkrLsZl7h1D64_nl2W_SXWAKH_tQjo0lSaSkdfbK5qRTWDwtx8VkpEBbGTlMXX9zTHw-Iu67OxiNKu5mtnTtWIaV7gjd-4TL42Ew-i-sHKH7SYsldL_IeSvovwEAAP__b2MQhA">