LLVM 22.0.0git
|
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) | |
Public Member Functions | |
SlotIndexes (SlotIndexes &&)=default | |
SlotIndexes (MachineFunction &MF) | |
LLVM_ABI | ~SlotIndexes () |
void | reanalyze (MachineFunction &MF) |
LLVM_ABI void | print (raw_ostream &OS) const |
LLVM_ABI void | dump () const |
Dump the indexes. | |
LLVM_ABI void | repairIndexesInRange (MachineBasicBlock *MBB, MachineBasicBlock::iterator Begin, MachineBasicBlock::iterator End) |
Repair indexes after adding and removing instructions. | |
SlotIndex | getZeroIndex () |
Returns the zero index for this analysis. | |
SlotIndex | getLastIndex () |
Returns the base index of the last slot in this analysis. | |
bool | hasIndex (const MachineInstr &instr) const |
Returns true if the given machine instr is mapped to an index, otherwise returns false. | |
SlotIndex | getInstructionIndex (const MachineInstr &MI, bool IgnoreBundle=false) const |
Returns the base index for the given instruction. | |
MachineInstr * | getInstructionFromIndex (SlotIndex index) const |
Returns the instruction for the given index, or null if the given index has no instruction associated with it. | |
SlotIndex | getNextNonNullIndex (SlotIndex Index) |
Returns the next non-null index, if one exists. | |
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. | |
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. | |
const std::pair< SlotIndex, SlotIndex > & | getMBBRange (unsigned Num) const |
Return the (start,end) range of the given basic block number. | |
const std::pair< SlotIndex, SlotIndex > & | getMBBRange (const MachineBasicBlock *MBB) const |
Return the (start,end) range of the given basic block. | |
SlotIndex | getMBBStartIdx (unsigned Num) const |
Returns the first index in the given basic block number. | |
SlotIndex | getMBBStartIdx (const MachineBasicBlock *mbb) const |
Returns the first index in the given basic block. | |
SlotIndex | getMBBEndIdx (unsigned Num) const |
Returns the last index in the given basic block number. | |
SlotIndex | getMBBEndIdx (const MachineBasicBlock *mbb) const |
Returns the last index in the given basic block. | |
MBBIndexIterator | getMBBLowerBound (MBBIndexIterator Start, SlotIndex Idx) const |
Get an iterator pointing to the first IdxMBBPair with SlotIndex greater than or equal to Idx . | |
MBBIndexIterator | getMBBLowerBound (SlotIndex Idx) const |
MBBIndexIterator | getMBBUpperBound (SlotIndex Idx) const |
Get an iterator pointing to the first IdxMBBPair with SlotIndex greater than Idx . | |
MBBIndexIterator | MBBIndexBegin () const |
Returns an iterator for the begin of the idx2MBBMap. | |
MBBIndexIterator | MBBIndexEnd () const |
Return an iterator for the end of the idx2MBBMap. | |
MachineBasicBlock * | getMBBFromIndex (SlotIndex index) const |
Returns the basic block which the given index falls in. | |
SlotIndex | insertMachineInstrInMaps (MachineInstr &MI, bool Late=false) |
Insert the given machine instruction into the mapping. | |
LLVM_ABI void | removeMachineInstrFromMaps (MachineInstr &MI, bool AllowBundled=false) |
Removes machine instruction (bundle) MI from the mapping. | |
LLVM_ABI void | removeSingleMachineInstrFromMaps (MachineInstr &MI) |
Removes a single machine instruction MI from the mapping. | |
SlotIndex | replaceMachineInstrInMaps (MachineInstr &MI, MachineInstr &NewMI) |
ReplaceMachineInstrInMaps - Replacing a machine instr with a new one in maps used by register allocator. | |
void | insertMBBInMaps (MachineBasicBlock *mbb) |
Add the given MachineBasicBlock into the maps. | |
LLVM_ABI void | packIndexes () |
Renumber all indexes using the default instruction distance. | |
Friends | |
class | SlotIndexesWrapperPass |
SlotIndexes pass.
This pass assigns indexes to each instruction.
Definition at line 298 of file SlotIndexes.h.
Iterator over the idx2MBBMap (sorted pairs of slot index of basic block begin and basic block)
Definition at line 482 of file SlotIndexes.h.
|
default |
|
inline |
Definition at line 343 of file SlotIndexes.h.
SlotIndexes::~SlotIndexes | ( | ) |
Definition at line 42 of file SlotIndexes.cpp.
References llvm::simple_ilist< T, Options >::clear().
LLVM_DUMP_METHOD void SlotIndexes::dump | ( | ) | const |
Dump the indexes.
Definition at line 282 of file SlotIndexes.cpp.
References llvm::dbgs(), and print().
|
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 434 of file SlotIndexes.h.
References assert(), E, llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), getMBBEndIdx(), I, MBB, and MI.
Referenced by insertMachineInstrInMaps().
|
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 417 of file SlotIndexes.h.
References assert(), B, llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), getMBBStartIdx(), I, MBB, and MI.
Referenced by insertMachineInstrInMaps().
|
inline |
Returns the instruction for the given index, or null if the given index has no instruction associated with it.
Definition at line 398 of file SlotIndexes.h.
References llvm::IndexListEntry::getInstr().
Referenced by llvm::LiveIntervals::getInstructionFromIndex(), getMBBFromIndex(), llvm::LiveRange::overlaps(), llvm::HexagonRegisterInfo::shouldCoalesce(), and stripValuesNotDefiningMask().
|
inline |
Returns the base index for the given instruction.
Definition at line 380 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::MachineInstr::isDebugInstr(), MI, and llvm::skipDebugInstructionsForward().
Referenced by buildVRegToDbgValueMap(), llvm::LiveInterval::computeSubRangeUndefs(), createDeadDef(), llvm::SystemZInstrInfo::foldMemoryOperandImpl(), llvm::LiveIntervals::getInstructionIndex(), llvm::LiveIntervals::handleMove(), llvm::LiveIntervals::handleMoveIntoNewBundle(), insertMBBInMaps(), llvm::MachineBasicBlock::print(), and repairIndexesInRange().
|
inline |
Returns the base index of the last slot in this analysis.
Definition at line 369 of file SlotIndexes.h.
References llvm::simple_ilist< T, Options >::back().
Referenced by getNextNonNullIndex().
|
inline |
Returns the last index in the given basic block.
Definition at line 476 of file SlotIndexes.h.
References getMBBRange().
Returns the last index in the given basic block number.
Definition at line 471 of file SlotIndexes.h.
References getMBBRange().
Referenced by buildVRegToDbgValueMap(), getIndexAfter(), llvm::LiveIntervals::getMBBEndIdx(), getMBBFromIndex(), llvm::LiveIntervals::hasPHIKill(), insertMBBInMaps(), llvm::LiveIntervals::pruneValue(), repairIndexesInRange(), llvm::GCNUpwardRPTracker::reset(), and llvm::GCNRegPressurePrinter::runOnMachineFunction().
|
inline |
Returns the basic block which the given index falls in.
Definition at line 516 of file SlotIndexes.h.
References assert(), getInstructionFromIndex(), getMBBEndIdx(), getMBBUpperBound(), I, MBBIndexEnd(), and MI.
Referenced by llvm::LiveRangeCalc::extend(), llvm::LiveIntervals::getMBBFromIndex(), llvm::LiveIntervals::intervalIsInOneMBB(), llvm::LiveRangeCalc::isJointlyDominated(), and llvm::LiveIntervals::pruneValue().
|
inline |
Get an iterator pointing to the first IdxMBBPair with SlotIndex greater than or equal to Idx
.
If Start
is provided, only search the range from Start
to the end of the function.
Definition at line 487 of file SlotIndexes.h.
References Idx, and MBBIndexEnd().
Referenced by getMBBLowerBound().
|
inline |
Definition at line 493 of file SlotIndexes.h.
References getMBBLowerBound(), Idx, and MBBIndexBegin().
|
inline |
Return the (start,end) range of the given basic block.
Definition at line 456 of file SlotIndexes.h.
References getMBBRange(), and MBB.
|
inline |
Return the (start,end) range of the given basic block number.
Definition at line 450 of file SlotIndexes.h.
Referenced by getMBBEndIdx(), getMBBRange(), getMBBStartIdx(), llvm::LiveIntervals::pruneValue(), llvm::SplitEditor::splitLiveThroughBlock(), llvm::SplitEditor::splitRegInBlock(), and llvm::SplitEditor::splitRegOutBlock().
|
inline |
Returns the first index in the given basic block.
Definition at line 466 of file SlotIndexes.h.
References getMBBRange().
Returns the first index in the given basic block number.
Definition at line 461 of file SlotIndexes.h.
References getMBBRange().
Referenced by buildVRegToDbgValueMap(), llvm::LiveRangeCalc::extend(), getIndexBefore(), llvm::LiveIntervals::getMBBStartIdx(), llvm::MachineBasicBlock::print(), repairIndexesInRange(), llvm::GCNRegPressurePrinter::runOnMachineFunction(), and llvm::LiveDebugVariables::LDVImpl::runOnMachineFunction().
|
inline |
Get an iterator pointing to the first IdxMBBPair with SlotIndex greater than Idx
.
Definition at line 499 of file SlotIndexes.h.
References Idx, MBBIndexBegin(), and MBBIndexEnd().
Referenced by getMBBFromIndex().
Returns the next non-null index, if one exists.
Otherwise returns getLastIndex().
Definition at line 404 of file SlotIndexes.h.
References E, llvm::simple_ilist< T, Options >::end(), getLastIndex(), I, and Index.
Referenced by llvm::LiveRange::isZeroLength().
|
inline |
Returns the zero index for this analysis.
Definition at line 363 of file SlotIndexes.h.
References assert(), and llvm::simple_ilist< T, Options >::front().
|
inline |
Returns true if the given machine instr is mapped to an index, otherwise returns false.
Definition at line 375 of file SlotIndexes.h.
References llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::count(), and instr.
Referenced by llvm::LiveIntervals::handleMoveIntoNewBundle(), llvm::LiveIntervals::isNotInMIMap(), llvm::MachineBasicBlock::print(), and llvm::LiveIntervals::repairIntervalsInRange().
|
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 532 of file SlotIndexes.h.
References assert(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::contains(), getIndexAfter(), getIndexBefore(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::insert(), llvm::simple_ilist< T, Options >::insert(), and MI.
Referenced by llvm::LiveIntervals::handleMove(), llvm::LiveIntervals::handleMoveIntoNewBundle(), insertCSRRestores(), insertCSRSaves(), llvm::LiveIntervals::InsertMachineInstrInMaps(), llvm::LiveIntervals::InsertMachineInstrRangeInMaps(), llvm::SIInstrInfo::insertScratchExecCopy(), llvm::LiveRangeEdit::rematerializeAt(), repairIndexesInRange(), llvm::SIInstrInfo::restoreExec(), llvm::SIRegisterInfo::restoreSGPR(), llvm::SIRegisterInfo::spillSGPR(), and SlotIndexUpdateDelegate::~SlotIndexUpdateDelegate().
|
inline |
Add the given MachineBasicBlock into the maps.
If it contains any instructions then they must already be in the maps. This is used after a block has been split by moving some suffix of its instructions into a newly created block.
Definition at line 607 of file SlotIndexes.h.
References assert(), llvm::MachineBasicBlock::empty(), llvm::MachineBasicBlock::front(), llvm::MachineFunction::front(), getInstructionIndex(), llvm::ilist_node_impl< OptionsT >::getIterator(), getMBBEndIdx(), llvm::MachineBasicBlock::getNumber(), llvm::MachineBasicBlock::getParent(), llvm::simple_ilist< T, Options >::insert(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::SmallVectorBase< Size_T >::size(), and llvm::sort().
Referenced by llvm::LiveIntervals::insertMBBInMaps(), and llvm::MachineBasicBlock::SplitCriticalEdge().
|
inline |
Returns an iterator for the begin of the idx2MBBMap.
Definition at line 506 of file SlotIndexes.h.
References llvm::SmallVectorTemplateCommon< T, typename >::begin().
Referenced by getMBBLowerBound(), and getMBBUpperBound().
|
inline |
Return an iterator for the end of the idx2MBBMap.
Definition at line 511 of file SlotIndexes.h.
References llvm::SmallVectorTemplateCommon< T, typename >::end().
Referenced by getMBBFromIndex(), getMBBLowerBound(), and getMBBUpperBound().
void SlotIndexes::packIndexes | ( | ) |
Renumber all indexes using the default instruction distance.
Definition at line 261 of file SlotIndexes.cpp.
References llvm::enumerate(), and llvm::SlotIndex::InstrDist.
void SlotIndexes::print | ( | raw_ostream & | OS | ) | const |
|
inline |
Definition at line 347 of file SlotIndexes.h.
void SlotIndexes::removeMachineInstrFromMaps | ( | MachineInstr & | MI, |
bool | AllowBundled = false |
||
) |
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. If AllowBundled
is set then this can be used on a bundled instruction; however, this exists to support handleMoveIntoBundle, and in general removeSingleMachineInstrFromMaps should be used instead.
Definition at line 127 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(), MI, and llvm::IndexListEntry::setInstr().
Referenced by llvm::WindowScheduler::backupMBB(), llvm::LiveIntervals::handleMove(), llvm::LiveIntervals::handleMoveIntoNewBundle(), SlotIndexUpdateDelegate::MF_HandleRemoval(), llvm::LiveIntervals::RemoveMachineInstrFromMaps(), repairIndexesInRange(), and llvm::WindowScheduler::restoreMBB().
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 143 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::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::insert(), MI, and llvm::IndexListEntry::setInstr().
void SlotIndexes::repairIndexesInRange | ( | MachineBasicBlock * | MBB, |
MachineBasicBlock::iterator | Begin, | ||
MachineBasicBlock::iterator | End | ||
) |
Repair indexes after adding and removing instructions.
Definition at line 191 of file SlotIndexes.cpp.
References assert(), llvm::MachineBasicBlock::begin(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::contains(), llvm::MachineBasicBlock::end(), End, getInstructionIndex(), llvm::ilist_node_impl< OptionsT >::getIterator(), getMBBEndIdx(), getMBBStartIdx(), llvm::MachineInstr::getParent(), insertMachineInstrInMaps(), llvm::MachineInstr::isDebugOrPseudoInstr(), MBB, MBBI, MI, and removeMachineInstrFromMaps().
Referenced by insertCSRRestores(), insertCSRSaves(), and llvm::LiveIntervals::repairIntervalsInRange().
|
inline |
ReplaceMachineInstrInMaps - Replacing a machine instr with a new one in maps used by register allocator.
Definition at line 589 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(), llvm::IndexListEntry::getInstr(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::insert(), MI, and llvm::IndexListEntry::setInstr().
Referenced by llvm::LiveIntervals::ReplaceMachineInstrInMaps(), llvm::SIRegisterInfo::restoreSGPR(), and llvm::SIRegisterInfo::spillSGPR().
|
friend |
Definition at line 299 of file SlotIndexes.h.