|
LLVM 23.0.0git
|
This class provides the reaching def analysis. More...
#include "llvm/CodeGen/ReachingDefAnalysis.h"
Public Member Functions | |
| LLVM_ABI | ReachingDefInfo () |
| LLVM_ABI | ReachingDefInfo (ReachingDefInfo &&) |
| LLVM_ABI | ~ReachingDefInfo () |
| LLVM_ABI bool | invalidate (MachineFunction &F, const PreservedAnalyses &PA, MachineFunctionAnalysisManager::Invalidator &) |
| Handle invalidation explicitly. | |
| LLVM_ABI void | run (MachineFunction &mf) |
| LLVM_ABI void | print (raw_ostream &OS) |
| LLVM_ABI void | releaseMemory () |
| LLVM_ABI void | reset () |
| Re-run the analysis. | |
| LLVM_ABI void | init () |
| Initialize data structures. | |
| LLVM_ABI void | traverse () |
| Traverse the machine function, mapping definitions. | |
| LLVM_ABI 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. | |
| LLVM_ABI bool | hasSameReachingDef (MachineInstr *A, MachineInstr *B, Register Reg) const |
| Return whether A and B use the same def of Reg. | |
| LLVM_ABI bool | isReachingDefLiveOut (MachineInstr *MI, Register Reg) const |
| Return whether the reaching def for MI also is live out of its parent block. | |
| LLVM_ABI 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. | |
| LLVM_ABI MachineInstr * | getUniqueReachingMIDef (MachineInstr *MI, Register Reg) const |
| If a single MachineInstr creates the reaching definition, then return it. | |
| LLVM_ABI MachineInstr * | getMIOperand (MachineInstr *MI, unsigned Idx) const |
| If a single MachineInstr creates the reaching definition, for MIs operand at Idx, then return it. | |
| LLVM_ABI MachineInstr * | getMIOperand (MachineInstr *MI, MachineOperand &MO) const |
| If a single MachineInstr creates the reaching definition, for MIs MO, then return it. | |
| LLVM_ABI bool | hasLocalDefBefore (MachineInstr *MI, Register Reg) const |
| Provide whether the register has been defined in the same basic block as, and before, MI. | |
| LLVM_ABI 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. | |
| LLVM_ABI bool | isRegDefinedAfter (MachineInstr *MI, Register Reg) const |
| Return whether the given register is defined after MI. | |
| LLVM_ABI 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. | |
| LLVM_ABI void | getReachingLocalUses (MachineInstr *MI, Register Reg, InstSet &Uses) const |
| Provides the uses, in the same block as MI, of register that MI defines. | |
| LLVM_ABI void | getLiveOuts (MachineBasicBlock *MBB, Register Reg, InstSet &Defs, BlockSet &VisitedBBs) const |
| Search MBB for a definition of Reg and insert it into Defs. | |
| LLVM_ABI void | getLiveOuts (MachineBasicBlock *MBB, Register Reg, InstSet &Defs) const |
| LLVM_ABI 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. | |
| LLVM_ABI void | getGlobalUses (MachineInstr *MI, Register Reg, InstSet &Uses) const |
| Collect the users of the value stored in Reg, which is defined by MI. | |
| LLVM_ABI void | getGlobalReachingDefs (MachineInstr *MI, Register Reg, InstSet &Defs) const |
| Collect all possible definitions of the value stored in Reg, which is used by MI. | |
| LLVM_ABI bool | isSafeToMoveForwards (MachineInstr *From, MachineInstr *To) const |
| Return whether From can be moved forwards to just before To. | |
| LLVM_ABI bool | isSafeToMoveBackwards (MachineInstr *From, MachineInstr *To) const |
| Return whether From can be moved backwards to just after To. | |
| LLVM_ABI 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. | |
| LLVM_ABI 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. | |
| LLVM_ABI 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. | |
| LLVM_ABI 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. | |
| LLVM_ABI 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. | |
This class provides the reaching def analysis.
Definition at line 114 of file ReachingDefAnalysis.h.
|
default |
References LLVM_ABI.
Referenced by ReachingDefInfo().
|
default |
References LLVM_ABI, and ReachingDefInfo().
|
default |
| void ReachingDefInfo::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.
Definition at line 795 of file ReachingDefAnalysis.cpp.
References collectKilledOperands(), llvm::Dead, getGlobalUses(), getMIOperand(), IsDead, isValidRegDef(), isValidRegUse(), mayHaveSideEffects(), MI, llvm::set_is_subset(), and Uses.
Referenced by collectKilledOperands().
| int ReachingDefInfo::getClearance | ( | MachineInstr * | MI, |
| Register | Reg ) const |
Provides the clearance - the number of instructions since the closest reaching def instuction of Reg that reaches MI.
Definition at line 472 of file ReachingDefAnalysis.cpp.
References assert(), getReachingDef(), and MI.
| void ReachingDefInfo::getGlobalReachingDefs | ( | MachineInstr * | MI, |
| Register | Reg, | ||
| InstSet & | Defs ) const |
Collect all possible definitions of the value stored in Reg, which is used by MI.
Definition at line 548 of file ReachingDefAnalysis.cpp.
References getLiveOuts(), getUniqueReachingMIDef(), llvm::SmallPtrSetImpl< PtrType >::insert(), MBB, and MI.
Referenced by print().
| void ReachingDefInfo::getGlobalUses | ( | MachineInstr * | MI, |
| Register | Reg, | ||
| InstSet & | Uses ) const |
Collect the users of the value stored in Reg, which is defined by MI.
Definition at line 523 of file ReachingDefAnalysis.cpp.
References llvm::append_range(), llvm::SmallPtrSetImpl< PtrType >::count(), llvm::SmallVectorTemplateCommon< T, typename >::empty(), getLiveInUses(), getLocalLiveOutMIDef(), getReachingLocalUses(), llvm::SmallPtrSetImpl< PtrType >::insert(), MBB, MI, llvm::SmallVectorImpl< T >::pop_back_val(), and Uses.
Referenced by collectKilledOperands(), and isSafeToDefRegAt().
| bool ReachingDefInfo::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.
Return whether the value is still live on exit.
Definition at line 505 of file ReachingDefAnalysis.cpp.
References getReachingDef(), llvm::instructionsWithoutDebug(), isReachingDefLiveOut(), isValidRegUseOf(), llvm::Last, MBB, MI, and Uses.
Referenced by getGlobalUses().
| void ReachingDefInfo::getLiveOuts | ( | MachineBasicBlock * | MBB, |
| Register | Reg, | ||
| InstSet & | Defs ) const |
Definition at line 559 of file ReachingDefAnalysis.cpp.
References getLiveOuts(), and MBB.
| void ReachingDefInfo::getLiveOuts | ( | MachineBasicBlock * | MBB, |
| Register | Reg, | ||
| InstSet & | Defs, | ||
| BlockSet & | VisitedBBs ) const |
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 565 of file ReachingDefAnalysis.cpp.
References llvm::SmallPtrSetImpl< PtrType >::count(), getLiveOuts(), getLocalLiveOutMIDef(), llvm::SmallPtrSetImpl< PtrType >::insert(), and MBB.
Referenced by getGlobalReachingDefs(), getLiveOuts(), getLiveOuts(), and getUniqueReachingMIDef().
| MachineInstr * ReachingDefInfo::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.
Definition at line 669 of file ReachingDefAnalysis.cpp.
References getReachingDef(), isFIDef(), isValidRegDefOf(), llvm::Last, and MBB.
Referenced by getGlobalUses(), getLiveOuts(), and isRegDefinedAfter().
| MachineInstr * ReachingDefInfo::getMIOperand | ( | MachineInstr * | MI, |
| MachineOperand & | MO ) const |
If a single MachineInstr creates the reaching definition, for MIs MO, then return it.
Otherwise return null.
Definition at line 609 of file ReachingDefAnalysis.cpp.
References assert(), llvm::MachineOperand::getReg(), getUniqueReachingMIDef(), llvm::MachineOperand::isReg(), and MI.
| MachineInstr * ReachingDefInfo::getMIOperand | ( | MachineInstr * | MI, |
| unsigned | Idx ) const |
If a single MachineInstr creates the reaching definition, for MIs operand at Idx, then return it.
Otherwise return null.
Definition at line 603 of file ReachingDefAnalysis.cpp.
References assert(), getUniqueReachingMIDef(), and MI.
Referenced by collectKilledOperands().
| int ReachingDefInfo::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.
Note that Reg may represent a stack slot.
Definition at line 399 of file ReachingDefAnalysis.cpp.
References assert(), Lookup(), and MI.
Referenced by getClearance(), getLiveInUses(), getLocalLiveOutMIDef(), hasLocalDefBefore(), hasSameReachingDef(), isReachingDefLiveOut(), and isRegDefinedAfter().
| void ReachingDefInfo::getReachingLocalUses | ( | MachineInstr * | MI, |
| Register | Reg, | ||
| InstSet & | Uses ) const |
Provides the uses, in the same block as MI, of register that MI defines.
This does not consider live-outs.
Definition at line 481 of file ReachingDefAnalysis.cpp.
References isValidRegUseOf(), MBB, MI, and Uses.
Referenced by getGlobalUses().
| MachineInstr * ReachingDefInfo::getUniqueReachingMIDef | ( | MachineInstr * | MI, |
| Register | Reg ) const |
If a single MachineInstr creates the reaching definition, then return it.
Otherwise return null.
Definition at line 583 of file ReachingDefAnalysis.cpp.
References llvm::SmallPtrSetImpl< PtrType >::begin(), getLiveOuts(), MI, llvm::MachineBasicBlock::predecessors(), and llvm::SmallPtrSetImplBase::size().
Referenced by getGlobalReachingDefs(), getMIOperand(), and getMIOperand().
| bool ReachingDefInfo::hasLocalDefBefore | ( | MachineInstr * | MI, |
| Register | Reg ) const |
Provide whether the register has been defined in the same basic block as, and before, MI.
Definition at line 477 of file ReachingDefAnalysis.cpp.
References getReachingDef(), and MI.
| bool ReachingDefInfo::hasSameReachingDef | ( | MachineInstr * | A, |
| MachineInstr * | B, | ||
| Register | Reg ) const |
Return whether A and B use the same def of Reg.
Definition at line 442 of file ReachingDefAnalysis.cpp.
References A(), B(), and getReachingDef().
| void ReachingDefInfo::init | ( | ) |
Initialize data structures.
Definition at line 368 of file ReachingDefAnalysis.cpp.
References llvm::LoopTraversal::traverse().
| bool ReachingDefInfo::invalidate | ( | MachineFunction & | F, |
| const PreservedAnalyses & | PA, | ||
| MachineFunctionAnalysisManager::Invalidator & | ) |
Handle invalidation explicitly.
Definition at line 57 of file ReachingDefAnalysis.cpp.
References llvm::PreservedAnalyses::getChecker().
| bool ReachingDefInfo::isReachingDefLiveOut | ( | MachineInstr * | MI, |
| Register | Reg ) const |
Return whether the reaching def for MI also is live out of its parent block.
Definition at line 648 of file ReachingDefAnalysis.cpp.
References getReachingDef(), isValidRegDefOf(), llvm::Last, MBB, and MI.
Referenced by getLiveInUses().
| bool ReachingDefInfo::isRegDefinedAfter | ( | MachineInstr * | MI, |
| Register | Reg ) const |
Return whether the given register is defined after MI.
Definition at line 635 of file ReachingDefAnalysis.cpp.
References getLocalLiveOutMIDef(), getReachingDef(), llvm::Last, MBB, and MI.
Referenced by isSafeToDefRegAt().
| bool ReachingDefInfo::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.
Definition at line 615 of file ReachingDefAnalysis.cpp.
References llvm::instructionsWithoutDebug(), llvm::Last, MBB, and MI.
Referenced by isSafeToDefRegAt().
| bool ReachingDefInfo::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.
Definition at line 827 of file ReachingDefAnalysis.cpp.
References Ignore, isSafeToDefRegAt(), and MI.
Referenced by isSafeToDefRegAt().
| bool ReachingDefInfo::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.
Definition at line 832 of file ReachingDefAnalysis.cpp.
References getGlobalUses(), I, Ignore, isRegDefinedAfter(), isRegUsedAfter(), isValidRegDefOf(), MBB, MI, llvm::set_is_subset(), and Uses.
| bool ReachingDefInfo::isSafeToMoveBackwards | ( | MachineInstr * | From, |
| MachineInstr * | To ) const |
Return whether From can be moved backwards to just after To.
Definition at line 743 of file ReachingDefAnalysis.cpp.
References llvm::MachineInstr::getParent(), I, and llvm::MachineBasicBlock::rend().
| bool ReachingDefInfo::isSafeToMoveForwards | ( | MachineInstr * | From, |
| MachineInstr * | To ) const |
Return whether From can be moved forwards to just before To.
Definition at line 733 of file ReachingDefAnalysis.cpp.
References llvm::MachineBasicBlock::end(), llvm::MachineInstr::getParent(), and I.
| bool ReachingDefInfo::isSafeToRemove | ( | MachineInstr * | MI, |
| InstSet & | ToRemove ) const |
Return whether removing this instruction will have no effect on the program, returning the redundant use-def chain.
Definition at line 753 of file ReachingDefAnalysis.cpp.
References Ignore, isSafeToRemove(), MI, and ToRemove.
Referenced by isSafeToRemove(), and isSafeToRemove().
| bool ReachingDefInfo::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.
Definition at line 760 of file ReachingDefAnalysis.cpp.
References Ignore, isSafeToRemove(), MI, and ToRemove.
| void ReachingDefInfo::print | ( | raw_ostream & | OS | ) |
Definition at line 301 of file ReachingDefAnalysis.cpp.
References llvm::SmallPtrSetImplBase::clear(), getGlobalReachingDefs(), llvm::Register::index2StackSlot(), MBB, MI, llvm::printMBBReference(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), and llvm::sort().
| void ReachingDefInfo::releaseMemory | ( | ) |
Definition at line 353 of file ReachingDefAnalysis.cpp.
Referenced by reset().
| void ReachingDefInfo::reset | ( | ) |
Re-run the analysis.
Definition at line 362 of file ReachingDefAnalysis.cpp.
References init(), releaseMemory(), and traverse().
| void ReachingDefInfo::run | ( | MachineFunction & | mf | ) |
Definition at line 291 of file ReachingDefAnalysis.cpp.
References llvm::dbgs(), llvm::TargetSubtargetInfo::getInstrInfo(), llvm::TargetSubtargetInfo::getRegisterInfo(), init(), LLVM_DEBUG, and traverse().
| void ReachingDefInfo::traverse | ( | ) |
Traverse the machine function, mapping definitions.
Definition at line 379 of file ReachingDefAnalysis.cpp.
References assert().