LLVM 19.0.0git
Classes | Public Member Functions | Friends | List of all members
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

 LiveVariables (MachineFunction &MF)
 
void print (raw_ostream &OS) const
 
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.
 
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.
 
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.
 
VarInfogetVarInfo (Register Reg)
 getVarInfo - Return the VarInfo structure for the specified VIRTUAL register.
 
void MarkVirtRegAliveInBlock (VarInfo &VRInfo, MachineBasicBlock *DefBlock, MachineBasicBlock *BB)
 
void MarkVirtRegAliveInBlock (VarInfo &VRInfo, MachineBasicBlock *DefBlock, MachineBasicBlock *BB, SmallVectorImpl< MachineBasicBlock * > &WorkList)
 
void HandleVirtRegDef (Register reg, MachineInstr &MI)
 
void HandleVirtRegUse (Register reg, MachineBasicBlock *MBB, MachineInstr &MI)
 
bool isLiveIn (Register Reg, const MachineBasicBlock &MBB)
 
bool isLiveOut (Register Reg, const MachineBasicBlock &MBB)
 isLiveOut - Determine if Reg is live out from MBB, when not considering PHI nodes.
 
void addNewBlock (MachineBasicBlock *BB, MachineBasicBlock *DomBB, MachineBasicBlock *SuccBB)
 addNewBlock - Add a new basic block BB between DomBB and SuccBB.
 
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 48 of file LiveVariables.h.

Constructor & Destructor Documentation

◆ LiveVariables()

LiveVariables::LiveVariables ( MachineFunction MF)

Definition at line 74 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 850 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(), llvm::MachineRegisterInfo::getNumVirtRegs(), 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 900 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 241 of file LiveVariables.h.

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

Referenced by llvm::ARMBaseInstrInfo::convertToThreeAddress().

◆ 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 206 of file LiveVariables.h.

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

Referenced by llvm::ARMBaseInstrInfo::convertToThreeAddress().

◆ getVarInfo()

LiveVariables::VarInfo & LiveVariables::getVarInfo ( Register  Reg)

◆ HandleVirtRegDef()

void LiveVariables::HandleVirtRegDef ( Register  reg,
MachineInstr MI 
)

◆ HandleVirtRegUse()

void LiveVariables::HandleVirtRegUse ( Register  reg,
MachineBasicBlock MBB,
MachineInstr MI 
)

◆ isLiveIn()

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

Definition at line 281 of file LiveVariables.h.

References getVarInfo(), llvm::LiveVariables::VarInfo::isLiveIn(), MBB, MRI, 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 825 of file LiveVariables.cpp.

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

◆ MarkVirtRegAliveInBlock() [1/2]

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

◆ MarkVirtRegAliveInBlock() [2/2]

void LiveVariables::MarkVirtRegAliveInBlock ( VarInfo VRInfo,
MachineBasicBlock DefBlock,
MachineBasicBlock BB,
SmallVectorImpl< MachineBasicBlock * > &  WorkList 
)

◆ print()

void LiveVariables::print ( raw_ostream OS) const

Definition at line 79 of file LiveVariables.cpp.

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

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

◆ recomputeForSingleDefVirtReg()

void LiveVariables::recomputeForSingleDefVirtReg ( Register  Reg)

◆ 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 251 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 216 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 778 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 770 of file LiveVariables.cpp.

References getVarInfo().

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

Friends And Related Function Documentation

◆ LiveVariablesWrapperPass

friend class LiveVariablesWrapperPass
friend

Definition at line 49 of file LiveVariables.h.


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