LLVM 19.0.0git
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]

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.
 
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.
 
VarInfogetVarInfo (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.
 
- 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.
 
- 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.
 
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.
 
- 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.
 
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 PasscreatePrinterPass (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)
 
AnalysisResolvergetResolver () 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 ImmutablePassgetAsImmutablePass ()
 
virtual PMDataManagergetAsPMDataManager ()
 
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 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)
 
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
 
- 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.
 

Detailed Description

Definition at line 47 of file LiveVariables.h.

Constructor & Destructor Documentation

◆ LiveVariables()

llvm::LiveVariables::LiveVariables ( )
inline

Member Function Documentation

◆ addNewBlock() [1/2]

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

◆ addNewBlock() [2/2]

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

◆ addVirtualRegisterDead()

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

References getVarInfo(), llvm::LiveVariables::VarInfo::Kills, MI, and TRI.

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

◆ addVirtualRegisterKilled()

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

References getVarInfo(), llvm::LiveVariables::VarInfo::Kills, MI, and TRI.

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.

◆ getVarInfo()

LiveVariables::VarInfo & LiveVariables::getVarInfo ( Register  Reg)

◆ HandleVirtRegDef()

void LiveVariables::HandleVirtRegDef ( Register  reg,
MachineInstr MI 
)

◆ HandleVirtRegUse()

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

◆ isLiveIn()

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

Definition at line 280 of file LiveVariables.h.

References getVarInfo(), llvm::LiveVariables::VarInfo::isLiveIn(), MBB, MRI, and Reg.

◆ isLiveOut()

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 796 of file LiveVariables.cpp.

References llvm::SmallPtrSetImpl< PtrType >::count(), getVarInfo(), llvm::SmallPtrSetImpl< PtrType >::insert(), MBB, MI, and llvm::MachineBasicBlock::successors().

◆ MarkVirtRegAliveInBlock() [1/2]

void LiveVariables::MarkVirtRegAliveInBlock ( VarInfo VRInfo,
MachineBasicBlock DefBlock,
MachineBasicBlock BB 
)

◆ MarkVirtRegAliveInBlock() [2/2]

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

◆ recomputeForSingleDefVirtReg()

void LiveVariables::recomputeForSingleDefVirtReg ( Register  Reg)

◆ 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 263 of file LiveVariables.h.

◆ removeVirtualRegisterDead()

bool llvm::LiveVariables::removeVirtualRegisterDead ( Register  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 244 of file LiveVariables.h.

References assert(), getVarInfo(), MI, and Reg.

◆ removeVirtualRegisterKilled()

bool llvm::LiveVariables::removeVirtualRegisterKilled ( Register  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 209 of file LiveVariables.h.

References assert(), getVarInfo(), MI, and Reg.

◆ removeVirtualRegistersKilled()

void LiveVariables::removeVirtualRegistersKilled ( MachineInstr MI)

removeVirtualRegistersKilled - Remove all killed info for the specified instruction.

Definition at line 749 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().

◆ replaceKillInstruction()

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 741 of file LiveVariables.cpp.

References getVarInfo().

Referenced by llvm::X86InstrInfo::classifyLEAReg(), llvm::RISCVInstrInfo::convertToThreeAddress(), llvm::SystemZInstrInfo::convertToThreeAddress(), llvm::X86InstrInfo::convertToThreeAddress(), and updateLiveVariables().

◆ runOnMachineFunction()

bool LiveVariables::runOnMachineFunction ( MachineFunction MF)
overridevirtual

Member Data Documentation

◆ ID

char LiveVariables::ID = 0
static

Definition at line 49 of file LiveVariables.h.


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