[PATCH] D20901: Remove all of the legacy home-grown atomic operations LLVM provided except for CompareAndSwap. That is the only one still being used anywhere now that statistics have been moved onto std::atomic.

Chandler Carruth via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 2 10:17:47 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL271540: Remove all of the legacy home-grown atomic operations LLVM provided (authored by chandlerc).

Changed prior to commit:
  http://reviews.llvm.org/D20901?vs=59351&id=59414#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20901

Files:
  llvm/trunk/include/llvm/Support/Atomic.h
  llvm/trunk/lib/Support/Atomic.cpp

Index: llvm/trunk/lib/Support/Atomic.cpp
===================================================================
--- llvm/trunk/lib/Support/Atomic.cpp
+++ llvm/trunk/lib/Support/Atomic.cpp
@@ -56,62 +56,3 @@
 #  error No compare-and-swap implementation for your platform!
 #endif
 }
-
-sys::cas_flag sys::AtomicIncrement(volatile sys::cas_flag* ptr) {
-#if LLVM_HAS_ATOMICS == 0
-  ++(*ptr);
-  return *ptr;
-#elif defined(GNU_ATOMICS)
-  return __sync_add_and_fetch(ptr, 1);
-#elif defined(_MSC_VER)
-  return InterlockedIncrement(ptr);
-#else
-#  error No atomic increment implementation for your platform!
-#endif
-}
-
-sys::cas_flag sys::AtomicDecrement(volatile sys::cas_flag* ptr) {
-#if LLVM_HAS_ATOMICS == 0
-  --(*ptr);
-  return *ptr;
-#elif defined(GNU_ATOMICS)
-  return __sync_sub_and_fetch(ptr, 1);
-#elif defined(_MSC_VER)
-  return InterlockedDecrement(ptr);
-#else
-#  error No atomic decrement implementation for your platform!
-#endif
-}
-
-sys::cas_flag sys::AtomicAdd(volatile sys::cas_flag* ptr, sys::cas_flag val) {
-#if LLVM_HAS_ATOMICS == 0
-  *ptr += val;
-  return *ptr;
-#elif defined(GNU_ATOMICS)
-  return __sync_add_and_fetch(ptr, val);
-#elif defined(_MSC_VER)
-  return InterlockedExchangeAdd(ptr, val) + val;
-#else
-#  error No atomic add implementation for your platform!
-#endif
-}
-
-sys::cas_flag sys::AtomicMul(volatile sys::cas_flag* ptr, sys::cas_flag val) {
-  sys::cas_flag original, result;
-  do {
-    original = *ptr;
-    result = original * val;
-  } while (sys::CompareAndSwap(ptr, result, original) != original);
-
-  return result;
-}
-
-sys::cas_flag sys::AtomicDiv(volatile sys::cas_flag* ptr, sys::cas_flag val) {
-  sys::cas_flag original, result;
-  do {
-    original = *ptr;
-    result = original / val;
-  } while (sys::CompareAndSwap(ptr, result, original) != original);
-
-  return result;
-}
Index: llvm/trunk/include/llvm/Support/Atomic.h
===================================================================
--- llvm/trunk/include/llvm/Support/Atomic.h
+++ llvm/trunk/include/llvm/Support/Atomic.h
@@ -9,6 +9,10 @@
 //
 // This file declares the llvm::sys atomic operations.
 //
+// DO NOT USE IN NEW CODE!
+//
+// New code should always rely on the std::atomic facilities in C++11.
+//
 //===----------------------------------------------------------------------===//
 
 #ifndef LLVM_SUPPORT_ATOMIC_H
@@ -28,11 +32,6 @@
     cas_flag CompareAndSwap(volatile cas_flag* ptr,
                             cas_flag new_value,
                             cas_flag old_value);
-    cas_flag AtomicIncrement(volatile cas_flag* ptr);
-    cas_flag AtomicDecrement(volatile cas_flag* ptr);
-    cas_flag AtomicAdd(volatile cas_flag* ptr, cas_flag val);
-    cas_flag AtomicMul(volatile cas_flag* ptr, cas_flag val);
-    cas_flag AtomicDiv(volatile cas_flag* ptr, cas_flag val);
   }
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20901.59414.patch
Type: text/x-patch
Size: 2843 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160602/26f4072b/attachment.bin>


More information about the llvm-commits mailing list