LLVM 20.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.
 
bool tailDuplicateBlocks ()
 Look for small blocks that are unconditionally branched to and do not fall through.
 
bool shouldTailDuplicate (bool IsSimple, MachineBasicBlock &TailBB)
 Determine if it is profitable to duplicate this block.
 
bool canTailDuplicate (MachineBasicBlock *TailBB, MachineBasicBlock *PredBB)
 Returns true if TailBB can successfully be duplicated into PredBB.
 
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.
 

Static Public Member Functions

static bool isSimpleBB (MachineBasicBlock *TailBB)
 True if this BB has only one unconditional jump.
 

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 
)

◆ initMF()

void TailDuplicator::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.

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

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

◆ 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,
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 166 of file TailDuplicator.cpp.

References llvm::MachineSSAUpdater::AddAvailableValue(), llvm::MachineBasicBlock::clear(), llvm::MachineRegisterInfo::constrainRegClass(), Copies, DefMI, llvm::MachineInstr::getParent(), llvm::MachineRegisterInfo::getRegClass(), llvm::MachineSSAUpdater::GetValueInMiddleOfBlock(), llvm::MachineRegisterInfo::getVRegDef(), llvm::MachineBasicBlock::hasAddressTaken(), llvm::MachineRegisterInfo::hasOneNonDBGUse(), llvm::MachineSSAUpdater::Initialize(), llvm::MachineInstr::isDebugValue(), llvm::MachineInstr::isPHI(), llvm::make_early_inc_range(), MBB, llvm::MachineBasicBlock::pred_empty(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::MachineRegisterInfo::replaceRegWith(), llvm::MachineSSAUpdater::RewriteUse(), llvm::SmallVectorBase< Size_T >::size(), llvm::MachineBasicBlock::size(), llvm::MachineBasicBlock::succ_begin(), llvm::MachineBasicBlock::succ_end(), llvm::MachineRegisterInfo::use_operands(), 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 279 of file TailDuplicator.cpp.

References llvm::dbgs(), llvm::drop_begin(), isSimpleBB(), LLVM_DEBUG, llvm::make_early_inc_range(), MBB, shouldTailDuplicate(), tailDuplicateAndUpdate(), TailDupLimit, TailDupVerify, and VerifyPHIs().


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