LLVM 22.0.0git
llvm::LiveVariables Class Reference

#include "llvm/CodeGen/LiveVariables.h"

Classes

struct  VarInfo
 VarInfo - This represents the regions where a virtual register is live in the program. More...

Public Member Functions

LLVM_ABI LiveVariables (MachineFunction &MF)
LLVM_ABI void print (raw_ostream &OS) const
LLVM_ABI void recomputeForSingleDefVirtReg (Register Reg)
 Recompute liveness from scratch for a virtual register Reg that is known to have a single def that dominates all uses.
LLVM_ABI void replaceKillInstruction (Register Reg, MachineInstr &OldMI, MachineInstr &NewMI)
 replaceKillInstruction - Update register kill info by replacing a kill instruction with a new one.
void addVirtualRegisterKilled (Register IncomingReg, MachineInstr &MI, bool AddIfNotFound=false)
 addVirtualRegisterKilled - Add information about the fact that the specified register is killed after being used by the specified instruction.
bool removeVirtualRegisterKilled (Register Reg, MachineInstr &MI)
 removeVirtualRegisterKilled - Remove the specified kill of the virtual register from the live variable information.
LLVM_ABI void removeVirtualRegistersKilled (MachineInstr &MI)
 removeVirtualRegistersKilled - Remove all killed info for the specified instruction.
void addVirtualRegisterDead (Register IncomingReg, MachineInstr &MI, bool AddIfNotFound=false)
 addVirtualRegisterDead - Add information about the fact that the specified register is dead after being used by the specified instruction.
bool removeVirtualRegisterDead (Register Reg, MachineInstr &MI)
 removeVirtualRegisterDead - Remove the specified kill of the virtual register from the live variable information.
LLVM_ABI VarInfogetVarInfo (Register Reg)
 getVarInfo - Return the VarInfo structure for the specified VIRTUAL register.
LLVM_ABI void MarkVirtRegAliveInBlock (VarInfo &VRInfo, MachineBasicBlock *DefBlock, MachineBasicBlock *BB)
LLVM_ABI void MarkVirtRegAliveInBlock (VarInfo &VRInfo, MachineBasicBlock *DefBlock, MachineBasicBlock *BB, SmallVectorImpl< MachineBasicBlock * > &WorkList)
LLVM_ABI void HandleVirtRegDef (Register reg, MachineInstr &MI)
LLVM_ABI void HandleVirtRegUse (Register reg, MachineBasicBlock *MBB, MachineInstr &MI)
bool isLiveIn (Register Reg, const MachineBasicBlock &MBB)
LLVM_ABI bool isLiveOut (Register Reg, const MachineBasicBlock &MBB)
 isLiveOut - Determine if Reg is live out from MBB, when not considering PHI nodes.
LLVM_ABI void addNewBlock (MachineBasicBlock *BB, MachineBasicBlock *DomBB, MachineBasicBlock *SuccBB)
 addNewBlock - Add a new basic block BB between DomBB and SuccBB.
LLVM_ABI void addNewBlock (MachineBasicBlock *BB, MachineBasicBlock *DomBB, MachineBasicBlock *SuccBB, std::vector< SparseBitVector<> > &LiveInSets)
 addNewBlock - Add a new basic block BB as an empty succcessor to DomBB.

Friends

class LiveVariablesWrapperPass

Detailed Description

Definition at line 49 of file LiveVariables.h.

Constructor & Destructor Documentation

◆ LiveVariables()

LiveVariables::LiveVariables ( MachineFunction & MF)

Definition at line 73 of file LiveVariables.cpp.

Member Function Documentation

◆ addNewBlock() [1/2]

void LiveVariables::addNewBlock ( MachineBasicBlock * BB,
MachineBasicBlock * DomBB,
MachineBasicBlock * SuccBB )

addNewBlock - Add a new basic block BB between DomBB and SuccBB.

addNewBlock - Add a new basic block BB as an empty succcessor to DomBB.

All variables that are live out of DomBB and live into SuccBB will be marked as passing live through BB. This method assumes that the machine code is still in SSA form.

All variables that are live out of DomBB will be marked as passing live through BB.

Definition at line 814 of file LiveVariables.cpp.

References llvm::LiveVariables::VarInfo::AliveBlocks, llvm::MachineBasicBlock::begin(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::count(), llvm::MachineBasicBlock::end(), llvm::MachineBasicBlock::getNumber(), getVarInfo(), llvm::Register::index2VirtReg(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::insert(), and llvm::SparseBitVector< ElementSize >::set().

◆ addNewBlock() [2/2]

void LiveVariables::addNewBlock ( MachineBasicBlock * BB,
MachineBasicBlock * DomBB,
MachineBasicBlock * SuccBB,
std::vector< SparseBitVector<> > & LiveInSets )

addNewBlock - Add a new basic block BB as an empty succcessor to DomBB.

All variables that are live out of DomBB will be marked as passing live through BB. LiveInSets[BB] is not updated (because it is not needed during PHIElimination).

Definition at line 864 of file LiveVariables.cpp.

References llvm::LiveVariables::VarInfo::AliveBlocks, llvm::MachineBasicBlock::begin(), llvm::MachineBasicBlock::end(), llvm::MachineBasicBlock::getNumber(), getVarInfo(), llvm::Register::index2VirtReg(), and llvm::SparseBitVector< ElementSize >::set().

◆ addVirtualRegisterDead()

void llvm::LiveVariables::addVirtualRegisterDead ( Register IncomingReg,
MachineInstr & MI,
bool AddIfNotFound = false )
inline

addVirtualRegisterDead - Add information about the fact that the specified register is dead after being used by the specified instruction.

If AddIfNotFound is true, add a implicit operand if it's not found.

Definition at line 240 of file LiveVariables.h.

References getVarInfo(), llvm::LiveVariables::VarInfo::Kills, and MI.

◆ addVirtualRegisterKilled()

void llvm::LiveVariables::addVirtualRegisterKilled ( Register IncomingReg,
MachineInstr & MI,
bool AddIfNotFound = false )
inline

addVirtualRegisterKilled - Add information about the fact that the specified register is killed after being used by the specified instruction.

If AddIfNotFound is true, add a implicit operand if it's not found.

Definition at line 205 of file LiveVariables.h.

References getVarInfo(), llvm::LiveVariables::VarInfo::Kills, and MI.

◆ getVarInfo()

◆ HandleVirtRegDef()

◆ HandleVirtRegUse()

◆ isLiveIn()

bool llvm::LiveVariables::isLiveIn ( Register Reg,
const MachineBasicBlock & MBB )
inline

Definition at line 283 of file LiveVariables.h.

References getVarInfo(), llvm::LiveVariables::VarInfo::isLiveIn(), MBB, and Reg.

◆ isLiveOut()

bool LiveVariables::isLiveOut ( Register Reg,
const MachineBasicBlock & MBB )

isLiveOut - Determine if Reg is live out from MBB, when not considering PHI nodes.

This means that Reg is either killed by a successor block or passed through one.

Definition at line 789 of file LiveVariables.cpp.

References llvm::SmallPtrSetImpl< PtrType >::count(), getVarInfo(), llvm::SmallPtrSetImpl< PtrType >::insert(), MBB, and MI.

◆ MarkVirtRegAliveInBlock() [1/2]

void LiveVariables::MarkVirtRegAliveInBlock ( VarInfo & VRInfo,
MachineBasicBlock * DefBlock,
MachineBasicBlock * BB )

◆ MarkVirtRegAliveInBlock() [2/2]

◆ print()

void LiveVariables::print ( raw_ostream & OS) const

Definition at line 78 of file LiveVariables.cpp.

References I, and llvm::Register::index2VirtReg().

Referenced by llvm::LiveVariables::VarInfo::dump().

◆ recomputeForSingleDefVirtReg()

void LiveVariables::recomputeForSingleDefVirtReg ( Register Reg)

Recompute liveness from scratch for a virtual register Reg that is known to have a single def that dominates all uses.

This can be useful after removing some uses of Reg. It is not necessary for the whole machine function to be in SSA form.

Definition at line 648 of file LiveVariables.cpp.

References llvm::SmallVectorImpl< T >::append(), assert(), DefMI, llvm::SmallVectorTemplateCommon< T, typename >::empty(), llvm::MachineBasicBlock::getNumber(), getVarInfo(), MI, llvm::SmallVectorImpl< T >::pop_back_val(), llvm::MachineBasicBlock::pred_begin(), llvm::MachineBasicBlock::pred_end(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::reverse(), llvm::SparseBitVector< ElementSize >::set(), and UseMI.

Referenced by llvm::PPCInstrInfo::promoteInstr32To64ForElimEXTSW().

◆ removeVirtualRegisterDead()

bool llvm::LiveVariables::removeVirtualRegisterDead ( Register Reg,
MachineInstr & MI )
inline

removeVirtualRegisterDead - Remove the specified kill of the virtual register from the live variable information.

Returns true if the variable was marked dead at the specified instruction, false otherwise.

Definition at line 250 of file LiveVariables.h.

References assert(), getVarInfo(), MI, and Reg.

◆ removeVirtualRegisterKilled()

bool llvm::LiveVariables::removeVirtualRegisterKilled ( Register Reg,
MachineInstr & MI )
inline

removeVirtualRegisterKilled - Remove the specified kill of the virtual register from the live variable information.

Returns true if the variable was marked as killed by the specified instruction, false otherwise.

Definition at line 215 of file LiveVariables.h.

References assert(), getVarInfo(), MI, and Reg.

◆ removeVirtualRegistersKilled()

void LiveVariables::removeVirtualRegistersKilled ( MachineInstr & MI)

removeVirtualRegistersKilled - Remove all killed info for the specified instruction.

Definition at line 742 of file LiveVariables.cpp.

References assert(), llvm::MachineOperand::getReg(), getVarInfo(), llvm::MachineOperand::isKill(), llvm::MachineOperand::isReg(), MI, llvm::LiveVariables::VarInfo::removeKill(), and llvm::MachineOperand::setIsKill().

◆ replaceKillInstruction()

void LiveVariables::replaceKillInstruction ( Register Reg,
MachineInstr & OldMI,
MachineInstr & NewMI )

replaceKillInstruction - Update register kill info by replacing a kill instruction with a new one.

Definition at line 734 of file LiveVariables.cpp.

References getVarInfo(), and llvm::replace().

Referenced by llvm::X86InstrInfo::classifyLEAReg(), llvm::RISCVInstrInfo::convertToThreeAddress(), llvm::SystemZInstrInfo::convertToThreeAddress(), llvm::X86InstrInfo::convertToThreeAddress(), and updateLiveVariables().

◆ LiveVariablesWrapperPass

friend class LiveVariablesWrapperPass
friend

Definition at line 50 of file LiveVariables.h.

References LiveVariablesWrapperPass.

Referenced by LiveVariablesWrapperPass.


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