LLVM 20.0.0git
|
SmallPtrSetImplBase - This is the common code shared among all the SmallPtrSet<>'s, which is almost everything. More...
#include "llvm/ADT/SmallPtrSet.h"
Inherits llvm::DebugEpochBase.
Inherited by llvm::SmallPtrSetImpl< BasicBlockT * >, llvm::SmallPtrSetImpl< BasicBlock * >, llvm::SmallPtrSetImpl< const BasicBlock * >, llvm::SmallPtrSetImpl< const BasicBlockT * >, llvm::SmallPtrSetImpl< const MachineBasicBlock * >, llvm::SmallPtrSetImpl< typename GraphTraits< std::conditional_t< IsConst, const BlockT, BlockT > * >::NodeRef >, llvm::SmallPtrSetImpl< PointeeType * >, llvm::SmallPtrSetImpl< typename GraphTraits< GraphT >::NodeRef >, llvm::SmallPtrSetImpl< typename GraphTraits< T >::NodeRef >, llvm::SmallPtrSetImpl< NodeRef >, llvm::SmallPtrSetImpl< const MDNode * >, llvm::SmallPtrSetImpl< Instruction * >, llvm::SmallPtrSetImpl< llvm::Value * >, llvm::SmallPtrSetImpl< llvm::MachineBasicBlock * >, llvm::SmallPtrSetImpl< llvm::LiveRange * >, llvm::SmallPtrSetImpl< const llvm::AllocaInst * >, llvm::SmallPtrSetImpl< CallBase * >, llvm::SmallPtrSetImpl< AssumeInst * >, llvm::SmallPtrSetImpl< const MachineInstr * >, llvm::SmallPtrSetImpl< const llvm::GlobalVariable * >, llvm::SmallPtrSetImpl< llvm::BasicBlock * >, llvm::SmallPtrSetImpl< const llvm::Value * >, llvm::SmallPtrSetImpl< const llvm::MachineBasicBlock * >, llvm::SmallPtrSetImpl< llvm::LazyCallGraph::SCC * >, llvm::SmallPtrSetImpl< llvm::Function * >, llvm::SmallPtrSetImpl< llvm::GlobalObject * >, llvm::SmallPtrSetImpl< const llvm::MDNode * >, llvm::SmallPtrSetImpl< llvm::Instruction * >, llvm::SmallPtrSetImpl< llvm::Use * >, llvm::SmallPtrSetImpl< llvm::GlobalVariable * >, llvm::SmallPtrSetImpl< llvm::Constant * >, llvm::SmallPtrSetImpl< llvm::GlobalValue * >, llvm::SmallPtrSetImpl< const llvm::DbgDeclareInst * >, llvm::SmallPtrSetImpl< const llvm::DbgVariableRecord * >, llvm::SmallPtrSetImpl< llvm::MachineInstr * >, llvm::SmallPtrSetImpl< const BlockT * >, llvm::SmallPtrSetImpl< const CycleT * >, llvm::SmallPtrSetImpl< const InstructionT * >, llvm::SmallPtrSetImpl< const llvm::GlobalValue * >, llvm::SmallPtrSetImpl< NodeTy * >, llvm::SmallPtrSetImpl< const Loop * >, llvm::SmallPtrSetImpl< const llvm::Function * >, llvm::SmallPtrSetImpl< llvm::InterleaveGroup< llvm::Instruction > * >, llvm::SmallPtrSetImpl< llvm::Module * >, llvm::SmallPtrSetImpl< const llvm::VNInfo * >, llvm::SmallPtrSetImpl< llvm::PHINode * >, llvm::SmallPtrSetImpl< llvm::Type * >, llvm::SmallPtrSetImpl< const PHINode * >, llvm::SmallPtrSetImpl< const llvm::Instruction * >, llvm::SmallPtrSetImpl< const llvm::MCSymbol * >, llvm::SmallPtrSetImpl< Module * >, llvm::SmallPtrSetImpl< const llvm::LazyCallGraph::Node * >, llvm::SmallPtrSetImpl< llvm::MachineRegisterInfo::Delegate * >, llvm::SmallPtrSetImpl< const llvm::BasicBlock * >, llvm::SmallPtrSetImpl< const Value * >, llvm::SmallPtrSetImpl< void * >, llvm::SmallPtrSetImpl< llvm::AnalysisKey * >, llvm::SmallPtrSetImpl< const llvm::SCEV * >, llvm::SmallPtrSetImpl< const llvm::Type * >, llvm::SmallPtrSetImpl< const llvm::PHINode * >, llvm::SmallPtrSetImpl< const llvm::SCEVAddRecExpr * >, llvm::SmallPtrSetImpl< llvm::cl::SubCommand * >, llvm::SmallPtrSetImpl< llvm::orc::JITDylib const * >, llvm::SmallPtrSetImpl< Value * >, and llvm::SmallPtrSetImpl< PtrType >.
Public Types | |
using | size_type = unsigned |
Public Member Functions | |
SmallPtrSetImplBase & | operator= (const SmallPtrSetImplBase &)=delete |
bool | empty () const |
size_type | size () const |
size_type | capacity () const |
void | clear () |
void | reserve (size_type NumEntries) |
Public Member Functions inherited from llvm::DebugEpochBase | |
void | incrementEpoch () |
Protected Member Functions | |
SmallPtrSetImplBase (const void **SmallStorage, const SmallPtrSetImplBase &that) | |
SmallPtrSetImplBase (const void **SmallStorage, unsigned SmallSize, const void **RHSSmallStorage, SmallPtrSetImplBase &&that) | |
SmallPtrSetImplBase (const void **SmallStorage, unsigned SmallSize) | |
~SmallPtrSetImplBase () | |
const void ** | EndPointer () const |
std::pair< const void *const *, bool > | insert_imp (const void *Ptr) |
insert_imp - This returns true if the pointer was new to the set, false if it was already in the set. | |
bool | erase_imp (const void *Ptr) |
erase_imp - If the set contains the specified pointer, remove it and return true, otherwise return false. | |
const void *const * | find_imp (const void *Ptr) const |
Returns the raw pointer needed to construct an iterator. | |
bool | contains_imp (const void *Ptr) const |
bool | isSmall () const |
void | swap (const void **SmallStorage, const void **RHSSmallStorage, SmallPtrSetImplBase &RHS) |
swap - Swaps the elements of two sets. | |
void | copyFrom (const void **SmallStorage, const SmallPtrSetImplBase &RHS) |
void | moveFrom (const void **SmallStorage, unsigned SmallSize, const void **RHSSmallStorage, SmallPtrSetImplBase &&RHS) |
Static Protected Member Functions | |
static void * | getTombstoneMarker () |
static void * | getEmptyMarker () |
Protected Attributes | |
const void ** | CurArray |
The current set of buckets, in either small or big representation. | |
unsigned | CurArraySize |
CurArraySize - The allocated size of CurArray, always a power of two. | |
unsigned | NumNonEmpty |
Number of elements in CurArray that contain a value or are a tombstone. | |
unsigned | NumTombstones |
Number of tombstones in CurArray. | |
bool | IsSmall |
Whether the set is in small representation. | |
Friends | |
class | SmallPtrSetIteratorImpl |
SmallPtrSetImplBase - This is the common code shared among all the SmallPtrSet<>'s, which is almost everything.
SmallPtrSet has two modes, one for small and one for large sets.
Small sets use an array of pointers allocated in the SmallPtrSet object, which is treated as a simple array of pointers. When a pointer is added to the set, the array is scanned to see if the element already exists, if not the element is 'pushed back' onto the array. If we run out of space in the array, we grow into the 'large set' case. SmallSet should be used when the sets are often small. In this case, no memory allocation is used, and only light-weight and cache-efficient scanning is used.
Large sets use a classic exponentially-probed hash table. Empty buckets are represented with an illegal pointer value (-1) to allow null pointers to be inserted. Tombstones are represented with another illegal pointer value (-2), to allow deletion. The hash table is resized when the table is 3/4 or more. When this happens, the table is doubled in size.
Definition at line 52 of file SmallPtrSet.h.
Definition at line 89 of file SmallPtrSet.h.
|
protected |
Definition at line 140 of file SmallPtrSet.cpp.
References CurArray, CurArraySize, IsSmall, isSmall(), and llvm::safe_malloc().
|
protected |
Definition at line 155 of file SmallPtrSet.cpp.
|
inlineexplicitprotected |
Definition at line 76 of file SmallPtrSet.h.
References assert().
|
inlineprotected |
Definition at line 83 of file SmallPtrSet.h.
|
inline |
Definition at line 95 of file SmallPtrSet.h.
References CurArraySize.
|
inline |
Definition at line 97 of file SmallPtrSet.h.
References CurArray, CurArraySize, llvm::DebugEpochBase::incrementEpoch(), isSmall(), NumNonEmpty, NumTombstones, and size().
Referenced by buildClonedLoopBlocks(), llvm::SampleProfileLoaderBaseImpl< FT >::buildEdges(), canonicalizePHIOperands(), llvm::SCEVExpander::clear(), llvm::AAExecutionDomain::ExecutionDomainTy::clearAssumeInstAndAlignedBarriers(), llvm::SCEVExpander::clearPostInc(), llvm::ObjectSizeOffsetEvaluator::compute(), ComputePostOrders(), llvm::SelectionDAG::copyExtraInfo(), llvm::slpvectorizer::BoUpSLP::deleteTree(), llvm::OpenMPIRBuilder::finalize(), findBBsToSinkInto(), llvm::LexicalScopes::getMachineBasicBlocks(), HandleMergeInputChains(), llvm::MergeBasicBlockIntoOnlyPred(), llvm::MergeBlockIntoPredecessor(), llvm::SmallPtrSet< PtrType, SmallSize >::operator=(), optimizeGlobalsInModule(), llvm::slpvectorizer::BoUpSLP::reorderBottomToTop(), llvm::SSPLayoutAnalysis::requiresStackProtector(), simplifyLoopInst(), stripDebugLocFromLoopID(), llvm::TryToSimplifyUncondBranchFromEmptyBlock(), updatePostorderSequenceForEdgeInsertion(), and llvm::LoopBase< BlockT, LoopT >::~LoopBase().
Definition at line 219 of file SmallPtrSet.h.
References CurArray, E, isSmall(), NumNonEmpty, and Ptr.
Referenced by llvm::SmallPtrSetImpl< PtrType >::contains(), and llvm::SmallPtrSetImpl< PtrType >::count().
|
protected |
Definition at line 162 of file SmallPtrSet.cpp.
References assert(), CurArray, CurArraySize, IsSmall, isSmall(), RHS, llvm::safe_malloc(), and llvm::safe_realloc().
Referenced by llvm::SmallPtrSet< PtrType, SmallSize >::operator=().
|
inline |
Definition at line 93 of file SmallPtrSet.h.
References size().
Referenced by alwaysInlineImpl(), buildClonedLoops(), llvm::buildModuleSummaryIndex(), collectInstructionsInBetween(), collectTransitivePredecessors(), dominatesMergePoint(), llvm::LoopVectorizationCostModel::getReductionPatternCost(), llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::hasPendingDeletedBB(), llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::isBBPendingDeletion(), llvm::ScalarEvolution::isKnownViaInduction(), llvm::isPotentiallyReachable(), isReachableImpl(), llvm::MergeBlockSuccessorsIntoGivenBlocks(), llvm::SelectionDAG::MorphNodeTo(), producesFalseLanesZero(), ReachabilityQueryInfo< ToTy >::ReachabilityQueryInfo(), rebuildLoopAfterUnswitch(), recomputeLoopBlockSet(), rewriteDebugUsers(), sink(), sinkInstruction(), llvm::MemorySSA::verifyDominationNumbers(), and llvm::LLVMContextImpl::~LLVMContextImpl().
|
inlineprotected |
Definition at line 142 of file SmallPtrSet.h.
References CurArray, CurArraySize, isSmall(), and NumNonEmpty.
Referenced by llvm::SmallPtrSetImpl< PtrType >::begin(), llvm::SmallPtrSetImpl< PtrType >::end(), find_imp(), and llvm::SmallPtrSetImpl< PtrType >::remove_if().
erase_imp - If the set contains the specified pointer, remove it and return true, otherwise return false.
This is hidden from the client so that the derived class can check that the right type of pointer is passed in.
Definition at line 174 of file SmallPtrSet.h.
References CurArray, E, getTombstoneMarker(), llvm::DebugEpochBase::incrementEpoch(), isSmall(), NumNonEmpty, NumTombstones, and Ptr.
Referenced by llvm::SmallPtrSetImpl< PtrType >::erase().
Returns the raw pointer needed to construct an iterator.
If element not found, this will be EndPointer. Otherwise, it will be a pointer to the slot which stores Ptr;
Definition at line 202 of file SmallPtrSet.h.
References CurArray, E, EndPointer(), isSmall(), NumNonEmpty, and Ptr.
Referenced by llvm::SmallPtrSetImpl< PtrType >::find().
|
inlinestaticprotected |
Definition at line 136 of file SmallPtrSet.h.
Referenced by llvm::SmallPtrSetIteratorImpl::AdvanceIfNotValid(), llvm::SmallPtrSetImpl< PtrType >::remove_if(), and llvm::SmallPtrSetIteratorImpl::RetreatIfNotValid().
|
inlinestaticprotected |
Definition at line 134 of file SmallPtrSet.h.
Referenced by llvm::SmallPtrSetIteratorImpl::AdvanceIfNotValid(), erase_imp(), llvm::SmallPtrSetImpl< PtrType >::remove_if(), and llvm::SmallPtrSetIteratorImpl::RetreatIfNotValid().
|
inlineprotected |
insert_imp - This returns true if the pointer was new to the set, false if it was already in the set.
This is hidden from the client so that the derived class can check that the right type of pointer is passed in.
Definition at line 149 of file SmallPtrSet.h.
References CurArray, CurArraySize, E, llvm::DebugEpochBase::incrementEpoch(), isSmall(), NumNonEmpty, and Ptr.
Referenced by llvm::SmallPtrSetImpl< PtrType >::insert().
|
inlineprotected |
Definition at line 233 of file SmallPtrSet.h.
References IsSmall.
Referenced by clear(), contains_imp(), copyFrom(), EndPointer(), erase_imp(), find_imp(), insert_imp(), moveFrom(), llvm::SmallPtrSetImpl< PtrType >::remove_if(), reserve(), SmallPtrSetImplBase(), swap(), and ~SmallPtrSetImplBase().
|
protected |
Definition at line 202 of file SmallPtrSet.cpp.
References CurArray, isSmall(), and RHS.
Referenced by llvm::SmallPtrSet< PtrType, SmallSize >::operator=().
|
delete |
|
inline |
Definition at line 112 of file SmallPtrSet.h.
References CurArraySize, llvm::DebugEpochBase::incrementEpoch(), isSmall(), and llvm::Log2_32_Ceil().
Referenced by llvm::IDFCalculatorBase< NodeTy, IsPostDom >::calculate(), llvm::VETargetLowering::emitSjLjDispatchBlock(), and llvm::sandboxir::Type::isSized().
|
inline |
Definition at line 94 of file SmallPtrSet.h.
References NumNonEmpty, and NumTombstones.
Referenced by adjustedSumFreq(), llvm::SampleProfileInference< FT >::apply(), buildClonedLoops(), llvm::LoopVectorizationCostModel::calculateRegisterUsage(), canFoldStoreIntoLibCallOutputPointers(), llvm::ScalarEvolution::canReuseInstruction(), clear(), empty(), findBBsToSinkInto(), findBestNonTrivialUnswitchCandidate(), llvm::objcarc::findSingleDependency(), llvm::InstCombinerImpl::foldDeadPhiWeb(), llvm::InstCombinerImpl::foldFreezeIntoRecurrence(), llvm::BasicTTIImplBase< T >::getEstimatedNumberOfCaseClusters(), llvm::LoopBase< BasicBlock, Loop >::getLoopLatch(), llvm::MemoryDependenceResults::getNonLocalCallDependency(), getOutliningPenalty(), llvm::slpvectorizer::BoUpSLP::getSpillCost(), llvm::getUnderlyingObjectAggressive(), llvm::hasPartialIVCondition(), llvm::SDNode::hasPredecessorHelper(), hasSameSuccessors(), isOnlyCopiedFromConstantMemory(), isPotentiallyReachable(), llvm::CombinerHelper::matchExtendThroughPhis(), optimizeLoopExitWithUnknownExitCount(), PHIsEqualValue(), llvm::AArch64TTIImpl::preferPredicateOverEpilogue(), llvm::SCCPSolver::removeNonFeasibleEdges(), llvm::removeUnreachableBlocks(), llvm::slpvectorizer::BoUpSLP::VLOperands::reorder(), runImpl(), llvm::SPIRVMergeRegionExitTargets::runOnConvergenceRegionNoRecurse(), llvm::AbstractDependenceGraphBuilder< GraphType >::simplify(), llvm::JumpThreadingPass::simplifyPartiallyRedundantLoad(), simplifyRecipe(), sinkInstruction(), llvm::SplitBlockAndInsertIfThenElse(), updateForAIXShLibTLSModelOpt(), usersDominator(), llvm::GenericCycle< ContextT >::verifyCycle(), and llvm::MemorySSAUpdater::wireOldPredecessorsToNewImmediatePredecessor().
|
protected |
swap - Swaps the elements of two sets.
Note: This method assumes that both sets have the same small size.
Definition at line 239 of file SmallPtrSet.cpp.
References assert(), CurArray, CurArraySize, IsSmall, isSmall(), NumTombstones, RHS, and std::swap().
Referenced by llvm::SmallPtrSet< PtrType, SmallSize >::swap().
|
friend |
Definition at line 53 of file SmallPtrSet.h.
|
protected |
The current set of buckets, in either small or big representation.
Definition at line 57 of file SmallPtrSet.h.
Referenced by llvm::SmallPtrSetImpl< PtrType >::begin(), clear(), contains_imp(), copyFrom(), EndPointer(), erase_imp(), find_imp(), insert_imp(), moveFrom(), llvm::SmallPtrSetImpl< PtrType >::remove_if(), SmallPtrSetImplBase(), swap(), and ~SmallPtrSetImplBase().
|
protected |
CurArraySize - The allocated size of CurArray, always a power of two.
Definition at line 59 of file SmallPtrSet.h.
Referenced by capacity(), clear(), copyFrom(), EndPointer(), insert_imp(), reserve(), SmallPtrSetImplBase(), and swap().
|
protected |
Whether the set is in small representation.
Definition at line 68 of file SmallPtrSet.h.
Referenced by copyFrom(), isSmall(), SmallPtrSetImplBase(), and swap().
|
protected |
Number of elements in CurArray that contain a value or are a tombstone.
If small, all these elements are at the beginning of CurArray and the rest is uninitialized.
Definition at line 64 of file SmallPtrSet.h.
Referenced by clear(), contains_imp(), EndPointer(), erase_imp(), find_imp(), insert_imp(), llvm::SmallPtrSetImpl< PtrType >::remove_if(), and size().
|
protected |
Number of tombstones in CurArray.
Definition at line 66 of file SmallPtrSet.h.
Referenced by clear(), erase_imp(), llvm::SmallPtrSetImpl< PtrType >::remove_if(), size(), and swap().