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

    <tr>
        <th>Summary</th>
        <td>
            [HLSL] Generate unique key object for resource handles
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
            V-FEXrt
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          V-FEXrt
      </td>
    </tr>
</table>

<pre>
    Late stage analysis such as #114130 require the ability to decern if handles are referencing the same resource. Infrastructure should be added to generate a value/key that is unique per resource given a `llvm::Value` to the ident.


Tex's notes:
 - optionally drill through an AnnotateHandle (depending on shader target)
 - value should be a CreateHandle of one kind or another.  There are four types, depending on target and whether it's a dynamic resource.
   - `CreateHandle` - bound resource on non-lib SM 6.5 and below:
use `resourceClass`, `rangeId` (index into metadata for the resource range), and the `index` to uniquely identify as a bound resource.
   - `CreateHandleFromBinding` - bound resource on non-lib SM 6.6 and above:
Use `resbind` and `index` to uniquely identify as a bound resource.
   - `CreateHandleFromHeap` - dynamic resource or sampler from heap (SM 6.6+):
Use `samplerHeap` to determine whether sampler or other resource
Use `index` value to uniquely identify resource.
   - `CreateHandleForLib` - create handle for library targets  
Use input `obj` loaded from global variable to uniquely identify resource (GV may be indexed with GEP)

In each case, `index` may be dynamic, in which case, if it's not the same `Value*`, you can't tell if it's the same resource as another value. For `CreateHandleForLib` the potential GEP from GV may have the dynamic index, so the combination of the GV and GEP indices are the key.  There is also the `nonUniformIndex` flag which might require some special consideration.

AC:
 - Unit tests verify that same resource handles map to an identical key while different handles don't. 
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJysVU1v2zgQ_TX0ZWBDpmzZPvjgpnUaIAss0DbY60gcSWwpUiUpp_r3i6FkJ81u0T0sYMAAxXl8780XhqAbS3QU23dCyqfl-cNfPgopxfb9AofYOn-cDxelU-PxESNBiNgQoEUzBh0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