LLVM  13.0.0git
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, MBFIWrapper *MBFI, ProfileSummaryInfo *PSI, 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, SmallVectorImpl< MachineBasicBlock * > *CandidatePtr=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 39 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 796 of file TailDuplicator.cpp.

References llvm::TargetInstrInfo::analyzeBranch(), and llvm::MachineBasicBlock::succ_size().

◆ initMF()

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

Prepare to run on a specific machine function.

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

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

◆ isSimpleBB()

bool TailDuplicator::isSimpleBB ( MachineBasicBlock TailBB)

◆ 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,
SmallVectorImpl< MachineBasicBlock * > *  CandidatePtr = 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. If CandidatePtr is not null, duplicate into these blocks only.

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

References llvm::MachineSSAUpdater::AddAvailableValue(), llvm::MachineRegisterInfo::constrainRegClass(), Copies, DefMI, llvm::numbers::e, llvm::MachineInstr::eraseFromParent(), llvm::MachineOperand::getParent(), llvm::MachineInstr::getParent(), llvm::MachineRegisterInfo::getRegClass(), llvm::MachineRegisterInfo::getVRegDef(), llvm::MachineBasicBlock::hasAddressTaken(), llvm::MachineRegisterInfo::hasOneNonDBGUse(), i, llvm::MachineSSAUpdater::Initialize(), llvm::MachineInstr::isDebugValue(), llvm::MachineInstr::isPHI(), j(), MBB, move, llvm::MachineBasicBlock::pred_empty(), llvm::MachineRegisterInfo::replaceRegWith(), llvm::MachineSSAUpdater::RewriteUse(), llvm::MachineBasicBlock::size(), llvm::MachineBasicBlock::succ_begin(), llvm::MachineBasicBlock::succ_end(), llvm::MachineRegisterInfo::use_begin(), llvm::MachineRegisterInfo::use_end(), and UseMI.

Referenced by 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 269 of file TailDuplicator.cpp.

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

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