LLVM: llvm::ReachingDefAnalysis Class Reference (original) (raw)

This class provides the reaching def analysis. More...

#include "[llvm/CodeGen/ReachingDefAnalysis.h](ReachingDefAnalysis%5F8h%5Fsource.html)"

Public Member Functions
ReachingDefAnalysis ()
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.
void getAnalysisUsage (AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
bool runOnMachineFunction (MachineFunction &MF) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformation or analysis.
MachineFunctionProperties getRequiredProperties () const override
void reset ()
Re-run the analysis.
void init ()
Initialize data structures.
void traverse ()
Traverse the machine function, mapping definitions.
int getReachingDef (MachineInstr *MI, Register Reg) const
Provides the instruction id of the closest reaching def instruction of Reg that reaches MI, relative to the begining of MI's basic block.
bool hasSameReachingDef (MachineInstr *A, MachineInstr *B, Register Reg) const
Return whether A and B use the same def of Reg.
bool isReachingDefLiveOut (MachineInstr *MI, Register Reg) const
Return whether the reaching def for MI also is live out of its parent block.
MachineInstr * getLocalLiveOutMIDef (MachineBasicBlock *MBB, Register Reg) const
Return the local MI that produces the live out value for Reg, or nullptr for a non-live out or non-local def.
MachineInstr * getUniqueReachingMIDef (MachineInstr *MI, Register Reg) const
If a single MachineInstr creates the reaching definition, then return it.
MachineInstr * getMIOperand (MachineInstr *MI, unsigned Idx) const
If a single MachineInstr creates the reaching definition, for MIs operand at Idx, then return it.
MachineInstr * getMIOperand (MachineInstr *MI, MachineOperand &MO) const
If a single MachineInstr creates the reaching definition, for MIs MO, then return it.
bool hasLocalDefBefore (MachineInstr *MI, Register Reg) const
Provide whether the register has been defined in the same basic block as, and before, MI.
bool isRegUsedAfter (MachineInstr *MI, Register Reg) const
Return whether the given register is used after MI, whether it's a local use or a live out.
bool isRegDefinedAfter (MachineInstr *MI, Register Reg) const
Return whether the given register is defined after MI.
int getClearance (MachineInstr *MI, Register Reg) const
Provides the clearance - the number of instructions since the closest reaching def instuction of Reg that reaches MI.
void getReachingLocalUses (MachineInstr *MI, Register Reg, InstSet &Uses) const
Provides the uses, in the same block as MI, of register that MI defines.
void getLiveOuts (MachineBasicBlock *MBB, Register Reg, InstSet &Defs, BlockSet &VisitedBBs) const
Search MBB for a definition of Reg and insert it into Defs.
void getLiveOuts (MachineBasicBlock *MBB, Register Reg, InstSet &Defs) const
bool getLiveInUses (MachineBasicBlock *MBB, Register Reg, InstSet &Uses) const
For the given block, collect the instructions that use the live-in value of the provided register.
void getGlobalUses (MachineInstr *MI, Register Reg, InstSet &Uses) const
Collect the users of the value stored in Reg, which is defined by MI.
void getGlobalReachingDefs (MachineInstr *MI, Register Reg, InstSet &Defs) const
Collect all possible definitions of the value stored in Reg, which is used by MI.
bool isSafeToMoveForwards (MachineInstr *From, MachineInstr *To) const
Return whether From can be moved forwards to just before To.
bool isSafeToMoveBackwards (MachineInstr *From, MachineInstr *To) const
Return whether From can be moved backwards to just after To.
void collectKilledOperands (MachineInstr *MI, InstSet &Dead) const
Assuming MI is dead, recursively search the incoming operands which are killed by MI and collect those that would become dead.
bool isSafeToRemove (MachineInstr *MI, InstSet &ToRemove) const
Return whether removing this instruction will have no effect on the program, returning the redundant use-def chain.
bool isSafeToRemove (MachineInstr *MI, InstSet &ToRemove, InstSet &Ignore) const
Return whether removing this instruction will have no effect on the program, ignoring the possible effects on some instructions, returning the redundant use-def chain.
bool isSafeToDefRegAt (MachineInstr *MI, Register Reg) const
Return whether a MachineInstr could be inserted at MI and safely define the given register without affecting the program.
bool isSafeToDefRegAt (MachineInstr *MI, Register Reg, InstSet &Ignore) const
Return whether a MachineInstr could be inserted at MI and safely define the given register without affecting the program, ignoring any effects on the provided instructions.
- 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)
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.
- 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.
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
AnalysisType * getAnalysisIfAvailable () const
getAnalysisIfAvailable() - 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
AnalysisType & getAnalysis () const
getAnalysis() - This function is used by subclasses to get to the analysis information that they claim to use by overriding the getAnalysisUsage function.
template
AnalysisType & getAnalysis (Function &F, bool *Changed=nullptr)
getAnalysis() - This function is used by subclasses to get to the analysis information that they claim to use by overriding the getAnalysisUsage function.
template
AnalysisType & getAnalysisID (AnalysisID PI) const
template
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 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)
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.

This class provides the reaching def analysis.

Definition at line 113 of file ReachingDefAnalysis.h.

llvm::ReachingDefAnalysis::ReachingDefAnalysis ( ) inline

collectKilledOperands()

Assuming MI is dead, recursively search the incoming operands which are killed by MI and collect those that would become dead.

Definition at line 641 of file ReachingDefAnalysis.cpp.

References collectKilledOperands(), getGlobalUses(), getMIOperand(), IsDead, isValidRegDef(), isValidRegUse(), mayHaveSideEffects(), MI, llvm::set_is_subset(), and Uses.

Referenced by collectKilledOperands(), and if().

getAnalysisUsage()

void llvm::ReachingDefAnalysis::getAnalysisUsage ( AnalysisUsage & AU) const inlineoverridevirtual

getClearance()

getGlobalReachingDefs()

getGlobalUses()

Collect the users of the value stored in Reg, which is defined by MI.

Definition at line 371 of file ReachingDefAnalysis.cpp.

References llvm::append_range(), llvm::SmallPtrSetImpl< PtrType >::count(), llvm::SmallVectorBase< Size_T >::empty(), getLiveInUses(), getLocalLiveOutMIDef(), getReachingLocalUses(), llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::MachineBasicBlock::isLiveIn(), MBB, MI, llvm::SmallVectorImpl< T >::pop_back_val(), llvm::MachineBasicBlock::successors(), and Uses.

Referenced by collectKilledOperands(), and isSafeToDefRegAt().

getLiveInUses()

For the given block, collect the instructions that use the live-in value of the provided register.

Return whether the value is still live on exit.

Definition at line 353 of file ReachingDefAnalysis.cpp.

References llvm::MachineBasicBlock::end(), llvm::MachineBasicBlock::getLastNonDebugInstr(), getReachingDef(), llvm::MachineBasicBlock::instr_begin(), llvm::MachineBasicBlock::instr_end(), llvm::instructionsWithoutDebug(), isReachingDefLiveOut(), isValidRegUseOf(), llvm::Last, MBB, MI, and Uses.

Referenced by getGlobalUses().

getLiveOuts() [1/2]

getLiveOuts() [2/2]

Search MBB for a definition of Reg and insert it into Defs.

If no definition is found, recursively search the predecessor blocks for them.

Definition at line 413 of file ReachingDefAnalysis.cpp.

References llvm::LiveRegUnits::addLiveOuts(), llvm::LiveRegUnits::available(), llvm::SmallPtrSetImpl< PtrType >::count(), getLiveOuts(), getLocalLiveOutMIDef(), llvm::SmallPtrSetImpl< PtrType >::insert(), MBB, and llvm::MachineBasicBlock::predecessors().

Referenced by getGlobalReachingDefs(), getLiveOuts(), and getUniqueReachingMIDef().

getLocalLiveOutMIDef()

Return the local MI that produces the live out value for Reg, or nullptr for a non-live out or non-local def.

Definition at line 519 of file ReachingDefAnalysis.cpp.

References llvm::LiveRegUnits::addLiveOuts(), llvm::LiveRegUnits::available(), llvm::MachineBasicBlock::end(), llvm::MachineBasicBlock::getLastNonDebugInstr(), getReachingDef(), isValidRegDefOf(), llvm::Last, and MBB.

Referenced by getGlobalUses(), getLiveOuts(), and isRegDefinedAfter().

getMIOperand() [1/2]

getMIOperand() [2/2]

getReachingDef()

Provides the instruction id of the closest reaching def instruction of Reg that reaches MI, relative to the begining of MI's basic block.

Definition at line 263 of file ReachingDefAnalysis.cpp.

References assert(), llvm::MBBReachingDefsInfo::defs(), MI, llvm::MBBReachingDefsInfo::numBlockIDs(), and llvm::MCRegisterInfo::regunits().

Referenced by getClearance(), getLiveInUses(), getLocalLiveOutMIDef(), hasLocalDefBefore(), hasSameReachingDef(), isReachingDefLiveOut(), and isRegDefinedAfter().

getReachingLocalUses()

getRequiredProperties()

getUniqueReachingMIDef()

hasLocalDefBefore()

hasSameReachingDef()

init()

void ReachingDefAnalysis::init ( )

isReachingDefLiveOut()

isRegDefinedAfter()

isRegUsedAfter()

isSafeToDefRegAt() [1/2]

isSafeToDefRegAt() [2/2]

Return whether a MachineInstr could be inserted at MI and safely define the given register without affecting the program, ignoring any effects on the provided instructions.

Definition at line 679 of file ReachingDefAnalysis.cpp.

References llvm::MachineBasicBlock::end(), getGlobalUses(), I, Ignore, isRegDefinedAfter(), isRegUsedAfter(), isValidRegDefOf(), MBB, MI, llvm::set_is_subset(), and Uses.

isSafeToMoveBackwards()

isSafeToMoveForwards()

isSafeToRemove() [1/2]

isSafeToRemove() [2/2]

releaseMemory()

void ReachingDefAnalysis::releaseMemory ( ) overridevirtual

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 221 of file ReachingDefAnalysis.cpp.

References llvm::SmallVectorImpl< T >::clear(), and llvm::MBBReachingDefsInfo::clear().

Referenced by reset().

reset()

void ReachingDefAnalysis::reset ( )

runOnMachineFunction()

traverse()

void ReachingDefAnalysis::traverse ( )

ID

char ReachingDefAnalysis::ID = 0 static

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