<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/137868>137868</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[HLSL] Report diagnostics for implicit resource bindings that cannot be assigned
</td>
</tr>
<tr>
<th>Labels</th>
<td>
HLSL
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
hekota
</td>
</tr>
</table>
<pre>
Report diagnostics for implicit resource bindings that cannot be assigned, such as:
```
RWBuffer<float> A : register(u1);
RWBuffer<float> B[]; // gets u6 (unbounded range)
RWBuffer<float> C : register(u5);
RWBuffer<float> D[4]; // error - does not fit in the remaining descriptor ranges in space0
[numthreads(4,1,1)]
void main() {
A[0] = D[2][0] + C[0] + B[10][0];
}
```
https://godbolt.org/z/6bYoG599P
Expected:
```<source>:4:1: error: resource D could not be allocated```
The error should be reported from `DXILPostOptimizationValidation` pass which can take the time and can depend on all completed resource analyses and/or debug info to lookup the resource variable name.
Implicit bindings are assigned by the `DXILResourceImplicitBinding` pass fairly early in the LLVM pipeline. It replaces `dx.resource.handlefromimplicitbinding` calls with `dx.resource.handlefrombinding` calls for all resources that can be allocated (= assigned a binding).
If a binding cannot be assigned, the pass will leave the `dx.resource.handlefromimplicitbinding` call associated with the resource in the IR to be picked up by the `DXILPostOptimizationValidation` pass for diagnostic. If there are no such resources (= all resources have binding), the `DXILResourceImplicitBinding` pass clear the `ContainsImplicitBindings` flag on `DXILResourceBindingAnalysis`.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJysVVlv4zYQ_jX0yyCGTB22HvTgI24DpOgiLbbtI0WOJDY0KZBUdrO_vhgd8Sa7KbZADfkiZr6Z75uDIgTdWsSK5QeWn1ZiiJ3zVYePLopV7dRz9YC98xGUFq11IWoZoHEe9KU3WuoIHoMbvESotVXatgFiJyJIYa2LUCPMMRTjRwiD7EAElu5ZMj5FMj_J_uGPw9A06Fl6bIwTk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