LLVM  6.0.0svn
Macros | Functions | Variables
MachineLICM.cpp File Reference
#include "llvm/ADT/BitVector.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineDominators.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineLoopInfo.h"
#include "llvm/CodeGen/MachineMemOperand.h"
#include "llvm/CodeGen/MachineOperand.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/PseudoSourceValue.h"
#include "llvm/CodeGen/TargetSchedule.h"
#include "llvm/IR/DebugLoc.h"
#include "llvm/MC/MCInstrDesc.h"
#include "llvm/MC/MCRegisterInfo.h"
#include "llvm/Pass.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetInstrInfo.h"
#include "llvm/Target/TargetLowering.h"
#include "llvm/Target/TargetRegisterInfo.h"
#include "llvm/Target/TargetSubtargetInfo.h"
#include <algorithm>
#include <cassert>
#include <limits>
#include <vector>
Include dependency graph for MachineLICM.cpp:

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "machinelicm"
 

Functions

 STATISTIC (NumHoisted, "Number of machine instructions hoisted out of loops")
 
 STATISTIC (NumLowRP, "Number of instructions hoisted in low reg pressure situation")
 
 STATISTIC (NumHighLatency, "Number of high latency instructions hoisted")
 
 STATISTIC (NumCSEed, "Number of hoisted machine instructions CSEed")
 
 STATISTIC (NumPostRAHoisted, "Number of machine instructions hoisted out of loops post regalloc")
 
 INITIALIZE_PASS_BEGIN (MachineLICM, DEBUG_TYPE, "Machine Loop Invariant Code Motion", false, false) INITIALIZE_PASS_END(MachineLICM
 
Machine Loop Invariant Code static false bool LoopIsOuterMostWithPredecessor (MachineLoop *CurLoop)
 Test if the given loop is the outer-most loop that has a unique predecessor. More...
 
static bool InstructionStoresToFI (const MachineInstr *MI, int FI)
 Return true if instruction stores to the specified frame. More...
 
static bool isOperandKill (const MachineOperand &MO, MachineRegisterInfo *MRI)
 
static bool mayLoadFromGOTOrConstantPool (MachineInstr &MI)
 Return true if this machine instruction loads from global offset table or constant pool. More...
 

Variables

static cl::opt< boolAvoidSpeculation ("avoid-speculation", cl::desc("MachineLICM should avoid speculation"), cl::init(true), cl::Hidden)
 
static cl::opt< boolHoistCheapInsts ("hoist-cheap-insts", cl::desc("MachineLICM should hoist even cheap instructions"), cl::init(false), cl::Hidden)
 
static cl::opt< boolSinkInstsToAvoidSpills ("sink-insts-to-avoid-spills", cl::desc("MachineLICM should sink instructions into " "loops to avoid register spills"), cl::init(false), cl::Hidden)
 
 DEBUG_TYPE
 
Machine Loop Invariant Code Motion
 
Machine Loop Invariant Code false
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "machinelicm"

Definition at line 57 of file MachineLICM.cpp.

Function Documentation

◆ INITIALIZE_PASS_BEGIN()

INITIALIZE_PASS_BEGIN ( MachineLICM  ,
DEBUG_TYPE  ,
"Machine Loop Invariant Code Motion ,
false  ,
false   
)

◆ InstructionStoresToFI()

static bool InstructionStoresToFI ( const MachineInstr MI,
int  FI 
)
static

Return true if instruction stores to the specified frame.

Definition at line 352 of file MachineLICM.cpp.

References AS, assert(), B, llvm::MachineBasicBlock::begin(), llvm::SmallSet< T, N, C >::clear(), llvm::SmallVectorImpl< T >::clear(), llvm::LoopBase< BlockT, LoopT >::contains(), llvm::SmallSet< T, N, C >::count(), llvm::dbgs(), DEBUG, llvm::tgtok::Def, llvm::MachineDominatorTree::dominates(), E, llvm::SmallVectorBase::empty(), llvm::MachineBasicBlock::end(), llvm::MachineDominatorTree::findNearestCommonDominator(), llvm::DomTreeNodeBase< NodeT >::getBlock(), llvm::LoopBase< BlockT, LoopT >::getBlocks(), llvm::DomTreeNodeBase< NodeT >::getChildren(), llvm::LoopBase< BlockT, LoopT >::getExitingBlocks(), llvm::MachineBasicBlock::getFirstNonPHI(), llvm::MachineBasicBlock::getFirstTerminator(), llvm::LoopBase< BlockT, LoopT >::getHeader(), llvm::MachineLoopInfo::getLoopFor(), llvm::MachineBasicBlock::getNumber(), llvm::MCRegisterInfo::getNumRegs(), llvm::MachineInstr::getParent(), llvm::MachineOperand::getReg(), llvm::MachineRegisterInfo::hasOneDef(), I, llvm::SmallSet< T, N, C >::insert(), llvm::MachineBasicBlock::instr_begin(), llvm::MachineBasicBlock::instr_end(), llvm::MachineInstr::isCopy(), llvm::MachineOperand::isDef(), llvm::MachineBasicBlock::isEHPad(), llvm::TargetInstrInfo::isLoadFromStackSlot(), llvm::TargetRegisterInfo::isPhysicalRegister(), llvm::MachineOperand::isReg(), llvm::MachineFrameInfo::isSpillSlotObjectIndex(), llvm::MCRegisterInfo::isSuperRegister(), llvm::MCRegAliasIterator::isValid(), llvm::Left, llvm::MachineInstr::memoperands(), llvm::MachineInstr::memoperands_empty(), MI, llvm::MachineInstr::operands(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::pop_back(), llvm::SmallVectorImpl< T >::pop_back_val(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), llvm::BitVector::set(), llvm::BitVector::setBitsNotInMask(), llvm::SmallVectorTemplateCommon< T >::size(), llvm::MachineBasicBlock::splice(), llvm::MachineBasicBlock::succ_size(), llvm::BitVector::test(), and llvm::MachineRegisterInfo::use_instructions().

◆ isOperandKill()

static bool isOperandKill ( const MachineOperand MO,
MachineRegisterInfo MRI 
)
static

◆ LoopIsOuterMostWithPredecessor()

Machine Loop Invariant Code static false bool LoopIsOuterMostWithPredecessor ( MachineLoop CurLoop)
static

◆ mayLoadFromGOTOrConstantPool()

static bool mayLoadFromGOTOrConstantPool ( MachineInstr MI)
static

Return true if this machine instruction loads from global offset table or constant pool.

Definition at line 858 of file MachineLICM.cpp.

References assert(), AvoidSpeculation, llvm::MachineInstr::canFoldAsLoad(), llvm::MachineRegisterInfo::clearKillFlags(), llvm::MachineRegisterInfo::constrainRegClass(), llvm::LoopBase< BlockT, LoopT >::contains(), llvm::MachineRegisterInfo::createVirtualRegister(), llvm::dbgs(), DEBUG, llvm::SmallVectorBase::empty(), llvm::DenseMapBase< DenseMap< KeyT, ValueT, KeyInfoT, BucketT >, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::MachineInstr::eraseFromParent(), llvm::DenseMapBase< DenseMap< KeyT, ValueT, KeyInfoT, BucketT >, KeyT, ValueT, KeyInfoT, BucketT >::find(), llvm::MCInstrInfo::get(), llvm::MachineBasicBlock::getBasicBlock(), llvm::MachineInstr::getDesc(), llvm::MachineBasicBlock::getFirstTerminator(), llvm::LoopBase< BlockT, LoopT >::getHeader(), llvm::LoopBase< BlockT, LoopT >::getLoopPredecessor(), llvm::LoopBase< BlockT, LoopT >::getLoopPreheader(), llvm::MachineInstr::getMF(), llvm::MachineBasicBlock::getNumber(), llvm::MCInstrDesc::getNumDefs(), llvm::MCInstrDesc::getNumOperands(), llvm::MachineInstr::getNumOperands(), llvm::MachineInstr::getOpcode(), llvm::TargetInstrInfo::getOpcodeAfterMemoryUnfold(), llvm::MachineInstr::getOperand(), llvm::MachineInstr::getParent(), llvm::MachineOperand::getReg(), llvm::TargetInstrInfo::getRegClass(), llvm::MachineRegisterInfo::getRegClass(), llvm::MachineRegisterInfo::getVRegDef(), llvm::TargetInstrInfo::hasHighOperandLatency(), llvm::TargetInstrInfo::hasLowDefLatency(), HoistCheapInsts, I, llvm::TargetInstrInfo::isAsCheapAsAMove(), llvm::TargetRegisterInfo::isCallerPreservedPhysReg(), llvm::MachineRegisterInfo::isConstantPhysReg(), llvm::MachineInstr::isCopyLike(), llvm::MachineOperand::isDef(), llvm::MachineInstr::isDereferenceableInvariantLoad(), isExitBlock(), llvm::MachineOperand::isImplicit(), llvm::MachineInstr::isImplicitDef(), llvm::MachineBasicBlock::isLiveIn(), llvm::TargetRegisterInfo::isPhysicalRegister(), llvm::MachineOperand::isReg(), llvm::MachineInstr::isSafeToMove(), llvm::TargetInstrInfo::isTriviallyReMaterializable(), llvm::MachineOperand::isUse(), llvm::TargetRegisterInfo::isVirtualRegister(), llvm::MachineInstr::mayLoad(), llvm::MachineInstr::memoperands(), llvm::MachineInstr::memoperands_empty(), MI, llvm::MachineInstr::operands(), llvm::SmallVectorImpl< T >::pop_back_val(), llvm::TargetInstrInfo::produceSameValue(), llvm::SmallVectorTemplateBase< T, isPodLike >::push_back(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), llvm::MachineRegisterInfo::replaceRegWith(), llvm::NVPTX::PTXCvtMode::RP, llvm::MachineInstr::setDebugLoc(), llvm::MachineRegisterInfo::setRegClass(), llvm::SmallVectorTemplateCommon< T, typename >::size(), llvm::SmallVectorTemplateCommon< T >::size(), llvm::MachineBasicBlock::splice(), llvm::MachineBasicBlock::SplitCriticalEdge(), Success, llvm::TargetInstrInfo::unfoldMemoryOperand(), llvm::MachineRegisterInfo::use_instructions(), llvm::MachineRegisterInfo::use_nodbg_empty(), llvm::MachineRegisterInfo::use_nodbg_instructions(), and UseMI.

◆ STATISTIC() [1/5]

STATISTIC ( NumHoisted  ,
"Number of machine instructions hoisted out of loops  
)

◆ STATISTIC() [2/5]

STATISTIC ( NumLowRP  ,
"Number of instructions hoisted in low reg pressure situation"   
)

◆ STATISTIC() [3/5]

STATISTIC ( NumHighLatency  ,
"Number of high latency instructions hoisted"   
)

◆ STATISTIC() [4/5]

STATISTIC ( NumCSEed  ,
"Number of hoisted machine instructions CSEed"   
)

◆ STATISTIC() [5/5]

STATISTIC ( NumPostRAHoisted  ,
"Number of machine instructions hoisted out of loops post regalloc"   
)

Variable Documentation

◆ AvoidSpeculation

cl::opt<bool> AvoidSpeculation("avoid-speculation", cl::desc("MachineLICM should avoid speculation"), cl::init(true), cl::Hidden)
static

◆ DEBUG_TYPE

DEBUG_TYPE

Definition at line 266 of file MachineLICM.cpp.

◆ false

Machine Loop Invariant Code false

Definition at line 266 of file MachineLICM.cpp.

◆ HoistCheapInsts

cl::opt<bool> HoistCheapInsts("hoist-cheap-insts", cl::desc("MachineLICM should hoist even cheap instructions"), cl::init(false), cl::Hidden)
static

◆ Motion

Machine Loop Invariant Code Motion

Definition at line 266 of file MachineLICM.cpp.

◆ SinkInstsToAvoidSpills

cl::opt<bool> SinkInstsToAvoidSpills("sink-insts-to-avoid-spills", cl::desc("MachineLICM should sink instructions into " "loops to avoid register spills"), cl::init(false), cl::Hidden)
static