|
LLVM 24.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. | |
| LLVM_ABI bool | isBlockBoundaryIndex (SlotIndex Idx) const |
Returns true if Idx refers to an entry created to mark a basic block boundary. | |
| bool | isStaleIndex (SlotIndex Idx) const |
Returns true if Idx refers to an instruction that has been erased. | |
| LLVM_ABI SlotIndex | canonicalizeIndex (SlotIndex Idx) const |
Returns the register slot of the closest instruction preceding a stale Idx, or the start index of its basic block if there is none. | |
| 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 (const MachineBasicBlock *MBB) const |
| Return the (start,end) range of the given basic block. | |
| SlotIndex | getMBBStartIdx (const MachineBasicBlock *mbb) const |
| Returns the first index in the given basic block. | |
| SlotIndex | getMBBEndIdx (const MachineBasicBlock *mbb) const |
| Returns the index past the last valid index in the given basic block. | |
| SlotIndex | getMBBLastIdx (const MachineBasicBlock *MBB) const |
| Returns the last valid 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 | removeMBBFromMaps (MachineBasicBlock &MBB) |
Inverse of insertMBBInMaps: merge MBB's slot range into its layout predecessor and drop it from 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 295 of file SlotIndexes.h.
Iterator over the idx2MBBMap (sorted pairs of slot index of basic block begin and basic block)
Definition at line 492 of file SlotIndexes.h.
|
default |
|
inline |
Definition at line 340 of file SlotIndexes.h.
| SlotIndexes::~SlotIndexes | ( | ) |
Definition at line 40 of file SlotIndexes.cpp.
Returns the register slot of the closest instruction preceding a stale Idx, or the start index of its basic block if there is none.
Returns Idx unchanged if it is not stale.
Definition at line 139 of file SlotIndexes.cpp.
References getMBBFromIndex(), getMBBStartIdx(), I, and isStaleIndex().
| LLVM_DUMP_METHOD void SlotIndexes::dump | ( | ) | const |
Dump the indexes.
Definition at line 341 of file SlotIndexes.cpp.
References llvm::dbgs(), LLVM_DUMP_METHOD, 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 447 of file SlotIndexes.h.
References assert(), E(), 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 428 of file SlotIndexes.h.
References assert(), B(), 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 395 of file SlotIndexes.h.
References llvm::IndexListEntry::getInstr().
Referenced by getMBBFromIndex(), isBlockBoundaryIndex(), isStaleIndex(), llvm::LiveRange::overlaps(), llvm::HexagonRegisterInfo::shouldCoalesce(), and stripValuesNotDefiningMask().
|
inline |
Returns the base index for the given instruction.
Definition at line 377 of file SlotIndexes.h.
References assert(), llvm::getBundleEnd(), llvm::getBundleStart(), llvm::MachineInstr::isDebugInstr(), MI, and llvm::skipDebugInstructionsForward().
Referenced by buildVRegToDbgValueMap(), llvm::LiveInterval::computeSubRangeUndefs(), createDeadDef(), llvm::SystemZInstrInfo::foldMemoryOperandImpl(), llvm::RISCV::getVNInfoFromReg(), insertMBBInMaps(), llvm::MachineBasicBlock::print(), and repairIndexesInRange().
|
inline |
Returns the base index of the last slot in this analysis.
Definition at line 366 of file SlotIndexes.h.
Referenced by getNextNonNullIndex().
|
inline |
Returns the index past the last valid index in the given basic block.
Definition at line 475 of file SlotIndexes.h.
References getMBBRange().
Referenced by buildVRegToDbgValueMap(), collectPHIKills(), llvm::dumpMaxRegPressure(), getIndexAfter(), getMBBFromIndex(), getMBBLastIdx(), insertMBBInMaps(), isBlockBoundaryIndex(), print(), and repairIndexesInRange().
|
inline |
Returns the basic block which the given index falls in.
Definition at line 526 of file SlotIndexes.h.
References assert(), getInstructionFromIndex(), getMBBEndIdx(), getMBBUpperBound(), I, MBBIndexEnd(), and MI.
Referenced by canonicalizeIndex(), and collectPHIKills().
|
inline |
Returns the last valid index in the given basic block.
This index corresponds to the dead slot of the last non-debug instruction and can be used to find live-out ranges of the block. Note that getMBBEndIdx returns the start index of the next block, which is also used as the start index for segments with phi-def values. If the basic block doesn't contain any non-debug instructions, this returns the same as getMBBStartIdx.getDeadSlot().
Definition at line 486 of file SlotIndexes.h.
References getMBBEndIdx(), llvm::SlotIndex::getPrevSlot(), and MBB.
Referenced by llvm::GCNRegPressurePrinter::runOnMachineFunction().
|
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 497 of file SlotIndexes.h.
References MBBIndexEnd().
Referenced by getMBBLowerBound(), and removeMBBFromMaps().
|
inline |
Definition at line 503 of file SlotIndexes.h.
References getMBBLowerBound(), and MBBIndexBegin().
|
inline |
Return the (start,end) range of the given basic block.
Definition at line 465 of file SlotIndexes.h.
References MBB.
Referenced by getMBBEndIdx(), and getMBBStartIdx().
|
inline |
Returns the first index in the given basic block.
Definition at line 470 of file SlotIndexes.h.
References getMBBRange().
Referenced by buildVRegToDbgValueMap(), canonicalizeIndex(), getIndexBefore(), llvm::MachineBasicBlock::print(), 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 509 of file SlotIndexes.h.
References MBBIndexBegin(), and MBBIndexEnd().
Referenced by getMBBFromIndex(), and isBlockBoundaryIndex().
Returns the next non-null index, if one exists.
Otherwise returns getLastIndex().
Definition at line 415 of file SlotIndexes.h.
References E(), getLastIndex(), and I.
Referenced by llvm::LiveRange::isZeroLength().
|
inline |
Returns the zero index for this analysis.
Definition at line 360 of file SlotIndexes.h.
References assert().
|
inline |
Returns true if the given machine instr is mapped to an index, otherwise returns false.
Definition at line 372 of file SlotIndexes.h.
References llvm::instr.
Referenced by llvm::MachineBasicBlock::print().
|
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 542 of file SlotIndexes.h.
References assert(), getIndexAfter(), getIndexBefore(), llvm::ilist_node_impl< OptionsT >::getIterator(), and MI.
Referenced by insertCSRRestores(), llvm::SIInstrInfo::insertScratchExecCopy(), repairIndexesInRange(), llvm::SIInstrInfo::restoreExec(), llvm::SIRegisterInfo::restoreSGPR(), and llvm::SIRegisterInfo::spillSGPR().
|
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 617 of file SlotIndexes.h.
References assert(), llvm::MachineBasicBlock::empty(), llvm::MachineBasicBlock::front(), llvm::MachineFunction::front(), llvm::MachineBasicBlock::getAnalysisNumber(), getInstructionIndex(), llvm::ilist_node_impl< OptionsT >::getIterator(), getMBBEndIdx(), llvm::MachineBasicBlock::getParent(), and llvm::partition_point().
Referenced by llvm::MachineBasicBlock::SplitCriticalEdge().
Returns true if Idx refers to an entry created to mark a basic block boundary.
Such entries never have an instruction attached.
Definition at line 125 of file SlotIndexes.cpp.
References assert(), llvm::sampleprof::Base, getInstructionFromIndex(), getMBBEndIdx(), getMBBUpperBound(), and I.
Referenced by isStaleIndex().
Returns true if Idx refers to an instruction that has been erased.
Definition at line 404 of file SlotIndexes.h.
References getInstructionFromIndex(), and isBlockBoundaryIndex().
Referenced by canonicalizeIndex().
|
inline |
Returns an iterator for the begin of the idx2MBBMap.
Definition at line 516 of file SlotIndexes.h.
Referenced by getMBBLowerBound(), and getMBBUpperBound().
|
inline |
Return an iterator for the end of the idx2MBBMap.
Definition at line 521 of file SlotIndexes.h.
Referenced by getMBBFromIndex(), getMBBLowerBound(), getMBBUpperBound(), and removeMBBFromMaps().
| void SlotIndexes::packIndexes | ( | ) |
Renumber all indexes using the default instruction distance.
Definition at line 320 of file SlotIndexes.cpp.
References llvm::enumerate(), and llvm::SlotIndex::InstrDist.
| void SlotIndexes::print | ( | raw_ostream & | OS | ) | const |
Definition at line 325 of file SlotIndexes.cpp.
References getMBBEndIdx(), getMBBStartIdx(), MBB, and llvm::printMBBReference().
Referenced by dump().
|
inline |
Definition at line 344 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 154 of file SlotIndexes.cpp.
References assert(), llvm::IndexListEntry::getInstr(), MI, and llvm::IndexListEntry::setInstr().
Referenced by repairIndexesInRange().
| void SlotIndexes::removeMBBFromMaps | ( | MachineBasicBlock & | MBB | ) |
Inverse of insertMBBInMaps: merge MBB's slot range into its layout predecessor and drop it from the maps.
Call before erasing MBB and after its instructions have been removed from the maps.
Definition at line 197 of file SlotIndexes.cpp.
References assert(), getMBBLowerBound(), MBB, MBBIndexEnd(), and llvm::IndexListEntry::setInstr().
| 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 170 of file SlotIndexes.cpp.
References assert(), llvm::IndexListEntry::getInstr(), MI, llvm::Next, 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 250 of file SlotIndexes.cpp.
References assert(), getInstructionIndex(), llvm::ilist_node_impl< OptionsT >::getIterator(), getMBBEndIdx(), getMBBStartIdx(), llvm::MachineInstr::getParent(), insertMachineInstrInMaps(), llvm::MachineInstr::isDebugOrPseudoInstr(), MBB, MBBI, MI, and removeMachineInstrFromMaps().
Referenced by insertCSRRestores().
|
inline |
ReplaceMachineInstrInMaps - Replacing a machine instr with a new one in maps used by register allocator.
Definition at line 599 of file SlotIndexes.h.
References assert(), llvm::IndexListEntry::getInstr(), MI, and llvm::IndexListEntry::setInstr().
Referenced by llvm::SIRegisterInfo::restoreSGPR(), and llvm::SIRegisterInfo::spillSGPR().
|
friend |
Definition at line 296 of file SlotIndexes.h.
References LLVM_ABI, and SlotIndexesWrapperPass.
Referenced by SlotIndexesWrapperPass.