diff options
author | Nico Weber <nicolasweber@gmx.de> | 2015-07-02 01:10:03 +0000 |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2015-07-02 01:10:03 +0000 |
commit | 5e8af5dbfb9d7d043cf39a7d4e49a45e8c4d1569 (patch) | |
tree | a74af4b10173cde8180cb5dc97519ca4cc5f587e | |
parent | 54cfca3b4459e03fe782d6a4db03c48092928da2 (diff) | |
download | compiler-rt-5e8af5dbfb9d7d043cf39a7d4e49a45e8c4d1569.tar.gz |
Revert r241217, it breaks the build on Windows.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@241219 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | cmake/config-ix.cmake | 13 | ||||
-rw-r--r-- | lib/sanitizer_common/sanitizer_atomic_msvc.h | 36 | ||||
-rw-r--r-- | lib/sanitizer_common/sanitizer_common.h | 5 | ||||
-rw-r--r-- | lib/ubsan/ubsan_diag.cc | 4 | ||||
-rw-r--r-- | lib/ubsan/ubsan_flags.cc | 11 | ||||
-rw-r--r-- | lib/ubsan/ubsan_platform.h | 2 |
6 files changed, 23 insertions, 48 deletions
diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake index 7ba85f864..b6fe8ffb0 100644 --- a/cmake/config-ix.cmake +++ b/cmake/config-ix.cmake @@ -181,11 +181,7 @@ else() test_target_arch(i686 __i686__ "-m32") test_target_arch(i386 __i386__ "-m32") else() - if (CMAKE_SIZEOF_VOID_P EQUAL 4) - test_target_arch(i386 "" "") - else() - test_target_arch(x86_64 "" "") - endif() + test_target_arch(i386 "" "") endif() elseif("${LLVM_NATIVE_ARCH}" STREQUAL "PowerPC") TEST_BIG_ENDIAN(HOST_IS_BIG_ENDIAN) @@ -271,14 +267,13 @@ endif() if (SANITIZER_COMMON_SUPPORTED_ARCH AND NOT LLVM_USE_SANITIZER AND (OS_NAME MATCHES "Android|Darwin|Linux|FreeBSD" OR - (OS_NAME MATCHES "Windows" AND MSVC))) + (OS_NAME MATCHES "Windows" AND MSVC AND CMAKE_SIZEOF_VOID_P EQUAL 4))) set(COMPILER_RT_HAS_SANITIZER_COMMON TRUE) else() set(COMPILER_RT_HAS_SANITIZER_COMMON FALSE) endif() -if (COMPILER_RT_HAS_SANITIZER_COMMON AND ASAN_SUPPORTED_ARCH AND - (NOT OS_NAME MATCHES "Windows" OR CMAKE_SIZEOF_VOID_P EQUAL 4)) +if (COMPILER_RT_HAS_SANITIZER_COMMON AND ASAN_SUPPORTED_ARCH) set(COMPILER_RT_HAS_ASAN TRUE) else() set(COMPILER_RT_HAS_ASAN FALSE) @@ -328,7 +323,7 @@ else() endif() if (COMPILER_RT_HAS_SANITIZER_COMMON AND UBSAN_SUPPORTED_ARCH AND - OS_NAME MATCHES "Darwin|Linux|FreeBSD|Windows") + OS_NAME MATCHES "Darwin|Linux|FreeBSD") set(COMPILER_RT_HAS_UBSAN TRUE) else() set(COMPILER_RT_HAS_UBSAN FALSE) diff --git a/lib/sanitizer_common/sanitizer_atomic_msvc.h b/lib/sanitizer_common/sanitizer_atomic_msvc.h index 24d6f0f34..12ffef3ba 100644 --- a/lib/sanitizer_common/sanitizer_atomic_msvc.h +++ b/lib/sanitizer_common/sanitizer_atomic_msvc.h @@ -21,15 +21,6 @@ extern "C" void _mm_mfence(); #pragma intrinsic(_mm_mfence) extern "C" void _mm_pause(); #pragma intrinsic(_mm_pause) -extern "C" char _InterlockedExchange8( // NOLINT - char volatile *Addend, char Value); // NOLINT -#pragma intrinsic(_InterlockedExchange8) -extern "C" short _InterlockedExchange16( // NOLINT - short volatile *Addend, short Value); // NOLINT -#pragma intrinsic(_InterlockedExchange16) -extern "C" long _InterlockedExchange( // NOLINT - long volatile *Addend, long Value); // NOLINT -#pragma intrinsic(_InterlockedExchange) extern "C" long _InterlockedExchangeAdd( // NOLINT long volatile * Addend, long Value); // NOLINT #pragma intrinsic(_InterlockedExchangeAdd) @@ -154,25 +145,28 @@ INLINE u8 atomic_exchange(volatile atomic_uint8_t *a, u8 v, memory_order mo) { (void)mo; DCHECK(!((uptr)a % sizeof(*a))); - return (u8)_InterlockedExchange8((volatile char*)&a->val_dont_use, v); + __asm { + mov eax, a + mov cl, v + xchg [eax], cl // NOLINT + mov v, cl + } + return v; } INLINE u16 atomic_exchange(volatile atomic_uint16_t *a, u16 v, memory_order mo) { (void)mo; DCHECK(!((uptr)a % sizeof(*a))); - return (u16)_InterlockedExchange16((volatile short*)&a->val_dont_use, v); -} - -INLINE u32 atomic_exchange(volatile atomic_uint32_t *a, - u32 v, memory_order mo) { - (void)mo; - DCHECK(!((uptr)a % sizeof(*a))); - return (u32)_InterlockedExchange((volatile long*)&a->val_dont_use, v); + __asm { + mov eax, a + mov cx, v + xchg [eax], cx // NOLINT + mov v, cx + } + return v; } -#ifndef _WIN64 - INLINE bool atomic_compare_exchange_strong(volatile atomic_uint8_t *a, u8 *cmp, u8 xchgv, @@ -194,8 +188,6 @@ INLINE bool atomic_compare_exchange_strong(volatile atomic_uint8_t *a, return false; } -#endif - INLINE bool atomic_compare_exchange_strong(volatile atomic_uintptr_t *a, uptr *cmp, uptr xchg, diff --git a/lib/sanitizer_common/sanitizer_common.h b/lib/sanitizer_common/sanitizer_common.h index 263dfaf44..7ddedccb7 100644 --- a/lib/sanitizer_common/sanitizer_common.h +++ b/lib/sanitizer_common/sanitizer_common.h @@ -383,7 +383,7 @@ INLINE uptr RoundUpToPowerOfTwo(uptr size) { uptr up = MostSignificantSetBitIndex(size); CHECK(size < (1ULL << (up + 1))); CHECK(size > (1ULL << up)); - return 1ULL << (up + 1); + return 1UL << (up + 1); } INLINE uptr RoundUpTo(uptr size, uptr boundary) { @@ -659,7 +659,8 @@ void MaybeStartBackgroudThread(); // memset/memcpy/etc. static inline void SanitizerBreakOptimization(void *arg) { #if _MSC_VER - _ReadWriteBarrier(); + // FIXME: make sure this is actually enough. + __asm; #else __asm__ __volatile__("" : : "r" (arg) : "memory"); #endif diff --git a/lib/ubsan/ubsan_diag.cc b/lib/ubsan/ubsan_diag.cc index b14412217..a4c9e3046 100644 --- a/lib/ubsan/ubsan_diag.cc +++ b/lib/ubsan/ubsan_diag.cc @@ -186,11 +186,7 @@ static void renderText(const char *Message, const Diag::Arg *Args) { // FIXME: Support floating-point formatting in sanitizer_common's // printf, and stop using snprintf here. char Buffer[32]; -#if SANITIZER_WINDOWS - sprintf_s(Buffer, sizeof(Buffer), "%Lg", (long double)A.Float); -#else snprintf(Buffer, sizeof(Buffer), "%Lg", (long double)A.Float); -#endif Printf("%s", Buffer); break; } diff --git a/lib/ubsan/ubsan_flags.cc b/lib/ubsan/ubsan_flags.cc index 59d6c4a0a..eda7557a0 100644 --- a/lib/ubsan/ubsan_flags.cc +++ b/lib/ubsan/ubsan_flags.cc @@ -64,18 +64,11 @@ void InitializeFlags() { } // namespace __ubsan -extern "C" { - #if !SANITIZER_SUPPORTS_WEAK_HOOKS +extern "C" { SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE const char *__ubsan_default_options() { return ""; } -#endif - -#if SANITIZER_WINDOWS -const char *__ubsan_default_default_options() { return ""; } -#pragma comment(linker, "/alternatename:__ubsan_default_options=__ubsan_default_default_options") -#endif - } // extern "C" +#endif #endif // CAN_SANITIZE_UB diff --git a/lib/ubsan/ubsan_platform.h b/lib/ubsan/ubsan_platform.h index 002ecf32a..8ba253bfe 100644 --- a/lib/ubsan/ubsan_platform.h +++ b/lib/ubsan/ubsan_platform.h @@ -18,8 +18,6 @@ (defined(__x86_64__) || defined(__i386__) || defined(__arm__) || \ defined(__aarch64__) || defined(__mips__) || defined(__powerpc64__)) # define CAN_SANITIZE_UB 1 -#elif defined(_WIN32) -# define CAN_SANITIZE_UB 1 #else # define CAN_SANITIZE_UB 0 #endif |