LLVM 17.0.0git
|
#include "llvm/CodeGen/LiveIntervals.h"
Classes | |
class | HMEditor |
Toolkit used by handleMove to trim or extend live intervals. More... | |
Public Member Functions | |
LiveIntervals () | |
~LiveIntervals () override | |
LiveInterval & | getInterval (Register Reg) |
const LiveInterval & | getInterval (Register Reg) const |
bool | hasInterval (Register Reg) const |
LiveInterval & | createEmptyInterval (Register Reg) |
Interval creation. | |
LiveInterval & | createAndComputeVirtRegInterval (Register Reg) |
void | removeInterval (Register Reg) |
Interval removal. | |
LiveInterval::Segment | addSegmentToEndOfBlock (Register Reg, MachineInstr &startInst) |
Given a register and an instruction, adds a live segment from that instruction to the end of its MBB. | |
bool | shrinkToUses (LiveInterval *li, SmallVectorImpl< MachineInstr * > *dead=nullptr) |
After removing some uses of a register, shrink its live range to just the remaining uses. | |
void | shrinkToUses (LiveInterval::SubRange &SR, Register Reg) |
Specialized version of shrinkToUses(LiveInterval li, SmallVectorImpl<MachineInstr> *dead) that works on a subregister live range and only looks at uses matching the lane mask of the subregister range. | |
void | extendToIndices (LiveRange &LR, ArrayRef< SlotIndex > Indices, ArrayRef< SlotIndex > Undefs) |
Extend the live range LR to reach all points in Indices . | |
void | extendToIndices (LiveRange &LR, ArrayRef< SlotIndex > Indices) |
void | pruneValue (LiveRange &LR, SlotIndex Kill, SmallVectorImpl< SlotIndex > *EndPoints) |
If LR has a live value at Kill , prune its live range by removing any liveness reachable from Kill. | |
LLVM_ATTRIBUTE_UNUSED void | pruneValue (LiveInterval &, SlotIndex, SmallVectorImpl< SlotIndex > *) |
This function should not be used. | |
SlotIndexes * | getSlotIndexes () const |
bool | isNotInMIMap (const MachineInstr &Instr) const |
Returns true if the specified machine instr has been removed or was never entered in the map. | |
SlotIndex | getInstructionIndex (const MachineInstr &Instr) const |
Returns the base index of the given instruction. | |
MachineInstr * | getInstructionFromIndex (SlotIndex index) const |
Returns the instruction associated with the given index. | |
SlotIndex | getMBBStartIdx (const MachineBasicBlock *mbb) const |
Return the first index in the given basic block. | |
SlotIndex | getMBBEndIdx (const MachineBasicBlock *mbb) const |
Return the last index in the given basic block. | |
bool | isLiveInToMBB (const LiveRange &LR, const MachineBasicBlock *mbb) const |
bool | isLiveOutOfMBB (const LiveRange &LR, const MachineBasicBlock *mbb) const |
MachineBasicBlock * | getMBBFromIndex (SlotIndex index) const |
void | insertMBBInMaps (MachineBasicBlock *MBB) |
SlotIndex | InsertMachineInstrInMaps (MachineInstr &MI) |
void | InsertMachineInstrRangeInMaps (MachineBasicBlock::iterator B, MachineBasicBlock::iterator E) |
void | RemoveMachineInstrFromMaps (MachineInstr &MI) |
SlotIndex | ReplaceMachineInstrInMaps (MachineInstr &MI, MachineInstr &NewMI) |
VNInfo::Allocator & | getVNInfoAllocator () |
void | getAnalysisUsage (AnalysisUsage &AU) const override |
getAnalysisUsage - This function should be overriden by passes that need analysis information to do their job. | |
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. | |
bool | runOnMachineFunction (MachineFunction &) override |
Pass entry point; Calculates LiveIntervals. | |
void | print (raw_ostream &O, const Module *=nullptr) const override |
Implement the dump method. | |
MachineBasicBlock * | intervalIsInOneMBB (const LiveInterval &LI) const |
If LI is confined to a single basic block, return a pointer to that block. | |
bool | hasPHIKill (const LiveInterval &LI, const VNInfo *VNI) const |
Returns true if VNI is killed by any PHI-def values in LI. | |
void | addKillFlags (const VirtRegMap *) |
Add kill flags to any instruction that kills a virtual register. | |
void | handleMove (MachineInstr &MI, bool UpdateFlags=false) |
Call this method to notify LiveIntervals that instruction MI has been moved within a basic block. | |
void | handleMoveIntoNewBundle (MachineInstr &BundleStart, bool UpdateFlags=false) |
Update intervals of operands of all instructions in the newly created bundle specified by BundleStart . | |
void | repairIntervalsInRange (MachineBasicBlock *MBB, MachineBasicBlock::iterator Begin, MachineBasicBlock::iterator End, ArrayRef< Register > OrigRegs) |
Update live intervals for instructions in a range of iterators. | |
ArrayRef< SlotIndex > | getRegMaskSlots () const |
Returns a sorted array of slot indices of all instructions with register mask operands. | |
ArrayRef< SlotIndex > | getRegMaskSlotsInBlock (unsigned MBBNum) const |
Returns a sorted array of slot indices of all instructions with register mask operands in the basic block numbered MBBNum . | |
ArrayRef< const uint32_t * > | getRegMaskBits () const |
Returns an array of register mask pointers corresponding to getRegMaskSlots(). | |
ArrayRef< const uint32_t * > | getRegMaskBitsInBlock (unsigned MBBNum) const |
Returns an array of mask pointers corresponding to getRegMaskSlotsInBlock(MBBNum). | |
bool | checkRegMaskInterference (const LiveInterval &LI, BitVector &UsableRegs) |
Test if LI is live across any register mask instructions, and compute a bit mask of physical registers that are not clobbered by any of them. | |
LiveRange & | getRegUnit (unsigned Unit) |
Return the live range for register unit Unit . | |
LiveRange * | getCachedRegUnit (unsigned Unit) |
Return the live range for register unit Unit if it has already been computed, or nullptr if it hasn't been computed yet. | |
const LiveRange * | getCachedRegUnit (unsigned Unit) const |
void | removeRegUnit (unsigned Unit) |
Remove computed live range for register unit Unit . | |
void | removeAllRegUnitsForPhysReg (MCRegister Reg) |
Remove associated live ranges for the register units associated with Reg . | |
void | removePhysRegDefAt (MCRegister Reg, SlotIndex Pos) |
Remove value numbers and related live segments starting at position Pos that are part of any liverange of physical register Reg or one of its subregisters. | |
void | removeVRegDefAt (LiveInterval &LI, SlotIndex Pos) |
Remove value number and related live segments of LI and its subranges that start at position Pos . | |
void | splitSeparateComponents (LiveInterval &LI, SmallVectorImpl< LiveInterval * > &SplitLIs) |
Split separate components in LiveInterval LI into separate intervals. | |
void | constructMainRangeFromSubranges (LiveInterval &LI) |
For live interval LI with correct SubRanges construct matching information for the main live range. | |
![]() | |
bool | doInitialization (Module &) override |
doInitialization - Virtual method overridden by subclasses to do any necessary initialization before any pass is run. | |
![]() | |
FunctionPass (char &pid) | |
Pass * | createPrinterPass (raw_ostream &OS, const std::string &Banner) const override |
createPrinterPass - Get a function printer pass. | |
virtual bool | runOnFunction (Function &F)=0 |
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass. | |
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. | |
PassManagerType | getPotentialPassManagerType () const override |
Return what kind of Pass Manager can manage this 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. | |
AnalysisID | getPassID () const |
getPassID - Return the PassID number that corresponds to this pass. | |
virtual bool | doInitialization (Module &) |
doInitialization - Virtual method overridden by subclasses to do any necessary initialization before any pass is run. | |
virtual bool | doFinalization (Module &) |
doFinalization - Virtual method overriden by subclasses to do any necessary clean up after all passes have run. | |
virtual void | print (raw_ostream &OS, const Module *M) const |
print - Print out the internal state of the pass. | |
void | dump () const |
virtual Pass * | createPrinterPass (raw_ostream &OS, const std::string &Banner) const =0 |
createPrinterPass - Get a Pass appropriate to print the IR this pass operates on (Module, Function or MachineFunction). | |
virtual void | assignPassManager (PMStack &, PassManagerType) |
Each pass is responsible for assigning a pass manager to itself. | |
virtual void | preparePassManager (PMStack &) |
Check if available pass managers are suitable for this pass or not. | |
virtual PassManagerType | getPotentialPassManagerType () const |
Return what kind of Pass Manager can manage this pass. | |
void | setResolver (AnalysisResolver *AR) |
AnalysisResolver * | getResolver () const |
virtual void | getAnalysisUsage (AnalysisUsage &) const |
getAnalysisUsage - This function should be overriden by passes that need analysis information to do their job. | |
virtual void | releaseMemory () |
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. | |
virtual void * | getAdjustedAnalysisPointer (AnalysisID ID) |
getAdjustedAnalysisPointer - This method is used when a pass implements an analysis interface through multiple inheritance. | |
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. | |
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. | |
bool | mustPreserveAnalysisID (char &AID) const |
mustPreserveAnalysisID - This method serves the same function as getAnalysisIfAvailable, but works if you just have an AnalysisID. | |
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. | |
template<typename AnalysisType > | |
AnalysisType & | getAnalysis (Function &F, bool *Changed=nullptr) |
getAnalysis<AnalysisType>() - This function is used by subclasses to get to the analysis information that they claim to use by overriding the getAnalysisUsage function. | |
template<typename AnalysisType > | |
AnalysisType & | getAnalysisID (AnalysisID PI) const |
template<typename AnalysisType > | |
AnalysisType & | getAnalysisID (AnalysisID PI, Function &F, bool *Changed=nullptr) |
Static Public Member Functions | |
static float | getSpillWeight (bool isDef, bool isUse, const MachineBlockFrequencyInfo *MBFI, const MachineInstr &MI) |
Calculate the spill weight to assign to a single instruction. | |
static float | getSpillWeight (bool isDef, bool isUse, const MachineBlockFrequencyInfo *MBFI, const MachineBasicBlock *MBB) |
Calculate the spill weight to assign to a single instruction. | |
![]() | |
static const PassInfo * | lookupPassInfo (const void *TI) |
static const PassInfo * | lookupPassInfo (StringRef Arg) |
static Pass * | createPass (AnalysisID ID) |
Static Public Attributes | |
static char | ID = 0 |
Additional Inherited Members | |
![]() | |
MachineFunctionPass (char &ID) | |
virtual bool | runOnMachineFunction (MachineFunction &MF)=0 |
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformation or analysis. | |
void | getAnalysisUsage (AnalysisUsage &AU) const override |
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this. | |
virtual MachineFunctionProperties | getRequiredProperties () const |
virtual MachineFunctionProperties | getSetProperties () const |
virtual MachineFunctionProperties | getClearedProperties () const |
![]() | |
bool | skipFunction (const Function &F) const |
Optional passes call this function to check whether the pass should be skipped. | |
Definition at line 53 of file LiveIntervals.h.
LiveIntervals::LiveIntervals | ( | ) |
Definition at line 97 of file LiveIntervals.cpp.
References llvm::PassRegistry::getPassRegistry(), and llvm::initializeLiveIntervalsPass().
|
override |
Definition at line 101 of file LiveIntervals.cpp.
void LiveIntervals::addKillFlags | ( | const VirtRegMap * | VRM | ) |
Add kill flags to any instruction that kills a virtual register.
Definition at line 687 of file LiveIntervals.cpp.
References llvm::LiveRange::advanceTo(), assert(), llvm::LiveRange::begin(), llvm::SmallVectorImpl< T >::clear(), llvm::LiveRange::empty(), llvm::LiveRange::Segment::end, llvm::LiveRange::end(), llvm::LiveRange::find(), llvm::LaneBitmask::getAll(), getInstructionFromIndex(), getInterval(), llvm::MachineRegisterInfo::getMaxLaneMaskForVReg(), llvm::LaneBitmask::getNone(), llvm::MachineRegisterInfo::getNumVirtRegs(), llvm::VirtRegMap::getPhys(), getRegUnit(), llvm::TargetRegisterInfo::getSubRegIndexLaneMask(), llvm::LiveInterval::hasSubRanges(), I, llvm::Register::index2VirtReg(), MI, N, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::MachineRegisterInfo::reg_nodbg_empty(), llvm::LiveRange::Segment::start, llvm::LiveInterval::subranges(), SubReg, and llvm::MachineRegisterInfo::subRegLivenessEnabled().
LiveRange::Segment LiveIntervals::addSegmentToEndOfBlock | ( | Register | Reg, |
MachineInstr & | startInst | ||
) |
Given a register and an instruction, adds a live segment from that instruction to the end of its MBB.
Definition at line 866 of file LiveIntervals.cpp.
References createEmptyInterval(), getInstructionIndex(), getMBBEndIdx(), llvm::MachineInstr::getParent(), and getVNInfoAllocator().
bool LiveIntervals::checkRegMaskInterference | ( | const LiveInterval & | LI, |
BitVector & | UsableRegs | ||
) |
Test if LI
is live across any register mask instructions, and compute a bit mask of physical registers that are not clobbered by any of them.
Returns false if LI
doesn't cross any register mask instructions. In that case, the bit vector is not filled in.
Definition at line 899 of file LiveIntervals.cpp.
References assert(), llvm::LiveRange::begin(), llvm::ArrayRef< T >::begin(), llvm::BitVector::clear(), llvm::BitVector::clearBitsNotInMask(), llvm::LiveRange::empty(), llvm::LiveRange::end(), llvm::ArrayRef< T >::end(), llvm::LiveRange::endIndex(), getInstructionFromIndex(), llvm::MachineBasicBlock::getNumber(), llvm::MCRegisterInfo::getNumRegs(), getRegMaskBits(), getRegMaskBitsInBlock(), getRegMaskSlots(), getRegMaskSlotsInBlock(), hasLiveThroughUse(), Idx, intervalIsInOneMBB(), llvm::lower_bound(), MBB, MI, llvm::LiveInterval::reg(), and llvm::BitVector::resize().
Referenced by llvm::LiveRegMatrix::checkRegMaskInterference().
void LiveIntervals::constructMainRangeFromSubranges | ( | LiveInterval & | LI | ) |
For live interval LI
with correct SubRanges construct matching information for the main live range.
Expects the main live range to not have any segments or value numbers.
Definition at line 1747 of file LiveIntervals.cpp.
References assert(), llvm::LiveIntervalCalc::constructMainRangeFromSubranges(), getSlotIndexes(), getVNInfoAllocator(), and llvm::LiveRangeCalc::reset().
Referenced by llvm::LiveIntervals::HMEditor::updateAllRanges().
|
inline |
Definition at line 136 of file LiveIntervals.h.
References createEmptyInterval(), and Reg.
Referenced by getInterval(), moveAndTeeForMultiUse(), moveForSingleUse(), rematerializeCheapDef(), and repairIntervalsInRange().
|
inline |
Interval creation.
Definition at line 129 of file LiveIntervals.h.
References assert(), llvm::IndexedMap< T, ToIndexT >::grow(), hasInterval(), and Reg.
Referenced by addSegmentToEndOfBlock(), createAndComputeVirtRegInterval(), replaceRegUsesAfterLoop(), and splitSeparateComponents().
Definition at line 185 of file LiveIntervals.h.
References extendToIndices().
void LiveIntervals::extendToIndices | ( | LiveRange & | LR, |
ArrayRef< SlotIndex > | Indices, | ||
ArrayRef< SlotIndex > | Undefs | ||
) |
Extend the live range LR
to reach all points in Indices
.
The points in the Indices
array must be jointly dominated by the union of the existing defs in LR
and points in Undefs
.
PHI-defs are added as needed to maintain SSA form.
If a SlotIndex in Indices
is the end index of a basic block, LR
will be extended to be live out of the basic block. If a SlotIndex in Indices
is jointy dominated only by points in Undefs
, the live range will not be extended to that point.
See also LiveRangeCalc::extend().
Definition at line 616 of file LiveIntervals.cpp.
References assert(), llvm::LiveRangeCalc::extend(), getSlotIndexes(), getVNInfoAllocator(), Idx, and llvm::LiveRangeCalc::reset().
Referenced by extendToIndices(), and replaceDominatedUses().
|
overridevirtual |
getAnalysisUsage - This function should be overriden by passes that need analysis information to do their job.
If a pass specifies that it uses a particular analysis result to this function, it can then use the getAnalysis<AnalysisType>() function, below.
Reimplemented from llvm::Pass.
Definition at line 86 of file LiveIntervals.cpp.
References llvm::AnalysisUsage::addPreserved(), llvm::AnalysisUsage::addPreservedID(), llvm::AnalysisUsage::addRequiredTransitive(), llvm::AnalysisUsage::addRequiredTransitiveID(), llvm::MachineFunctionPass::getAnalysisUsage(), llvm::MachineDominatorsID, llvm::MachineLoopInfoID, and llvm::AnalysisUsage::setPreservesCFG().
Return the live range for register unit Unit
if it has already been computed, or nullptr if it hasn't been computed yet.
Definition at line 400 of file LiveIntervals.h.
Referenced by getLanesWithProperty(), getLiveRange(), llvm::LiveIntervals::HMEditor::getRegUnitLI(), and removePhysRegDefAt().
Definition at line 404 of file LiveIntervals.h.
|
inline |
Returns the instruction associated with the given index.
Definition at line 225 of file LiveIntervals.h.
References llvm::SlotIndexes::getInstructionFromIndex().
Referenced by addKillFlags(), checkRegMaskInterference(), llvm::ScheduleDAGMILive::computeCyclicCriticalPath(), llvm::SplitEditor::enterIntvAfter(), llvm::SplitEditor::enterIntvBefore(), findInsertLocation(), llvm::SIRegisterInfo::findReachingDef(), llvm::InsertPointAnalysis::getLastInsertPointIter(), getVRegDef(), llvm::VirtRegAuxInfo::isRematerializable(), llvm::SplitEditor::leaveIntvAfter(), llvm::SplitEditor::leaveIntvBefore(), llvm::SplitEditor::overlapIntv(), llvm::SystemZRegisterInfo::shouldCoalesce(), and llvm::SplitAnalysis::shouldSplitSingleBlock().
|
inline |
Returns the base index of the given instruction.
Definition at line 220 of file LiveIntervals.h.
References llvm::SlotIndexes::getInstructionIndex().
Referenced by addSegmentToEndOfBlock(), llvm::GCNDownwardRPTracker::advanceBeforeNext(), llvm::ScheduleDAGInstrs::buildSchedGraph(), llvm::RegPressureTracker::bumpDownwardPressure(), llvm::RegPressureTracker::bumpUpwardPressure(), llvm::LiveRangeEdit::canRematerializeAt(), llvm::X86InstrInfo::classifyLEAReg(), llvm::ScheduleDAGMILive::computeCyclicCriticalPath(), llvm::RegisterOperands::detectDeadDefs(), dumpMachineInstrRangeWithSlotIndex(), findNextInsertLocation(), llvm::SIRegisterInfo::findReachingDef(), findUseBetween(), llvm::RegPressureTracker::getCurrSlot(), llvm::InsertPointAnalysis::getFirstInsertPoint(), llvm::getLiveRegsAfter(), llvm::getLiveRegsBefore(), getUsedRegMask(), getVRegDef(), handleMoveIntoNewBundle(), hasOneNonDBGUse(), isDefBetween(), isPlainlyKilled(), llvm::GCNUpwardRPTracker::isValid(), moveAndTeeForMultiUse(), moveForSingleUse(), oneUseDominatesOtherUses(), printRegion(), llvm::RegPressureTracker::recede(), llvm::RegPressureTracker::recedeSkipDebugValues(), regJustKilledBefore(), rematerializeCheapDef(), repairIntervalsInRange(), replaceDominatedUses(), llvm::GCNSchedStage::revertScheduling(), llvm::ScheduleDAGMILive::scheduleMI(), llvm::GCNIterativeScheduler::scheduleRegion(), shrinkToUses(), llvm::ScheduleDAGMILive::updatePressureDiffs(), and llvm::VirtRegAuxInfo::weightCalcHelper().
|
inline |
Definition at line 112 of file LiveIntervals.h.
References createAndComputeVirtRegInterval(), hasInterval(), and Reg.
Referenced by addKillFlags(), llvm::GCNDownwardRPTracker::advanceBeforeNext(), llvm::RegAllocBase::allocatePhysRegs(), llvm::LiveRangeEdit::allUsesAvailableAt(), llvm::LiveRangeEdit::calculateRegClassAndHint(), llvm::VirtRegAuxInfo::calculateSpillWeightsAndHints(), llvm::X86InstrInfo::classifyLEAReg(), llvm::ScheduleDAGMILive::computeCyclicCriticalPath(), llvm::RISCVInstrInfo::convertToThreeAddress(), llvm::X86InstrInfo::convertToThreeAddress(), llvm::LiveRangeEdit::createFrom(), llvm::SIRegisterInfo::findReachingDef(), llvm::SplitEditor::finish(), getInterval(), getLanesWithProperty(), llvm::getLiveLaneMask(), getLiveRange(), llvm::getLiveRegMap(), getVDefInterval(), getVRegDef(), handleMoveIntoNewBundle(), hasOneNonDBGUse(), isDefBetween(), isLocalCopy(), llvm::SplitAnalysis::isOriginalEndpoint(), isPlainlyKilled(), llvm::VirtRegAuxInfo::isRematerializable(), moveAndTeeForMultiUse(), moveForSingleUse(), oneUseDominatesOtherUses(), print(), regJustKilledBefore(), rematerializeCheapDef(), repairIntervalsInRange(), replaceDominatedUses(), llvm::HexagonRegisterInfo::shouldCoalesce(), llvm::SystemZRegisterInfo::shouldCoalesce(), llvm::MachineBasicBlock::SplitCriticalEdge(), llvm::LiveIntervals::HMEditor::updateAllRanges(), llvm::ScheduleDAGMILive::updatePressureDiffs(), and llvm::VirtRegAuxInfo::weightCalcHelper().
|
inline |
Definition at line 119 of file LiveIntervals.h.
References getInterval(), and Reg.
|
inline |
Return the last index in the given basic block.
Definition at line 235 of file LiveIntervals.h.
References llvm::SlotIndexes::getMBBEndIdx().
Referenced by addSegmentToEndOfBlock(), llvm::ScheduleDAGMILive::computeCyclicCriticalPath(), llvm::SplitAnalysis::countLiveBlocks(), llvm::SplitEditor::enterIntvAtEnd(), llvm::RegPressureTracker::getCurrSlot(), llvm::InsertPointAnalysis::getLastInsertPointIter(), handleMove(), isLiveOutOfMBB(), repairIntervalsInRange(), llvm::ScheduleDAGMILive::updatePressureDiffs(), and llvm::SplitEditor::useIntv().
|
inline |
Definition at line 249 of file LiveIntervals.h.
References llvm::SlotIndexes::getMBBFromIndex().
Referenced by llvm::SplitAnalysis::countLiveBlocks(), hasPHIKill(), llvm::SplitEditor::overlapIntv(), and llvm::VirtRegAuxInfo::weightCalcHelper().
|
inline |
Return the first index in the given basic block.
Definition at line 230 of file LiveIntervals.h.
References llvm::SlotIndexes::getMBBStartIdx().
Referenced by findInsertLocation(), llvm::InsertPointAnalysis::getFirstInsertPoint(), handleMove(), isLiveInToMBB(), llvm::SplitEditor::leaveIntvAtTop(), llvm::MachineBasicBlock::SplitCriticalEdge(), and llvm::SplitEditor::useIntv().
Returns an array of register mask pointers corresponding to getRegMaskSlots().
Definition at line 356 of file LiveIntervals.h.
Referenced by checkRegMaskInterference(), and getRegMaskBitsInBlock().
|
inline |
Returns an array of mask pointers corresponding to getRegMaskSlotsInBlock(MBBNum).
Definition at line 360 of file LiveIntervals.h.
References getRegMaskBits(), and P.
Referenced by checkRegMaskInterference().
Returns a sorted array of slot indices of all instructions with register mask operands.
Definition at line 345 of file LiveIntervals.h.
Referenced by checkRegMaskInterference(), getRegMaskSlotsInBlock(), and llvm::VirtRegAuxInfo::weightCalcHelper().
Returns a sorted array of slot indices of all instructions with register mask operands in the basic block numbered MBBNum
.
Definition at line 349 of file LiveIntervals.h.
References getRegMaskSlots(), and P.
Referenced by checkRegMaskInterference().
Return the live range for register unit Unit
.
It will be computed if it doesn't exist.
Definition at line 387 of file LiveIntervals.h.
References llvm::UseSegmentSetForPhysRegs.
Referenced by addKillFlags(), llvm::LiveRegMatrix::checkRegUnitInterference(), llvm::SIRegisterInfo::findReachingDef(), llvm::SystemZInstrInfo::foldMemoryOperandImpl(), llvm::LiveIntervals::HMEditor::getRegUnitLI(), isDefBetween(), and runOnMachineFunction().
|
inline |
Definition at line 209 of file LiveIntervals.h.
Referenced by llvm::LiveRegMatrix::checkRegUnitInterference(), constructMainRangeFromSubranges(), extendToIndices(), llvm::SystemZInstrInfo::foldMemoryOperandImpl(), llvm::getLiveRegMap(), llvm::LiveRangeEdit::rematerializeAt(), llvm::SplitEditor::reset(), llvm::HexagonRegisterInfo::shouldCoalesce(), llvm::SplitEditor::splitLiveThroughBlock(), llvm::SplitEditor::splitRegInBlock(), llvm::SplitEditor::splitRegOutBlock(), and llvm::VirtRegAuxInfo::weightCalcHelper().
|
static |
Calculate the spill weight to assign to a single instruction.
Definition at line 859 of file LiveIntervals.cpp.
References llvm::MachineBlockFrequencyInfo::getBlockFreqRelativeToEntryBlock(), and MBB.
|
static |
Calculate the spill weight to assign to a single instruction.
Definition at line 853 of file LiveIntervals.cpp.
References getSpillWeight(), and MI.
Referenced by computeWeight(), getSpillWeight(), and llvm::VirtRegAuxInfo::weightCalcHelper().
|
inline |
Definition at line 278 of file LiveIntervals.h.
Referenced by addSegmentToEndOfBlock(), constructMainRangeFromSubranges(), extendToIndices(), llvm::SystemZInstrInfo::foldMemoryOperandImpl(), and llvm::SplitEditor::reset().
void LiveIntervals::handleMove | ( | MachineInstr & | MI, |
bool | UpdateFlags = false |
||
) |
Call this method to notify LiveIntervals that instruction MI
has been moved within a basic block.
This will update the live intervals for all operands of MI
. Moves between basic blocks are not supported.
UpdateFlags | Update live intervals for nonallocatable physregs. |
Definition at line 1501 of file LiveIntervals.cpp.
References assert(), llvm::SlotIndexes::getInstructionIndex(), getMBBEndIdx(), getMBBStartIdx(), llvm::SlotIndexes::insertMachineInstrInMaps(), MI, MRI, llvm::SlotIndexes::removeMachineInstrFromMaps(), TRI, and llvm::LiveIntervals::HMEditor::updateAllRanges().
Referenced by moveAndTeeForMultiUse(), moveForSingleUse(), llvm::ScheduleDAGMI::moveInstruction(), llvm::GCNSchedStage::revertScheduling(), and llvm::GCNIterativeScheduler::scheduleRegion().
void LiveIntervals::handleMoveIntoNewBundle | ( | MachineInstr & | BundleStart, |
bool | UpdateFlags = false |
||
) |
Update intervals of operands of all instructions in the newly created bundle specified by BundleStart
.
UpdateFlags | Update live intervals for nonallocatable physregs. |
Assumes existing liveness is accurate.
Definition at line 1517 of file LiveIntervals.cpp.
References assert(), E, llvm::getBundleEnd(), getInstructionIndex(), llvm::SlotIndexes::getInstructionIndex(), getInterval(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::MachineInstr::getNumOperands(), llvm::MachineInstr::getOpcode(), llvm::MachineInstr::getOperand(), llvm::MachineOperand::getReg(), llvm::SlotIndexes::hasIndex(), hasInterval(), I, Idx, llvm::SlotIndexes::insertMachineInstrInMaps(), llvm::LiveQueryResult::isDeadDef(), llvm::MachineOperand::isReg(), llvm::MachineOperand::isUndef(), MRI, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::LiveRange::Query(), llvm::SlotIndexes::removeMachineInstrFromMaps(), llvm::MachineOperand::setIsDead(), TRI, and llvm::LiveIntervals::HMEditor::updateAllRanges().
Definition at line 123 of file LiveIntervals.h.
References llvm::IndexedMap< T, ToIndexT >::inBounds(), and Reg.
Referenced by llvm::RegAllocBase::allocatePhysRegs(), createEmptyInterval(), llvm::SIRegisterInfo::findReachingDef(), getInterval(), llvm::getLiveRegMap(), llvm::getLiveRegs(), handleMoveIntoNewBundle(), print(), repairIntervalsInRange(), replaceRegUsesAfterLoop(), and llvm::MachineBasicBlock::SplitCriticalEdge().
bool LiveIntervals::hasPHIKill | ( | const LiveInterval & | LI, |
const VNInfo * | VNI | ||
) | const |
Returns true if VNI is killed by any PHI-def values in LI.
This may conservatively return true to avoid expensive computations.
Definition at line 838 of file LiveIntervals.cpp.
References llvm::SlotIndexes::getMBBEndIdx(), getMBBFromIndex(), llvm::LiveRange::getVNInfoBefore(), PHI, llvm::MachineBasicBlock::pred_size(), llvm::MachineBasicBlock::predecessors(), and llvm::LiveRange::valnos.
|
inline |
Definition at line 260 of file LiveIntervals.h.
References llvm::SlotIndexes::insertMachineInstrInMaps(), and MI.
Referenced by llvm::X86InstrInfo::classifyLEAReg(), moveAndTeeForMultiUse(), and rematerializeCheapDef().
|
inline |
Definition at line 264 of file LiveIntervals.h.
References B, E, I, and llvm::SlotIndexes::insertMachineInstrInMaps().
|
inline |
Definition at line 253 of file LiveIntervals.h.
References assert(), llvm::SlotIndexes::insertMBBInMaps(), MBB, llvm::SmallVectorTemplateBase< T, bool >::push_back(), and llvm::SmallVectorBase< Size_T >::size().
Referenced by llvm::MachineBasicBlock::splitAt(), and llvm::MachineBasicBlock::SplitCriticalEdge().
MachineBasicBlock * LiveIntervals::intervalIsInOneMBB | ( | const LiveInterval & | LI | ) | const |
If LI is confined to a single basic block, return a pointer to that block.
If LI is live in to or out of any block, return NULL.
Definition at line 812 of file LiveIntervals.cpp.
References assert(), llvm::LiveRange::beginIndex(), llvm::LiveRange::empty(), llvm::LiveRange::endIndex(), llvm::SlotIndexes::getMBBFromIndex(), and llvm::SlotIndex::isBlock().
Referenced by checkRegMaskInterference(), and isLocalCopy().
|
inline |
Definition at line 239 of file LiveIntervals.h.
References getMBBStartIdx(), and llvm::LiveRange::liveAt().
|
inline |
Definition at line 244 of file LiveIntervals.h.
References getMBBEndIdx(), and llvm::LiveRange::liveAt().
Referenced by llvm::VirtRegAuxInfo::weightCalcHelper().
|
inline |
Returns true if the specified machine instr has been removed or was never entered in the map.
Definition at line 215 of file LiveIntervals.h.
References llvm::SlotIndexes::hasIndex().
Referenced by findNextInsertLocation(), and isPlainlyKilled().
|
overridevirtual |
Implement the dump method.
Reimplemented from llvm::Pass.
Definition at line 148 of file LiveIntervals.cpp.
References getInterval(), llvm::MachineRegisterInfo::getNumVirtRegs(), hasInterval(), Idx, llvm::Register::index2VirtReg(), OS, and llvm::printRegUnit().
|
inline |
This function should not be used.
Its intent is to tell you that you are doing something wrong if you call pruneValue directly on a LiveInterval. Indeed, you are supposed to call pruneValue on the main LiveRange and all the LiveRanges of the subranges if any.
Definition at line 203 of file LiveIntervals.h.
References llvm_unreachable.
void LiveIntervals::pruneValue | ( | LiveRange & | LR, |
SlotIndex | Kill, | ||
SmallVectorImpl< SlotIndex > * | EndPoints | ||
) |
If LR
has a live value at Kill
, prune its live range by removing any liveness reachable from Kill.
Add live range end points to EndPoints such that extendToIndices(LI, EndPoints) will reconstruct the value's live range.
Calling pruneValue() and extendToIndices() can be used to reconstruct SSA form after adding defs to a virtual register.
Definition at line 625 of file LiveIntervals.cpp.
References llvm::df_ext_begin(), llvm::df_ext_end(), E, llvm::LiveQueryResult::endPoint(), llvm::SlotIndexes::getMBBEndIdx(), llvm::SlotIndexes::getMBBFromIndex(), llvm::SlotIndexes::getMBBRange(), I, MBB, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::LiveRange::Query(), llvm::LiveRange::removeSegment(), llvm::MachineBasicBlock::successors(), llvm::LiveQueryResult::valueIn(), and llvm::LiveQueryResult::valueOutOrDead().
|
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 103 of file LiveIntervals.cpp.
References llvm::SmallVectorImpl< T >::clear(), llvm::Register::index2VirtReg(), and llvm::BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold, GrowthDelay >::Reset().
|
inline |
Remove associated live ranges for the register units associated with Reg
.
Subsequent uses should rely on on-demand recomputation.
Definition at line 419 of file LiveIntervals.h.
References llvm::MCRegisterInfo::DiffListIterator::isValid(), Reg, removeRegUnit(), and TRI.
Referenced by insertCSRRestores(), llvm::SIRegisterInfo::restoreSGPR(), and llvm::SIRegisterInfo::spillSGPR().
|
inline |
Interval removal.
Definition at line 143 of file LiveIntervals.h.
References Reg.
Referenced by llvm::RegAllocBase::allocatePhysRegs(), llvm::LiveRangeEdit::eraseVirtReg(), rematerializeCheapDef(), and repairIntervalsInRange().
|
inline |
Definition at line 270 of file LiveIntervals.h.
References MI, and llvm::SlotIndexes::removeMachineInstrFromMaps().
Referenced by llvm::ModuloScheduleExpander::cleanup(), llvm::PeelingModuloScheduleExpander::filterInstructions(), llvm::PeelingModuloScheduleExpander::peelPrologAndEpilogs(), llvm::RegAllocBase::postOptimization(), rematerializeCheapDef(), and llvm::PeelingModuloScheduleExpander::rewriteUsesOf().
void LiveIntervals::removePhysRegDefAt | ( | MCRegister | Reg, |
SlotIndex | Pos | ||
) |
Remove value numbers and related live segments starting at position Pos
that are part of any liverange of physical register Reg
or one of its subregisters.
Definition at line 1705 of file LiveIntervals.cpp.
References getCachedRegUnit(), llvm::LiveRange::getVNInfoAt(), llvm::LiveRange::removeValNo(), and TRI.
Referenced by rematerializeCheapDef().
|
inline |
Remove computed live range for register unit Unit
.
Subsequent uses should rely on on-demand recomputation.
Definition at line 410 of file LiveIntervals.h.
Referenced by removeAllRegUnitsForPhysReg().
void LiveIntervals::removeVRegDefAt | ( | LiveInterval & | LI, |
SlotIndex | Pos | ||
) |
Remove value number and related live segments of LI
and its subranges that start at position Pos
.
Definition at line 1713 of file LiveIntervals.cpp.
References assert(), llvm::VNInfo::def, llvm::SlotIndex::getBaseIndex(), llvm::LiveRange::getVNInfoAt(), llvm::LiveInterval::removeEmptySubRanges(), llvm::LiveRange::removeValNo(), and llvm::LiveInterval::subranges().
void LiveIntervals::repairIntervalsInRange | ( | MachineBasicBlock * | MBB, |
MachineBasicBlock::iterator | Begin, | ||
MachineBasicBlock::iterator | End, | ||
ArrayRef< Register > | OrigRegs | ||
) |
Update live intervals for instructions in a range of iterators.
It is intended for use after target hooks that may insert or remove instructions, and is only efficient for a small number of instructions.
OrigRegs is a vector of registers that were originally used by the instructions in the range between the two iterators.
Currently, the only only changes that are supported are simple removal and addition of uses.
Definition at line 1643 of file LiveIntervals.cpp.
References llvm::MachineBasicBlock::begin(), llvm::ArrayRef< T >::begin(), createAndComputeVirtRegInterval(), llvm::MachineBasicBlock::end(), llvm::ArrayRef< T >::end(), End, llvm::erase_value(), getInstructionIndex(), getInterval(), getMBBEndIdx(), llvm::SlotIndex::getPrevSlot(), llvm::LiveRange::hasAtLeastOneValue(), llvm::SlotIndexes::hasIndex(), hasInterval(), I, MBB, MI, MRI, llvm::LiveInterval::removeEmptySubRanges(), removeInterval(), llvm::SlotIndexes::repairIndexesInRange(), and llvm::LiveInterval::subranges().
Referenced by llvm::MachineBasicBlock::SplitCriticalEdge().
|
inline |
Definition at line 274 of file LiveIntervals.h.
References MI, and llvm::SlotIndexes::replaceMachineInstrInMaps().
Referenced by llvm::SIInstrInfo::convertToThreeAddress(), llvm::RISCVInstrInfo::convertToThreeAddress(), llvm::SystemZInstrInfo::convertToThreeAddress(), llvm::X86InstrInfo::convertToThreeAddress(), and llvm::LiveRangeEdit::rematerializeAt().
|
overridevirtual |
Pass entry point; Calculates LiveIntervals.
Implements llvm::MachineFunctionPass.
Definition at line 120 of file LiveIntervals.cpp.
References llvm::Pass::dump(), EnablePrecomputePhysRegs(), llvm::TargetSubtargetInfo::getInstrInfo(), llvm::MCRegisterInfo::getNumRegUnits(), llvm::MachineRegisterInfo::getNumVirtRegs(), llvm::MachineFunction::getRegInfo(), llvm::TargetSubtargetInfo::getRegisterInfo(), getRegUnit(), llvm::MachineFunction::getSubtarget(), and LLVM_DEBUG.
bool LiveIntervals::shrinkToUses | ( | LiveInterval * | li, |
SmallVectorImpl< MachineInstr * > * | dead = nullptr |
||
) |
After removing some uses of a register, shrink its live range to just the remaining uses.
This method does not compute reaching defs for new uses, and it doesn't remove dead defs. Dead PHIDef values are marked as unused. New dead machine instructions are added to the dead vector. Returns true if the interval may have been separated into multiple connected components.
Definition at line 445 of file LiveIntervals.cpp.
References assert(), createSegmentsForValues(), llvm::dbgs(), getInstructionIndex(), llvm::LaneBitmask::getNone(), llvm::SlotIndex::getRegSlot(), Idx, llvm::Register::isVirtual(), LLVM_DEBUG, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::LiveRange::Query(), llvm::LiveInterval::reg(), llvm::MachineRegisterInfo::reg_instructions(), llvm::LiveInterval::removeEmptySubRanges(), llvm::LiveRange::segments, shrinkToUses(), llvm::LiveInterval::subranges(), llvm::SmallVectorImpl< T >::swap(), UseMI, llvm::LiveQueryResult::valueDefined(), llvm::LiveQueryResult::valueIn(), and llvm::LiveRange::vnis().
Referenced by llvm::LiveRangeEdit::eliminateDeadDefs(), replaceDominatedUses(), shrinkToUses(), and shrinkToUses().
void LiveIntervals::shrinkToUses | ( | LiveInterval::SubRange & | SR, |
Register | Reg | ||
) |
Specialized version of shrinkToUses(LiveInterval li, SmallVectorImpl<MachineInstr> *dead) that works on a subregister live range and only looks at uses matching the lane mask of the subregister range.
This may leave the subrange empty which needs to be cleaned up with LiveInterval::removeEmptySubranges() afterwards.
Definition at line 547 of file LiveIntervals.cpp.
References assert(), createSegmentsForValues(), llvm::dbgs(), llvm::VNInfo::def, llvm::LiveRange::Segment::end, llvm::SlotIndex::getDeadSlot(), getInstructionIndex(), llvm::SlotIndex::getRegSlot(), llvm::LiveRange::getSegmentContaining(), llvm::TargetRegisterInfo::getSubRegIndexLaneMask(), Idx, llvm::VNInfo::isPHIDef(), llvm::VNInfo::isUnused(), llvm::LiveInterval::SubRange::LaneMask, LLVM_DEBUG, llvm::VNInfo::markUnused(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::LiveRange::Query(), llvm::LiveRange::removeSegment(), llvm::LiveRange::segments, SubReg, llvm::SmallVectorImpl< T >::swap(), llvm::MachineRegisterInfo::use_nodbg_operands(), UseMI, llvm::LiveRange::valnos, llvm::LiveQueryResult::valueDefined(), llvm::LiveQueryResult::valueIn(), and llvm::LiveRange::vnis().
void LiveIntervals::splitSeparateComponents | ( | LiveInterval & | LI, |
SmallVectorImpl< LiveInterval * > & | SplitLIs | ||
) |
Split separate components in LiveInterval LI
into separate intervals.
Definition at line 1731 of file LiveIntervals.cpp.
References llvm::ConnectedVNInfoEqClasses::Classify(), createEmptyInterval(), llvm::SmallVectorTemplateCommon< T, typename >::data(), llvm::dbgs(), llvm::ConnectedVNInfoEqClasses::Distribute(), I, LLVM_DEBUG, MRI, llvm::SmallVectorTemplateBase< T, bool >::push_back(), and llvm::LiveInterval::reg().
Referenced by llvm::LiveRangeEdit::eliminateDeadDefs(), llvm::SplitEditor::finish(), and shrinkToUses().
|
static |
Definition at line 97 of file LiveIntervals.h.