class RegPressureTracker

Declaration

class RegPressureTracker { /* full declaration omitted */ };

Description

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.

Declared at: llvm/include/llvm/CodeGen/RegisterPressure.h:357

Member Variables

private const llvm::MachineFunction* MF = nullptr
private const llvm::TargetRegisterInfo* TRI = nullptr
private const llvm::RegisterClassInfo* RCI = nullptr
private const llvm::MachineRegisterInfo* MRI
private const llvm::LiveIntervals* LIS = nullptr
private const llvm::MachineBasicBlock* MBB = nullptr
We currently only allow pressure tracking within a block.
private llvm::RegisterPressure& P
Track the max pressure within the region traversed so far.
private bool RequireIntervals
Run in two modes dependending on whether constructed with IntervalPressure or RegisterPressure. If requireIntervals is false, LIS are ignored.
private bool TrackUntiedDefs = false
True if UntiedDefs will be populated.
private bool TrackLaneMasks = false
True if lanemasks should be tracked.
private MachineBasicBlock::const_iterator CurrPos
Register pressure corresponds to liveness before this instruction iterator. It may point to the end of the block or a DebugValue rather than an instruction.
private std::vector<unsigned int> CurrSetPressure
Pressure map indexed by pressure set ID, not class ID.
private llvm::LiveRegSet LiveRegs
Set of live registers.
private SparseSet<llvm::Register, llvm::VirtReg2IndexFunctor> UntiedDefs
Set of vreg defs that start a live range.
private std::vector<unsigned int> LiveThruPressure
Live-through pressure.

Method Overview

  • public RegPressureTracker(llvm::RegionPressure & rp)
  • public RegPressureTracker(llvm::IntervalPressure & rp)
  • public void addLiveRegs(ArrayRef<llvm::RegisterMaskPair> Regs)
  • public void advance(const llvm::RegisterOperands & RegOpers)
  • public void advance()
  • protected void bumpDeadDefs(ArrayRef<llvm::RegisterMaskPair> DeadDefs)
  • protected void bumpDownwardPressure(const llvm::MachineInstr * MI)
  • protected void bumpUpwardPressure(const llvm::MachineInstr * MI)
  • public void closeBottom()
  • public void closeRegion()
  • public void closeTop()
  • protected void decreaseRegPressure(llvm::Register RegUnit, llvm::LaneBitmask PreviousMask, llvm::LaneBitmask NewMask)
  • protected void discoverLiveIn(llvm::RegisterMaskPair Pair)
  • protected void discoverLiveInOrOut(llvm::RegisterMaskPair Pair, SmallVectorImpl<llvm::RegisterMaskPair> & LiveInOrOut)
  • protected void discoverLiveOut(llvm::RegisterMaskPair Pair)
  • public void dump() const
  • protected llvm::SlotIndex getCurrSlot() const
  • public void getDownwardPressure(const llvm::MachineInstr * MI, std::vector<unsigned int> & PressureResult, std::vector<unsigned int> & MaxPressureResult)
  • protected llvm::LaneBitmask getLastUsedLanes(llvm::Register RegUnit, llvm::SlotIndex Pos) const
  • protected llvm::LaneBitmask getLiveLanesAt(llvm::Register RegUnit, llvm::SlotIndex Pos) const
  • protected llvm::LaneBitmask getLiveThroughAt(llvm::Register RegUnit, llvm::SlotIndex Pos) const
  • public ArrayRef<unsigned int> getLiveThru() const
  • public void getMaxDownwardPressureDelta(const llvm::MachineInstr * MI, llvm::RegPressureDelta & Delta, ArrayRef<llvm::PressureChange> CriticalPSets, ArrayRef<unsigned int> MaxPressureLimit)
  • public void getMaxPressureDelta(const llvm::MachineInstr * MI, llvm::RegPressureDelta & Delta, ArrayRef<llvm::PressureChange> CriticalPSets, ArrayRef<unsigned int> MaxPressureLimit)
  • public void getMaxUpwardPressureDelta(const llvm::MachineInstr * MI, llvm::PressureDiff * PDiff, llvm::RegPressureDelta & Delta, ArrayRef<llvm::PressureChange> CriticalPSets, ArrayRef<unsigned int> MaxPressureLimit)
  • public MachineBasicBlock::const_iterator getPos() const
  • public const llvm::RegisterPressure & getPressure() const
  • public llvm::RegisterPressure & getPressure()
  • public void getPressureAfterInst(const llvm::MachineInstr * MI, std::vector<unsigned int> & PressureResult, std::vector<unsigned int> & MaxPressureResult)
  • public const std::vector<unsigned int> & getRegSetPressureAtPos() const
  • public void getUpwardPressure(const llvm::MachineInstr * MI, std::vector<unsigned int> & PressureResult, std::vector<unsigned int> & MaxPressureResult)
  • public void getUpwardPressureDelta(const llvm::MachineInstr * MI, llvm::PressureDiff & PDiff, llvm::RegPressureDelta & Delta, ArrayRef<llvm::PressureChange> CriticalPSets, ArrayRef<unsigned int> MaxPressureLimit) const
  • public bool hasUntiedDef(llvm::Register VirtReg) const
  • protected void increaseRegPressure(llvm::Register RegUnit, llvm::LaneBitmask PreviousMask, llvm::LaneBitmask NewMask)
  • public void init(const llvm::MachineFunction * mf, const llvm::RegisterClassInfo * rci, const llvm::LiveIntervals * lis, const llvm::MachineBasicBlock * mbb, MachineBasicBlock::const_iterator pos, bool TrackLaneMasks, bool TrackUntiedDefs)
  • public void initLiveThru(ArrayRef<unsigned int> PressureSet)
  • public void initLiveThru(const llvm::RegPressureTracker & RPTracker)
  • public bool isBottomClosed() const
  • public bool isTopClosed() const
  • public void recede(SmallVectorImpl<llvm::RegisterMaskPair> * LiveUses = nullptr)
  • public void recede(const llvm::RegisterOperands & RegOpers, SmallVectorImpl<llvm::RegisterMaskPair> * LiveUses = nullptr)
  • public void recedeSkipDebugValues()
  • public void reset()
  • public void setPos(MachineBasicBlock::const_iterator Pos)

Methods

RegPressureTracker(llvm::RegionPressure& rp)

Declared at: llvm/include/llvm/CodeGen/RegisterPressure.h:398

Parameters

llvm::RegionPressure& rp

RegPressureTracker(llvm::IntervalPressure& rp)

Declared at: llvm/include/llvm/CodeGen/RegisterPressure.h:397

Parameters

llvm::IntervalPressure& rp

void addLiveRegs(
    ArrayRef<llvm::RegisterMaskPair> Regs)

Description

Force liveness of virtual registers or physical register units. Particularly useful to initialize the livein/out state of the tracker before the first call to advance/recede.

Declared at: llvm/include/llvm/CodeGen/RegisterPressure.h:410

Parameters

ArrayRef<llvm::RegisterMaskPair> Regs

void advance(
    const llvm::RegisterOperands& RegOpers)

Description

Advance across the current instruction. This is a "low-level" variant of advance() which takes precomputed RegisterOperands of the instruction.

Declared at: llvm/include/llvm/CodeGen/RegisterPressure.h:440

Parameters

const llvm::RegisterOperands& RegOpers

void advance()

Description

Advance across the current instruction.

Declared at: llvm/include/llvm/CodeGen/RegisterPressure.h:435

void bumpDeadDefs(
    ArrayRef<llvm::RegisterMaskPair> DeadDefs)

Declared at: llvm/include/llvm/CodeGen/RegisterPressure.h:555

Parameters

ArrayRef<llvm::RegisterMaskPair> DeadDefs

void bumpDownwardPressure(
    const llvm::MachineInstr* MI)

Declared at: llvm/include/llvm/CodeGen/RegisterPressure.h:558

Parameters

const llvm::MachineInstr* MI

void bumpUpwardPressure(
    const llvm::MachineInstr* MI)

Declared at: llvm/include/llvm/CodeGen/RegisterPressure.h:557

Parameters

const llvm::MachineInstr* MI

void closeBottom()

Declared at: llvm/include/llvm/CodeGen/RegisterPressure.h:471

void closeRegion()

Description

Finalize the region boundaries and recored live ins and live outs.

Declared at: llvm/include/llvm/CodeGen/RegisterPressure.h:443

void closeTop()

Declared at: llvm/include/llvm/CodeGen/RegisterPressure.h:470

void decreaseRegPressure(
    llvm::Register RegUnit,
    llvm::LaneBitmask PreviousMask,
    llvm::LaneBitmask NewMask)

Declared at: llvm/include/llvm/CodeGen/RegisterPressure.h:552

Parameters

llvm::Register RegUnit
llvm::LaneBitmask PreviousMask
llvm::LaneBitmask NewMask

void discoverLiveIn(llvm::RegisterMaskPair Pair)

Description

Add Reg to the live in set and increase max pressure.

Declared at: llvm/include/llvm/CodeGen/RegisterPressure.h:544

Parameters

llvm::RegisterMaskPair Pair

void discoverLiveInOrOut(
    llvm::RegisterMaskPair Pair,
    SmallVectorImpl<llvm::RegisterMaskPair>&
        LiveInOrOut)

Declared at: llvm/include/llvm/CodeGen/RegisterPressure.h:560

Parameters

llvm::RegisterMaskPair Pair
SmallVectorImpl<llvm::RegisterMaskPair>& LiveInOrOut

void discoverLiveOut(llvm::RegisterMaskPair Pair)

Description

Add Reg to the live out set and increase max pressure.

Declared at: llvm/include/llvm/CodeGen/RegisterPressure.h:542

Parameters

llvm::RegisterMaskPair Pair

void dump() const

Declared at: llvm/include/llvm/CodeGen/RegisterPressure.h:538

llvm::SlotIndex getCurrSlot() const

Description

Get the SlotIndex for the first nondebug instruction including or after the current position.

Declared at: llvm/include/llvm/CodeGen/RegisterPressure.h:548

void getDownwardPressure(
    const llvm::MachineInstr* MI,
    std::vector<unsigned int>& PressureResult,
    std::vector<unsigned int>& MaxPressureResult)

Description

Get the pressure of each PSet after traversing this instruction top-down.

Declared at: llvm/include/llvm/CodeGen/RegisterPressure.h:520

Parameters

const llvm::MachineInstr* MI
std::vector<unsigned int>& PressureResult
std::vector<unsigned int>& MaxPressureResult

llvm::LaneBitmask getLastUsedLanes(
    llvm::Register RegUnit,
    llvm::SlotIndex Pos) const

Declared at: llvm/include/llvm/CodeGen/RegisterPressure.h:563

Parameters

llvm::Register RegUnit
llvm::SlotIndex Pos

llvm::LaneBitmask getLiveLanesAt(
    llvm::Register RegUnit,
    llvm::SlotIndex Pos) const

Declared at: llvm/include/llvm/CodeGen/RegisterPressure.h:564

Parameters

llvm::Register RegUnit
llvm::SlotIndex Pos

llvm::LaneBitmask getLiveThroughAt(
    llvm::Register RegUnit,
    llvm::SlotIndex Pos) const

Declared at: llvm/include/llvm/CodeGen/RegisterPressure.h:565

Parameters

llvm::Register RegUnit
llvm::SlotIndex Pos

ArrayRef<unsigned int> getLiveThru() const

Declared at: llvm/include/llvm/CodeGen/RegisterPressure.h:454

void getMaxDownwardPressureDelta(
    const llvm::MachineInstr* MI,
    llvm::RegPressureDelta& Delta,
    ArrayRef<llvm::PressureChange> CriticalPSets,
    ArrayRef<unsigned int> MaxPressureLimit)

Description

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.

Declared at: llvm/include/llvm/CodeGen/RegisterPressure.h:493

Parameters

const llvm::MachineInstr* MI
llvm::RegPressureDelta& Delta
ArrayRef<llvm::PressureChange> CriticalPSets
ArrayRef<unsigned int> MaxPressureLimit

void getMaxPressureDelta(
    const llvm::MachineInstr* MI,
    llvm::RegPressureDelta& Delta,
    ArrayRef<llvm::PressureChange> CriticalPSets,
    ArrayRef<unsigned int> MaxPressureLimit)

Description

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.

Declared at: llvm/include/llvm/CodeGen/RegisterPressure.h:501

Parameters

const llvm::MachineInstr* MI
llvm::RegPressureDelta& Delta
ArrayRef<llvm::PressureChange> CriticalPSets
ArrayRef<unsigned int> MaxPressureLimit

void getMaxUpwardPressureDelta(
    const llvm::MachineInstr* MI,
    llvm::PressureDiff* PDiff,
    llvm::RegPressureDelta& Delta,
    ArrayRef<llvm::PressureChange> CriticalPSets,
    ArrayRef<unsigned int> MaxPressureLimit)

Description

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.

Declared at: llvm/include/llvm/CodeGen/RegisterPressure.h:477

Parameters

const llvm::MachineInstr* MI
llvm::PressureDiff* PDiff
llvm::RegPressureDelta& Delta
ArrayRef<llvm::PressureChange> CriticalPSets
ArrayRef<unsigned int> MaxPressureLimit

MachineBasicBlock::const_iterator getPos() const

Description

Get the MI position corresponding to this register pressure.

Declared at: llvm/include/llvm/CodeGen/RegisterPressure.h:413

const llvm::RegisterPressure& getPressure() const

Declared at: llvm/include/llvm/CodeGen/RegisterPressure.h:459

llvm::RegisterPressure& getPressure()

Description

Get the resulting register pressure over the traversed region. This result is complete if closeRegion() was explicitly invoked.

Declared at: llvm/include/llvm/CodeGen/RegisterPressure.h:458

void getPressureAfterInst(
    const llvm::MachineInstr* MI,
    std::vector<unsigned int>& PressureResult,
    std::vector<unsigned int>& MaxPressureResult)

Declared at: llvm/include/llvm/CodeGen/RegisterPressure.h:524

Parameters

const llvm::MachineInstr* MI
std::vector<unsigned int>& PressureResult
std::vector<unsigned int>& MaxPressureResult

const std::vector<unsigned int>&
getRegSetPressureAtPos() const

Description

Get the register set pressure at the current position, which may be less than the pressure across the traversed region.

Declared at: llvm/include/llvm/CodeGen/RegisterPressure.h:463

void getUpwardPressure(
    const llvm::MachineInstr* MI,
    std::vector<unsigned int>& PressureResult,
    std::vector<unsigned int>& MaxPressureResult)

Description

Get the pressure of each PSet after traversing this instruction bottom-up.

Declared at: llvm/include/llvm/CodeGen/RegisterPressure.h:515

Parameters

const llvm::MachineInstr* MI
std::vector<unsigned int>& PressureResult
std::vector<unsigned int>& MaxPressureResult

void getUpwardPressureDelta(
    const llvm::MachineInstr* MI,
    llvm::PressureDiff& PDiff,
    llvm::RegPressureDelta& Delta,
    ArrayRef<llvm::PressureChange> CriticalPSets,
    ArrayRef<unsigned int> MaxPressureLimit) const

Declared at: llvm/include/llvm/CodeGen/RegisterPressure.h:483

Parameters

const llvm::MachineInstr* MI
llvm::PressureDiff& PDiff
llvm::RegPressureDelta& Delta
ArrayRef<llvm::PressureChange> CriticalPSets
ArrayRef<unsigned int> MaxPressureLimit

bool hasUntiedDef(llvm::Register VirtReg) const

Declared at: llvm/include/llvm/CodeGen/RegisterPressure.h:534

Parameters

llvm::Register VirtReg

void increaseRegPressure(
    llvm::Register RegUnit,
    llvm::LaneBitmask PreviousMask,
    llvm::LaneBitmask NewMask)

Declared at: llvm/include/llvm/CodeGen/RegisterPressure.h:550

Parameters

llvm::Register RegUnit
llvm::LaneBitmask PreviousMask
llvm::LaneBitmask NewMask

void init(const llvm::MachineFunction* mf,
          const llvm::RegisterClassInfo* rci,
          const llvm::LiveIntervals* lis,
          const llvm::MachineBasicBlock* mbb,
          MachineBasicBlock::const_iterator pos,
          bool TrackLaneMasks,
          bool TrackUntiedDefs)

Declared at: llvm/include/llvm/CodeGen/RegisterPressure.h:402

Parameters

const llvm::MachineFunction* mf
const llvm::RegisterClassInfo* rci
const llvm::LiveIntervals* lis
const llvm::MachineBasicBlock* mbb
MachineBasicBlock::const_iterator pos
bool TrackLaneMasks
bool TrackUntiedDefs

void initLiveThru(
    ArrayRef<unsigned int> PressureSet)

Description

Copy an existing live thru pressure result.

Declared at: llvm/include/llvm/CodeGen/RegisterPressure.h:450

Parameters

ArrayRef<unsigned int> PressureSet

void initLiveThru(
    const llvm::RegPressureTracker& RPTracker)

Description

Initialize the LiveThru pressure set based on the untied defs found in RPTracker.

Declared at: llvm/include/llvm/CodeGen/RegisterPressure.h:447

Parameters

const llvm::RegPressureTracker& RPTracker

bool isBottomClosed() const

Declared at: llvm/include/llvm/CodeGen/RegisterPressure.h:468

bool isTopClosed() const

Declared at: llvm/include/llvm/CodeGen/RegisterPressure.h:467

void recede(
    SmallVectorImpl<llvm::RegisterMaskPair>*
        LiveUses = nullptr)

Description

Recede across the previous instruction.

Declared at: llvm/include/llvm/CodeGen/RegisterPressure.h:422

Parameters

SmallVectorImpl<llvm::RegisterMaskPair>* LiveUses = nullptr

void recede(
    const llvm::RegisterOperands& RegOpers,
    SmallVectorImpl<llvm::RegisterMaskPair>*
        LiveUses = nullptr)

Description

Recede across the previous instruction. This "low-level" variant assumes that recedeSkipDebugValues() was called previously and takes precomputed RegisterOperands for the instruction.

Declared at: llvm/include/llvm/CodeGen/RegisterPressure.h:428

Parameters

const llvm::RegisterOperands& RegOpers
SmallVectorImpl<llvm::RegisterMaskPair>* LiveUses = nullptr

void recedeSkipDebugValues()

Description

Recede until we find an instruction which is not a DebugValue.

Declared at: llvm/include/llvm/CodeGen/RegisterPressure.h:432

void reset()

Declared at: llvm/include/llvm/CodeGen/RegisterPressure.h:400

void setPos(MachineBasicBlock::const_iterator Pos)

Declared at: llvm/include/llvm/CodeGen/RegisterPressure.h:419

Parameters

MachineBasicBlock::const_iterator Pos