15 #ifndef LLVM_SUPPORT_RECYCLER_H
16 #define LLVM_SUPPORT_RECYCLER_H
57 llvm_unreachable(
"Recycler's ilist_traits shouldn't see a deleteNode call!");
65 template<class T, size_t Size = sizeof(T), size_t Align = AlignOf<T>::Alignment>
77 assert(FreeList.empty() &&
"Non-empty recycler deleted!");
83 template<
class AllocatorType>
84 void clear(AllocatorType &Allocator) {
85 while (!FreeList.empty()) {
86 T *t =
reinterpret_cast<T *
>(FreeList.remove(FreeList.begin()));
87 Allocator.Deallocate(t);
97 FreeList.clearAndLeakNodesUnsafely();
100 template<
class SubClass,
class AllocatorType>
103 "Recycler allocation alignment is less than object align!");
104 static_assert(
sizeof(SubClass) <= Size,
105 "Recycler allocation size is less than object size!");
106 return !FreeList.empty() ?
107 reinterpret_cast<SubClass *
>(FreeList.remove(FreeList.begin())) :
108 static_cast<SubClass *
>(Allocator.Allocate(Size,
Align));
111 template<
class AllocatorType>
113 return Allocate<T>(Allocator);
116 template<
class SubClass,
class AllocatorType>
118 FreeList.push_front(reinterpret_cast<RecyclerStruct *>(Element));
AlignOf - A templated class that contains an enum value representing the alignment of the template ar...
void PrintRecyclerStats(size_t Size, size_t Align, size_t FreeListSize)
PrintRecyclingAllocatorStats - Helper for RecyclingAllocator for printing statistics.
static RecyclerStruct * getNext(const RecyclerStruct *t)
static void setNext(RecyclerStruct *t, RecyclerStruct *n)
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
void clear(BumpPtrAllocator &)
Special case for BumpPtrAllocator which has an empty Deallocate() function.
static void setPrev(RecyclerStruct *t, RecyclerStruct *p)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static void destroySentinel(RecyclerStruct *)
ilist_default_traits - Default template traits for intrusive list.
static RecyclerStruct * getPrev(const RecyclerStruct *t)
SubClass * Allocate(AllocatorType &Allocator)
static void deleteNode(RecyclerStruct *)
Allocate memory in an ever growing pool, as if by bump-pointer.
iplist - The subset of list functionality that can safely be used on nodes of polymorphic types...
RecyclerStruct * provideInitialHead() const
T * Allocate(AllocatorType &Allocator)
Recycler - This class manages a linked-list of deallocated nodes and facilitates reusing deallocated ...
static cl::opt< AlignMode > Align(cl::desc("Load/store alignment support"), cl::Hidden, cl::init(NoStrictAlign), cl::values(clEnumValN(StrictAlign,"aarch64-strict-align","Disallow all unaligned memory accesses"), clEnumValN(NoStrictAlign,"aarch64-no-strict-align","Allow unaligned memory accesses"), clEnumValEnd))
RecyclerStruct * ensureHead(RecyclerStruct *) const
RecyclerStruct * createSentinel() const
void Deallocate(AllocatorType &, SubClass *Element)
static NodeTy * createSentinel()
createSentinel - create the dynamic sentinel
void clear(AllocatorType &Allocator)
clear - Release all the tracked allocations to the allocator.
RecyclerStruct - Implementation detail for Recycler.
static void noteHead(RecyclerStruct *, RecyclerStruct *)