|
LLVM
4.0.0
|
Utility class to perform tail duplication. More...
#include <TailDuplicator.h>
Public Member Functions | |
| void | initMF (MachineFunction &MF, const MachineBranchProbabilityInfo *MBPI, bool LayoutMode, unsigned TailDupSize=0) |
| Prepare to run on a specific machine function. More... | |
| bool | tailDuplicateBlocks () |
| Look for small blocks that are unconditionally branched to and do not fall through. More... | |
| bool | shouldTailDuplicate (bool IsSimple, MachineBasicBlock &TailBB) |
| Determine if it is profitable to duplicate this block. More... | |
| bool | canTailDuplicate (MachineBasicBlock *TailBB, MachineBasicBlock *PredBB) |
| Returns true if TailBB can successfully be duplicated into PredBB. More... | |
| bool | tailDuplicateAndUpdate (bool IsSimple, MachineBasicBlock *MBB, MachineBasicBlock *ForcedLayoutPred, SmallVectorImpl< MachineBasicBlock * > *DuplicatedPreds=nullptr, llvm::function_ref< void(MachineBasicBlock *)> *RemovalCallback=nullptr) |
| Tail duplicate a single basic block into its predecessors, and then clean up. More... | |
Static Public Member Functions | |
| static bool | isSimpleBB (MachineBasicBlock *TailBB) |
| True if this BB has only one unconditional jump. More... | |
Utility class to perform tail duplication.
Definition at line 33 of file TailDuplicator.h.
| bool llvm::TailDuplicator::canTailDuplicate | ( | MachineBasicBlock * | TailBB, |
| MachineBasicBlock * | PredBB | ||
| ) |
Returns true if TailBB can successfully be duplicated into PredBB.
Definition at line 745 of file TailDuplicator.cpp.
References llvm::TargetInstrInfo::analyzeBranch(), llvm::SmallVectorBase::empty(), and llvm::MachineBasicBlock::succ_size().
| void llvm::TailDuplicator::initMF | ( | MachineFunction & | MF, |
| const MachineBranchProbabilityInfo * | MBPI, | ||
| bool | LayoutMode, | ||
| unsigned | TailDupSize = 0 |
||
| ) |
Prepare to run on a specific machine function.
| MF | - Function that will be processed |
| MBPI | - Branch Probability Info. Used to propagate correct probabilities when modifying the CFG. |
| LayoutMode | - When true, don't use the existing layout to make decisions. |
| TailDupSize | - Maxmimum size of blocks to tail-duplicate. Zero default implies using the command line value TailDupSize. |
Definition at line 66 of file TailDuplicator.cpp.
References assert(), llvm::TargetSubtargetInfo::getInstrInfo(), llvm::MachineFunction::getMMI(), llvm::MachineFunction::getRegInfo(), llvm::TargetSubtargetInfo::getRegisterInfo(), llvm::MachineFunction::getSubtarget(), and llvm::MachineRegisterInfo::isSSA().
|
static |
True if this BB has only one unconditional jump.
Definition at line 636 of file TailDuplicator.cpp.
References llvm::MachineBasicBlock::end(), llvm::MachineBasicBlock::getFirstNonDebugInstr(), I, llvm::MachineBasicBlock::pred_empty(), and llvm::MachineBasicBlock::succ_size().
Referenced by tailDuplicateBlocks().
| bool llvm::TailDuplicator::shouldTailDuplicate | ( | bool | IsSimple, |
| MachineBasicBlock & | TailBB | ||
| ) |
Determine if it is profitable to duplicate this block.
Definition at line 522 of file TailDuplicator.cpp.
References llvm::TargetInstrInfo::analyzeBranch(), assert(), llvm::MachineBasicBlock::back(), llvm::MachineBasicBlock::canFallThrough(), llvm::MachineBasicBlock::empty(), llvm::MachineFunction::getFunction(), llvm::getPHISrcRegOpIdx(), llvm::MachineOperand::getSubReg(), I, InstrCount, llvm::MachineInstr::isCall(), llvm::MachineInstr::isConvergent(), llvm::MachineInstr::isDebugValue(), llvm::MachineInstr::isIndirectBranch(), llvm::MachineInstr::isNotDuplicable(), llvm::MachineInstr::isPHI(), llvm::MachineInstr::isReturn(), llvm::MachineBasicBlock::isSuccessor(), llvm::Function::optForSize(), SB, llvm::TailDupIndirectBranchSize, and llvm::TailDuplicateSize.
Referenced by tailDuplicateBlocks().
| bool llvm::TailDuplicator::tailDuplicateAndUpdate | ( | bool | IsSimple, |
| MachineBasicBlock * | MBB, | ||
| MachineBasicBlock * | ForcedLayoutPred, | ||
| SmallVectorImpl< MachineBasicBlock * > * | DuplicatedPreds = nullptr, |
||
| llvm::function_ref< void(MachineBasicBlock *)> * | RemovalCallback = nullptr |
||
| ) |
Tail duplicate a single basic block into its predecessors, and then clean up.
Tail duplicate the block and cleanup.
If DuplicatePreds is not null, it will be updated to contain the list of predecessors that received a copy of MBB. If RemovalCallback is non-null. It will be called before MBB is deleted.
IsSimple - return value of isSimpleBB MBB - block to be duplicated ForcedLayoutPred - If non-null, treat this block as the layout predecessor, instead of using the ordering in MF DuplicatedPreds - if non-null, DuplicatedPreds will contain a list of all Preds that received a copy of MBB. RemovalCallback - if non-null, called just before MBB is deleted.
Definition at line 137 of file TailDuplicator.cpp.
References llvm::MachineSSAUpdater::AddAvailableValue(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::clear(), llvm::SmallVectorImpl< T >::clear(), llvm::MachineRegisterInfo::constrainRegClass(), llvm::SmallVectorBase::empty(), llvm::MachineInstr::eraseFromParent(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), llvm::MachineInstr::getOperand(), llvm::MachineInstr::getParent(), llvm::MachineOperand::getParent(), llvm::MachineOperand::getReg(), llvm::MachineRegisterInfo::getRegClass(), llvm::MachineRegisterInfo::getVRegDef(), llvm::MachineBasicBlock::hasAddressTaken(), llvm::MachineRegisterInfo::hasOneNonDBGUse(), i, llvm::MachineSSAUpdater::Initialize(), llvm::MachineInstr::isCopy(), llvm::MachineInstr::isDebugValue(), llvm::MachineInstr::isPHI(), llvm::MachineBasicBlock::pred_empty(), llvm::MachineRegisterInfo::replaceRegWith(), llvm::MachineSSAUpdater::RewriteUse(), llvm::DenseMapBase< DenseMap< KeyT, ValueT, KeyInfoT, BucketT >, KeyT, ValueT, KeyInfoT, BucketT >::size(), llvm::SmallVectorTemplateCommon< T >::size(), llvm::SmallVectorTemplateCommon< T, typename >::size(), llvm::MachineBasicBlock::size(), llvm::MachineBasicBlock::succ_begin(), llvm::MachineBasicBlock::succ_end(), llvm::MachineRegisterInfo::use_begin(), llvm::MachineRegisterInfo::use_end(), and UseMI.
Referenced by tailDuplicateBlocks().
| bool llvm::TailDuplicator::tailDuplicateBlocks | ( | ) |
Look for small blocks that are unconditionally branched to and do not fall through.
Tail-duplicate their instructions into their predecessors to eliminate (dynamic) branches.
Definition at line 246 of file TailDuplicator.cpp.
References llvm::MachineFunction::begin(), llvm::dbgs(), DEBUG, E, llvm::MachineFunction::end(), I, isSimpleBB(), shouldTailDuplicate(), tailDuplicateAndUpdate(), llvm::TailDupLimit, llvm::TailDupVerify, and llvm::VerifyPHIs().
1.8.6