diff options
| author | Xinliang David Li <davidxl@google.com> | 2015-12-09 22:46:49 +0000 |
|---|---|---|
| committer | Xinliang David Li <davidxl@google.com> | 2015-12-09 22:46:49 +0000 |
| commit | bf56c0a5124254edfb2cdee4aa44b2eda058b99e (patch) | |
| tree | 4f420c1debf549756aa444d160d12de86f9e9bb7 /compiler-rt | |
| parent | 3d9f89f04f18af17592cb8df181d697702a261ba (diff) | |
| download | bcm5719-llvm-bf56c0a5124254edfb2cdee4aa44b2eda058b99e.tar.gz bcm5719-llvm-bf56c0a5124254edfb2cdee4aa44b2eda058b99e.zip | |
[PGO] Add cmake check to determine atomics op availability
This allows the profile runtime to pick the right impl
for cmp&swap for a given target.
Differential Revision: http://reviews.llvm.org/D15248
llvm-svn: 255173
Diffstat (limited to 'compiler-rt')
| -rw-r--r-- | compiler-rt/lib/profile/CMakeLists.txt | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/compiler-rt/lib/profile/CMakeLists.txt b/compiler-rt/lib/profile/CMakeLists.txt index 0da9e0147eb..0e726d83b01 100644 --- a/compiler-rt/lib/profile/CMakeLists.txt +++ b/compiler-rt/lib/profile/CMakeLists.txt @@ -1,3 +1,27 @@ + +CHECK_CXX_SOURCE_COMPILES(" +#ifdef _MSC_VER +#include <Intrin.h> /* Workaround for PR19898. */ +#include <windows.h> +#endif +int main() { +#ifdef _MSC_VER + volatile LONG val = 1; + MemoryBarrier(); + InterlockedCompareExchange(&val, 0, 1); + InterlockedIncrement(&val); + InterlockedDecrement(&val); +#else + volatile unsigned long val = 1; + __sync_synchronize(); + __sync_val_compare_and_swap(&val, 1, 0); + __sync_add_and_fetch(&val, 1); + __sync_sub_and_fetch(&val, 1); +#endif + return 0; + } +" COMPILER_RT_TARGET_HAS_ATOMICS) + add_custom_target(profile) set(PROFILE_SOURCES @@ -21,6 +45,12 @@ else() -fPIC) endif() +if(COMPILER_RT_TARGET_HAS_ATOMICS) + set(EXTRA_FLAGS + ${EXTRA_FLAGS} + -DCOMPILER_RT_HAS_ATOMICS=1) +endif() + if(APPLE) add_compiler_rt_runtime(clang_rt.profile STATIC |

