LLVM API Documentation

Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes
llvm::LiveIntervals Class Reference

#include <LiveIntervalAnalysis.h>

Inheritance diagram for llvm::LiveIntervals:
Inheritance graph
[legend]
Collaboration diagram for llvm::LiveIntervals:
Collaboration graph
[legend]

List of all members.

Classes

class  HMEditor

Public Member Functions

 LiveIntervals ()
virtual ~LiveIntervals ()
LiveIntervalgetInterval (unsigned Reg)
const LiveIntervalgetInterval (unsigned Reg) const
bool hasInterval (unsigned Reg) const
LiveIntervalcreateEmptyInterval (unsigned Reg)
LiveIntervalcreateAndComputeVirtRegInterval (unsigned Reg)
void removeInterval (unsigned Reg)
LiveInterval::Segment addSegmentToEndOfBlock (unsigned reg, MachineInstr *startInst)
bool shrinkToUses (LiveInterval *li, SmallVectorImpl< MachineInstr * > *dead=nullptr)
void computeDeadValues (LiveInterval *li, LiveRange &LR, bool *CanSeparate, SmallVectorImpl< MachineInstr * > *dead)
 Walk the values in the given interval and compute which ones are dead. Dead values are not deleted, however:
void extendToIndices (LiveRange &LR, ArrayRef< SlotIndex > Indices)
void pruneValue (LiveInterval *LI, SlotIndex Kill, SmallVectorImpl< SlotIndex > *EndPoints)
SlotIndexesgetSlotIndexes () const
AliasAnalysisgetAliasAnalysis () const
bool isNotInMIMap (const MachineInstr *Instr) const
SlotIndex getInstructionIndex (const MachineInstr *instr) const
 Returns the base index of the given instruction.
MachineInstrgetInstructionFromIndex (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
MachineBasicBlockgetMBBFromIndex (SlotIndex index) const
void insertMBBInMaps (MachineBasicBlock *MBB)
SlotIndex InsertMachineInstrInMaps (MachineInstr *MI)
void InsertMachineInstrRangeInMaps (MachineBasicBlock::iterator B, MachineBasicBlock::iterator E)
void RemoveMachineInstrFromMaps (MachineInstr *MI)
void ReplaceMachineInstrInMaps (MachineInstr *MI, MachineInstr *NewMI)
bool findLiveInMBBs (SlotIndex Start, SlotIndex End, SmallVectorImpl< MachineBasicBlock * > &MBBs) const
VNInfo::AllocatorgetVNInfoAllocator ()
void getAnalysisUsage (AnalysisUsage &AU) const override
void releaseMemory () override
bool runOnMachineFunction (MachineFunction &) override
 runOnMachineFunction - pass entry point
void print (raw_ostream &O, const Module *=nullptr) const override
 print - Implement the dump method.
MachineBasicBlockintervalIsInOneMBB (const LiveInterval &LI) const
bool hasPHIKill (const LiveInterval &LI, const VNInfo *VNI) const
void addKillFlags (const VirtRegMap *)
void handleMove (MachineInstr *MI, bool UpdateFlags=false)
void handleMoveIntoBundle (MachineInstr *MI, MachineInstr *BundleStart, bool UpdateFlags=false)
void repairIntervalsInRange (MachineBasicBlock *MBB, MachineBasicBlock::iterator Begin, MachineBasicBlock::iterator End, ArrayRef< unsigned > OrigRegs)
ArrayRef< SlotIndexgetRegMaskSlots () const
ArrayRef< SlotIndexgetRegMaskSlotsInBlock (unsigned MBBNum) const
ArrayRef< const uint32_t * > getRegMaskBits () const
ArrayRef< const uint32_t * > getRegMaskBitsInBlock (unsigned MBBNum) const
bool checkRegMaskInterference (LiveInterval &LI, BitVector &UsableRegs)
LiveRangegetRegUnit (unsigned Unit)
LiveRangegetCachedRegUnit (unsigned Unit)
const LiveRangegetCachedRegUnit (unsigned Unit) const

Static Public Member Functions

static float getSpillWeight (bool isDef, bool isUse, const MachineBlockFrequencyInfo *MBFI, const MachineInstr *Instr)

Static Public Attributes

static char ID = 0

Detailed Description

Definition at line 50 of file LiveIntervalAnalysis.h.


Constructor & Destructor Documentation

Definition at line 88 of file LiveIntervalAnalysis.cpp.


Member Function Documentation

Given a register and an instruction, adds a live segment from that instruction to the end of its MBB.

Definition at line 646 of file LiveIntervalAnalysis.cpp.

References llvm::LiveRange::addSegment(), createEmptyInterval(), getInstructionIndex(), getMBBEndIdx(), llvm::LiveRange::getNextValue(), llvm::MachineInstr::getParent(), and getVNInfoAllocator().

checkRegMaskInterference - 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 664 of file LiveIntervalAnalysis.cpp.

References llvm::LiveRange::advanceTo(), llvm::ArrayRef< T >::begin(), llvm::LiveRange::begin(), llvm::tgtok::Bits, llvm::BitVector::clear(), llvm::BitVector::clearBitsNotInMask(), llvm::LiveRange::empty(), llvm::sys::path::end(), llvm::ArrayRef< T >::end(), llvm::LiveRange::end(), llvm::MachineBasicBlock::getNumber(), llvm::MCRegisterInfo::getNumRegs(), getRegMaskBits(), getRegMaskBitsInBlock(), getRegMaskSlots(), getRegMaskSlotsInBlock(), intervalIsInOneMBB(), and llvm::BitVector::resize().

Referenced by llvm::PBQPBuilder::build(), and llvm::LiveRegMatrix::checkRegMaskInterference().

void LiveIntervals::computeDeadValues ( LiveInterval li,
LiveRange LR,
bool CanSeparate,
SmallVectorImpl< MachineInstr * > *  dead 
)

Walk the values in the given interval and compute which ones are dead. Dead values are not deleted, however:

  • Dead PHIDef values are marked as unused.
  • New dead machine instructions are added to the dead vector.
  • CanSeparate is set to true if the interval may have been separated into multiple connected components.

Definition at line 425 of file LiveIntervalAnalysis.cpp.

References llvm::MachineInstr::addRegisterDead(), llvm::MachineInstr::allDefsAreDead(), llvm::dbgs(), DEBUG, llvm::VNInfo::def, llvm::LiveRange::end(), llvm::LiveRange::FindSegmentContaining(), llvm::SlotIndex::getDeadSlot(), getInstructionFromIndex(), I, llvm::VNInfo::isPHIDef(), llvm::VNInfo::isUnused(), llvm::VNInfo::markUnused(), llvm::AArch64CC::MI, llvm::SmallVectorTemplateBase< T, isPodLike >::push_back(), llvm::LiveInterval::reg, llvm::LiveRange::removeSegment(), llvm::LiveRange::vni_begin(), and llvm::LiveRange::vni_end().

Referenced by shrinkToUses().

Definition at line 131 of file LiveIntervalAnalysis.h.

References createEmptyInterval(), and LI.

Referenced by getInterval(), and repairIntervalsInRange().

extendToIndices - Extend the live range of LI to reach all points in Indices. The points in the Indices array must be jointly dominated by existing defs in LI. PHI-defs are added as needed to maintain SSA form.

If a SlotIndex in Indices is the end index of a basic block, LI will be extended to be live out of the basic block.

See also LiveRangeCalc::extend().

Definition at line 458 of file LiveIntervalAnalysis.cpp.

References llvm::LiveRangeCalc::extend(), getSlotIndexes(), getVNInfoAllocator(), llvm::LiveRangeCalc::reset(), and llvm::ArrayRef< T >::size().

Definition at line 262 of file LiveIntervalAnalysis.h.

References llvm::SlotIndexes::findLiveInMBBs().

Definition at line 193 of file LiveIntervalAnalysis.h.

Referenced by isRematerializable().

void LiveIntervals::getAnalysisUsage ( AnalysisUsage AU) const [override, virtual]

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 66 of file LiveIntervalAnalysis.cpp.

References llvm::AnalysisUsage::addPreserved(), llvm::AnalysisUsage::addPreservedID(), llvm::AnalysisUsage::addRequired(), llvm::AnalysisUsage::addRequiredTransitive(), llvm::AnalysisUsage::addRequiredTransitiveID(), llvm::MachineDominatorsID, llvm::MachineLoopInfoID, and llvm::AnalysisUsage::setPreservesCFG().

getCachedRegUnit - Return the live range for Unit if it has already been computed, or NULL if it hasn't been computed yet.

Definition at line 393 of file LiveIntervalAnalysis.h.

Referenced by llvm::RegPressureTracker::getLiveRange().

Definition at line 397 of file LiveIntervalAnalysis.h.

Definition at line 115 of file LiveIntervalAnalysis.h.

References getInterval().

Return the first index in the given basic block.

Definition at line 214 of file LiveIntervalAnalysis.h.

References llvm::SlotIndexes::getMBBStartIdx().

Referenced by findInsertLocation(), handleMove(), isLiveInToMBB(), llvm::SplitEditor::leaveIntvAtTop(), shrinkToUses(), and llvm::SplitEditor::useIntv().

ArrayRef<const uint32_t*> llvm::LiveIntervals::getRegMaskBits ( ) const [inline]

getRegMaskBits() - Returns an array of register mask pointers corresponding to getRegMaskSlots().

Definition at line 350 of file LiveIntervalAnalysis.h.

Referenced by checkRegMaskInterference(), and getRegMaskBitsInBlock().

ArrayRef<const uint32_t*> llvm::LiveIntervals::getRegMaskBitsInBlock ( unsigned  MBBNum) const [inline]

getRegMaskBitsInBlock - Returns an array of mask pointers corresponding to getRegMaskSlotsInBlock(MBBNum).

Definition at line 354 of file LiveIntervalAnalysis.h.

References getRegMaskBits(), and P.

Referenced by checkRegMaskInterference().

getRegMaskSlots - Returns a sorted array of slot indices of all instructions with register mask operands.

Definition at line 338 of file LiveIntervalAnalysis.h.

Referenced by checkRegMaskInterference(), and getRegMaskSlotsInBlock().

getRegMaskSlotsInBlock - Returns a sorted array of slot indices of all instructions with register mask operands in the basic block numbered MBBNum.

Definition at line 343 of file LiveIntervalAnalysis.h.

References getRegMaskSlots(), and P.

Referenced by checkRegMaskInterference().

getRegUnit - Return the live range for Unit. It will be computed if it doesn't exist.

Definition at line 381 of file LiveIntervalAnalysis.h.

Referenced by addKillFlags(), llvm::PBQPBuilder::build(), llvm::LiveRegMatrix::checkRegUnitInterference(), and runOnMachineFunction().

float LiveIntervals::getSpillWeight ( bool  isDef,
bool  isUse,
const MachineBlockFrequencyInfo MBFI,
const MachineInstr Instr 
) [static]
void LiveIntervals::handleMove ( MachineInstr MI,
bool  UpdateFlags = false 
)

handleMove - 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.

Parameters:
UpdateFlagsUpdate live intervals for nonallocatable physregs.

Definition at line 1044 of file LiveIntervalAnalysis.cpp.

References llvm::SlotIndexes::getInstructionIndex(), getMBBEndIdx(), getMBBStartIdx(), llvm::MachineInstr::getParent(), llvm::SlotIndexes::insertMachineInstrInMaps(), llvm::MachineInstr::isBundled(), llvm::SlotIndexes::removeMachineInstrFromMaps(), and llvm::LiveIntervals::HMEditor::updateAllRanges().

void LiveIntervals::handleMoveIntoBundle ( MachineInstr MI,
MachineInstr BundleStart,
bool  UpdateFlags = false 
)

moveIntoBundle - Update intervals for operands of MI so that they begin/end on the SlotIndex for BundleStart.

Parameters:
UpdateFlagsUpdate live intervals for nonallocatable physregs.

Requires MI and BundleStart to have SlotIndexes, and assumes existing liveness is accurate. BundleStart should be the first instruction in the Bundle.

Definition at line 1057 of file LiveIntervalAnalysis.cpp.

References llvm::SlotIndexes::getInstructionIndex(), and llvm::LiveIntervals::HMEditor::updateAllRanges().

Definition at line 248 of file LiveIntervalAnalysis.h.

References I, and llvm::SlotIndexes::insertMachineInstrInMaps().

intervalIsInOneMBB - 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 594 of file LiveIntervalAnalysis.cpp.

References llvm::LiveRange::beginIndex(), llvm::LiveRange::endIndex(), llvm::SlotIndexes::getMBBFromIndex(), and llvm::SlotIndex::isBlock().

Referenced by checkRegMaskInterference(), and isLocalCopy().

Definition at line 223 of file LiveIntervalAnalysis.h.

References getMBBStartIdx(), and llvm::LiveRange::liveAt().

isNotInMIMap - returns true if the specified machine instr has been removed or was never entered in the map.

Definition at line 199 of file LiveIntervalAnalysis.h.

References llvm::SlotIndexes::hasIndex().

Referenced by isPlainlyKilled().

void LiveIntervals::print ( raw_ostream O,
const Module = nullptr 
) const [override, virtual]
void LiveIntervals::pruneValue ( LiveInterval LI,
SlotIndex  Kill,
SmallVectorImpl< SlotIndex > *  EndPoints 
)

pruneValue - If an LI value is live 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 466 of file LiveIntervalAnalysis.cpp.

References llvm::df_ext_begin(), llvm::df_ext_end(), llvm::LiveQueryResult::endPoint(), llvm::SlotIndexes::getMBBFromIndex(), llvm::SlotIndexes::getMBBRange(), I, llvm::SmallVectorTemplateBase< T, isPodLike >::push_back(), llvm::LiveRange::Query(), llvm::LiveRange::removeSegment(), llvm::MachineBasicBlock::succ_begin(), llvm::MachineBasicBlock::succ_end(), llvm::LiveQueryResult::valueIn(), and llvm::LiveQueryResult::valueOut().

void LiveIntervals::releaseMemory ( ) [override, virtual]

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 92 of file LiveIntervalAnalysis.cpp.

References llvm::IndexedMap< T, ToIndexT >::clear(), llvm::SmallVectorImpl< T >::clear(), llvm::TargetRegisterInfo::index2VirtReg(), llvm::BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold >::Reset(), llvm::IndexedMap< T, ToIndexT >::size(), and llvm::SmallVectorTemplateCommon< T, typename >::size().

repairIntervalsInRange - 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 1067 of file LiveIntervalAnalysis.cpp.

References llvm::LiveRange::addSegment(), llvm::LiveRange::begin(), llvm::MachineBasicBlock::begin(), createAndComputeVirtRegInterval(), llvm::LiveRange::end(), llvm::MachineBasicBlock::end(), llvm::LiveRange::find(), llvm::SlotIndex::getDeadSlot(), getInstructionFromIndex(), getInstructionIndex(), getInterval(), getMBBEndIdx(), llvm::LiveRange::getNextValue(), llvm::SlotIndex::getPrevSlot(), llvm::MachineOperand::getReg(), llvm::SlotIndex::getRegSlot(), llvm::MachineOperand::getSubReg(), llvm::LiveRange::hasAtLeastOneValue(), llvm::SlotIndexes::hasIndex(), hasInterval(), I, llvm::MachineInstr::isDebugValue(), llvm::MachineOperand::isDef(), llvm::MachineOperand::isReg(), llvm::MachineOperand::isUndef(), llvm::MachineOperand::isUse(), llvm::SlotIndex::isValid(), llvm::TargetRegisterInfo::isVirtualRegister(), llvm::MachineInstr::operands_begin(), llvm::MachineInstr::operands_end(), llvm::LiveRange::removeSegment(), llvm::SlotIndexes::repairIndexesInRange(), and llvm::ArrayRef< T >::size().

shrinkToUses - 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. Return true if the interval may have been separated into multiple connected components.

shrinkToUses - 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.

Definition at line 320 of file LiveIntervalAnalysis.cpp.

References llvm::LiveRange::addSegment(), llvm::SmallVectorTemplateCommon< T >::back(), computeDeadValues(), llvm::dbgs(), DEBUG, llvm::VNInfo::def, llvm::SmallVectorBase::empty(), llvm::LiveRange::extendInBlock(), llvm::SlotIndex::getDeadSlot(), getInstructionIndex(), getMBBEndIdx(), getMBBFromIndex(), getMBBStartIdx(), llvm::SlotIndex::getPrevSlot(), llvm::SlotIndex::getRegSlot(), llvm::LiveRange::getVNInfoBefore(), I, llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::MachineInstr::isDebugValue(), llvm::VNInfo::isPHIDef(), llvm::VNInfo::isUnused(), llvm::TargetRegisterInfo::isVirtualRegister(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::pop_back(), llvm::MachineBasicBlock::pred_begin(), llvm::MachineBasicBlock::pred_end(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), llvm::LiveRange::Query(), llvm::MachineInstr::readsVirtualRegister(), llvm::LiveInterval::reg, llvm::MachineRegisterInfo::reg_instr_begin(), llvm::MachineRegisterInfo::reg_instr_end(), llvm::LiveRange::segments, llvm::SmallVectorImpl< T >::swap(), llvm::LiveQueryResult::valueDefined(), llvm::LiveQueryResult::valueIn(), llvm::LiveRange::vni_begin(), and llvm::LiveRange::vni_end().

Referenced by llvm::LiveRangeEdit::eliminateDeadDefs().


Member Data Documentation

char LiveIntervals::ID = 0 [static]

Definition at line 99 of file LiveIntervalAnalysis.h.


The documentation for this class was generated from the following files: