|
LLVM 23.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< MachineInstr * >, llvm::SmallPtrSetImpl< MachineBasicBlock * >, llvm::SmallPtrSetImpl< BasicBlock * >, llvm::SmallPtrSetImpl< const BasicBlockT * >, llvm::SmallPtrSetImpl< PointeeType * >, llvm::SmallPtrSetImpl< NodeRef >, llvm::SmallPtrSetImpl< const llvm::MDNode * >, llvm::SmallPtrSetImpl< llvm::Instruction * >, llvm::SmallPtrSetImpl< Value * >, llvm::SmallPtrSetImpl< llvm::DIScope * >, llvm::SmallPtrSetImpl< llvm::MachineBasicBlock * >, llvm::SmallPtrSetImpl< llvm::LiveRange * >, llvm::SmallPtrSetImpl< llvm::VPRecipeBase * >, llvm::SmallPtrSetImpl< const llvm::AllocaInst * >, 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< llvm::Value * >, llvm::SmallPtrSetImpl< llvm::Use * >, llvm::SmallPtrSetImpl< const llvm::DISubprogram * >, llvm::SmallPtrSetImpl< llvm::GlobalVariable * >, llvm::SmallPtrSetImpl< llvm::Constant * >, llvm::SmallPtrSetImpl< llvm::GlobalValue * >, llvm::SmallPtrSetImpl< const llvm::DbgVariableRecord * >, llvm::SmallPtrSetImpl< llvm::MachineInstr * >, llvm::SmallPtrSetImpl< BasicBlockT * >, llvm::SmallPtrSetImpl< const BlockT * >, llvm::SmallPtrSetImpl< const InstructionT * >, llvm::SmallPtrSetImpl< const CycleT * >, llvm::SmallPtrSetImpl< const llvm::GlobalValue * >, llvm::SmallPtrSetImpl< NodeTy * >, llvm::SmallPtrSetImpl< const llvm::Function * >, llvm::SmallPtrSetImpl< llvm::InterleaveGroup< llvm::Instruction > * >, llvm::SmallPtrSetImpl< llvm::Module * >, llvm::SmallPtrSetImpl< const llvm::VNInfo * >, llvm::SmallPtrSetImpl< const llvm::Instruction * >, llvm::SmallPtrSetImpl< const llvm::MCSymbol * >, llvm::SmallPtrSetImpl< const llvm::LazyCallGraph::Node * >, llvm::SmallPtrSetImpl< llvm::MachineRegisterInfo::Delegate * >, llvm::SmallPtrSetImpl< const llvm::BasicBlock * >, llvm::SmallPtrSetImpl< void * >, llvm::SmallPtrSetImpl< llvm::AnalysisKey * >, llvm::SmallPtrSetImpl< llvm::Rematerializer::Listener * >, llvm::SmallPtrSetImpl< const llvm::SCEV * >, llvm::SmallPtrSetImpl< const llvm::Type * >, llvm::SmallPtrSetImpl< const llvm::PHINode * >, llvm::SmallPtrSetImpl< const llvm::SCEVAddRecExpr * >, llvm::SmallPtrSetImpl< llvm::Type * >, llvm::SmallPtrSetImpl< llvm::PHINode * >, llvm::SmallPtrSetImpl< llvm::cl::SubCommand * >, llvm::SmallPtrSetImpl< llvm::orc::JITDylib const * >, llvm::SmallPtrSetImpl< const TreeEntry * >, llvm::SmallPtrSetImpl< Instruction * >, llvm::SmallPtrSetImpl< const 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 NewNumEntries) |
| Public Member Functions inherited from llvm::DebugEpochBase | |
| void | incrementEpoch () |
Protected Member Functions | |
| LLVM_ABI | SmallPtrSetImplBase (const void **SmallStorage, const SmallPtrSetImplBase &that) |
| LLVM_ABI | SmallPtrSetImplBase (const void **SmallStorage, unsigned SmallSize, const void **RHSSmallStorage, SmallPtrSetImplBase &&that) |
| SmallPtrSetImplBase (const void **SmallStorage, unsigned SmallSize) | |
| ~SmallPtrSetImplBase () | |
| const void ** | EndPointer () const |
| iterator_range< const void ** > | small_buckets () |
| iterator_range< const void *const * > | small_buckets () const |
| iterator_range< const void ** > | buckets () |
| iterator_range< const void *const * > | buckets () 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 |
| LLVM_ABI void | eraseFromBucket (const void **Bucket) |
Erase the entry at Bucket and close the resulting hole via Knuth TAOCP 6.4 Algorithm R. | |
| LLVM_ABI void | Grow (unsigned NewSize) |
| Allocate a larger backing store for the buckets and move it over. | |
| LLVM_ABI void | swap (const void **SmallStorage, const void **RHSSmallStorage, SmallPtrSetImplBase &RHS) |
| swap - Swaps the elements of two sets. | |
| LLVM_ABI void | copyFrom (const void **SmallStorage, const SmallPtrSetImplBase &RHS) |
| LLVM_ABI void | moveFrom (const void **SmallStorage, unsigned SmallSize, const void **RHSSmallStorage, SmallPtrSetImplBase &&RHS) |
Static Protected Member Functions | |
| 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 | NumEntries |
| Number of elements in CurArray that contain a value. | |
| 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 linear-probed hash table with deletion implemented using Knuth TAOCP 6.4 Algorithm R: erase opens a hole, walks forward sliding each following entry whose probe path crosses the hole back into it (the hole moves with each slide), and stops at the next empty slot. Empty buckets are represented with an illegal pointer value (-1) to allow null pointers to be inserted; no tombstone state is needed. The hash table is resized when the table is 2/3 or more. When this happens, the table is doubled in size.
Definition at line 58 of file SmallPtrSet.h.
Definition at line 94 of file SmallPtrSet.h.
|
protected |
Definition at line 128 of file SmallPtrSet.cpp.
References CurArray, CurArraySize, IsSmall, isSmall(), llvm::safe_malloc(), and SmallPtrSetImplBase().
Referenced by copyFrom(), moveFrom(), operator=(), SmallPtrSetImplBase(), SmallPtrSetImplBase(), and swap().
|
protected |
Definition at line 143 of file SmallPtrSet.cpp.
References SmallPtrSetImplBase().
|
inlineexplicitprotected |
Definition at line 81 of file SmallPtrSet.h.
References assert(), CurArray, CurArraySize, llvm::has_single_bit(), IsSmall, and NumEntries.
|
inlineprotected |
Definition at line 88 of file SmallPtrSet.h.
|
inlineprotected |
Definition at line 156 of file SmallPtrSet.h.
References CurArray, EndPointer(), and llvm::make_range().
Referenced by Grow(), and llvm::SmallPtrSetImpl< MachineInstr * >::remove_if().
|
inlineprotected |
Definition at line 160 of file SmallPtrSet.h.
References CurArray, EndPointer(), and llvm::make_range().
|
inlinenodiscard |
Definition at line 100 of file SmallPtrSet.h.
References CurArraySize.
|
inline |
Definition at line 102 of file SmallPtrSet.h.
References CurArray, CurArraySize, llvm::DebugEpochBase::incrementEpoch(), isSmall(), NumEntries, and size().
Referenced by llvm::HexagonSubtarget::adjustSchedDependency(), buildClonedLoopBlocks(), llvm::SampleProfileLoaderBaseImpl< FT >::buildEdges(), canonicalizePHIOperands(), llvm::SCEVExpanderCleaner::cleanup(), ComputePostOrders(), llvm::SelectionDAG::copyExtraInfo(), llvm::detachDeadBlocks(), llvm::OpenMPIRBuilder::finalize(), findBBsToSinkInto(), findConsecutiveLoad(), llvm::LexicalScopes::getMachineBasicBlocks(), HandleMergeInputChains(), llvm::MergeBasicBlockIntoOnlyPred(), llvm::MergeBlockIntoPredecessor(), llvm::SmallPtrSet< NodeRef, SmallSize >::operator=(), slpvectorizer::BoUpSLP::optimizeGatherSequence(), optimizeGlobalsInModule(), llvm::ReachingDefInfo::print(), slpvectorizer::BoUpSLP::reorderBottomToTop(), simplifyLoopInst(), stripDebugLocFromLoopID(), llvm::TryToSimplifyUncondBranchFromEmptyBlock(), and updatePostorderSequenceForEdgeInsertion().
Definition at line 230 of file SmallPtrSet.h.
References isSmall(), and small_buckets().
Referenced by llvm::SmallPtrSetImpl< MachineInstr * >::contains(), and llvm::SmallPtrSetImpl< MachineInstr * >::count().
|
protected |
Definition at line 150 of file SmallPtrSet.cpp.
References assert(), CurArray, CurArraySize, IsSmall, isSmall(), llvm::safe_malloc(), llvm::safe_realloc(), SmallPtrSetImplBase(), and T.
Referenced by llvm::SmallPtrSet< NodeRef, SmallSize >::operator=().
|
inlinenodiscard |
Definition at line 98 of file SmallPtrSet.h.
References size().
Referenced by alwaysInlineImpl(), buildClonedLoops(), llvm::buildModuleSummaryIndex(), llvm::AArch64TargetMachine::clearLinkerOptimizationHints(), collectInstructionsInBetween(), llvm::ScopedNoAliasAAResult::collectScopedDomains(), collectTransitivePredecessors(), dominatesMergePoint(), expandProtectedFieldPtr(), getFSqrtDivOptPattern(), getGatherLanePattern(), llvm::ScalarEvolution::isKnownViaInduction(), llvm::isPotentiallyReachable(), llvm::isPotentiallyReachable(), isReachableImpl(), llvm::memtag::isSupportedLifetime(), IsValueFullyAvailableInBlock(), lowerKernelByValParam(), llvm::ScopedNoAliasAAResult::mayAliasInScopes(), llvm::MergeBlockSuccessorsIntoGivenBlocks(), mergeReplicateRegionsIntoSuccessors(), llvm::SelectionDAG::MorphNodeTo(), producesFalseLanesZero(), ReachabilityQueryInfo< ToTy >::ReachabilityQueryInfo(), rebuildLoopAfterUnswitch(), recomputeLoopBlockSet(), rewriteDebugUsers(), runImpl(), simplifyLoopInst(), sink(), sinkInstruction(), and llvm::MemorySSA::verifyDominationNumbers().
|
inlineprotected |
Definition at line 144 of file SmallPtrSet.h.
References CurArray, CurArraySize, isSmall(), and NumEntries.
Referenced by llvm::SmallPtrSetImpl< MachineInstr * >::begin(), buckets(), buckets(), llvm::SmallPtrSetImpl< MachineInstr * >::end(), and find_imp().
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 190 of file SmallPtrSet.h.
References CurArray, eraseFromBucket(), llvm::DebugEpochBase::incrementEpoch(), isSmall(), NumEntries, and small_buckets().
Referenced by llvm::SmallPtrSetImpl< MachineInstr * >::erase().
|
protected |
Erase the entry at Bucket and close the resulting hole via Knuth TAOCP 6.4 Algorithm R.
Caller must update NumEntries and the epoch.
Definition at line 85 of file SmallPtrSet.cpp.
References CurArray, CurArraySize, DenseMapInfo< LocallyHashedType >::Empty, getEmptyMarker(), and I.
Referenced by erase_imp().
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 215 of file SmallPtrSet.h.
References EndPointer(), isSmall(), and small_buckets().
Referenced by llvm::SmallPtrSetImpl< MachineInstr * >::find().
|
inlinestaticprotected |
Definition at line 138 of file SmallPtrSet.h.
Referenced by eraseFromBucket(), Grow(), and llvm::SmallPtrSetImpl< MachineInstr * >::remove_if().
|
protected |
Allocate a larger backing store for the buckets and move it over.
Grow - Allocate a larger backing store for the buckets and move it over.
Passing the current size triggers a same-size rehash, used by batch erase to compact away empty slots left by mark-then-rebuild.
Definition at line 104 of file SmallPtrSet.cpp.
References buckets(), CurArray, CurArraySize, getEmptyMarker(), IsSmall, isSmall(), and llvm::safe_malloc().
Referenced by llvm::SmallPtrSetImpl< MachineInstr * >::remove_if(), and reserve().
|
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 167 of file SmallPtrSet.h.
References CurArray, CurArraySize, llvm::DebugEpochBase::incrementEpoch(), isSmall(), NumEntries, and small_buckets().
Referenced by llvm::SmallPtrSetImpl< MachineInstr * >::insert().
|
inlineprotected |
Definition at line 242 of file SmallPtrSet.h.
References IsSmall.
Referenced by clear(), contains_imp(), copyFrom(), EndPointer(), erase_imp(), find_imp(), Grow(), insert_imp(), moveFrom(), llvm::SmallPtrSetImpl< MachineInstr * >::remove_if(), reserve(), SmallPtrSetImplBase(), swap(), and ~SmallPtrSetImplBase().
|
protected |
Definition at line 189 of file SmallPtrSet.cpp.
References CurArray, isSmall(), and SmallPtrSetImplBase().
Referenced by llvm::SmallPtrSet< NodeRef, SmallSize >::operator=().
|
delete |
References SmallPtrSetImplBase().
|
inline |
Definition at line 116 of file SmallPtrSet.h.
References llvm::bit_ceil(), CurArraySize, Grow(), llvm::DebugEpochBase::incrementEpoch(), and isSmall().
Referenced by llvm::IDFCalculatorBase< NodeTy, IsPostDom >::calculate(), and llvm::sandboxir::Type::isSized().
|
inlinenodiscard |
Definition at line 99 of file SmallPtrSet.h.
References NumEntries.
Referenced by adjustedSumFreq(), llvm::applyDebugifyMetadataToMachineFunction(), llvm::sandboxir::LegalityAnalysis::areUnique(), buildClonedLoops(), llvm::MachineIDFSSAUpdater::calculate(), llvm::calculateRegisterUsageForPlan(), slpvectorizer::BoUpSLP::canBuildSplitNode(), canFoldStoreIntoLibCallOutputPointers(), llvm::ScalarEvolution::canReuseInstruction(), llvm::changeToUnreachable(), checkIVUsers(), clear(), llvm::DomTreeNodeBase< BlockT >::compare(), llvm::compareLoops(), llvm::ConstantFoldTerminator(), containsUnreachable(), empty(), feedsIntoVectorReduction(), findBBsToSinkInto(), findBestNonTrivialUnswitchCandidate(), findReaching(), llvm::objcarc::findSingleDependency(), llvm::InstCombinerImpl::foldDeadPhiWeb(), llvm::InstCombinerImpl::foldFreezeIntoRecurrence(), llvm::LoopBase< BasicBlock, Loop >::getLoopLatch(), llvm::MemoryDependenceResults::getNonLocalCallDependency(), getOutliningPenalty(), llvm::getUnderlyingObjectAggressive(), llvm::ReachingDefInfo::getUniqueReachingMIDef(), llvm::hasPartialIVCondition(), llvm::SDNode::hasPredecessorHelper(), hasSameSuccessors(), isOnlyCopiedFromConstantMemory(), isPotentiallyReachable(), llvm::CombinerHelper::matchExtendThroughPhis(), optimizeLoopExitWithUnknownExitCount(), PHIsEqualValue(), llvm::PointerMayBeCaptured(), llvm::AArch64TTIImpl::preferTailFoldingOverEpilogue(), llvm::SCCPSolver::removeNonFeasibleEdges(), slpvectorizer::BoUpSLP::VLOperands::reorder(), llvm::SSAUpdaterBulk::RewriteAllUses(), runImpl(), llvm::AbstractDependenceGraphBuilder< GraphType >::simplify(), simplifyBlends(), llvm::JumpThreadingPass::simplifyPartiallyRedundantLoad(), sinkInstruction(), llvm::SplitBlockAndInsertIfThenElse(), updateForAIXShLibTLSModelOpt(), usersDominator(), llvm::GenericCycle< ContextT >::verifyCycle(), and llvm::MemorySSAUpdater::wireOldPredecessorsToNewImmediatePredecessor().
|
inlineprotected |
Definition at line 148 of file SmallPtrSet.h.
References CurArray, llvm::make_range(), and NumEntries.
Referenced by contains_imp(), erase_imp(), find_imp(), insert_imp(), llvm::SmallPtrSetImpl< MachineInstr * >::remove_if(), and swap().
|
inlineprotected |
Definition at line 152 of file SmallPtrSet.h.
References CurArray, and NumEntries.
|
protected |
swap - Swaps the elements of two sets.
Note: This method assumes that both sets have the same small size.
Definition at line 224 of file SmallPtrSet.cpp.
References assert(), llvm::copy(), CurArray, CurArraySize, IsSmall, isSmall(), NumEntries, small_buckets(), SmallPtrSetImplBase(), and std::swap().
Referenced by llvm::SmallPtrSet< NodeRef, SmallSize >::swap().
|
friend |
Definition at line 59 of file SmallPtrSet.h.
References SmallPtrSetIteratorImpl.
Referenced by SmallPtrSetIteratorImpl.
|
protected |
The current set of buckets, in either small or big representation.
Definition at line 63 of file SmallPtrSet.h.
Referenced by llvm::SmallPtrSetImpl< MachineInstr * >::begin(), buckets(), buckets(), clear(), copyFrom(), EndPointer(), erase_imp(), eraseFromBucket(), Grow(), insert_imp(), moveFrom(), small_buckets(), small_buckets(), llvm::SmallPtrSetImpl< PtrType >::SmallPtrSetImplBase(), SmallPtrSetImplBase(), SmallPtrSetImplBase(), swap(), and ~SmallPtrSetImplBase().
|
protected |
CurArraySize - The allocated size of CurArray, always a power of two.
Definition at line 65 of file SmallPtrSet.h.
Referenced by capacity(), clear(), copyFrom(), EndPointer(), eraseFromBucket(), Grow(), insert_imp(), llvm::SmallPtrSetImpl< MachineInstr * >::remove_if(), reserve(), SmallPtrSetImplBase(), SmallPtrSetImplBase(), and swap().
|
protected |
Whether the set is in small representation.
Definition at line 72 of file SmallPtrSet.h.
Referenced by copyFrom(), Grow(), isSmall(), SmallPtrSetImplBase(), SmallPtrSetImplBase(), and swap().
|
protected |
Number of elements in CurArray that contain a value.
If small, all these elements are at the beginning of CurArray and the rest is uninitialized.
Definition at line 70 of file SmallPtrSet.h.
Referenced by clear(), EndPointer(), erase_imp(), insert_imp(), llvm::SmallPtrSetImpl< MachineInstr * >::remove_if(), size(), small_buckets(), small_buckets(), SmallPtrSetImplBase(), and swap().