LLVM 20.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) | |
~SlotIndexes () | |
void | reanalyze (MachineFunction &MF) |
void | print (raw_ostream &OS) const |
void | dump () const |
Dump the indexes. | |
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. | |
void | removeMachineInstrFromMaps (MachineInstr &MI, bool AllowBundled=false) |
Removes machine instruction (bundle) MI from the mapping. | |
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. | |
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 297 of file SlotIndexes.h.
Iterator over the idx2MBBMap (sorted pairs of slot index of basic block begin and basic block)
Definition at line 481 of file SlotIndexes.h.
|
default |
|
inline |
Definition at line 342 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 273 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 433 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 416 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 397 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 379 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 368 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 475 of file SlotIndexes.h.
References getMBBRange().
Returns the last index in the given basic block number.
Definition at line 470 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(), llvm::GCNRegPressurePrinter::runOnMachineFunction(), and llvm::MachineBasicBlock::SplitCriticalEdge().
|
inline |
Returns the basic block which the given index falls in.
Definition at line 515 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 486 of file SlotIndexes.h.
References Idx, and MBBIndexEnd().
Referenced by getMBBLowerBound().
|
inline |
Definition at line 492 of file SlotIndexes.h.
References getMBBLowerBound(), Idx, and MBBIndexBegin().
|
inline |
Return the (start,end) range of the given basic block.
Definition at line 455 of file SlotIndexes.h.
References getMBBRange(), and MBB.
|
inline |
Return the (start,end) range of the given basic block number.
Definition at line 449 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 465 of file SlotIndexes.h.
References getMBBRange().
Returns the first index in the given basic block number.
Definition at line 460 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 498 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 403 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 362 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 374 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 531 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(), 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 606 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 505 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 510 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 252 of file SlotIndexes.cpp.
References llvm::enumerate(), and llvm::SlotIndex::InstrDist.
Referenced by llvm::RAGreedy::runOnMachineFunction().
void SlotIndexes::print | ( | raw_ostream & | OS | ) | const |
|
inline |
Definition at line 346 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(), I, insertMachineInstrInMaps(), MBB, MBBI, MI, and removeMachineInstrFromMaps().
Referenced by llvm::LiveIntervals::repairIntervalsInRange().
|
inline |
ReplaceMachineInstrInMaps - Replacing a machine instr with a new one in maps used by register allocator.
Definition at line 588 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 298 of file SlotIndexes.h.