<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/95133>95133</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
_xend() declaration in intrin.h may cause function multiversioning error on Windows
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
stampho
</td>
</tr>
</table>
<pre>
This is a simplified example to reproduce the issue:
```
#include <immintrin.h>
#pragma clang attribute push(__attribute__((target("avx"))), apply_to=function)
#include <atomic>
#pragma clang attribute pop
int main()
{
return 0;
}
```
Build the example with:
`clang-cl.exe /c main.cpp /Fomain.obj /nologo /std:c++20`
or
`clang-cl.exe /c main.cpp /Fomain.obj /nologo -D__RTM__`
The result is:
```
In file included from main.cpp:1:
In file included from C:\tools\LLVM-18.1.6\lib\clang\18\include\immintrin.h:603:
C:\tools\LLVM-18.1.6\lib\clang\18\include\rtmintrin.h(36,1): error: attribute 'target' multiversioning cannot be combined with attribute 'always_inline'
36 | _xend(void)
| ^
C:\tools\LLVM-18.1.6\lib\clang\18\include\intrin.h(167,6): note: function multiversioning caused by this declaration
167 | void _xend(void);
| ^
1 error generated.
```
I reproduce this with:
```
clang version 18.1.6
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Tools\LLVM-18.1.6\bin
```
and
```
Visual Studio Community 2022
17.10.1
```
The example is artificial, I have the same issue when building skia ( https://github.com/google/skia ) with clang-cl and c++20 enabled.
I'm not absolutely sure if this is really a clang issue but it seems reasonable to me to push attributes before including a header which declares a set of functions which also happen to use standard library functions.
Does the declaration of `_xend()` in intrin.h really necessary if the intrinsics are enabled?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVs-v2jgQ_mvMZQRKHBLCgQOEIj2pvew-dY_IiQcyXceObAce__3K-QG0pT1sn1CeHY_HM9988znCOTprxA1Ldyzdz0Tna2M3zoumrc2s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