LLVM 20.0.0git
Macros | Functions | Variables
TailDuplicator.cpp File Reference
#include "llvm/CodeGen/TailDuplicator.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineBranchProbabilityInfo.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineOperand.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/MachineSSAUpdater.h"
#include "llvm/CodeGen/MachineSizeOpts.h"
#include "llvm/CodeGen/TargetInstrInfo.h"
#include "llvm/CodeGen/TargetRegisterInfo.h"
#include "llvm/CodeGen/TargetSubtargetInfo.h"
#include "llvm/IR/DebugLoc.h"
#include "llvm/IR/Function.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetMachine.h"
#include <algorithm>
#include <cassert>
#include <iterator>
#include <utility>

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "tailduplication"
 

Functions

 STATISTIC (NumTails, "Number of tails duplicated")
 
 STATISTIC (NumTailDups, "Number of tail duplicated blocks")
 
 STATISTIC (NumTailDupAdded, "Number of instructions added due to tail duplication")
 
 STATISTIC (NumTailDupRemoved, "Number of instructions removed due to tail duplication")
 
 STATISTIC (NumDeadBlocks, "Number of dead blocks removed")
 
 STATISTIC (NumAddedPHIs, "Number of phis added")
 
static void VerifyPHIs (MachineFunction &MF, bool CheckExtra)
 
static bool isDefLiveOut (Register Reg, MachineBasicBlock *BB, const MachineRegisterInfo *MRI)
 
static unsigned getPHISrcRegOpIdx (MachineInstr *MI, MachineBasicBlock *SrcBB)
 
static void getRegsUsedByPHIs (const MachineBasicBlock &BB, DenseSet< Register > *UsedByPhi)
 
static bool bothUsedInPHI (const MachineBasicBlock &A, const SmallPtrSet< MachineBasicBlock *, 8 > &SuccsB)
 

Variables

static cl::opt< unsignedTailDuplicateSize ("tail-dup-size", cl::desc("Maximum instructions to consider tail duplicating"), cl::init(2), cl::Hidden)
 
static cl::opt< unsignedTailDupIndirectBranchSize ("tail-dup-indirect-size", cl::desc("Maximum instructions to consider tail duplicating blocks that " "end with indirect branches."), cl::init(20), cl::Hidden)
 
static cl::opt< unsignedTailDupPredSize ("tail-dup-pred-size", cl::desc("Maximum predecessors (maximum successors at the " "same time) to consider tail duplicating blocks."), cl::init(16), cl::Hidden)
 
static cl::opt< unsignedTailDupSuccSize ("tail-dup-succ-size", cl::desc("Maximum successors (maximum predecessors at the " "same time) to consider tail duplicating blocks."), cl::init(16), cl::Hidden)
 
static cl::opt< boolTailDupVerify ("tail-dup-verify", cl::desc("Verify sanity of PHI instructions during taildup"), cl::init(false), cl::Hidden)
 
static cl::opt< unsignedTailDupLimit ("tail-dup-limit", cl::init(~0U), cl::Hidden)
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "tailduplication"

Definition at line 48 of file TailDuplicator.cpp.

Function Documentation

◆ bothUsedInPHI()

static bool bothUsedInPHI ( const MachineBasicBlock A,
const SmallPtrSet< MachineBasicBlock *, 8 > &  SuccsB 
)
static

◆ getPHISrcRegOpIdx()

static unsigned getPHISrcRegOpIdx ( MachineInstr MI,
MachineBasicBlock SrcBB 
)
static

Definition at line 317 of file TailDuplicator.cpp.

References MI.

Referenced by llvm::TailDuplicator::shouldTailDuplicate().

◆ getRegsUsedByPHIs()

static void getRegsUsedByPHIs ( const MachineBasicBlock BB,
DenseSet< Register > *  UsedByPhi 
)
static

◆ isDefLiveOut()

static bool isDefLiveOut ( Register  Reg,
MachineBasicBlock BB,
const MachineRegisterInfo MRI 
)
static

Definition at line 306 of file TailDuplicator.cpp.

References MRI, and UseMI.

◆ STATISTIC() [1/6]

STATISTIC ( NumAddedPHIs  ,
"Number of phis added"   
)

◆ STATISTIC() [2/6]

STATISTIC ( NumDeadBlocks  ,
"Number of dead blocks removed"   
)

◆ STATISTIC() [3/6]

STATISTIC ( NumTailDupAdded  ,
"Number of instructions added due to tail duplication"   
)

◆ STATISTIC() [4/6]

STATISTIC ( NumTailDupRemoved  ,
"Number of instructions removed due to tail duplication"   
)

◆ STATISTIC() [5/6]

STATISTIC ( NumTailDups  ,
"Number of tail duplicated blocks"   
)

◆ STATISTIC() [6/6]

STATISTIC ( NumTails  ,
"Number of tails duplicated"   
)

◆ VerifyPHIs()

static void VerifyPHIs ( MachineFunction MF,
bool  CheckExtra 
)
static

Variable Documentation

◆ TailDupIndirectBranchSize

cl::opt< unsigned > TailDupIndirectBranchSize("tail-dup-indirect-size", cl::desc("Maximum instructions to consider tail duplicating blocks that " "end with indirect branches."), cl::init(20), cl::Hidden) ( "tail-dup-indirect-size"  ,
cl::desc("Maximum instructions to consider tail duplicating blocks that " "end with indirect branches.")  ,
cl::init(20)  ,
cl::Hidden   
)
static

◆ TailDuplicateSize

cl::opt< unsigned > TailDuplicateSize("tail-dup-size", cl::desc("Maximum instructions to consider tail duplicating"), cl::init(2), cl::Hidden) ( "tail-dup-size"  ,
cl::desc("Maximum instructions to consider tail duplicating")  ,
cl::init(2)  ,
cl::Hidden   
)
static

◆ TailDupLimit

cl::opt< unsigned > TailDupLimit("tail-dup-limit", cl::init(~0U), cl::Hidden) ( "tail-dup-limit"  ,
cl::init(~0U)  ,
cl::Hidden   
)
static

◆ TailDupPredSize

cl::opt< unsigned > TailDupPredSize("tail-dup-pred-size", cl::desc("Maximum predecessors (maximum successors at the " "same time) to consider tail duplicating blocks."), cl::init(16), cl::Hidden) ( "tail-dup-pred-size"  ,
cl::desc("Maximum predecessors (maximum successors at the " "same time) to consider tail duplicating blocks.")  ,
cl::init(16)  ,
cl::Hidden   
)
static

◆ TailDupSuccSize

cl::opt< unsigned > TailDupSuccSize("tail-dup-succ-size", cl::desc("Maximum successors (maximum predecessors at the " "same time) to consider tail duplicating blocks."), cl::init(16), cl::Hidden) ( "tail-dup-succ-size"  ,
cl::desc("Maximum successors (maximum predecessors at the " "same time) to consider tail duplicating blocks.")  ,
cl::init(16)  ,
cl::Hidden   
)
static

◆ TailDupVerify

cl::opt< bool > TailDupVerify("tail-dup-verify", cl::desc("Verify sanity of PHI instructions during taildup"), cl::init(false), cl::Hidden) ( "tail-dup-verify"  ,
cl::desc("Verify sanity of PHI instructions during taildup")  ,
cl::init(false)  ,
cl::Hidden   
)
static