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

    <tr>
        <th>Summary</th>
        <td>
            [SPIR-V] Set non-kernel function linkage type via OpDecorate for all linkage types except for static functions
        </td>
    </tr>

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

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

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

<pre>
    Now SPIR-V Backend generates linkage type declaration via OpDecorate only for external and linkonce_odr linkage types. This makes it impossible to use, for example, `extern_weak` functions. The following example would crash:

```
define i32 @abs(i32 noundef %x) {
entry:
  %call = tail call spir_func i32 @__devicelib_abs(i32 noundef %x) #11
  ret i32 %call
}

declare extern_weak i32 @__devicelib_abs(i32 noundef)
```

We should fix the behaviour, probably in a way that corresponds to Khronos SPIRV Translator that sets non-kernel function linkage type via OpDecorate for all linkage types except for static functions.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0U0GL8zYQ_TXyZUiw5TiODz50GwKlpS39lu0xjKVxrEaRjEZO4n9fbCfb3bKUXj4wMoPmPc28eYPM5uSIalG8CCnfRlQdscXrL3QdI5_HUUgpin2CQ-x8qL9ISBqvx_pXf4Nvv__0x-oNXlCdyWk4kaOAkRiscWc8EcSxJ9CkLAaMxju4GoTf-j0pPyWCd3aE1gege6Tg0AI6PaO9U3T0Onyi4jW8dobhgmdiMBHMpffMprEE0cPAJOSPDz689HYOxTZd2I83wrPYptAOTk3VzHQErbfW34w7PVFw84PVoAJyJ_IfRLoX6fPcpo9vDjW1xhGYXILYpNiwkLspcH5wmloQsrgLWYEoXxYAuRjGd06YEhRaCyLfQ0RjYY64N-E4VflkPh41XY0ia5rjf7wi8yx7MgeKC3p54VF-uf_YzTIZgg_6_K8Xhay-lGM5_yTgblawNXeIHUFDHV6NH8I0jz74Bhs7gnGAcMMRYocRlA-BuPdO8zTLn7vgnefZYm_wGtCxxejDkswUGZx3qzMFR_Z9op-N9y-zTb6Y1P3kKKC7oj7OlxwxGvXBHomuc13lFSZUZ2VWyK2sql3S1WW7K9OiLPSuqlSpyrIssrLVG5JUbTKVJaaWqdykRVplebHNd-t2V1RKF1mT01buKi02KV3Q2LW118vah1NimAeqq6yoisRiQ5YfO-roBvPlYzNDPWFWzXBisUmt4cj_sEQT7bzcy26KYg_fKH5_rZIh2LqLsefJ3fIg5OFkYjc0a-UvQh6mAh-_VR_8X6SikIe5LRbyMLf9dwAAAP__BwyFtw">