LLVM
8.0.1
|
SlotIndexes pass. More...
#include "llvm/CodeGen/SlotIndexes.h"
Public Types | |
using | MBBIndexIterator = SmallVectorImpl< IdxMBBPair >::const_iterator |
Iterator over the idx2MBBMap (sorted pairs of slot index of basic block begin and basic block) More... | |
Public Member Functions | |
SlotIndexes () | |
~SlotIndexes () override | |
void | getAnalysisUsage (AnalysisUsage &au) const override |
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this. More... | |
void | releaseMemory () override |
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memory when it is no longer needed. More... | |
bool | runOnMachineFunction (MachineFunction &fn) override |
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformation or analysis. More... | |
void | dump () const |
Dump the indexes. More... | |
void | renumberIndexes () |
Renumber the index list, providing space for new instructions. More... | |
void | repairIndexesInRange (MachineBasicBlock *MBB, MachineBasicBlock::iterator Begin, MachineBasicBlock::iterator End) |
Repair indexes after adding and removing instructions. More... | |
SlotIndex | getZeroIndex () |
Returns the zero index for this analysis. More... | |
SlotIndex | getLastIndex () |
Returns the base index of the last slot in this analysis. More... | |
bool | hasIndex (const MachineInstr &instr) const |
Returns true if the given machine instr is mapped to an index, otherwise returns false. More... | |
SlotIndex | getInstructionIndex (const MachineInstr &MI) const |
Returns the base index for the given instruction. More... | |
MachineInstr * | getInstructionFromIndex (SlotIndex index) const |
Returns the instruction for the given index, or null if the given index has no instruction associated with it. More... | |
SlotIndex | getNextNonNullIndex (SlotIndex Index) |
Returns the next non-null index, if one exists. More... | |
SlotIndex | getIndexBefore (const MachineInstr &MI) const |
getIndexBefore - Returns the index of the last indexed instruction before MI, or the start index of its basic block. More... | |
SlotIndex | getIndexAfter (const MachineInstr &MI) const |
getIndexAfter - Returns the index of the first indexed instruction after MI, or the end index of its basic block. More... | |
const std::pair< SlotIndex, SlotIndex > & | getMBBRange (unsigned Num) const |
Return the (start,end) range of the given basic block number. More... | |
const std::pair< SlotIndex, SlotIndex > & | getMBBRange (const MachineBasicBlock *MBB) const |
Return the (start,end) range of the given basic block. More... | |
SlotIndex | getMBBStartIdx (unsigned Num) const |
Returns the first index in the given basic block number. More... | |
SlotIndex | getMBBStartIdx (const MachineBasicBlock *mbb) const |
Returns the first index in the given basic block. More... | |
SlotIndex | getMBBEndIdx (unsigned Num) const |
Returns the last index in the given basic block number. More... | |
SlotIndex | getMBBEndIdx (const MachineBasicBlock *mbb) const |
Returns the last index in the given basic block. More... | |
MBBIndexIterator | advanceMBBIndex (MBBIndexIterator I, SlotIndex To) const |
Move iterator to the next IdxMBBPair where the SlotIndex is greater or equal to To . More... | |
MBBIndexIterator | findMBBIndex (SlotIndex Idx) const |
Get an iterator pointing to the IdxMBBPair with the biggest SlotIndex that is greater or equal to Idx . More... | |
MBBIndexIterator | MBBIndexBegin () const |
Returns an iterator for the begin of the idx2MBBMap. More... | |
MBBIndexIterator | MBBIndexEnd () const |
Return an iterator for the end of the idx2MBBMap. More... | |
MachineBasicBlock * | getMBBFromIndex (SlotIndex index) const |
Returns the basic block which the given index falls in. More... | |
MachineBasicBlock * | getMBBCoveringRange (SlotIndex start, SlotIndex end) const |
Returns the MBB covering the given range, or null if the range covers more than one basic block. More... | |
SlotIndex | insertMachineInstrInMaps (MachineInstr &MI, bool Late=false) |
Insert the given machine instruction into the mapping. More... | |
void | removeMachineInstrFromMaps (MachineInstr &MI) |
Removes machine instruction (bundle) MI from the mapping. More... | |
void | removeSingleMachineInstrFromMaps (MachineInstr &MI) |
Removes a single machine instruction MI from the mapping. More... | |
SlotIndex | replaceMachineInstrInMaps (MachineInstr &MI, MachineInstr &NewMI) |
ReplaceMachineInstrInMaps - Replacing a machine instr with a new one in maps used by register allocator. More... | |
void | insertMBBInMaps (MachineBasicBlock *mbb) |
Add the given MachineBasicBlock into the maps. More... | |
void | eraseIndex (SlotIndex index) |
Free the resources that were required to maintain a SlotIndex. More... | |
Public Member Functions inherited from llvm::MachineFunctionPass | |
bool | doInitialization (Module &) override |
doInitialization - Virtual method overridden by subclasses to do any necessary initialization before any pass is run. More... | |
Public Member Functions inherited from llvm::FunctionPass | |
FunctionPass (char &pid) | |
Pass * | createPrinterPass (raw_ostream &OS, const std::string &Banner) const override |
createPrinterPass - Get a function printer pass. More... | |
void | assignPassManager (PMStack &PMS, PassManagerType T) override |
Find appropriate Function Pass Manager or Call Graph Pass Manager in the PM Stack and add self into that manager. More... | |
PassManagerType | getPotentialPassManagerType () const override |
Return what kind of Pass Manager can manage this pass. More... | |
Public Member Functions inherited from llvm::Pass | |
Pass (PassKind K, char &pid) | |
Pass (const Pass &)=delete | |
Pass & | operator= (const Pass &)=delete |
virtual | ~Pass () |
PassKind | getPassKind () const |
virtual StringRef | getPassName () const |
getPassName - Return a nice clean name for a pass. More... | |
AnalysisID | getPassID () const |
getPassID - Return the PassID number that corresponds to this pass. More... | |
virtual bool | doFinalization (Module &) |
doFinalization - Virtual method overriden by subclasses to do any necessary clean up after all passes have run. More... | |
virtual void | print (raw_ostream &OS, const Module *M) const |
print - Print out the internal state of the pass. More... | |
void | dump () const |
virtual void | preparePassManager (PMStack &) |
Check if available pass managers are suitable for this pass or not. More... | |
void | setResolver (AnalysisResolver *AR) |
AnalysisResolver * | getResolver () const |
virtual void * | getAdjustedAnalysisPointer (AnalysisID ID) |
getAdjustedAnalysisPointer - This method is used when a pass implements an analysis interface through multiple inheritance. More... | |
virtual ImmutablePass * | getAsImmutablePass () |
virtual PMDataManager * | getAsPMDataManager () |
virtual void | verifyAnalysis () const |
verifyAnalysis() - This member can be implemented by a analysis pass to check state of analysis information. More... | |
virtual void | dumpPassStructure (unsigned Offset=0) |
template<typename AnalysisType > | |
AnalysisType * | getAnalysisIfAvailable () const |
getAnalysisIfAvailable<AnalysisType>() - Subclasses use this function to get analysis information that might be around, for example to update it. More... | |
bool | mustPreserveAnalysisID (char &AID) const |
mustPreserveAnalysisID - This method serves the same function as getAnalysisIfAvailable, but works if you just have an AnalysisID. More... | |
template<typename AnalysisType > | |
AnalysisType & | getAnalysis () const |
getAnalysis<AnalysisType>() - This function is used by subclasses to get to the analysis information that they claim to use by overriding the getAnalysisUsage function. More... | |
template<typename AnalysisType > | |
AnalysisType & | getAnalysis (Function &F) |
getAnalysis<AnalysisType>() - This function is used by subclasses to get to the analysis information that they claim to use by overriding the getAnalysisUsage function. More... | |
template<typename AnalysisType > | |
AnalysisType & | getAnalysisID (AnalysisID PI) const |
template<typename AnalysisType > | |
AnalysisType & | getAnalysisID (AnalysisID PI, Function &F) |
Static Public Attributes | |
static char | ID = 0 |
Additional Inherited Members | |
Static Public Member Functions inherited from llvm::Pass | |
static const PassInfo * | lookupPassInfo (const void *TI) |
static const PassInfo * | lookupPassInfo (StringRef Arg) |
static Pass * | createPass (AnalysisID ID) |
Protected Member Functions inherited from llvm::MachineFunctionPass | |
MachineFunctionPass (char &ID) | |
virtual MachineFunctionProperties | getRequiredProperties () const |
virtual MachineFunctionProperties | getSetProperties () const |
virtual MachineFunctionProperties | getClearedProperties () const |
Protected Member Functions inherited from llvm::FunctionPass | |
bool | skipFunction (const Function &F) const |
Optional passes call this function to check whether the pass should be skipped. More... | |
SlotIndexes pass.
This pass assigns indexes to each instruction.
Definition at line 331 of file SlotIndexes.h.
using llvm::SlotIndexes::MBBIndexIterator = SmallVectorImpl<IdxMBBPair>::const_iterator |
Iterator over the idx2MBBMap (sorted pairs of slot index of basic block begin and basic block)
Definition at line 514 of file SlotIndexes.h.
|
inline |
Definition at line 371 of file SlotIndexes.h.
References llvm::PassRegistry::getPassRegistry(), and llvm::initializeSlotIndexesPass().
|
inlineoverride |
Definition at line 375 of file SlotIndexes.h.
References llvm::iplist_impl< IntrusiveListT, TraitsT >::clearAndLeakNodesUnsafely(), and llvm::dump().
|
inline |
Move iterator to the next IdxMBBPair where the SlotIndex is greater or equal to To
.
Definition at line 518 of file SlotIndexes.h.
References llvm::SmallVectorTemplateCommon< T, typename >::end(), and llvm::lower_bound().
LLVM_DUMP_METHOD void SlotIndexes::dump | ( | ) | const |
|
inline |
Free the resources that were required to maintain a SlotIndex.
Once an index is no longer needed (for instance because the instruction at that index has been moved), the resources required to maintain the index can be relinquished to reduce memory use and improve renumbering performance. Any remaining SlotIndex objects that point to the same index are left 'dangling' (much the same as a dangling pointer to a freed object) and should not be accessed, except to destruct them.
Like dangling pointers, access to dangling SlotIndexes can cause painful-to-track-down bugs, especially if the memory for the index previously pointed to has been re-used. To detect dangling SlotIndex bugs, build with EXPENSIVE_CHECKS=1. This will cause "erased" indexes to be retained in a graveyard instead of being freed. Operations on indexes in the graveyard will trigger an assertion.
Definition at line 701 of file SlotIndexes.h.
References entry, llvm::iplist_impl< IntrusiveListT, TraitsT >::erase(), llvm::iplist_impl< IntrusiveListT, TraitsT >::push_back(), and llvm::iplist_impl< IntrusiveListT, TraitsT >::remove().
|
inline |
Get an iterator pointing to the IdxMBBPair with the biggest SlotIndex that is greater or equal to Idx
.
Definition at line 524 of file SlotIndexes.h.
References llvm::SmallVectorTemplateCommon< T, typename >::begin().
|
overridevirtual |
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
For MachineFunctionPasses, calling AU.preservesCFG() indicates that the pass does not modify the MachineBasicBlock CFG.
Reimplemented from llvm::MachineFunctionPass.
Definition at line 28 of file SlotIndexes.cpp.
References llvm::MachineFunctionPass::getAnalysisUsage().
|
inline |
getIndexAfter - Returns the index of the first indexed instruction after MI, or the end index of its basic block.
MI is not required to have an index.
Definition at line 466 of file SlotIndexes.h.
References assert(), E, llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::MachineBasicBlock::end(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), llvm::MachineInstr::getParent(), I, and MI.
|
inline |
getIndexBefore - Returns the index of the last indexed instruction before MI, or the start index of its basic block.
MI is not required to have an index.
Definition at line 449 of file SlotIndexes.h.
References assert(), B, llvm::MachineBasicBlock::begin(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), llvm::MachineInstr::getParent(), I, and MI.
|
inline |
Returns the instruction for the given index, or null if the given index has no instruction associated with it.
Definition at line 430 of file SlotIndexes.h.
References llvm::IndexListEntry::getInstr(), and llvm::SlotIndex::isValid().
Referenced by llvm::LiveIntervals::getInstructionFromIndex(), getNumAllocatableRegsForConstraints(), llvm::LiveRange::overlaps(), llvm::HexagonRegisterInfo::shouldCoalesce(), and llvm::LiveIntervals::HMEditor::updateAllRanges().
|
inline |
Returns the base index for the given instruction.
Definition at line 414 of file SlotIndexes.h.
References assert(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), llvm::getBundleEnd(), llvm::getBundleStart(), llvm::ilist_node_impl< OptionsT >::getIterator(), and llvm::skipDebugInstructionsForward().
Referenced by llvm::LiveInterval::computeSubRangeUndefs(), createDeadDef(), llvm::LiveRangeCalc::createDeadDefs(), llvm::SystemZInstrInfo::foldMemoryOperandImpl(), llvm::LiveIntervals::getInstructionIndex(), getStartOrEndSlot(), matchPair(), llvm::LiveIntervals::print(), llvm::MachineBasicBlock::print(), llvm::LiveIntervals::HMEditor::updateAllRanges(), and llvm::MachineFunction::verify().
|
inline |
Returns the base index of the last slot in this analysis.
Definition at line 403 of file SlotIndexes.h.
Referenced by llvm::createGreedyRegisterAllocator().
|
inline |
Returns the MBB covering the given range, or null if the range covers more than one basic block.
Definition at line 557 of file SlotIndexes.h.
References assert().
Returns the last index in the given basic block number.
Definition at line 503 of file SlotIndexes.h.
Referenced by llvm::LiveRangeCalc::createDeadDefs(), createSegmentsForValues(), llvm::LiveIntervals::getMBBEndIdx(), getStartOrEndSlot(), llvm::LiveIntervals::hasPHIKill(), matchPair(), llvm::LiveIntervals::pruneValue(), subRangeLiveAt(), and llvm::MachineFunction::verify().
|
inline |
Returns the last index in the given basic block.
Definition at line 508 of file SlotIndexes.h.
|
inline |
Returns the basic block which the given index falls in.
Definition at line 539 of file SlotIndexes.h.
References assert(), llvm::SmallVectorBase::empty(), I, and MI.
Referenced by createSegmentsForValues(), llvm::LiveRangeCalc::extend(), llvm::LiveIntervals::getMBBFromIndex(), llvm::LiveRangeCalc::isJointlyDominated(), llvm::LiveIntervals::pruneValue(), subRangeLiveAt(), and llvm::LiveIntervals::HMEditor::updateAllRanges().
Return the (start,end) range of the given basic block number.
Definition at line 482 of file SlotIndexes.h.
Referenced by llvm::LiveIntervals::pruneValue().
|
inline |
Return the (start,end) range of the given basic block.
Definition at line 488 of file SlotIndexes.h.
References llvm::MachineBasicBlock::getNumber().
Returns the first index in the given basic block number.
Definition at line 493 of file SlotIndexes.h.
Referenced by createSegmentsForValues(), llvm::LiveRangeCalc::extend(), llvm::LiveIntervals::getMBBStartIdx(), getStartOrEndSlot(), matchPair(), llvm::LiveIntervals::print(), llvm::MachineBasicBlock::print(), llvm::GCNScheduleDAGMILive::schedule(), and llvm::MachineFunction::verify().
|
inline |
Returns the first index in the given basic block.
Definition at line 498 of file SlotIndexes.h.
Returns the next non-null index, if one exists.
Otherwise returns getLastIndex().
Definition at line 436 of file SlotIndexes.h.
References E, llvm::ilist_node_impl< OptionsT >::getIterator(), and I.
Referenced by llvm::LiveRange::isZeroLength(), and llvm::LiveIntervals::HMEditor::updateAllRanges().
|
inline |
Returns the zero index for this analysis.
Definition at line 397 of file SlotIndexes.h.
References assert().
Referenced by llvm::createGreedyRegisterAllocator(), and getStartOrEndSlot().
|
inline |
Returns true if the given machine instr is mapped to an index, otherwise returns false.
Definition at line 409 of file SlotIndexes.h.
References llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::count().
Referenced by llvm::LiveIntervals::isNotInMIMap(), matchPair(), llvm::MachineBasicBlock::print(), and llvm::MachineFunction::verify().
|
inline |
Insert the given machine instruction into the mapping.
Returns the assigned index. If Late is set and there are null indexes between mi's neighboring instructions, create the new index after the null indexes instead of before them.
Definition at line 583 of file SlotIndexes.h.
References assert(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), llvm::MachineInstr::getParent(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::insert(), llvm::iplist_impl< IntrusiveListT, TraitsT >::insert(), llvm::MachineInstr::isDebugInstr(), llvm::MachineInstr::isInsideBundle(), and MI.
Referenced by llvm::SplitEditor::dump(), llvm::LiveIntervals::InsertMachineInstrInMaps(), llvm::LiveIntervals::InsertMachineInstrRangeInMaps(), and llvm::MachinePipeliner::runOnMachineFunction().
|
inline |
Add the given MachineBasicBlock into the maps.
Definition at line 651 of file SlotIndexes.h.
References assert(), llvm::MachineFunction::end(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::MachineBasicBlock::getNumber(), llvm::MachineBasicBlock::getParent(), llvm::iplist_impl< IntrusiveListT, TraitsT >::insert(), llvm::iplist_impl< IntrusiveListT, TraitsT >::insertAfter(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::SmallVectorTemplateBase< T >::push_back(), llvm::SmallVectorBase::size(), and llvm::sort().
Referenced by llvm::LiveIntervals::insertMBBInMaps().
|
inline |
Returns an iterator for the begin of the idx2MBBMap.
Definition at line 529 of file SlotIndexes.h.
References llvm::SmallVectorTemplateCommon< T, typename >::begin().
Referenced by llvm::MachineFunction::verify().
|
inline |
Return an iterator for the end of the idx2MBBMap.
Definition at line 534 of file SlotIndexes.h.
References llvm::SmallVectorTemplateCommon< T, typename >::end().
Referenced by llvm::MachineFunction::verify().
|
overridevirtual |
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memory when it is no longer needed.
The default behavior of passes is to hold onto memory for the entire duration of their lifetime (which is the entire compile time). For pipelined passes, this is not a big deal because that memory gets recycled every time the pass is invoked on another program unit. For IP passes, it is more important to free memory when it is unused.
Optionally implement this function to release pass memory when it is no longer used.
Reimplemented from llvm::Pass.
Definition at line 33 of file SlotIndexes.cpp.
References llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::clear(), llvm::iplist_impl< IntrusiveListT, TraitsT >::clear(), llvm::SmallVectorImpl< T >::clear(), and llvm::BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold >::Reset().
void SlotIndexes::removeMachineInstrFromMaps | ( | MachineInstr & | MI | ) |
Removes machine instruction (bundle) MI
from the mapping.
This should be called before MachineInstr::eraseFromParent() is used to remove a whole bundle or an unbundled instruction.
Definition at line 106 of file SlotIndexes.cpp.
References assert(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::erase(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), llvm::IndexListEntry::getInstr(), llvm::MachineInstr::isBundledWithPred(), and llvm::IndexListEntry::setInstr().
Referenced by llvm::LiveIntervals::RemoveMachineInstrFromMaps().
void SlotIndexes::removeSingleMachineInstrFromMaps | ( | MachineInstr & | MI | ) |
Removes a single machine instruction MI
from the mapping.
This should be called before MachineInstr::eraseFromBundle() is used to remove a single instruction (out of a bundle).
Definition at line 121 of file SlotIndexes.cpp.
References assert(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::erase(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), llvm::IndexListEntry::getInstr(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::insert(), llvm::MachineInstr::isBundledWithPred(), llvm::MachineInstr::isBundledWithSucc(), and llvm::IndexListEntry::setInstr().
void SlotIndexes::renumberIndexes | ( | ) |
Renumber the index list, providing space for new instructions.
Definition at line 148 of file SlotIndexes.cpp.
References llvm::dbgs(), E, I, llvm::SlotIndex::InstrDist, LLVM_DEBUG, and Space.
void SlotIndexes::repairIndexesInRange | ( | MachineBasicBlock * | MBB, |
MachineBasicBlock::iterator | Begin, | ||
MachineBasicBlock::iterator | End | ||
) |
Repair indexes after adding and removing instructions.
Definition at line 183 of file SlotIndexes.cpp.
|
inline |
ReplaceMachineInstrInMaps - Replacing a machine instr with a new one in maps used by register allocator.
Definition at line 636 of file SlotIndexes.h.
References assert(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::erase(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), and llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::insert().
Referenced by llvm::LiveIntervals::ReplaceMachineInstrInMaps().
|
overridevirtual |
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformation or analysis.
Implements llvm::MachineFunctionPass.
Definition at line 41 of file SlotIndexes.cpp.
References assert(), llvm::dbgs(), llvm::SmallVectorBase::empty(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::empty(), llvm::MachineFunction::getNumBlockIDs(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::insert(), llvm::SlotIndex::InstrDist, LLVM_DEBUG, MI, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::iplist_impl< IntrusiveListT, TraitsT >::push_back(), llvm::SmallVectorImpl< T >::reserve(), llvm::MachineFunction::size(), and llvm::sort().
|
static |
Definition at line 369 of file SlotIndexes.h.