[ARM] Support for ARMv6-Z / ARMv6-ZK missing
[oota-llvm.git] / include / llvm / Support / Recycler.h
index fa6e189e97bd063d6c2b17963d6a6b8f6bf1e4b6..e97f36a735fdf64ece518c5afac4200565b19dd6 100644 (file)
@@ -17,6 +17,7 @@
 
 #include "llvm/ADT/ilist.h"
 #include "llvm/Support/AlignOf.h"
+#include "llvm/Support/Allocator.h"
 #include "llvm/Support/ErrorHandling.h"
 #include <cassert>
 
@@ -87,12 +88,21 @@ public:
     }
   }
 
+  /// Special case for BumpPtrAllocator which has an empty Deallocate()
+  /// function.
+  ///
+  /// There is no need to traverse the free list, pulling all the objects into
+  /// cache.
+  void clear(BumpPtrAllocator&) {
+    FreeList.clearAndLeakNodesUnsafely();
+  }
+
   template<class SubClass, class AllocatorType>
   SubClass *Allocate(AllocatorType &Allocator) {
-    assert(sizeof(SubClass) <= Size &&
-           "Recycler allocation size is less than object size!");
-    assert(AlignOf<SubClass>::Alignment <= Align &&
-           "Recycler allocation alignment is less than object alignment!");
+    static_assert(AlignOf<SubClass>::Alignment <= Align,
+                  "Recycler allocation alignment is less than object align!");
+    static_assert(sizeof(SubClass) <= Size,
+                  "Recycler allocation size is less than object size!");
     return !FreeList.empty() ?
            reinterpret_cast<SubClass *>(FreeList.remove(FreeList.begin())) :
            static_cast<SubClass *>(Allocator.Allocate(Size, Align));