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

    <tr>
        <th>Summary</th>
        <td>
            [SPIRV] The clang-dxc enables SPV extension not allowed in Vulkan
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            HLSL,
            backend:SPIR-V
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
            s-perron
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          s-perron
      </td>
    </tr>
</table>

<pre>
    When the `-fspv-extension` is not on the command line it is suppose to enable "all" SPIR-V extensions. This is implemented in Clang by passing the `-spv-ext=all` to the SPIR-V backend. In the DXC context, this did not require any qualifications because if an extension was not used in Vulkan, it was not part of the compiler. However, the SPIR-V backend in Clang generates code for OpenCL as well, and uses extensions that are not allowed in Vulkan.

See https://godbolt.org/z/E1484Pqan for an example. The SPV_KHR_no_integer_wrap_decoration extension is generated, but it is not legal.

```
RWBuffer<int> sb;

[numthreads(1,1,1)]
void main() {
 sb[0] = -sb[1];
}
```

This needs to be fixed. I see two options based on whose responsibility it is to limit "all" extensions to just those allowed in Vulkan.

1. The SPIR-V backend will have two list for the SPIRVExtensionMap. 

</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJx0VF1v6zYM_TXMC5FAlu2kfvBDPhr0Yh120Q69ewskm451ryy5kpy0-_WDHKfNig1IYNgSD88hDym8V0dDVEK-Ac79vCfnrAHOId_NxBBa68rr15m09Xv5oyWDoSWEJZs3vj_N6S2Q8coaWDJUHo0NaC93Ktt1wtSolSFUIZ76oe-tJwwWyQipCYFzoTVwjs_fvz3NX_AD0C_wz1b5GKa6XlNHJlCNyuBWC3NE-Y59lGCOH4wmQpDuIuaSxTzxbIKWovpFpl7gtwvB3V9brKwJMYRvMcRstapHDY5eB-UIhXnH10Fo1ahKhEgLJVVi8ISqQWE--eJZXOQP_kLzZdC_hInIKnwc9sIFtM21QL3S5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