<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/132980>132980</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [HLSL] Add resource variable names to resource metadata and binding table
        </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>
    Clang is not preserving the resource variable names between the source code and the DXIL resource metadata. This information is needed to generate resource binding table with resource names so that users can identify the resource bindings (if implicit).

It would be also useful for diagnostic, such as overlapping resource bindings, which looks like will need to be done in the LLVM backend after unused resources are eliminated.

```
RWBuffer<float4> A : register(u0);
RWBuffer<float4> B : register(u1);

[numthreads(4,1,1)]
void main() {
    A[0] = B[0];
}
```
DXC:

```
; Resource Bindings:
;
; Name Type  Format         Dim      ID      HLSL Bind  Count
; ------------------------------ ---------- ------- ----------- ------- -------------- ------
; A                                     UAV     f32 buf      U0             u0     1
; B UAV     f32         buf      U1             u1     1
...
!dx.resources = !{!33}
!33 = !{null, !34, null, null}
!34 = !{!35, !37}
!35 = !{i32 0, %"class.RWBuffer<vector<float, 4> >"* undef, !"A", i32 0, i32 0, i32 1, i32 10, i1 false, i1 false, i1 false, !36}
!36 = !{i32 0, i32 9}
!37 = !{i32 1, %"class.RWBuffer<vector<float, 4> >"* undef, !"B", i32 0, i32 1, i32 1, i32 10, i1 false, i1 false, i1 false, !36}
```

Clang:
```
; Resource Bindings:
;
; Name                                 Type  Format Dim      ID      HLSL Bind     Count
; ------------------------------ ---------- ------- ----------- ------- -------------- ---------
; UAV     f32         buf      U0             u0 1
;                                       UAV     f32         buf U1             u1         1
...
!dx.resources = !{!44}
!44 = !{null, !45, null, null}
!45 = !{!46, !48}
!46 = !{i32 0, ptr @0, !"", i32 0, i32 0, i32 1, i32 10, i1 false, i1 false, i1 false, !47}
!47 = !{i32 0, i32 9}
!48 = !{i32 1, ptr @1, !"", i32 0, i32 1, i32 1, i32 10, i1 false, i1 false, i1 false, !47}
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy8Vk-T4rYT_TTi0rWU_tiADxwMXuq3VfPLYbPZ7FW22lgZWaIkmcl8-5SNwcPATDbJJipTasv9Xndb_YxkCHpvEdck3ZC0mMkuNs6vG3x0Uc5Kp57XWyPtHnQA6yIcPAb0R233EBsEj8F1vkI4Sq9laRCsbDFAifEJ0Q4-o0flFIK0algrvn16mMAtRqlklHP40ugA2tbOtzJqZ4ewiAoVRAd7tOhlfBG21FYNuQyxn3RspmenTIKD2MgIXUAfoJIWtEIbdf18XcDIFIDwla5BtwejKx0Jz-aE5oTmnyI8uc4oKBGkCa5nrDsDtfOgtNxbF6KuCN9C6KoGZAB3RG_k4dAneBOnd3xqdNWAce4xgNGPfQHGDPX21ZYIylkEfXqNDw9f_w-lrB7RKpB1RA-d7QKqC3cA6RHQ6FZbGVGNiZMFHS-af_5109U1eiK2tXEyJkR8hByIyMHjXoeInvBVRwnPiNi8BdjcANgF0F_pxnZtbDxKFQhfJYRv2emXkbQgND86raCV2hK-IjwDsuyhAAA9mJK0ACIK2Iw3I_OyeFVN8W1LRH5bJREb-Hx-4ZvzCz95nqjEBn6SLcKX5wMC7IZ2g_ModHsyPhWn-X8PPz8MPABb19k4Mnx4d8CtCXcew13UGCGH7xm_5F-HuRYcyq4eF-mVT3e6ZSPx5gp0HhOYXYPZBTyfD13Fmfp9PvVdv1mEs34bORNi3KnefPHIdsb0Xd-v9y0B54VhvkCSV2zpGbOcfNIXPlpwoCeflHBeGRnC_EXbHrGK7tK_vePQw0R8JJwTnkNnFdZjEMJ5Pixv4cJ7ZbCLcVpiUEsT8D27T3gx5b64l3tvZJPP8pUP-4H1be7Vx35QfS9FSPPhn2PU3d-S55-NK_m-J1v4z5Q7ifd9hd3I8yzN7xtvkd9X7l9Qb5Jc2jBJ7qs3Sd9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