LLVM 18.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 () | |
bool | runOnMachineFunction (MachineFunction &MF) override |
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformation or analysis. | |
bool | RegisterDefIsDead (MachineInstr &MI, Register Reg) const |
RegisterDefIsDead - Return true if the specified instruction defines the specified register, but that definition is dead. | |
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. | |
void | getAnalysisUsage (AnalysisUsage &AU) const override |
getAnalysisUsage - This function should be overriden by passes that need analysis information to do their job. | |
void | releaseMemory () override |
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. | |
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. | |
bool | isPHIJoin (Register Reg) |
isPHIJoin - Return true if Reg is a phi join register. | |
void | setPHIJoin (Register Reg) |
setPHIJoin - Mark Reg as a phi join register. | |
![]() | |
bool | doInitialization (Module &) override |
doInitialization - Virtual method overridden by subclasses to do any necessary initialization before any pass is run. | |
![]() | |
FunctionPass (char &pid) | |
Pass * | createPrinterPass (raw_ostream &OS, const std::string &Banner) const override |
createPrinterPass - Get a function printer pass. | |
virtual bool | runOnFunction (Function &F)=0 |
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass. | |
void | assignPassManager (PMStack &PMS, PassManagerType T) override |
Find appropriate Function Pass Manager or Call Graph Pass Manager in the PM Stack and add self into that manager. | |
PassManagerType | getPotentialPassManagerType () const override |
Return what kind of Pass Manager can manage this pass. | |
![]() | |
Pass (PassKind K, char &pid) | |
Pass (const Pass &)=delete | |
Pass & | operator= (const Pass &)=delete |
virtual | ~Pass () |
PassKind | getPassKind () const |
virtual StringRef | getPassName () const |
getPassName - Return a nice clean name for a pass. | |
AnalysisID | getPassID () const |
getPassID - Return the PassID number that corresponds to this pass. | |
virtual bool | doInitialization (Module &) |
doInitialization - Virtual method overridden by subclasses to do any necessary initialization before any pass is run. | |
virtual bool | doFinalization (Module &) |
doFinalization - Virtual method overriden by subclasses to do any necessary clean up after all passes have run. | |
virtual void | print (raw_ostream &OS, const Module *M) const |
print - Print out the internal state of the pass. | |
void | dump () const |
virtual Pass * | createPrinterPass (raw_ostream &OS, const std::string &Banner) const =0 |
createPrinterPass - Get a Pass appropriate to print the IR this pass operates on (Module, Function or MachineFunction). | |
virtual void | assignPassManager (PMStack &, PassManagerType) |
Each pass is responsible for assigning a pass manager to itself. | |
virtual void | preparePassManager (PMStack &) |
Check if available pass managers are suitable for this pass or not. | |
virtual PassManagerType | getPotentialPassManagerType () const |
Return what kind of Pass Manager can manage this pass. | |
void | setResolver (AnalysisResolver *AR) |
AnalysisResolver * | getResolver () const |
virtual void | getAnalysisUsage (AnalysisUsage &) const |
getAnalysisUsage - This function should be overriden by passes that need analysis information to do their job. | |
virtual void | releaseMemory () |
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. | |
virtual void * | getAdjustedAnalysisPointer (AnalysisID ID) |
getAdjustedAnalysisPointer - This method is used when a pass implements an analysis interface through multiple inheritance. | |
virtual ImmutablePass * | getAsImmutablePass () |
virtual PMDataManager * | getAsPMDataManager () |
virtual void | verifyAnalysis () const |
verifyAnalysis() - This member can be implemented by a analysis pass to check state of analysis information. | |
virtual void | dumpPassStructure (unsigned Offset=0) |
template<typename AnalysisType > | |
AnalysisType * | getAnalysisIfAvailable () const |
getAnalysisIfAvailable<AnalysisType>() - Subclasses use this function to get analysis information that might be around, for example to update it. | |
bool | mustPreserveAnalysisID (char &AID) const |
mustPreserveAnalysisID - This method serves the same function as getAnalysisIfAvailable, but works if you just have an AnalysisID. | |
template<typename AnalysisType > | |
AnalysisType & | getAnalysis () const |
getAnalysis<AnalysisType>() - This function is used by subclasses to get to the analysis information that they claim to use by overriding the getAnalysisUsage function. | |
template<typename AnalysisType > | |
AnalysisType & | getAnalysis (Function &F, bool *Changed=nullptr) |
getAnalysis<AnalysisType>() - This function is used by subclasses to get to the analysis information that they claim to use by overriding the getAnalysisUsage function. | |
template<typename AnalysisType > | |
AnalysisType & | getAnalysisID (AnalysisID PI) const |
template<typename AnalysisType > | |
AnalysisType & | getAnalysisID (AnalysisID PI, Function &F, bool *Changed=nullptr) |
Static Public Attributes | |
static char | ID = 0 |
Additional Inherited Members | |
![]() | |
static const PassInfo * | lookupPassInfo (const void *TI) |
static const PassInfo * | lookupPassInfo (StringRef Arg) |
static Pass * | createPass (AnalysisID ID) |
![]() | |
MachineFunctionPass (char &ID) | |
virtual bool | runOnMachineFunction (MachineFunction &MF)=0 |
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformation or analysis. | |
void | getAnalysisUsage (AnalysisUsage &AU) const override |
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this. | |
virtual MachineFunctionProperties | getRequiredProperties () const |
virtual MachineFunctionProperties | getSetProperties () const |
virtual MachineFunctionProperties | getClearedProperties () const |
![]() | |
bool | skipFunction (const Function &F) const |
Optional passes call this function to check whether the pass should be skipped. | |
Definition at line 47 of file LiveVariables.h.
|
inline |
Definition at line 50 of file LiveVariables.h.
References llvm::PassRegistry::getPassRegistry(), and llvm::initializeLiveVariablesPass().
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 820 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().
Referenced by llvm::MachineBasicBlock::SplitCriticalEdge().
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 870 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 242 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 207 of file LiveVariables.h.
References getVarInfo(), llvm::LiveVariables::VarInfo::Kills, MI, and TRI.
Referenced by llvm::ARMBaseInstrInfo::convertToThreeAddress().
|
overridevirtual |
getAnalysisUsage - This function should be overriden by passes that need analysis information to do their job.
If a pass specifies that it uses a particular analysis result to this function, it can then use the getAnalysis<AnalysisType>() function, below.
Reimplemented from llvm::Pass.
Definition at line 53 of file LiveVariables.cpp.
References llvm::MachineFunctionPass::getAnalysisUsage(), and llvm::UnreachableMachineBlockElimID.
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 84 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(), replaceKillInstruction(), and llvm::MachineBasicBlock::SplitCriticalEdge().
void LiveVariables::HandleVirtRegDef | ( | Register | reg, |
MachineInstr & | MI | ||
) |
Definition at line 178 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 127 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 288 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 795 of file LiveVariables.cpp.
References llvm::SmallPtrSetImpl< PtrType >::count(), getVarInfo(), llvm::SmallPtrSetImpl< PtrType >::insert(), MBB, MI, and llvm::MachineBasicBlock::successors().
isPHIJoin - Return true if Reg is a phi join register.
Definition at line 311 of file LiveVariables.h.
References Reg, and llvm::SparseBitVector< ElementSize >::test().
void LiveVariables::MarkVirtRegAliveInBlock | ( | VarInfo & | VRInfo, |
MachineBasicBlock * | DefBlock, | ||
MachineBasicBlock * | BB | ||
) |
Definition at line 115 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 90 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::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 654 of file LiveVariables.cpp.
References llvm::SmallVectorImpl< T >::append(), assert(), DefMI, llvm::SmallVectorBase< Size_T >::empty(), llvm::MachineFunction::getBlockNumbered(), 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.
bool llvm::LiveVariables::RegisterDefIsDead | ( | MachineInstr & | MI, |
Register | Reg | ||
) | const |
RegisterDefIsDead - Return true if the specified instruction defines the specified register, but that definition is dead.
|
inlineoverridevirtual |
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.
Reimplemented from llvm::Pass.
Definition at line 271 of file LiveVariables.h.
|
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 252 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 217 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 748 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 740 of file LiveVariables.cpp.
References getVarInfo().
Referenced by llvm::X86InstrInfo::classifyLEAReg(), llvm::RISCVInstrInfo::convertToThreeAddress(), llvm::SystemZInstrInfo::convertToThreeAddress(), llvm::X86InstrInfo::convertToThreeAddress(), and updateLiveVariables().
|
overridevirtual |
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformation or analysis.
Implements llvm::MachineFunctionPass.
Definition at line 595 of file LiveVariables.cpp.
References assert(), llvm::SparseBitVector< ElementSize >::clear(), llvm::SmallPtrSetImpl< PtrType >::contains(), llvm::depth_first_ext(), llvm::MachineFunction::front(), llvm::MachineFunction::getNumBlockIDs(), llvm::MCRegisterInfo::getNumRegs(), llvm::MachineFunction::getRegInfo(), llvm::TargetSubtargetInfo::getRegisterInfo(), llvm::MachineFunction::getSubtarget(), llvm::MachineRegisterInfo::getVRegDef(), llvm::Register::index2VirtReg(), llvm::MachineRegisterInfo::isSSA(), MBB, and llvm::report_fatal_error().
|
inline |
setPHIJoin - Mark Reg as a phi join register.
Definition at line 314 of file LiveVariables.h.
References Reg, and llvm::SparseBitVector< ElementSize >::set().
|
static |
Definition at line 49 of file LiveVariables.h.