LLVM  6.0.0svn
Public Member Functions | Static Public Member Functions | List of all members
llvm::TailDuplicator Class Reference

Utility class to perform tail duplication. More...

#include "llvm/CodeGen/TailDuplicator.h"

Public Member Functions

void initMF (MachineFunction &MF, bool PreRegAlloc, 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, 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...
 

Detailed Description

Utility class to perform tail duplication.

Definition at line 41 of file TailDuplicator.h.

Member Function Documentation

◆ canTailDuplicate()

bool TailDuplicator::canTailDuplicate ( MachineBasicBlock TailBB,
MachineBasicBlock PredBB 
)

Returns true if TailBB can successfully be duplicated into PredBB.

Definition at line 757 of file TailDuplicator.cpp.

References llvm::MachineInstrBuilder::addReg(), llvm::MachineBasicBlock::addSuccessor(), llvm::TargetInstrInfo::analyzeBranch(), assert(), llvm::MachineBasicBlock::begin(), llvm::BuildMI(), C, llvm::MachineBasicBlock::canFallThrough(), llvm::dbgs(), DEBUG, E, llvm::SmallVectorBase::empty(), llvm::MachineBasicBlock::end(), llvm::MachineBasicBlock::eraseFromParent(), llvm::MachineInstr::eraseFromParent(), llvm::MCInstrInfo::get(), llvm::MachineBranchProbabilityInfo::getEdgeProbability(), llvm::MachineBasicBlock::getFirstTerminator(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::MachineBasicBlock::getNumber(), getRegsUsedByPHIs(), llvm::MachineBasicBlock::hasAddressTaken(), I, llvm::is_contained(), llvm::MachineInstr::isBundle(), llvm::MachineBasicBlock::isLayoutSuccessor(), llvm::MachineInstr::isPHI(), llvm::MachineBasicBlock::pred_begin(), llvm::MachineBasicBlock::pred_empty(), llvm::MachineBasicBlock::pred_end(), llvm::MachineBasicBlock::pred_size(), llvm::SmallVectorTemplateBase< T, isPodLike >::push_back(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), llvm::TargetInstrInfo::removeBranch(), llvm::MachineBasicBlock::removeSuccessor(), llvm::MachineBasicBlock::size(), llvm::MachineBasicBlock::splice(), llvm::MachineBasicBlock::succ_begin(), llvm::MachineBasicBlock::succ_empty(), llvm::MachineBasicBlock::succ_end(), llvm::MachineBasicBlock::succ_size(), llvm::MachineBasicBlock::successors(), and llvm::MachineBasicBlock::transferSuccessors().

Referenced by greaterWithBias().

◆ initMF()

void TailDuplicator::initMF ( MachineFunction MF,
bool  PreRegAlloc,
const MachineBranchProbabilityInfo MBPI,
bool  LayoutMode,
unsigned  TailDupSize = 0 
)

Prepare to run on a specific machine function.

Parameters
MF- Function that will be processed
PreRegAlloc- true if used before register allocation
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 78 of file TailDuplicator.cpp.

References assert(), llvm::TargetSubtargetInfo::getInstrInfo(), llvm::MachineFunction::getMMI(), llvm::MachineFunction::getRegInfo(), llvm::TargetSubtargetInfo::getRegisterInfo(), and llvm::MachineFunction::getSubtarget().

Referenced by getLayoutSuccessorProbThreshold().

◆ isSimpleBB()

bool TailDuplicator::isSimpleBB ( MachineBasicBlock TailBB)
static

◆ shouldTailDuplicate()

bool TailDuplicator::shouldTailDuplicate ( bool  IsSimple,
MachineBasicBlock TailBB 
)

◆ tailDuplicateAndUpdate()

bool TailDuplicator::tailDuplicateAndUpdate ( bool  IsSimple,
MachineBasicBlock MBB,
MachineBasicBlock ForcedLayoutPred,
SmallVectorImpl< MachineBasicBlock *> *  DuplicatedPreds = nullptr,
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 149 of file TailDuplicator.cpp.

References llvm::MachineSSAUpdater::AddAvailableValue(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::clear(), llvm::SmallVectorImpl< T >::clear(), llvm::MachineRegisterInfo::constrainRegClass(), DefMI, 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(), 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, typename >::size(), llvm::SmallVectorTemplateCommon< T >::size(), llvm::MachineBasicBlock::size(), llvm::MachineBasicBlock::succ_begin(), llvm::MachineBasicBlock::succ_end(), llvm::MachineRegisterInfo::use_begin(), llvm::MachineRegisterInfo::use_end(), and UseMI.

Referenced by getLayoutSuccessorProbThreshold(), and tailDuplicateBlocks().

◆ tailDuplicateBlocks()

bool 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 258 of file TailDuplicator.cpp.

References llvm::MachineFunction::begin(), llvm::dbgs(), DEBUG, E, llvm::MachineFunction::end(), I, isSimpleBB(), shouldTailDuplicate(), tailDuplicateAndUpdate(), TailDupLimit, TailDupVerify, and VerifyPHIs().


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