LLVM  8.0.1
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/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>
Include dependency graph for TailDuplicator.cpp:

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 (unsigned Reg, MachineBasicBlock *BB, const MachineRegisterInfo *MRI)
 
static unsigned getPHISrcRegOpIdx (MachineInstr *MI, MachineBasicBlock *SrcBB)
 
static void getRegsUsedByPHIs (const MachineBasicBlock &BB, DenseSet< unsigned > *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< 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

◆ getRegsUsedByPHIs()

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

Definition at line 310 of file TailDuplicator.cpp.

References assert(), llvm::MachineBasicBlock::begin(), llvm::BuildMI(), llvm::TargetRegisterInfo::composeSubRegIndices(), llvm::MachineRegisterInfo::constrainRegClass(), Copies, llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::count(), llvm::MachineRegisterInfo::createVirtualRegister(), llvm::TargetInstrInfo::duplicate(), llvm::DenseMapBase< DenseMap< KeyT, ValueT, KeyInfoT, BucketT >, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::MachineBasicBlock::end(), llvm::DenseMapBase< DenseMap< KeyT, ValueT, KeyInfoT, BucketT >, KeyT, ValueT, KeyInfoT, BucketT >::erase(), llvm::MachineInstr::eraseFromParent(), llvm::DenseMapBase< DenseMap< KeyT, ValueT, KeyInfoT, BucketT >, KeyT, ValueT, KeyInfoT, BucketT >::find(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), llvm::MachineBasicBlock::findDebugLoc(), llvm::MCInstrInfo::get(), llvm::MachineOperand::getCFIIndex(), llvm::MachineInstr::getDebugLoc(), llvm::TargetRegisterInfo::getMatchingSuperRegClass(), llvm::MachineOperand::getMBB(), llvm::MachineInstr::getNumOperands(), llvm::MachineInstr::getOperand(), llvm::MachineBasicBlock::getParent(), getPHISrcRegOpIdx(), llvm::MachineOperand::getReg(), llvm::MachineRegisterInfo::getRegClass(), llvm::MachineInstr::getRegClassConstraint(), llvm::MachineOperand::getSubReg(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::insert(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::insert(), llvm::DenseMapBase< DenseMap< KeyT, ValueT, KeyInfoT, BucketT >, KeyT, ValueT, KeyInfoT, BucketT >::insert(), llvm::MachineInstr::isCFIInstruction(), llvm::MachineOperand::isDef(), isDefLiveOut(), llvm::MachineInstr::isPHI(), llvm::MachineOperand::isReg(), llvm::MachineBasicBlock::isSuccessor(), llvm::TargetRegisterInfo::isVirtualRegister(), MI, llvm::SmallVectorTemplateBase< T, bool >::push_back(), Reg, llvm::MachineInstr::RemoveOperand(), llvm::MachineOperand::setIsKill(), llvm::MachineOperand::setMBB(), llvm::MachineOperand::setReg(), llvm::MachineRegisterInfo::setRegClass(), llvm::MachineOperand::setSubReg(), llvm::SmallVectorBase::size(), llvm::DenseMapBase< DenseMap< KeyT, ValueT, KeyInfoT, BucketT >, KeyT, ValueT, KeyInfoT, BucketT >::size(), and VI.

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

◆ isDefLiveOut()

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

Definition at line 289 of file TailDuplicator.cpp.

References llvm::MachineRegisterInfo::use_instructions(), and UseMI.

Referenced by getRegsUsedByPHIs().

◆ STATISTIC() [1/6]

STATISTIC ( NumTails  ,
"Number of tails duplicated"   
)

◆ STATISTIC() [2/6]

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

◆ 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 ( NumDeadBlocks  ,
"Number of dead blocks removed"   
)

◆ STATISTIC() [6/6]

STATISTIC ( NumAddedPHIs  ,
"Number of phis added"   
)

◆ 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)
static

◆ TailDuplicateSize

cl::opt<unsigned> TailDuplicateSize("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)
static

◆ TailDupVerify

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