LLVM
8.0.1
|
#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. More... | |
bool | RegisterDefIsDead (MachineInstr &MI, unsigned Reg) const |
RegisterDefIsDead - Return true if the specified instruction defines the specified register, but that definition is dead. More... | |
void | replaceKillInstruction (unsigned Reg, MachineInstr &OldMI, MachineInstr &NewMI) |
replaceKillInstruction - Update register kill info by replacing a kill instruction with a new one. More... | |
void | addVirtualRegisterKilled (unsigned 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. More... | |
bool | removeVirtualRegisterKilled (unsigned reg, MachineInstr &MI) |
removeVirtualRegisterKilled - Remove the specified kill of the virtual register from the live variable information. More... | |
void | removeVirtualRegistersKilled (MachineInstr &MI) |
removeVirtualRegistersKilled - Remove all killed info for the specified instruction. More... | |
void | addVirtualRegisterDead (unsigned 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. More... | |
bool | removeVirtualRegisterDead (unsigned reg, MachineInstr &MI) |
removeVirtualRegisterDead - Remove the specified kill of the virtual register from the live variable information. More... | |
void | getAnalysisUsage (AnalysisUsage &AU) const override |
getAnalysisUsage - This function should be overriden by passes that need analysis information to do their job. More... | |
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. More... | |
VarInfo & | getVarInfo (unsigned RegIdx) |
getVarInfo - Return the VarInfo structure for the specified VIRTUAL register. More... | |
void | MarkVirtRegAliveInBlock (VarInfo &VRInfo, MachineBasicBlock *DefBlock, MachineBasicBlock *BB) |
void | MarkVirtRegAliveInBlock (VarInfo &VRInfo, MachineBasicBlock *DefBlock, MachineBasicBlock *BB, std::vector< MachineBasicBlock *> &WorkList) |
void | HandleVirtRegDef (unsigned reg, MachineInstr &MI) |
void | HandleVirtRegUse (unsigned reg, MachineBasicBlock *MBB, MachineInstr &MI) |
bool | isLiveIn (unsigned Reg, const MachineBasicBlock &MBB) |
bool | isLiveOut (unsigned Reg, const MachineBasicBlock &MBB) |
isLiveOut - Determine if Reg is live out from MBB, when not considering PHI nodes. More... | |
void | addNewBlock (MachineBasicBlock *BB, MachineBasicBlock *DomBB, MachineBasicBlock *SuccBB) |
addNewBlock - Add a new basic block BB between DomBB and SuccBB. More... | |
bool | isPHIJoin (unsigned Reg) |
isPHIJoin - Return true if Reg is a phi join register. More... | |
void | setPHIJoin (unsigned Reg) |
setPHIJoin - Mark Reg as a phi join register. More... | |
Public Member Functions inherited from llvm::MachineFunctionPass | |
bool | doInitialization (Module &) override |
doInitialization - Virtual method overridden by subclasses to do any necessary initialization before any pass is run. More... | |
Public Member Functions inherited from llvm::FunctionPass | |
FunctionPass (char &pid) | |
Pass * | createPrinterPass (raw_ostream &OS, const std::string &Banner) const override |
createPrinterPass - Get a function printer pass. More... | |
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. More... | |
PassManagerType | getPotentialPassManagerType () const override |
Return what kind of Pass Manager can manage this pass. More... | |
Public Member Functions inherited from llvm::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. More... | |
AnalysisID | getPassID () const |
getPassID - Return the PassID number that corresponds to this pass. More... | |
virtual bool | doFinalization (Module &) |
doFinalization - Virtual method overriden by subclasses to do any necessary clean up after all passes have run. More... | |
virtual void | print (raw_ostream &OS, const Module *M) const |
print - Print out the internal state of the pass. More... | |
void | dump () const |
virtual void | preparePassManager (PMStack &) |
Check if available pass managers are suitable for this pass or not. More... | |
void | setResolver (AnalysisResolver *AR) |
AnalysisResolver * | getResolver () const |
virtual void * | getAdjustedAnalysisPointer (AnalysisID ID) |
getAdjustedAnalysisPointer - This method is used when a pass implements an analysis interface through multiple inheritance. More... | |
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. More... | |
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. More... | |
bool | mustPreserveAnalysisID (char &AID) const |
mustPreserveAnalysisID - This method serves the same function as getAnalysisIfAvailable, but works if you just have an AnalysisID. More... | |
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. More... | |
template<typename AnalysisType > | |
AnalysisType & | getAnalysis (Function &F) |
getAnalysis<AnalysisType>() - This function is used by subclasses to get to the analysis information that they claim to use by overriding the getAnalysisUsage function. More... | |
template<typename AnalysisType > | |
AnalysisType & | getAnalysisID (AnalysisID PI) const |
template<typename AnalysisType > | |
AnalysisType & | getAnalysisID (AnalysisID PI, Function &F) |
Static Public Attributes | |
static char | ID = 0 |
Additional Inherited Members | |
Static Public Member Functions inherited from llvm::Pass | |
static const PassInfo * | lookupPassInfo (const void *TI) |
static const PassInfo * | lookupPassInfo (StringRef Arg) |
static Pass * | createPass (AnalysisID ID) |
Protected Member Functions inherited from llvm::MachineFunctionPass | |
MachineFunctionPass (char &ID) | |
void | getAnalysisUsage (AnalysisUsage &AU) const override |
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this. More... | |
virtual MachineFunctionProperties | getRequiredProperties () const |
virtual MachineFunctionProperties | getSetProperties () const |
virtual MachineFunctionProperties | getClearedProperties () const |
Protected Member Functions inherited from llvm::FunctionPass | |
bool | skipFunction (const Function &F) const |
Optional passes call this function to check whether the pass should be skipped. More... | |
Definition at line 46 of file LiveVariables.h.
|
inline |
Definition at line 49 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 765 of file LiveVariables.cpp.
References llvm::LiveVariables::VarInfo::AliveBlocks, llvm::MachineBasicBlock::begin(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::count(), E, llvm::MachineBasicBlock::end(), llvm::MachineBasicBlock::getNumber(), getVarInfo(), I, llvm::TargetRegisterInfo::index2VirtReg(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::insert(), llvm::TargetRegisterInfo::isVirtualRegister(), llvm::LiveVariables::VarInfo::Kills, MRI, llvm::SparseBitVector< ElementSize >::set(), llvm::SparseBitVector< ElementSize >::test(), and VI.
Referenced by isLiveIn(), and llvm::MachineBasicBlock::SplitCriticalEdge().
|
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 237 of file LiveVariables.h.
References llvm::MachineInstr::addRegisterDead(), getVarInfo(), and llvm::LiveVariables::VarInfo::Kills.
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 201 of file LiveVariables.h.
References llvm::MachineInstr::addRegisterKilled(), getVarInfo(), and llvm::LiveVariables::VarInfo::Kills.
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.
Referenced by removeVirtualRegisterDead().
LiveVariables::VarInfo & LiveVariables::getVarInfo | ( | unsigned | RegIdx | ) |
getVarInfo - Return the VarInfo structure for the specified VIRTUAL register.
getVarInfo - Get (possibly creating) a VarInfo object for the given vreg.
Definition at line 85 of file LiveVariables.cpp.
References assert(), and llvm::TargetRegisterInfo::isVirtualRegister().
Referenced by addNewBlock(), addVirtualRegisterDead(), addVirtualRegisterKilled(), llvm::X86InstrInfo::classifyLEAReg(), llvm::ARMBaseInstrInfo::convertToThreeAddress(), HandleVirtRegDef(), HandleVirtRegUse(), isLiveIn(), isLiveOut(), matchPair(), regOverlapsSet(), releaseMemory(), removeVirtualRegisterDead(), removeVirtualRegisterKilled(), removeVirtualRegistersKilled(), replaceKillInstruction(), and llvm::MachineBasicBlock::SplitCriticalEdge().
void LiveVariables::HandleVirtRegDef | ( | unsigned | reg, |
MachineInstr & | MI | ||
) |
Definition at line 182 of file LiveVariables.cpp.
References llvm::MachineInstr::addOperand(), llvm::MachineInstr::addRegisterDead(), llvm::MachineInstr::addRegisterKilled(), llvm::LiveVariables::VarInfo::AliveBlocks, assert(), llvm::SmallVectorTemplateCommon< T, typename >::back(), llvm::SmallVectorTemplateCommon< T, typename >::begin(), llvm::MachineOperand::clobbersPhysReg(), llvm::SmallSet< T, N, C >::count(), llvm::MachineOperand::CreateReg(), llvm::tgtok::Def, E, llvm::SmallVectorBase::empty(), llvm::SparseBitVector< ElementSize >::empty(), llvm::SmallVectorTemplateCommon< T, typename >::end(), llvm::SmallSet< T, N, C >::erase(), llvm::MachineInstr::findRegisterDefOperand(), llvm::MachineInstr::getNumOperands(), llvm::MachineInstr::getOperand(), llvm::MachineInstr::getParent(), llvm::MachineOperand::getReg(), getVarInfo(), HandleVirtRegUse(), I, llvm::SmallSet< T, N, C >::insert(), llvm::MachineOperand::isDead(), llvm::MachineInstr::isDebugInstr(), llvm::MachineOperand::isDef(), llvm::MachineOperand::isEarlyClobber(), llvm::MachineBasicBlock::isEHPad(), llvm::MachineInstr::isPHI(), llvm::TargetRegisterInfo::isPhysicalRegister(), llvm::MachineOperand::isReg(), llvm::MachineOperand::isRegMask(), llvm::MachineOperand::isUse(), llvm::MCRegisterInfo::DiffListIterator::isValid(), llvm::TargetRegisterInfo::isVirtualRegister(), llvm::LiveVariables::VarInfo::Kills, llvm::MachineBasicBlock::liveins(), MarkVirtRegAliveInBlock(), MI, MRI, llvm::SmallVectorTemplateBase< T, bool >::pop_back(), llvm::SmallVectorTemplateBase< T >::push_back(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::MachineOperand::readsReg(), Reg, llvm::MachineOperand::setIsDead(), llvm::MachineOperand::setIsEarlyClobber(), llvm::MachineOperand::setIsKill(), SI, llvm::SmallVectorBase::size(), SubReg, and TRI.
Referenced by releaseMemory().
void LiveVariables::HandleVirtRegUse | ( | unsigned | reg, |
MachineBasicBlock * | MBB, | ||
MachineInstr & | MI | ||
) |
Definition at line 131 of file LiveVariables.cpp.
References llvm::LiveVariables::VarInfo::AliveBlocks, assert(), E, llvm::MachineBasicBlock::getNumber(), getVarInfo(), llvm::LiveVariables::VarInfo::Kills, MarkVirtRegAliveInBlock(), MI, MRI, llvm::MachineBasicBlock::pred_begin(), llvm::MachineBasicBlock::pred_end(), and llvm::SparseBitVector< ElementSize >::test().
Referenced by HandleVirtRegDef(), and releaseMemory().
|
inline |
Definition at line 283 of file LiveVariables.h.
References addNewBlock(), getVarInfo(), llvm::LiveVariables::VarInfo::isLiveIn(), and isLiveOut().
bool LiveVariables::isLiveOut | ( | unsigned | 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 740 of file LiveVariables.cpp.
References llvm::LiveVariables::VarInfo::AliveBlocks, llvm::SmallPtrSetImpl< PtrType >::count(), getVarInfo(), llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::LiveVariables::VarInfo::Kills, llvm::MachineBasicBlock::successors(), llvm::SparseBitVector< ElementSize >::test(), and VI.
Referenced by isLiveIn().
isPHIJoin - Return true if Reg is a phi join register.
Definition at line 301 of file LiveVariables.h.
References llvm::SparseBitVector< ElementSize >::test().
void LiveVariables::MarkVirtRegAliveInBlock | ( | VarInfo & | VRInfo, |
MachineBasicBlock * | DefBlock, | ||
MachineBasicBlock * | BB | ||
) |
Definition at line 118 of file LiveVariables.cpp.
References llvm::MachineBasicBlock::back().
Referenced by HandleVirtRegDef(), HandleVirtRegUse(), and releaseMemory().
void LiveVariables::MarkVirtRegAliveInBlock | ( | VarInfo & | VRInfo, |
MachineBasicBlock * | DefBlock, | ||
MachineBasicBlock * | BB, | ||
std::vector< MachineBasicBlock *> & | WorkList | ||
) |
Definition at line 92 of file LiveVariables.cpp.
References llvm::LiveVariables::VarInfo::AliveBlocks, assert(), llvm::MachineBasicBlock::front(), llvm::MachineBasicBlock::getNumber(), llvm::LiveVariables::VarInfo::Kills, llvm::MachineBasicBlock::pred_rbegin(), llvm::MachineBasicBlock::pred_rend(), llvm::SparseBitVector< ElementSize >::set(), and llvm::SparseBitVector< ElementSize >::test().
bool llvm::LiveVariables::RegisterDefIsDead | ( | MachineInstr & | MI, |
unsigned | Reg | ||
) | const |
RegisterDefIsDead - Return true if the specified instruction defines the specified register, but that definition is dead.
Referenced by llvm::LiveVariables::VarInfo::removeKill().
|
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 267 of file LiveVariables.h.
References llvm::IndexedMap< T, ToIndexT >::clear(), getVarInfo(), HandleVirtRegDef(), HandleVirtRegUse(), and MarkVirtRegAliveInBlock().
|
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 247 of file LiveVariables.h.
References assert(), getAnalysisUsage(), llvm::MachineInstr::getNumOperands(), llvm::MachineInstr::getOperand(), llvm::MachineOperand::getReg(), getVarInfo(), llvm::MachineOperand::isDef(), llvm::MachineOperand::isReg(), llvm::LiveVariables::VarInfo::removeKill(), and llvm::MachineOperand::setIsDead().
|
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 211 of file LiveVariables.h.
References assert(), llvm::MachineInstr::getNumOperands(), llvm::MachineInstr::getOperand(), llvm::MachineOperand::getReg(), getVarInfo(), llvm::MachineOperand::isKill(), llvm::MachineOperand::isReg(), llvm::LiveVariables::VarInfo::removeKill(), removeVirtualRegistersKilled(), and llvm::MachineOperand::setIsKill().
void LiveVariables::removeVirtualRegistersKilled | ( | MachineInstr & | MI | ) |
removeVirtualRegistersKilled - Remove all killed info for the specified instruction.
Definition at line 691 of file LiveVariables.cpp.
References assert(), llvm::MachineInstr::getNumOperands(), llvm::MachineInstr::getOperand(), llvm::MachineOperand::getReg(), getVarInfo(), llvm::MachineOperand::isKill(), llvm::MachineOperand::isReg(), llvm::TargetRegisterInfo::isVirtualRegister(), llvm::LiveVariables::VarInfo::removeKill(), and llvm::MachineOperand::setIsKill().
Referenced by removeVirtualRegisterKilled().
void LiveVariables::replaceKillInstruction | ( | unsigned | Reg, |
MachineInstr & | OldMI, | ||
MachineInstr & | NewMI | ||
) |
replaceKillInstruction - Update register kill info by replacing a kill instruction with a new one.
Definition at line 683 of file LiveVariables.cpp.
References getVarInfo(), llvm::LiveVariables::VarInfo::Kills, replace(), and VI.
Referenced by llvm::X86InstrInfo::classifyLEAReg(), llvm::X86InstrInfo::convertToThreeAddress(), finishConvertToThreeAddress(), and llvm::LiveVariables::VarInfo::removeKill().
|
overridevirtual |
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformation or analysis.
Implements llvm::MachineFunctionPass.
Definition at line 622 of file LiveVariables.cpp.
References assert(), llvm::SmallPtrSetImpl< NodeRef >::count(), llvm::depth_first_ext(), llvm::MachineBasicBlock::front(), llvm::MachineFunction::getRegInfo(), llvm::TargetRegisterInfo::index2VirtReg(), llvm::LiveVariables::VarInfo::Kills, MRI, Reg, llvm::report_fatal_error(), and TRI.
Referenced by llvm::LiveVariables::VarInfo::removeKill().
|
inline |
setPHIJoin - Mark Reg as a phi join register.
Definition at line 304 of file LiveVariables.h.
References llvm::SparseBitVector< ElementSize >::set().
|
static |
Definition at line 48 of file LiveVariables.h.