-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[Windows] Support microsoft intrinsics #13655
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It seems to me they can be implemented using inline asm. So, we can just provide header which might be automagically included when targeting vcpp ABI. |
One intrinsic that looks easy to implement hits me more often than others: $ cat return_address.cpp int main() { $ cl -nologo return_address.cpp >/dev/null && echo "OK" $ clang -Xclang -cxx-abi -Xclang microsoft return_address.cpp
|
http://llvm.org/bugs/show_bug.cgi?id=12074#c4 "The MS compiler provides its own <intrin.h> that includes a lot of other Some of them are provided by Clang built-in headers and they get picked up, but If those are relaxed, then the compiler errors later because some macros are I got a little farther with a custom <intrin.h> header based on the MinGW-w64 Need some feedback on how we want to proceed on this." I'd still like some feedback on this. I want to work on it since it's preventing simple things like #include from working. |
FYI, some intrinsics needed for <type_traits> header support in MSVC 2012 have landed in r178111. |
Looks like Warren has started working on this Based on the diff, I assumed _InterlockedExchangeAdd should work by now, but it doesn't: $ cat test.cpp int main() {
|
The result of building the #else clause doesn't change if I add #pragma instrnsic (_InterlockedExchangeAdd) |
#include <Intrin.h> returns 84 for me... I'm running with the visual studio integrated version of clang-cl (llvm-VS2012 toolchain). |
This does not compile with clang-cl.exe but it does using cl.exe: #include <Windows.h> void** Dest; int main(void) |
I updated Interin.h in http://llvm-reviews.chandlerc.com/D2600 by adding _ InterlockedCompareExchangePointer . Please review it and submit it if it's acceptable. |
These programs run successfully, and we have our own intrin.h. |
mentioned in issue llvm/llvm-bugzilla-archive#13707 |
Extended Description
E.g. _InterlockedDecrement http://msdn.microsoft.com/en-us/library/windows/desktop/f24ya7ct(v=vs.85).aspx
$ cat interlocked_decrement.c
#include <windows.h>
int main(void) {
LONG val = 1;
_InterlockedDecrement(&val);
return val != 0;
}
$ cl -nologo interlocked_decrement.c && interlocked_decrement.exe && echo "OK"
interlocked_decrement.c
OK
$ clang interlocked_decrement.c
interlocked_decrement.c:5:3: warning: implicit declaration of function '_InterlockedDecrement' is invalid in C99 [-Wimplicit-function-declaration]
_InterlockedDecrement(&val);
^
1 warning generated.
interlocked_decrement-199938.o : error LNK2019: unresolved external symbol __InterlockedDecrement referenced in function _main
a.out : fatal error LNK1120: 1 unresolved externals
clang: error: linker command failed with exit code 1120 (use -v to see invocation)
The text was updated successfully, but these errors were encountered: