[llvm-dev] `_m_prefetchw` type signature mismatch on Windows

Rickard Andersson via llvm-dev llvm-dev at lists.llvm.org
Thu Jun 11 06:15:29 PDT 2020


Hi,

I was compiling `sqlite3.c` via Zig a while ago and noticed a type 
mismatch between the Windows headers and the LLVM headers that Zig ships 
with.

The Windows header `mm3dnow.h` declares it as:

     void _m_prefetchw(volatile const void*_Source);

Whereas the LLVM header `clang\lib\Headers\prfchwintrin.h` declares:

     static __inline__ void __attribute__((__always_inline__, 
__nodebug__))
     _m_prefetchw(volatile const void *__P) {
       __builtin_prefetch (__P, 1, 3 /* _MM_HINT_T0 */);
     }

`__builtin_prefetch`, which `_m_prefetchw` is using, is defined as 
taking `const void*` at the moment.

The mismatch effectively causes the function to have two different 
signatures when compiling C source in Zig on Windows. The most direct 
change is to modify the shipped Zig headers, but it'd be interesting to 
see this fixed at the source.

Is there any major issue with `ifdef`ing a solution when using MSVC that 
anyone can see?

With regards,
Rickard Andersson



More information about the llvm-dev mailing list