class LiveIntervals

Declaration

class LiveIntervals : public MachineFunctionPass { /* full declaration omitted */ };

Description

MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of passes that operate on the MachineFunction representation. Instead of overriding runOnFunction, subclasses override runOnMachineFunction.

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:53

Inherits from: MachineFunctionPass

Member Variables

private llvm::MachineFunction* MF
private llvm::MachineRegisterInfo* MRI
private const llvm::TargetRegisterInfo* TRI
private const llvm::TargetInstrInfo* TII
private llvm::SlotIndexes* Indexes
private llvm::MachineDominatorTree* DomTree = nullptr
private llvm::LiveIntervalCalc* LICalc = nullptr
private VNInfo::Allocator VNInfoAllocator
Special pool allocator for VNInfo's (LiveInterval val#).
private IndexedMap<llvm::LiveInterval*, llvm::VirtReg2IndexFunctor> VirtRegIntervals
Live interval pointers for all the virtual registers.
private SmallVector<llvm::SlotIndex, 8> RegMaskSlots
Sorted list of instructions with register mask operands. Always use the 'r' slot, RegMasks are normal clobbers, not early clobbers.
private SmallVector<const uint32_t*, 8> RegMaskBits
This is kept in a separate vector partly because some standard libraries don't support lower_bound() with mixed objects, partly to improve locality when searching in RegMaskSlots. Also see the comment in LiveInterval::find().
private SmallVector<std::pair<unsigned int, unsigned int>, 8> RegMaskBlocks
For each basic block number, keep (begin, size) pairs indexing into the RegMaskSlots and RegMaskBits arrays. Note that basic block numbers may not be layout contiguous, that's why we can't just keep track of the first register mask in each basic block.
private SmallVector<llvm::LiveRange*, 0> RegUnitRanges
Keeps a live range set for each register unit to track fixed physreg interference.
public static char ID

Method Overview

Inherited from MachineFunctionPass:

Inherited from FunctionPass:

Inherited from Pass:

Methods

llvm::SlotIndex InsertMachineInstrInMaps(
    llvm::MachineInstr& MI)

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:260

Parameters

llvm::MachineInstr& MI

void InsertMachineInstrRangeInMaps(
    MachineBasicBlock::iterator B,
    MachineBasicBlock::iterator E)

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:264

Parameters

MachineBasicBlock::iterator B
MachineBasicBlock::iterator E

LiveIntervals()

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:99

void RemoveMachineInstrFromMaps(
    llvm::MachineInstr& MI)

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:270

Parameters

llvm::MachineInstr& MI

llvm::SlotIndex ReplaceMachineInstrInMaps(
    llvm::MachineInstr& MI,
    llvm::MachineInstr& NewMI)

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:274

Parameters

llvm::MachineInstr& MI
llvm::MachineInstr& NewMI

void addKillFlags(const llvm::VirtRegMap*)

Description

Add kill flags to any instruction that kills a virtual register.

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:298

Parameters

const llvm::VirtRegMap*

LiveInterval::Segment addSegmentToEndOfBlock(
    llvm::Register Reg,
    llvm::MachineInstr& startInst)

Description

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

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:150

Parameters

llvm::Register Reg
llvm::MachineInstr& startInst

bool checkRegMaskInterference(
    const llvm::LiveInterval& LI,
    llvm::BitVector& UsableRegs)

Description

Test if \p 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 \p LI doesn't cross any register mask instructions. In that case, the bit vector is not filled in.

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:371

Parameters

const llvm::LiveInterval& LI
llvm::BitVector& UsableRegs

bool computeDeadValues(
    llvm::LiveInterval& LI,
    SmallVectorImpl<llvm::MachineInstr*>* dead)

Description

Walk the values in \p LI and check for dead values: - Dead PHIDef values are marked as unused. - Dead operands are marked as such. - Completely dead machine instructions are added to the \p dead vector if it is not nullptr. Returns true if any PHI value numbers have been removed which may have separated the interval into multiple connected components.

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:456

Parameters

llvm::LiveInterval& LI
SmallVectorImpl<llvm::MachineInstr*>* dead

void computeLiveInRegUnits()

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:464

void computeRegMasks()

Description

Compute RegMaskSlots and RegMaskBits.

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

void computeRegUnitRange(llvm::LiveRange&,
                         unsigned int Unit)

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:465

Parameters

llvm::LiveRange&
unsigned int Unit

bool computeVirtRegInterval(llvm::LiveInterval&)

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:466

Parameters

llvm::LiveInterval&

void computeVirtRegs()

Description

Compute live intervals for all virtual registers.

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:444

void constructMainRangeFromSubranges(
    llvm::LiveInterval& LI)

Description

For live interval \p 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.

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

Parameters

llvm::LiveInterval& LI

llvm::LiveInterval&
createAndComputeVirtRegInterval(
    llvm::Register Reg)

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:136

Parameters

llvm::Register Reg

llvm::LiveInterval& createEmptyInterval(
    llvm::Register Reg)

Description

Interval creation.

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:129

Parameters

llvm::Register Reg

static llvm::LiveInterval* createInterval(
    llvm::Register Reg)

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

Parameters

llvm::Register Reg

void dumpInstrs() const

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:462

void extendSegmentsToUses(
    llvm::LiveRange& Segments,
    llvm::LiveIntervals::ShrinkToUsesWorkList&
        WorkList,
    llvm::Register Reg,
    llvm::LaneBitmask LaneMask)

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:469

Parameters

llvm::LiveRange& Segments
llvm::LiveIntervals::ShrinkToUsesWorkList& WorkList
llvm::Register Reg
llvm::LaneBitmask LaneMask

void extendToIndices(
    llvm::LiveRange& LR,
    ArrayRef<llvm::SlotIndex> Indices,
    ArrayRef<llvm::SlotIndex> Undefs)

Description

Extend the live range \p LR to reach all points in \p Indices. The points in the \p Indices array must be jointly dominated by the union of the existing defs in \p LR and points in \p Undefs. PHI-defs are added as needed to maintain SSA form. If a SlotIndex in \p Indices is the end index of a basic block, \p LR will be extended to be live out of the basic block. If a SlotIndex in \p Indices is jointy dominated only by points in\p Undefs, the live range will not be extended to that point. See also LiveRangeCalc::extend().

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:182

Parameters

llvm::LiveRange& LR
ArrayRef<llvm::SlotIndex> Indices
ArrayRef<llvm::SlotIndex> Undefs

void extendToIndices(
    llvm::LiveRange& LR,
    ArrayRef<llvm::SlotIndex> Indices)

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:185

Parameters

llvm::LiveRange& LR
ArrayRef<llvm::SlotIndex> Indices

void getAnalysisUsage(
    llvm::AnalysisUsage& AU) const

Description

getAnalysisUsage - Subclasses that override getAnalysisUsage must call this. For MachineFunctionPasses, calling AU.preservesCFG() indicates that the pass does not modify the MachineBasicBlock CFG.

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:280

Parameters

llvm::AnalysisUsage& AU

const llvm::LiveRange* getCachedRegUnit(
    unsigned int Unit) const

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:404

Parameters

unsigned int Unit

llvm::LiveRange* getCachedRegUnit(
    unsigned int Unit)

Description

Return the live range for register unit \p Unit if it has already been computed, or nullptr if it hasn't been computed yet.

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

Parameters

unsigned int Unit

llvm::MachineInstr* getInstructionFromIndex(
    llvm::SlotIndex index) const

Description

Returns the instruction associated with the given index.

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:225

Parameters

llvm::SlotIndex index

llvm::SlotIndex getInstructionIndex(
    const llvm::MachineInstr& Instr) const

Description

Returns the base index of the given instruction.

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:220

Parameters

const llvm::MachineInstr& Instr

llvm::LiveInterval& getInterval(
    llvm::Register Reg)

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:112

Parameters

llvm::Register Reg

const llvm::LiveInterval& getInterval(
    llvm::Register Reg) const

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:119

Parameters

llvm::Register Reg

llvm::SlotIndex getMBBEndIdx(
    const llvm::MachineBasicBlock* mbb) const

Description

Return the last index in the given basic block.

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:235

Parameters

const llvm::MachineBasicBlock* mbb

llvm::MachineBasicBlock* getMBBFromIndex(
    llvm::SlotIndex index) const

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:249

Parameters

llvm::SlotIndex index

llvm::SlotIndex getMBBStartIdx(
    const llvm::MachineBasicBlock* mbb) const

Description

Return the first index in the given basic block.

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:230

Parameters

const llvm::MachineBasicBlock* mbb

ArrayRef<const uint32_t*> getRegMaskBits() const

Description

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

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:356

ArrayRef<const uint32_t*> getRegMaskBitsInBlock(
    unsigned int MBBNum) const

Description

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

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:360

Parameters

unsigned int MBBNum

ArrayRef<llvm::SlotIndex> getRegMaskSlots() const

Description

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

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:345

ArrayRef<llvm::SlotIndex> getRegMaskSlotsInBlock(
    unsigned int MBBNum) const

Description

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

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:349

Parameters

unsigned int MBBNum

llvm::LiveRange& getRegUnit(unsigned int Unit)

Description

Return the live range for register unit \p Unit. It will be computed if it doesn't exist.

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:387

Parameters

unsigned int Unit

llvm::SlotIndexes* getSlotIndexes() const

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:209

static float getSpillWeight(
    bool isDef,
    bool isUse,
    const llvm::MachineBlockFrequencyInfo* MBFI,
    const llvm::MachineBasicBlock* MBB)

Description

Calculate the spill weight to assign to a single instruction.

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:108

Parameters

bool isDef
bool isUse
const llvm::MachineBlockFrequencyInfo* MBFI
const llvm::MachineBasicBlock* MBB

static float getSpillWeight(
    bool isDef,
    bool isUse,
    const llvm::MachineBlockFrequencyInfo* MBFI,
    const llvm::MachineInstr& MI)

Description

Calculate the spill weight to assign to a single instruction.

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:103

Parameters

bool isDef
bool isUse
const llvm::MachineBlockFrequencyInfo* MBFI
const llvm::MachineInstr& MI

VNInfo::Allocator& getVNInfoAllocator()

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:278

void handleMove(llvm::MachineInstr& MI,
                bool UpdateFlags = false)

Description

Call this method to notify LiveIntervals that instruction \p MI has been moved within a basic block. This will update the live intervals for all operands of \p MI. Moves between basic blocks are not supported.

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:305

Parameters

llvm::MachineInstr& MI
bool UpdateFlags = false
Update live intervals for nonallocatable physregs.

void handleMoveIntoNewBundle(
    llvm::MachineInstr& BundleStart,
    bool UpdateFlags = false)

Description

Update intervals of operands of all instructions in the newly created bundle specified by \p BundleStart. Assumes existing liveness is accurate.

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:315

Parameters

llvm::MachineInstr& BundleStart
bool UpdateFlags = false
Update live intervals for nonallocatable physregs.

bool hasInterval(llvm::Register Reg) const

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:123

Parameters

llvm::Register Reg

bool hasPHIKill(const llvm::LiveInterval& LI,
                const llvm::VNInfo* VNI) const

Description

Returns true if VNI is killed by any PHI-def values in LI. This may conservatively return true to avoid expensive computations.

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:295

Parameters

const llvm::LiveInterval& LI
const llvm::VNInfo* VNI

void insertMBBInMaps(llvm::MachineBasicBlock* MBB)

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:253

Parameters

llvm::MachineBasicBlock* MBB

llvm::MachineBasicBlock* intervalIsInOneMBB(
    const llvm::LiveInterval& LI) const

Description

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.

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:291

Parameters

const llvm::LiveInterval& LI

bool isLiveInToMBB(
    const llvm::LiveRange& LR,
    const llvm::MachineBasicBlock* mbb) const

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:239

Parameters

const llvm::LiveRange& LR
const llvm::MachineBasicBlock* mbb

bool isLiveOutOfMBB(
    const llvm::LiveRange& LR,
    const llvm::MachineBasicBlock* mbb) const

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:244

Parameters

const llvm::LiveRange& LR
const llvm::MachineBasicBlock* mbb

bool isNotInMIMap(
    const llvm::MachineInstr& Instr) const

Description

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

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:215

Parameters

const llvm::MachineInstr& Instr

void print(llvm::raw_ostream& O,
           const llvm::Module* = nullptr) const

Description

Implement the dump method.

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:287

Parameters

llvm::raw_ostream& O
const llvm::Module* = nullptr

void printInstrs(llvm::raw_ostream& O) const

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:461

Parameters

llvm::raw_ostream& O

void pruneValue(
    llvm::LiveRange& LR,
    llvm::SlotIndex Kill,
    SmallVectorImpl<llvm::SlotIndex>* EndPoints)

Description

If \p LR has a live value at \p 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.

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:196

Parameters

llvm::LiveRange& LR
llvm::SlotIndex Kill
SmallVectorImpl<llvm::SlotIndex>* EndPoints

void pruneValue(llvm::LiveInterval&,
                llvm::SlotIndex,
                SmallVectorImpl<llvm::SlotIndex>*)

Description

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.

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:203

Parameters

llvm::LiveInterval&
llvm::SlotIndex
SmallVectorImpl<llvm::SlotIndex>*

void releaseMemory()

Description

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.

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:281

void removeAllRegUnitsForPhysReg(
    llvm::MCRegister Reg)

Description

Remove associated live ranges for the register units associated with \p Reg. Subsequent uses should rely on on-demand recomputation.

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

Parameters

llvm::MCRegister Reg

void removeInterval(llvm::Register Reg)

Description

Interval removal.

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:143

Parameters

llvm::Register Reg

void removePhysRegDefAt(llvm::MCRegister Reg,
                        llvm::SlotIndex Pos)

Description

Remove value numbers and related live segments starting at position\p Pos that are part of any liverange of physical register \p Reg or one of its subregisters.

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:427

Parameters

llvm::MCRegister Reg
llvm::SlotIndex Pos

void removeRegUnit(unsigned int Unit)

Description

Remove computed live range for register unit \p Unit. Subsequent uses should rely on on-demand recomputation.

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

Parameters

unsigned int Unit

void removeVRegDefAt(llvm::LiveInterval& LI,
                     llvm::SlotIndex Pos)

Description

Remove value number and related live segments of \p LI and its subranges that start at position \p Pos.

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:431

Parameters

llvm::LiveInterval& LI
llvm::SlotIndex Pos

void repairIntervalsInRange(
    llvm::MachineBasicBlock* MBB,
    MachineBasicBlock::iterator Begin,
    MachineBasicBlock::iterator End,
    ArrayRef<llvm::Register> OrigRegs)

Description

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.

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:327

Parameters

llvm::MachineBasicBlock* MBB
MachineBasicBlock::iterator Begin
MachineBasicBlock::iterator End
ArrayRef<llvm::Register> OrigRegs

void repairOldRegInRange(
    MachineBasicBlock::iterator Begin,
    MachineBasicBlock::iterator End,
    const llvm::SlotIndex endIdx,
    llvm::LiveRange& LR,
    llvm::Register Reg,
    llvm::LaneBitmask LaneMask =
        LaneBitmask::getAll())

Description

Helper function for repairIntervalsInRange(), walks backwards and creates/modifies live segments in \p LR to match the operands found. Only full operands or operands with subregisters matching \p LaneMask are considered.

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

Parameters

MachineBasicBlock::iterator Begin
MachineBasicBlock::iterator End
const llvm::SlotIndex endIdx
llvm::LiveRange& LR
llvm::Register Reg
llvm::LaneBitmask LaneMask = LaneBitmask::getAll()

bool runOnMachineFunction(llvm::MachineFunction&)

Description

Pass entry point; Calculates LiveIntervals.

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:284

Parameters

llvm::MachineFunction&

void shrinkToUses(LiveInterval::SubRange& SR,
                  llvm::Register Reg)

Description

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.

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:168

Parameters

LiveInterval::SubRange& SR
llvm::Register Reg

bool shrinkToUses(
    llvm::LiveInterval* li,
    SmallVectorImpl<llvm::MachineInstr*>* dead =
        nullptr)

Description

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.

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:159

Parameters

llvm::LiveInterval* li
SmallVectorImpl<llvm::MachineInstr*>* dead = nullptr

void splitSeparateComponents(
    llvm::LiveInterval& LI,
    SmallVectorImpl<llvm::LiveInterval*>&
        SplitLIs)

Description

Split separate components in LiveInterval \p LI into separate intervals.

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:434

Parameters

llvm::LiveInterval& LI
SmallVectorImpl<llvm::LiveInterval*>& SplitLIs

~LiveIntervals()

Declared at: llvm/include/llvm/CodeGen/LiveIntervals.h:100