LLVM  8.0.1
Classes | Public Member Functions | Static Public Attributes | List of all members
llvm::LiveVariables Class Reference

#include "llvm/CodeGen/LiveVariables.h"

Inheritance diagram for llvm::LiveVariables:
Inheritance graph
[legend]
Collaboration diagram for llvm::LiveVariables:
Collaboration graph
[legend]

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...
 
VarInfogetVarInfo (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)
 
PasscreatePrinterPass (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
 
Passoperator= (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)
 
AnalysisResolvergetResolver () const
 
virtual void * getAdjustedAnalysisPointer (AnalysisID ID)
 getAdjustedAnalysisPointer - This method is used when a pass implements an analysis interface through multiple inheritance. More...
 
virtual ImmutablePassgetAsImmutablePass ()
 
virtual PMDataManagergetAsPMDataManager ()
 
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 PassInfolookupPassInfo (const void *TI)
 
static const PassInfolookupPassInfo (StringRef Arg)
 
static PasscreatePass (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...
 

Detailed Description

Definition at line 46 of file LiveVariables.h.

Constructor & Destructor Documentation

◆ LiveVariables()

llvm::LiveVariables::LiveVariables ( )
inline

Member Function Documentation

◆ addNewBlock()

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().

◆ addVirtualRegisterDead()

void llvm::LiveVariables::addVirtualRegisterDead ( unsigned  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 237 of file LiveVariables.h.

References llvm::MachineInstr::addRegisterDead(), getVarInfo(), and llvm::LiveVariables::VarInfo::Kills.

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

◆ addVirtualRegisterKilled()

void llvm::LiveVariables::addVirtualRegisterKilled ( unsigned  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 201 of file LiveVariables.h.

References llvm::MachineInstr::addRegisterKilled(), getVarInfo(), and llvm::LiveVariables::VarInfo::Kills.

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

◆ getAnalysisUsage()

Live Variable false void LiveVariables::getAnalysisUsage ( AnalysisUsage ) const
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().

◆ getVarInfo()

LiveVariables::VarInfo & LiveVariables::getVarInfo ( unsigned  RegIdx)

◆ HandleVirtRegDef()

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().

◆ HandleVirtRegUse()

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

◆ isLiveIn()

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

◆ 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()

bool llvm::LiveVariables::isPHIJoin ( unsigned  Reg)
inline

isPHIJoin - Return true if Reg is a phi join register.

Definition at line 301 of file LiveVariables.h.

References llvm::SparseBitVector< ElementSize >::test().

◆ MarkVirtRegAliveInBlock() [1/2]

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().

◆ MarkVirtRegAliveInBlock() [2/2]

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

◆ RegisterDefIsDead()

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().

◆ releaseMemory()

void llvm::LiveVariables::releaseMemory ( )
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().

◆ removeVirtualRegisterDead()

bool llvm::LiveVariables::removeVirtualRegisterDead ( unsigned  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 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().

◆ removeVirtualRegisterKilled()

bool llvm::LiveVariables::removeVirtualRegisterKilled ( unsigned  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 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().

◆ removeVirtualRegistersKilled()

void LiveVariables::removeVirtualRegistersKilled ( MachineInstr MI)

◆ replaceKillInstruction()

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().

◆ runOnMachineFunction()

bool LiveVariables::runOnMachineFunction ( MachineFunction MF)
overridevirtual

◆ setPHIJoin()

void llvm::LiveVariables::setPHIJoin ( unsigned  Reg)
inline

setPHIJoin - Mark Reg as a phi join register.

Definition at line 304 of file LiveVariables.h.

References llvm::SparseBitVector< ElementSize >::set().

Member Data Documentation

◆ ID

char LiveVariables::ID = 0
static

Definition at line 48 of file LiveVariables.h.


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