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

    <tr>
        <th>Summary</th>
        <td>
            [DirectX] dx.rootsignatures metadata is left around, causing validation failure
        </td>
    </tr>

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

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

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

<pre>
    Currently, the `dx.rootsignatures` metadata is never removed. This causes us to emit it into the DXIL module, which then fails validation (ie, `dxv`) because DXIL doesn't have such metadata.

To fix this, we should make the `DXILPrepare` pass depend on root and preserve root signature analysis to ensure that the analysis runs early enough, and then have that same pass do something to the effect of:
```c++
    if (NamedMDNode *RootSignature = M.getNamedMetadata("dx.rootsignatures"))
 RootSignature->eraseFromParent();
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJxkU01v6zYQ_DXUZRGBIS3bOujgPNdAgb6HoM0h15W4EtlQpMEPNf73BWXHL0GABQSI3NmZ2SHGaCZH1LHmiTXHCnPSPnS9nxyFqvfq0v3IIZBL9sLED0iagG25eq-D96n0YsqBIttymCmhwoRgIjhaKECg2S-kanjRJsKAOVKEHCF5oNkkKOWSX1GPr3_-BbNX2VIZ9J82gy4HDkY0NsKC1ihMxjtgYm_WSyuThW05Ey30tA64AilP0TGxS6BxIYh50Hd-NeMHxg8vHkbzDkmbuA4kiNpnq2DGN_oQWsCeA50xUJF4xhhB0ZmcAu-geADoFJwDRQoLXf_cbQF0aC_RXBW7WH4ljWlFv5-F7CIQBnsBcj5PutApqKv6lf_aFHGmGwMP0c-UtHET3PyjcaQhgR-ZLOqKKWsNTDyV4gcAADMW937hTOrn8ZdXBEwc_vY-_XPnzOQRftYTpeutm2lM7JkQ3_cuBBNtKX6ALzgPTP5BASOdgp-fsURoxWiZfPrMr1KdVK1ssaLucdfwnRCc7yrd9e1IAoVE2cod9u2jIqlErxTHfi-JV6YTXDR8K6SQG8539Z7UljdcEaKUyBu24TSjsbW1y1z7MFUmxkzd46bZyF1lsScb1-QL0ePwRk4xeTiaQEN6LcqaYxW60vzQ5ymyDbcmpvgbLplk16fz0dMc4ZtFX96FpTEBBp-dKlsuiS07_BTukvYcqMrBdjqlcyz7FCcmTpNJOvf14GcmToXD7fNwDv5fGhITp1VfZOJ0k7h04v8AAAD__1o8SKs">