LLVM
8.0.1
|
#include "CodeGen/LiveRangeCalc.h"
Public Member Functions | |
LiveRangeCalc ()=default | |
void | reset (const MachineFunction *mf, SlotIndexes *SI, MachineDominatorTree *MDT, VNInfo::Allocator *VNIA) |
reset - Prepare caches for a new set of non-overlapping live ranges. More... | |
void | extend (LiveRange &LR, SlotIndex Use, unsigned PhysReg, ArrayRef< SlotIndex > Undefs) |
Extend the live range of LR to reach Use . More... | |
void | createDeadDefs (LiveRange &LR, unsigned Reg) |
createDeadDefs - Create a dead def in LI for every def operand of Reg. More... | |
void | extendToUses (LiveRange &LR, unsigned PhysReg) |
Extend the live range of LR to reach all uses of Reg. More... | |
void | calculate (LiveInterval &LI, bool TrackSubRegs) |
Calculates liveness for the register specified in live interval LI . More... | |
void | constructMainRangeFromSubranges (LiveInterval &LI) |
For live interval LI with correct SubRanges construct matching information for the main live range. More... | |
void | setLiveOutValue (MachineBasicBlock *MBB, VNInfo *VNI) |
setLiveOutValue - Indicate that VNI is live out from MBB. More... | |
void | addLiveInBlock (LiveRange &LR, MachineDomTreeNode *DomNode, SlotIndex Kill=SlotIndex()) |
addLiveInBlock - Add a block with an unknown live-in value. More... | |
void | calculateValues () |
calculateValues - Calculate the value that will be live-in to each block added with addLiveInBlock. More... | |
Static Public Member Functions | |
static LLVM_ATTRIBUTE_UNUSED bool | isJointlyDominated (const MachineBasicBlock *MBB, ArrayRef< SlotIndex > Defs, const SlotIndexes &Indexes) |
A diagnostic function to check if the end of the block MBB is jointly dominated by the blocks corresponding to the slot indices in Defs . More... | |
Definition at line 45 of file LiveRangeCalc.h.
|
default |
|
inline |
addLiveInBlock - Add a block with an unknown live-in value.
This function can only be called once per basic block. Once the live-in value has been determined, calculateValues() will add liveness to LI.
LR | The live range that is live-in to the block. |
DomNode | The domtree node for the block. |
Kill | Index in block where LI is killed. If the value is live-through, set Kill = SLotIndex() and also call setLiveOutValue(MBB, 0). |
Definition at line 271 of file LiveRangeCalc.h.
References calculateValues(), isJointlyDominated(), llvm::RegState::Kill, LLVM_ATTRIBUTE_UNUSED, and llvm::SmallVectorTemplateBase< T, bool >::push_back().
void LiveRangeCalc::calculate | ( | LiveInterval & | LI, |
bool | TrackSubRegs | ||
) |
Calculates liveness for the register specified in live interval LI
.
Creates subregister live ranges as needed if subreg liveness tracking is enabled.
Definition at line 75 of file LiveRangeCalc.cpp.
References assert(), llvm::LiveRange::clear(), constructMainRangeFromSubranges(), createDeadDef(), llvm::LiveInterval::createSubRangeFrom(), llvm::LiveRange::empty(), llvm::LaneBitmask::getAll(), llvm::MachineRegisterInfo::getMaxLaneMaskForVReg(), llvm::TargetRegisterInfo::getSubRegIndexLaneMask(), llvm::MachineRegisterInfo::getTargetRegisterInfo(), llvm::LiveInterval::hasSubRanges(), llvm::LiveInterval::refineSubRanges(), llvm::LiveInterval::reg, Reg, llvm::MachineRegisterInfo::reg_nodbg_operands(), llvm::LiveInterval::removeEmptySubRanges(), reset(), llvm::LiveInterval::subranges(), SubReg, and TRI.
Referenced by extendToUses(), and llvm::LiveIntervals::print().
void LiveRangeCalc::calculateValues | ( | ) |
calculateValues - Calculate the value that will be live-in to each block added with addLiveInBlock.
Add PHI-def values as needed to preserve SSA form. Add liveness to all live-in blocks up to the Kill point, or the whole block for live-through blocks.
Every predecessor of a live-in block must have been given a value with setLiveOutValue, the value may be null for live-trough blocks.
Definition at line 269 of file LiveRangeCalc.cpp.
References assert(), B, llvm::MachineFunction::getBlockNumbered(), llvm::MachineBasicBlock::getNumber(), llvm::SetVector< T, Vector, Set >::insert(), N, P, llvm::MachineBasicBlock::predecessors(), llvm::SetVector< T, Vector, Set >::size(), and UndefVNI.
Referenced by addLiveInBlock(), and extend().
void LiveRangeCalc::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 131 of file LiveRangeCalc.cpp.
References assert(), llvm::LiveRange::createDeadDef(), llvm::VNInfo::def, llvm::SmallVectorBase::empty(), llvm::LaneBitmask::getAll(), llvm::VNInfo::isPHIDef(), llvm::VNInfo::isUnused(), llvm::LiveInterval::reg, llvm::LiveRange::segments, llvm::LiveInterval::subranges(), and llvm::LiveRange::valnos.
Referenced by calculate(), and extendToUses().
createDeadDefs - Create a dead def in LI for every def operand of Reg.
Each instruction defining Reg gets a new VNInfo with a corresponding minimal live range.
Definition at line 147 of file LiveRangeCalc.cpp.
References llvm::LaneBitmask::all(), assert(), llvm::LiveInterval::computeSubRangeUndefs(), createDeadDef(), llvm::MachineRegisterInfo::def_operands(), extend(), llvm::SlotIndexes::getInstructionIndex(), llvm::MachineOperand::getMBB(), llvm::SlotIndexes::getMBBEndIdx(), llvm::MachineInstr::getOperand(), llvm::SlotIndex::getRegSlot(), llvm::TargetRegisterInfo::getSubRegIndexLaneMask(), llvm::MachineRegisterInfo::getTargetRegisterInfo(), I, llvm::MachineOperand::isEarlyClobber(), llvm::MachineInstr::isPHI(), llvm::MachineInstr::isRegTiedToDefOperand(), llvm::BitmaskEnumDetail::Mask(), MI, Reg, llvm::MachineRegisterInfo::reg_nodbg_operands(), SubReg, and TRI.
Referenced by llvm::LiveIntervals::print().
void LiveRangeCalc::extend | ( | LiveRange & | LR, |
SlotIndex | Use, | ||
unsigned | PhysReg, | ||
ArrayRef< SlotIndex > | Undefs | ||
) |
Extend the live range of LR
to reach Use
.
The existing values in LR
must be live so they jointly dominate Use
. If Use
is not dominated by a single existing value, PHI-defs are inserted as required to preserve SSA form.
PhysReg, when set, is used to verify live-in lists on basic blocks.
Definition at line 241 of file LiveRangeCalc.cpp.
References assert(), calculateValues(), llvm::LiveRange::extendInBlock(), llvm::SlotIndexes::getMBBFromIndex(), llvm::SlotIndexes::getMBBStartIdx(), llvm::SlotIndex::getPrevSlot(), and llvm::SlotIndex::isValid().
Referenced by createDeadDefs(), and llvm::LiveIntervals::extendToIndices().
Extend the live range of LR
to reach all uses of Reg.
All uses must be jointly dominated by existing liveness. PHI-defs are inserted as needed to preserve SSA form.
Definition at line 224 of file LiveRangeCalc.h.
References calculate(), constructMainRangeFromSubranges(), and llvm::LaneBitmask::getAll().
|
static |
A diagnostic function to check if the end of the block MBB
is jointly dominated by the blocks corresponding to the slot indices in Defs
.
This function is mainly for use in self-verification checks.
Definition at line 588 of file LiveRangeCalc.cpp.
References B, llvm::MachineFunction::getBlockNumbered(), llvm::SlotIndexes::getMBBFromIndex(), llvm::MachineBasicBlock::getNumber(), llvm::MachineFunction::getNumBlockIDs(), llvm::MachineBasicBlock::getParent(), I, llvm::SetVector< T, Vector, Set >::insert(), P, llvm::MachineBasicBlock::predecessors(), llvm::BitVector::set(), and llvm::SetVector< T, Vector, Set >::size().
Referenced by addLiveInBlock(), createSegmentsForValues(), and matchPair().
void LiveRangeCalc::reset | ( | const MachineFunction * | mf, |
SlotIndexes * | SI, | ||
MachineDominatorTree * | MDT, | ||
VNInfo::Allocator * | VNIA | ||
) |
reset - Prepare caches for a new set of non-overlapping live ranges.
The caches must be reset before attempting calculations with a live range that may overlap a previously computed live range, and before the first live range in a function. If live ranges are not known to be non-overlapping, call reset before each.
Definition at line 52 of file LiveRangeCalc.cpp.
References llvm::SmallVectorImpl< T >::clear(), llvm::MachineFunction::getRegInfo(), and SI.
Referenced by calculate(), llvm::LiveIntervals::extendToIndices(), llvm::LiveIntervals::print(), and llvm::SplitEditor::reset().
|
inline |
setLiveOutValue - Indicate that VNI is live out from MBB.
The calculateValues() function will not add liveness for MBB, the caller should take care of that.
VNI may be null only if MBB is a live-through block also passed to addLiveInBlock().
Definition at line 257 of file LiveRangeCalc.h.
References llvm::MachineBasicBlock::getNumber(), and llvm::BitVector::set().