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

    <tr>
        <th>Summary</th>
        <td>
            [DirectX] Implement Shader Flag Analysis for RequiresGroup
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            backend:DirectX
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          bharadwajy
      </td>
    </tr>
</table>

<pre>
    DXC sets the flag `m_bRequiresGroup` to indicate a function accesses group shared memory. It is set if any of the function instruction's type or operand type being a pointer into thread group shared memory - per [this](https://github.com/microsoft/DirectXShaderCompiler/blob/ac36a797d3470e8ee906b98457a59270d01db30d/lib/DXIL/DxilShaderFlags.cpp#L545) and [this](https://github.com/microsoft/DirectXShaderCompiler/blob/ac36a797d3470e8ee906b98457a59270d01db30d/lib/DXIL/DxilShaderFlags.cpp#L555).

1. Need to add `SHADER_FEATURE_FLAG(32, 40, RequiresGroup, "Function accesses thread group shared memory")` to `llvm/include/llvm/BinaryFormat/DXContainerConstants.def`.
2. Set `RequiresGroup` if any of the function instruction's type or operand type being a pointer into thread group shared memory.

Clarification needed: Does clang use a separate address space or some other mechanism to represent thread group shared memory?

AC:

Add tests to verify correctness of analysis.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUlM9u4zYQxp-GugxWkKg_tg46OFa0DRD0kLSAb8GIHFncSqTKodL67QvaXnSDbfdYoBfSJjTDmY-_b5DZnC1RK6oHUXUJbmFyvh0m9Kj_wC-XZHD60nanIzAFhjARjDOeQdTZ8ja80O-b8cSfvdtWUWcQHBirjcJAgDBuVgXjLKBSxEwM5_gh8ISeNCy0OH9J4SmA4ZgfzAhoL-DG20Vfw43l4LfrbyF3DOGyEjgPbiWPVt_-D2TsGRBWZ2wgD8YGB2HyhPqfroVPsJIHUT2EybCoOiH3Uwgri-IgZC9kfzZh2oZUuUXIfjHKO3ZjELLvjCcVTq8TavJHt6xmJi9kP8xuELJHVdS4a3a6KHcZ7YmarB6afVntsGrkLtNZroci00L2s4kB3enpOW5_mvmWs5_xzKlaVyGL56qshGwg9vk_KLaKxaYi60R2uK15Cj8T6YgGah3Bef3p0D2-vPWPh19-fXl8658Pn4XcF1LII5RZXD9yJY8gpOy_g-nfH1dIKWRzB1LU2Ty_R12MVfOmKfZyO3gwFv2ld37Bq1ano7MBjY1KWQ5oA6eaRlFn95ZkCq8UYsrv0P8P2f2g73FGb8ZouXidJdKkRXGAzhGDmtGeYePoRqYV_dWYWntiBl5RXWthtxC4MJGHhdSE1vASlfO0emKy4UdSF_231RyOEclvD7SGQBxnh4N38ma8gHI-QmljES7KhvOFDaeJbgvdFA0m1Oa7Iq_zal9WydSWUu_qOldFqbWiumn2pa7LUck9oRr2MjGtzGSZ53kZ96xKEaWWusrybKC8GnNRZrSgmdP48qnz58Qwb9TmeS13dTLjQDNfp6CUA6rfyEYR7-aJOFVd4tsY_GnYzizKbDYc-O90wYT5Oka_xlQdPC3rTEvU72YViF6Bw71dGJ3_SHqy-bn9ga_v1F6rWL37QipSe22Ehezvvby38q8AAAD__50e7Cs">