LLVM 20.0.0git
|
#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. | |
VarInfo & | getVarInfo (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 |
Definition at line 48 of file LiveVariables.h.
LiveVariables::LiveVariables | ( | MachineFunction & | MF | ) |
Definition at line 74 of file LiveVariables.cpp.
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().
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().
|
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().
|
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().
LiveVariables::VarInfo & LiveVariables::getVarInfo | ( | Register | Reg | ) |
getVarInfo - Return the VarInfo structure for the specified VIRTUAL register.
getVarInfo - Get (possibly creating) a VarInfo object for the given vreg.
Definition at line 114 of file LiveVariables.cpp.
References assert().
Referenced by addNewBlock(), addVirtualRegisterDead(), addVirtualRegisterKilled(), llvm::SIInstrInfo::convertToThreeAddress(), llvm::ARMBaseInstrInfo::convertToThreeAddress(), llvm::X86InstrInfo::convertToThreeAddress(), HandleVirtRegDef(), HandleVirtRegUse(), isLiveIn(), isLiveOut(), recomputeForSingleDefVirtReg(), removeVirtualRegisterDead(), removeVirtualRegisterKilled(), removeVirtualRegistersKilled(), and replaceKillInstruction().
void LiveVariables::HandleVirtRegDef | ( | Register | reg, |
MachineInstr & | MI | ||
) |
Definition at line 208 of file LiveVariables.cpp.
References llvm::LiveVariables::VarInfo::AliveBlocks, llvm::SparseBitVector< ElementSize >::empty(), getVarInfo(), llvm::LiveVariables::VarInfo::Kills, and MI.
void LiveVariables::HandleVirtRegUse | ( | Register | reg, |
MachineBasicBlock * | MBB, | ||
MachineInstr & | MI | ||
) |
Definition at line 157 of file LiveVariables.cpp.
References llvm::LiveVariables::VarInfo::AliveBlocks, assert(), llvm::MachineBasicBlock::getNumber(), llvm::MachineInstr::getParent(), getVarInfo(), llvm::MachineRegisterInfo::getVRegDef(), llvm::LiveVariables::VarInfo::Kills, MarkVirtRegAliveInBlock(), MBB, MI, llvm::MachineBasicBlock::predecessors(), and llvm::SparseBitVector< ElementSize >::test().
|
inline |
Definition at line 281 of file LiveVariables.h.
References getVarInfo(), llvm::LiveVariables::VarInfo::isLiveIn(), MBB, MRI, and Reg.
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().
void LiveVariables::MarkVirtRegAliveInBlock | ( | VarInfo & | VRInfo, |
MachineBasicBlock * | DefBlock, | ||
MachineBasicBlock * | BB | ||
) |
Definition at line 145 of file LiveVariables.cpp.
References llvm::SmallVectorBase< Size_T >::empty(), MarkVirtRegAliveInBlock(), MBB, and llvm::SmallVectorImpl< T >::pop_back_val().
Referenced by HandleVirtRegUse(), and MarkVirtRegAliveInBlock().
void LiveVariables::MarkVirtRegAliveInBlock | ( | VarInfo & | VRInfo, |
MachineBasicBlock * | DefBlock, | ||
MachineBasicBlock * | BB, | ||
SmallVectorImpl< MachineBasicBlock * > & | WorkList | ||
) |
Definition at line 120 of file LiveVariables.cpp.
References llvm::LiveVariables::VarInfo::AliveBlocks, assert(), llvm::SmallVectorTemplateCommon< T, typename >::end(), llvm::MachineFunction::front(), llvm::MachineBasicBlock::getNumber(), llvm::SmallVectorImpl< T >::insert(), llvm::LiveVariables::VarInfo::Kills, MBB, llvm::MachineBasicBlock::pred_rbegin(), llvm::MachineBasicBlock::pred_rend(), llvm::SparseBitVector< ElementSize >::set(), and llvm::SparseBitVector< ElementSize >::test().
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().
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 684 of file LiveVariables.cpp.
References llvm::SmallVectorImpl< T >::append(), assert(), DefMI, llvm::SmallVectorBase< Size_T >::empty(), llvm::MachineBasicBlock::getNumber(), llvm::MachineRegisterInfo::getUniqueVRegDef(), getVarInfo(), Idx, 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(), llvm::MachineRegisterInfo::use_nodbg_operands(), and UseMI.
|
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.
|
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.
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().
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().
|
friend |
Definition at line 49 of file LiveVariables.h.