LLVM 22.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 | |
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 VarInfo & | getVarInfo (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 |
Definition at line 49 of file LiveVariables.h.
LiveVariables::LiveVariables | ( | MachineFunction & | MF | ) |
Definition at line 73 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 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(), 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 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().
|
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, MI, and TRI.
|
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, MI, and TRI.
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 113 of file LiveVariables.cpp.
References assert().
Referenced by addNewBlock(), addVirtualRegisterDead(), addVirtualRegisterKilled(), llvm::SIInstrInfo::convertToThreeAddress(), llvm::X86InstrInfo::convertToThreeAddress(), HandleVirtRegDef(), HandleVirtRegUse(), isLiveIn(), isLiveOut(), recomputeForSingleDefVirtReg(), removeVirtualRegisterDead(), removeVirtualRegisterKilled(), removeVirtualRegistersKilled(), and replaceKillInstruction().
void LiveVariables::HandleVirtRegDef | ( | Register | reg, |
MachineInstr & | MI | ||
) |
Definition at line 207 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 156 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 283 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 789 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 144 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 119 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 78 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 648 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.
Referenced by llvm::PPCInstrInfo::promoteInstr32To64ForElimEXTSW().
|
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.
|
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.
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().
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().
|
friend |
Definition at line 50 of file LiveVariables.h.