Index: cmake/config-ix.cmake
===================================================================
--- cmake/config-ix.cmake	(revision 82253)
+++ cmake/config-ix.cmake	(working copy)
@@ -77,8 +77,12 @@
   add_llvm_definitions( -D_GNU_SOURCE )
 endif()
 
-# Define LLVM_MULTITHREADED if gcc atomic builtins exists.
-include(CheckAtomic)
+if( MSVC )
+  set( LLVM_MULTITHREADED 1 )
+else( MSVC )
+  # Define LLVM_MULTITHREADED if gcc atomic builtins exists.
+  include(CheckAtomic)
+endif( MSVC )
 
 include(CheckCXXCompilerFlag)
 # On windows all code is position-independent and mingw warns if -fPIC
Index: include/llvm/System/Atomic.h
===================================================================
--- include/llvm/System/Atomic.h	(revision 82253)
+++ include/llvm/System/Atomic.h	(working copy)
@@ -20,7 +20,12 @@
   namespace sys {
     void MemoryFence();
 
+#if defined(__GNUC__)
     typedef uint32_t cas_flag;
+#else
+    // for MSVC
+    typedef long cas_flag;
+#endif
     cas_flag CompareAndSwap(volatile cas_flag* ptr,
                             cas_flag new_value,
                             cas_flag old_value);
Index: lib/System/Atomic.cpp
===================================================================
--- lib/System/Atomic.cpp	(revision 82253)
+++ lib/System/Atomic.cpp	(working copy)
@@ -19,6 +19,11 @@
 #if defined(_MSC_VER)
 #include <windows.h>
 #undef MemoryFence
+#include <intrin.h>
+#pragma intrinsic (_InterlockedDecrement)
+#pragma intrinsic (_InterlockedIncrement)
+#pragma intrinsic (_InterlockedCompareExchange)
+#pragma intrinsic (_InterlockedExchangeAdd)
 #endif
 
 void sys::MemoryFence() {
@@ -46,7 +51,7 @@
 #elif defined(__GNUC__)
   return __sync_val_compare_and_swap(ptr, old_value, new_value);
 #elif defined(_MSC_VER)
-  return InterlockedCompareExchange(ptr, new_value, old_value);
+  return _InterlockedCompareExchange(ptr, new_value, old_value);
 #else
 #  error No compare-and-swap implementation for your platform!
 #endif
@@ -59,7 +64,7 @@
 #elif defined(__GNUC__)
   return __sync_add_and_fetch(ptr, 1);
 #elif defined(_MSC_VER)
-  return InterlockedIncrement(ptr);
+  return _InterlockedIncrement(ptr);
 #else
 #  error No atomic increment implementation for your platform!
 #endif
@@ -72,7 +77,7 @@
 #elif defined(__GNUC__)
   return __sync_sub_and_fetch(ptr, 1);
 #elif defined(_MSC_VER)
-  return InterlockedDecrement(ptr);
+  return _InterlockedDecrement(ptr);
 #else
 #  error No atomic decrement implementation for your platform!
 #endif
@@ -85,7 +90,11 @@
 #elif defined(__GNUC__)
   return __sync_add_and_fetch(ptr, val);
 #elif defined(_MSC_VER)
-  return InterlockedAdd(ptr, val);
+  // MSVC does not have intrisic for this...
+  // could/should be replaced by assembly
+  // this operation is only used for statistic, so the performance
+  // impact should be minimal
+  return _InterlockedExchangeAdd(ptr, val)+val;
 #else
 #  error No atomic add implementation for your platform!
 #endif
