LLVM API Documentation
Allocate memory in an ever growing pool, as if by bump-pointer. More...
#include <Allocator.h>
Public Member Functions | |
static_assert (SizeThreshold<=SlabSize,"The SizeThreshold must be at most the SlabSize to ensure ""that objects larger than a slab go into their own memory ""allocation.") | |
BumpPtrAllocatorImpl () | |
template<typename T > | |
BumpPtrAllocatorImpl (T &&Allocator) | |
BumpPtrAllocatorImpl (BumpPtrAllocatorImpl &&Old) | |
~BumpPtrAllocatorImpl () | |
BumpPtrAllocatorImpl & | operator= (BumpPtrAllocatorImpl &&RHS) |
void | Reset () |
Deallocate all but the current slab and reset the current pointer to the beginning of it, freeing all memory allocated so far. | |
LLVM_ATTRIBUTE_RETURNS_NONNULL void * | Allocate (size_t Size, size_t Alignment) |
Allocate space at the specified alignment. | |
void | Deallocate (const void *, size_t) |
Deallocate Ptr to Size bytes of memory allocated by this allocator. | |
size_t | GetNumSlabs () const |
size_t | getTotalMemory () const |
void | PrintStats () const |
Friends | |
class | SpecificBumpPtrAllocator |
Allocate memory in an ever growing pool, as if by bump-pointer.
This isn't strictly a bump-pointer allocator as it uses backing slabs of memory rather than relying on boundless contiguous heap. However, it has bump-pointer semantics in that is a monotonically growing pool of memory where every allocation is found by merely allocating the next N bytes in the slab, or the next N bytes in the next slab.
Note that this also has a threshold for forcing allocations above a certain size into their own slab.
The BumpPtrAllocatorImpl template defaults to using a MallocAllocator object, which wraps malloc, to allocate memory, but it can be changed to use a custom allocator.
Definition at line 135 of file Allocator.h.
llvm::BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold >::BumpPtrAllocatorImpl | ( | ) | [inline] |
Definition at line 144 of file Allocator.h.
llvm::BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold >::BumpPtrAllocatorImpl | ( | T && | Allocator | ) | [inline] |
Definition at line 147 of file Allocator.h.
llvm::BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold >::BumpPtrAllocatorImpl | ( | BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold > && | Old | ) | [inline] |
Definition at line 153 of file Allocator.h.
llvm::BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold >::~BumpPtrAllocatorImpl | ( | ) | [inline] |
Definition at line 164 of file Allocator.h.
References llvm::SmallVectorTemplateCommon< T, typename >::begin(), and llvm::SmallVectorTemplateCommon< T, typename >::end().
LLVM_ATTRIBUTE_RETURNS_NONNULL void* llvm::BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold >::Allocate | ( | size_t | Size, |
size_t | Alignment | ||
) | [inline] |
Allocate space at the specified alignment.
Reimplemented from llvm::AllocatorBase< BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold > >.
Definition at line 206 of file Allocator.h.
References __msan_allocated_memory, llvm::alignAddr(), llvm::alignmentAdjustment(), and llvm::SmallVectorTemplateBase< T, isPodLike >::push_back().
Referenced by llvm::SpecificBumpPtrAllocator< SCC >::Allocate(), llvm::MCContext::Allocate(), llvm::MachineFunction::allocateMemRefsArray(), llvm::MachineFunction::allocateRegisterMask(), llvm::SSAUpdaterImpl< UpdaterT >::BuildBlockList(), llvm::ImmutableListFactory< T >::concat(), llvm::ImutAVLFactory< ImutInfo >::createNode(), llvm::ScalarEvolution::getAddExpr(), llvm::ScalarEvolution::getAddRecExpr(), llvm::SelectionDAG::getAtomic(), llvm::MachineFunction::getInfo(), llvm::SelectionDAG::getMachineNode(), llvm::ScalarEvolution::getMulExpr(), llvm::ScalarEvolution::getSMaxExpr(), llvm::ScalarEvolution::getUMaxExpr(), llvm::SelectionDAG::getVectorShuffle(), llvm::SelectionDAG::getVTList(), llvm::FoldingSetNodeID::Intern(), llvm::SelectionDAG::MorphNodeTo(), llvm::yaml::Node::operator new(), and llvm::StructType::setBody().
void llvm::BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold >::Deallocate | ( | const void * | Ptr, |
size_t | Size | ||
) | [inline] |
Deallocate Ptr to Size bytes of memory allocated by this allocator.
Reimplemented from llvm::AllocatorBase< BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold > >.
Definition at line 253 of file Allocator.h.
Referenced by llvm::MachineFunction::~MachineFunction().
size_t llvm::BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold >::GetNumSlabs | ( | ) | const [inline] |
Definition at line 258 of file Allocator.h.
References llvm::SmallVectorTemplateCommon< T, typename >::size().
size_t llvm::BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold >::getTotalMemory | ( | ) | const [inline] |
Definition at line 260 of file Allocator.h.
References llvm::SmallVectorTemplateCommon< T, typename >::begin(), llvm::SmallVectorTemplateCommon< T, typename >::end(), and I.
Referenced by llvm::BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold >::PrintStats().
BumpPtrAllocatorImpl& llvm::BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold >::operator= | ( | BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold > && | RHS | ) | [inline] |
Definition at line 169 of file Allocator.h.
References llvm::SmallVectorTemplateCommon< T, typename >::begin(), and llvm::SmallVectorTemplateCommon< T, typename >::end().
void llvm::BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold >::PrintStats | ( | ) | const [inline] |
Definition at line 269 of file Allocator.h.
References llvm::BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold >::getTotalMemory(), llvm::detail::printBumpPtrAllocatorStats(), and llvm::SmallVectorTemplateCommon< T, typename >::size().
void llvm::BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold >::Reset | ( | ) | [inline] |
Deallocate all but the current slab and reset the current pointer to the beginning of it, freeing all memory allocated so far.
Definition at line 189 of file Allocator.h.
References llvm::SmallVectorTemplateCommon< T, typename >::begin(), llvm::SmallVectorImpl< T >::clear(), llvm::SmallVectorBase::empty(), llvm::SmallVectorTemplateCommon< T, typename >::end(), llvm::SmallVectorImpl< T >::erase(), and llvm::SmallVectorTemplateCommon< T, typename >::front().
Referenced by llvm::SelectionDAG::clear(), llvm::SpecificBumpPtrAllocator< SCC >::DestroyAll(), llvm::yaml::Scanner::getNext(), llvm::LiveStacks::releaseMemory(), llvm::LiveIntervals::releaseMemory(), llvm::SlotIndexes::releaseMemory(), llvm::ScalarEvolution::releaseMemory(), and llvm::MCContext::reset().
llvm::BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold >::static_assert | ( | SizeThreshold<= | SlabSize, |
"The SizeThreshold must be at most the SlabSize to ensure ""that objects larger than a slab go into their own memory ""allocation." | |||
) |
friend class SpecificBumpPtrAllocator [friend] |
Definition at line 349 of file Allocator.h.