LLVM: llvm::RegPressureTracker Class Reference (original) (raw)
Track the current register pressure at some position in the instruction stream, and remember the high water mark within the region traversed. More...
#include "[llvm/CodeGen/RegisterPressure.h](RegisterPressure%5F8h%5Fsource.html)"
| Public Member Functions | |
|---|---|
| RegPressureTracker (IntervalPressure &rp) | |
| RegPressureTracker (RegionPressure &rp) | |
| LLVM_ABI void | reset () |
| LLVM_ABI void | init (const MachineFunction *mf, const RegisterClassInfo *rci, const LiveIntervals *lis, const MachineBasicBlock *mbb, MachineBasicBlock::const_iterator pos, bool TrackLaneMasks, bool TrackUntiedDefs) |
| Setup the RegPressureTracker. | |
| LLVM_ABI void | addLiveRegs (ArrayRef< VRegMaskOrUnit > Regs) |
| Force liveness of virtual registers or physical register units. | |
| MachineBasicBlock::const_iterator | getPos () const |
| Get the MI position corresponding to this register pressure. | |
| void | setPos (MachineBasicBlock::const_iterator Pos) |
| LLVM_ABI void | recede (SmallVectorImpl< VRegMaskOrUnit > *LiveUses=nullptr) |
| Recede across the previous instruction. | |
| LLVM_ABI void | recede (const RegisterOperands &RegOpers, SmallVectorImpl< VRegMaskOrUnit > *LiveUses=nullptr) |
| Recede across the previous instruction. | |
| LLVM_ABI void | recedeSkipDebugValues () |
| Recede until we find an instruction which is not a DebugValue. | |
| LLVM_ABI void | advance () |
| Advance across the current instruction. | |
| LLVM_ABI void | advance (const RegisterOperands &RegOpers) |
| Advance across the current instruction. | |
| LLVM_ABI void | closeRegion () |
| Finalize the region boundaries and recored live ins and live outs. | |
| LLVM_ABI void | initLiveThru (const RegPressureTracker &RPTracker) |
| Initialize the LiveThru pressure set based on the untied defs found in RPTracker. | |
| void | initLiveThru (ArrayRef< unsigned > PressureSet) |
| Copy an existing live thru pressure result. | |
| ArrayRef< unsigned > | getLiveThru () const |
| RegisterPressure & | getPressure () |
| Get the resulting register pressure over the traversed region. | |
| const RegisterPressure & | getPressure () const |
| const std::vector< unsigned > & | getRegSetPressureAtPos () const |
| Get the register set pressure at the current position, which may be less than the pressure across the traversed region. | |
| LLVM_ABI bool | isTopClosed () const |
| Does this pressure result have a valid top position and live ins. | |
| LLVM_ABI bool | isBottomClosed () const |
| Does this pressure result have a valid bottom position and live outs. | |
| LLVM_ABI void | closeTop () |
| Set the boundary for the top of the region and summarize live ins. | |
| LLVM_ABI void | closeBottom () |
| Set the boundary for the bottom of the region and summarize live outs. | |
| LLVM_ABI void | getMaxUpwardPressureDelta (const MachineInstr *MI, PressureDiff *PDiff, RegPressureDelta &Delta, ArrayRef< PressureChange > CriticalPSets, ArrayRef< unsigned > MaxPressureLimit) |
| Consider the pressure increase caused by traversing this instruction bottom-up. | |
| LLVM_ABI void | getUpwardPressureDelta (const MachineInstr *MI, PressureDiff &PDiff, RegPressureDelta &Delta, ArrayRef< PressureChange > CriticalPSets, ArrayRef< unsigned > MaxPressureLimit) const |
| This is the fast version of querying register pressure that does not directly depend on current liveness. | |
| LLVM_ABI void | getMaxDownwardPressureDelta (const MachineInstr *MI, RegPressureDelta &Delta, ArrayRef< PressureChange > CriticalPSets, ArrayRef< unsigned > MaxPressureLimit) |
| Consider the pressure increase caused by traversing this instruction top-down. | |
| void | getMaxPressureDelta (const MachineInstr *MI, RegPressureDelta &Delta, ArrayRef< PressureChange > CriticalPSets, ArrayRef< unsigned > MaxPressureLimit) |
| Find the pressure set with the most change beyond its pressure limit after traversing this instruction either upward or downward depending on the closed end of the current region. | |
| LLVM_ABI void | getUpwardPressure (const MachineInstr *MI, std::vector< unsigned > &PressureResult, std::vector< unsigned > &MaxPressureResult) |
| Get the pressure of each PSet after traversing this instruction bottom-up. | |
| LLVM_ABI void | getDownwardPressure (const MachineInstr *MI, std::vector< unsigned > &PressureResult, std::vector< unsigned > &MaxPressureResult) |
| Get the pressure of each PSet after traversing this instruction top-down. | |
| void | getPressureAfterInst (const MachineInstr *MI, std::vector< unsigned > &PressureResult, std::vector< unsigned > &MaxPressureResult) |
| bool | hasUntiedDef (Register VirtReg) const |
| LLVM_ABI void | dump () const |
| LLVM_ABI void | increaseRegPressure (VirtRegOrUnit VRegOrUnit, LaneBitmask PreviousMask, LaneBitmask NewMask) |
| LLVM_ABI void | decreaseRegPressure (VirtRegOrUnit VRegOrUnit, LaneBitmask PreviousMask, LaneBitmask NewMask) |
| Protected Member Functions | |
|---|---|
| LLVM_ABI void | discoverLiveOut (VRegMaskOrUnit Pair) |
| Add Reg to the live out set and increase max pressure. | |
| LLVM_ABI void | discoverLiveIn (VRegMaskOrUnit Pair) |
| Add Reg to the live in set and increase max pressure. | |
| LLVM_ABI SlotIndex | getCurrSlot () const |
| Get the SlotIndex for the first nondebug instruction including or after the current position. | |
| LLVM_ABI void | bumpDeadDefs (ArrayRef< VRegMaskOrUnit > DeadDefs) |
| LLVM_ABI void | bumpUpwardPressure (const MachineInstr *MI) |
| Record the upward impact of a single instruction on current register pressure. | |
| LLVM_ABI void | bumpDownwardPressure (const MachineInstr *MI) |
| Record the downward impact of a single instruction on current register pressure. | |
| LLVM_ABI void | discoverLiveInOrOut (VRegMaskOrUnit Pair, SmallVectorImpl< VRegMaskOrUnit > &LiveInOrOut) |
| LLVM_ABI LaneBitmask | getLastUsedLanes (VirtRegOrUnit VRegOrUnit, SlotIndex Pos) const |
| LLVM_ABI LaneBitmask | getLiveLanesAt (VirtRegOrUnit VRegOrUnit, SlotIndex Pos) const |
| LLVM_ABI LaneBitmask | getLiveThroughAt (VirtRegOrUnit VRegOrUnit, SlotIndex Pos) const |
Track the current register pressure at some position in the instruction stream, and remember the high water mark within the region traversed.
This does not automatically consider live-through ranges. The client may independently adjust for global liveness.
Each RegPressureTracker only works within a MachineBasicBlock. Pressure can be tracked across a larger region by storing a RegisterPressure result at each block boundary and explicitly adjusting pressure to account for block live-in and live-out register sets.
RegPressureTracker holds a reference to a RegisterPressure result that it computes incrementally. During downward tracking, P.BottomIdx or P.BottomPos is invalid until it reaches the end of the block or closeRegion() is explicitly called. Similarly, P.TopIdx is invalid during upward tracking. Changing direction has the side effect of closing region, and traversing past TopIdx or BottomIdx reopens it.
Definition at line 361 of file RegisterPressure.h.
◆ RegPressureTracker() [2/2]
| llvm::RegPressureTracker::RegPressureTracker ( RegionPressure & rp) | inline |
|---|
◆ addLiveRegs()
Force liveness of virtual registers or physical register units.
Force liveness of registers.
Particularly useful to initialize the livein/out state of the tracker before the first call to advance/recede.
Definition at line 698 of file RegisterPressure.cpp.
References increaseRegPressure().
Referenced by computeLiveOuts().
◆ advance() [1/2]
| void RegPressureTracker::advance | ( | ) |
|---|
◆ advance() [2/2]
Advance across the current instruction.
This is a "low-level" variant of advance() which takes precomputed RegisterOperands of the instruction.
Definition at line 885 of file RegisterPressure.cpp.
References llvm::LaneBitmask::any(), assert(), bumpDeadDefs(), closeTop(), llvm::RegisterOperands::DeadDefs, decreaseRegPressure(), llvm::RegisterOperands::Defs, discoverLiveIn(), getCurrSlot(), getLastUsedLanes(), increaseRegPressure(), isBottomClosed(), isTopClosed(), llvm::next_nodbg(), and llvm::RegisterOperands::Uses.
◆ bumpDeadDefs()
◆ bumpDownwardPressure()
Record the downward impact of a single instruction on current register pressure.
Unlike the advance/recede pressure tracking interface, this does not discover live in/outs.
This is intended for speculative queries. It leaves pressure inconsistent with the current position, so must be restored by the caller.
Definition at line 1277 of file RegisterPressure.cpp.
References llvm::RegisterOperands::adjustLaneLiveness(), assert(), bumpDeadDefs(), llvm::RegisterOperands::collect(), llvm::RegisterOperands::DeadDefs, decreaseRegPressure(), llvm::RegisterOperands::Defs, findUseBetween(), getCurrSlot(), getLastUsedLanes(), llvm::SlotIndex::getRegSlot(), increaseRegPressure(), MI, llvm::LaneBitmask::none(), and llvm::RegisterOperands::Uses.
Referenced by getDownwardPressure(), and getMaxDownwardPressureDelta().
◆ bumpUpwardPressure()
Record the upward impact of a single instruction on current register pressure.
Unlike the advance/recede pressure tracking interface, this does not discover live in/outs.
This is intended for speculative queries. It leaves pressure inconsistent with the current position, so must be restored by the caller.
Definition at line 1031 of file RegisterPressure.cpp.
References llvm::RegisterOperands::adjustLaneLiveness(), assert(), bumpDeadDefs(), llvm::RegisterOperands::collect(), llvm::RegisterOperands::DeadDefs, decreaseRegPressure(), llvm::RegisterOperands::Defs, llvm::RegisterOperands::detectDeadDefs(), getRegLanes(), llvm::SlotIndex::getRegSlot(), increaseRegPressure(), MI, and llvm::RegisterOperands::Uses.
Referenced by getMaxUpwardPressureDelta(), and getUpwardPressure().
◆ closeBottom()
| void RegPressureTracker::closeBottom | ( | ) |
|---|
◆ closeRegion()
| void RegPressureTracker::closeRegion | ( | ) |
|---|
◆ closeTop()
| void RegPressureTracker::closeTop | ( | ) |
|---|
◆ decreaseRegPressure()
◆ discoverLiveIn()
| void RegPressureTracker::discoverLiveIn ( VRegMaskOrUnit Pair) | protected |
|---|
◆ discoverLiveInOrOut()
Definition at line 706 of file RegisterPressure.cpp.
References llvm::LaneBitmask::any(), assert(), llvm::SmallVectorTemplateCommon< T, typename >::end(), llvm::find_if(), llvm::LaneBitmask::getNone(), I, increaseSetPressure(), llvm::VRegMaskOrUnit::LaneMask, llvm::Other, llvm::SmallVectorTemplateBase< T, bool >::push_back(), and llvm::VRegMaskOrUnit::VRegOrUnit.
Referenced by discoverLiveIn(), and discoverLiveOut().
◆ discoverLiveOut()
| void RegPressureTracker::discoverLiveOut ( VRegMaskOrUnit Pair) | protected |
|---|
◆ dump()
◆ getCurrSlot()
| SlotIndex RegPressureTracker::getCurrSlot ( ) const | protected |
|---|
◆ getDownwardPressure()
◆ getLastUsedLanes()
◆ getLiveLanesAt()
◆ getLiveThroughAt()
◆ getLiveThru()
◆ getMaxDownwardPressureDelta()
Consider the pressure increase caused by traversing this instruction top-down.
Find the pressure set with the most change beyond its pressure limit based on the tracker's current pressure, and record the number of excess register units of that pressure set introduced by this instruction.
Find the register class with the most change in its pressure limit based on the tracker's current pressure, and return the number of excess register units of that pressure set introduced by this instruction.
This assumes that the current LiveIn set is sufficient.
This is expensive for an on-the-fly query because it calls bumpDownwardPressure to recompute the pressure sets based on current liveness. We don't yet have a fast version of downward pressure tracking analogous to getUpwardPressureDelta.
Definition at line 1335 of file RegisterPressure.cpp.
References assert(), bumpDownwardPressure(), computeExcessPressureDelta(), computeMaxPressureDelta(), llvm::RegPressureDelta::CriticalMax, llvm::RegPressureDelta::CurrentMax, llvm::PressureChange::getUnitInc(), and MI.
Referenced by getMaxPressureDelta(), and llvm::GenericScheduler::initCandidate().
◆ getMaxPressureDelta()
◆ getMaxUpwardPressureDelta()
Consider the pressure increase caused by traversing this instruction bottom-up.
Find the pressure set with the most change beyond its pressure limit based on the tracker's current pressure, and record the number of excess register units of that pressure set introduced by this instruction.
Find the pressure set with the most change beyond its pressure limit based on the tracker's current pressure, and return the change in number of register units of that pressure set introduced by this instruction.
This assumes that the current LiveOut set is sufficient.
This is expensive for an on-the-fly query because it calls bumpUpwardPressure to recompute the pressure sets based on current liveness. This mainly exists to verify correctness, e.g. with -verify-misched. getUpwardPressureDelta is the fast version of this query that uses the per-SUnit cache of the PressureDiff.
Definition at line 1083 of file RegisterPressure.cpp.
References assert(), bumpUpwardPressure(), computeExcessPressureDelta(), computeMaxPressureDelta(), llvm::RegPressureDelta::CriticalMax, llvm::RegPressureDelta::CurrentMax, llvm::dbgs(), llvm::PressureDiff::dump(), llvm::RegPressureDelta::Excess, llvm::PressureChange::getPSet(), llvm::PressureChange::getUnitInc(), getUpwardPressureDelta(), llvm::PressureChange::isValid(), llvm_unreachable, and MI.
Referenced by getMaxPressureDelta(), and llvm::GenericScheduler::initCandidate().
◆ getPos()
◆ getPressure() [1/2]
◆ getPressure() [2/2]
◆ getPressureAfterInst()
| void llvm::RegPressureTracker::getPressureAfterInst ( const MachineInstr * MI, std::vector< unsigned > & PressureResult, std::vector< unsigned > & MaxPressureResult ) | inline |
|---|
◆ getRegSetPressureAtPos()
| const std::vector< unsigned > & llvm::RegPressureTracker::getRegSetPressureAtPos ( ) const | inline |
|---|
◆ getUpwardPressure()
◆ getUpwardPressureDelta()
This is the fast version of querying register pressure that does not directly depend on current liveness.
Parameters
| Delta | captures information needed for heuristics. |
|---|---|
| CriticalPSets | Are the pressure sets that are known to exceed some limit within the region, not necessarily at the current position. |
| MaxPressureLimit | Is the max pressure within the region, not necessarily at the current position. |
Definition at line 1151 of file RegisterPressure.cpp.
References assert(), llvm::PressureDiff::begin(), llvm::RegPressureDelta::CriticalMax, llvm::RegPressureDelta::CurrentMax, llvm::PressureDiff::end(), llvm::RegPressureDelta::Excess, llvm::PressureChange::isValid(), MI, llvm::PressureChange::setUnitInc(), and llvm::ArrayRef< T >::size().
Referenced by getMaxUpwardPressureDelta(), and llvm::GenericScheduler::initCandidate().
◆ hasUntiedDef()
| bool llvm::RegPressureTracker::hasUntiedDef ( Register VirtReg) const | inline |
|---|
◆ increaseRegPressure()
◆ init()
◆ initLiveThru() [1/2]
| void llvm::RegPressureTracker::initLiveThru ( ArrayRef< unsigned > PressureSet) | inline |
|---|
◆ initLiveThru() [2/2]
Initialize the LiveThru pressure set based on the untied defs found in RPTracker.
The register tracker is unaware of global liveness so ignores normal live-thru ranges.
However, two-address or coalesced chains can also lead to live ranges with no holes. Count these to inform heuristics that we can never drop below this pressure.
Definition at line 358 of file RegisterPressure.cpp.
References assert(), llvm::VirtRegOrUnit::asVirtualReg(), llvm::LaneBitmask::getNone(), hasUntiedDef(), increaseSetPressure(), isBottomClosed(), llvm::VirtRegOrUnit::isVirtualReg(), llvm::VRegMaskOrUnit::LaneMask, RegPressureTracker(), and llvm::VRegMaskOrUnit::VRegOrUnit.
◆ isBottomClosed()
| bool RegPressureTracker::isBottomClosed | ( | ) | const |
|---|
◆ isTopClosed()
| bool RegPressureTracker::isTopClosed | ( | ) | const |
|---|
◆ recede() [1/2]
Recede across the previous instruction.
This "low-level" variant assumes that recedeSkipDebugValues() was called previously and takes precomputed RegisterOperands for the instruction.
If LiveUses is provided, record any RegUnits that are made live by the current instruction's uses. This includes registers that are both defined and used by the instruction. If a pressure difference pointer is provided record the changes is pressure caused by this instruction independent of liveness.
Definition at line 754 of file RegisterPressure.cpp.
References addRegLanes(), llvm::LaneBitmask::any(), assert(), llvm::VirtRegOrUnit::asVirtualReg(), bumpDeadDefs(), llvm::RegisterOperands::DeadDefs, decreaseRegPressure(), llvm::RegisterOperands::Defs, discoverLiveOut(), llvm::SmallVectorTemplateCommon< T, typename >::end(), llvm::find_if(), getLiveThroughAt(), llvm::LaneBitmask::getNone(), llvm::SlotIndex::getRegSlot(), I, increaseRegPressure(), increaseSetPressure(), llvm::VirtRegOrUnit::isVirtualReg(), llvm::LaneBitmask::none(), llvm::Other, removeRegLanes(), setRegZero(), and llvm::RegisterOperands::Uses.
◆ recede() [2/2]
◆ recedeSkipDebugValues()
| void RegPressureTracker::recedeSkipDebugValues | ( | ) |
|---|
◆ reset()
| void RegPressureTracker::reset | ( | ) |
|---|
◆ setPos()
The documentation for this class was generated from the following files:
- include/llvm/CodeGen/RegisterPressure.h
- lib/CodeGen/RegisterPressure.cpp