14#ifndef LLVM_SUPPORT_RECYCLER_H
15#define LLVM_SUPPORT_RECYCLER_H
35template <
class T,
size_t Size = sizeof(T),
size_t Align = alignof(T)>
42 FreeNode *FreeList =
nullptr;
47 FreeList = FreeList->Next;
52 void push(FreeNode *
N) {
63 assert(!FreeList &&
"Non-empty recycler deleted!");
67 : FreeList(
std::exchange(
Other.FreeList, nullptr)) {}
73 template<
class AllocatorType>
76 T *t =
reinterpret_cast<T *
>(pop_val());
88 template<
class SubClass,
class AllocatorType>
90 static_assert(
alignof(SubClass) <=
Align,
91 "Recycler allocation alignment is less than object align!");
92 static_assert(
sizeof(SubClass) <=
Size,
93 "Recycler allocation size is less than object size!");
94 static_assert(
Size >=
sizeof(FreeNode) &&
95 "Recycler allocation size must be at least sizeof(FreeNode)");
96 return FreeList ?
reinterpret_cast<SubClass *
>(pop_val())
100 template<
class AllocatorType>
105 template<
class SubClass,
class AllocatorType>
107 push(
reinterpret_cast<FreeNode *
>(Element));
113template <
class T,
size_t Size,
size_t Align>
116 for (
auto *
I = FreeList;
I;
I =
I->Next)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the BumpPtrAllocator interface.
#define __asan_poison_memory_region(p, size)
#define __asan_unpoison_memory_region(p, size)
#define __msan_allocated_memory(p, size)
void clear(BumpPtrAllocator &)
Special case for BumpPtrAllocator which has an empty Deallocate() function.
void clear(AllocatorType &Allocator)
clear - Release all the tracked allocations to the allocator.
Recycler(Recycler &&Other)
void Deallocate(AllocatorType &, SubClass *Element)
Recycler(const Recycler &)=delete
SubClass * Allocate(AllocatorType &Allocator)
T * Allocate(AllocatorType &Allocator)
This file defines classes to implement an intrusive doubly linked list class (i.e.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI void PrintRecyclerStats(size_t Size, size_t Align, size_t FreeListSize)
PrintRecyclingAllocatorStats - Helper for RecyclingAllocator for printing statistics.
BumpPtrAllocatorImpl BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
FunctionAddr VTableAddr Next
Implement std::hash so that hash_code can be used in STL containers.
This struct is a compact representation of a valid (non-zero power of two) alignment.