|
LLVM
8.0.1
|
#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/TargetInstrInfo.h"#include "llvm/CodeGen/TargetLowering.h"#include "llvm/CodeGen/TargetRegisterInfo.h"#include "llvm/CodeGen/TargetSchedule.h"#include "llvm/CodeGen/TargetSubtargetInfo.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 <algorithm>#include <cassert>#include <limits>#include <vector>
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") | |
| STATISTIC (NumStoreConst, "Number of stores of const phys reg hoisted out of loops") | |
| INITIALIZE_PASS_BEGIN (MachineLICM, DEBUG_TYPE, "Machine Loop Invariant Code Motion", false, false) INITIALIZE_PASS_END(MachineLICM | |
| Machine Loop Invariant Code false | INITIALIZE_PASS_BEGIN (EarlyMachineLICM, "early-machinelicm", "Early Machine Loop Invariant Code Motion", false, false) INITIALIZE_PASS_END(EarlyMachineLICM |
| Machine Loop Invariant Code false early Early 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... | |
| static bool | isInvariantStore (const MachineInstr &MI, const TargetRegisterInfo *TRI, const MachineRegisterInfo *MRI) |
| static bool | isCopyFeedingInvariantStore (const MachineInstr &MI, const MachineRegisterInfo *MRI, const TargetRegisterInfo *TRI) |
Variables | |
| static cl::opt< bool > | AvoidSpeculation ("avoid-speculation", cl::desc("MachineLICM should avoid speculation"), cl::init(true), cl::Hidden) |
| static cl::opt< bool > | HoistCheapInsts ("hoist-cheap-insts", cl::desc("MachineLICM should hoist even cheap instructions"), cl::init(false), cl::Hidden) |
| static 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 cl::opt< bool > | HoistConstStores ("hoist-const-stores", cl::desc("Hoist invariant stores"), cl::init(true), cl::Hidden) |
| DEBUG_TYPE | |
| Machine Loop Invariant Code | Motion |
| Machine Loop Invariant Code | false |
| Machine Loop Invariant Code false early | machinelicm |
| #define DEBUG_TYPE "machinelicm" |
Definition at line 57 of file MachineLICM.cpp.
| INITIALIZE_PASS_BEGIN | ( | MachineLICM | , |
| DEBUG_TYPE | , | ||
| "Machine Loop Invariant Code Motion" | , | ||
| false | , | ||
| false | |||
| ) |
| Machine Loop Invariant Code false INITIALIZE_PASS_BEGIN | ( | EarlyMachineLICM | , |
| "early-machinelicm" | , | ||
| "Early Machine Loop Invariant Code Motion" | , | ||
| false | , | ||
| false | |||
| ) |
|
static |
Return true if instruction stores to the specified frame.
Definition at line 376 of file MachineLICM.cpp.
References assert(), llvm::SmallSet< T, N, C >::count(), llvm::dbgs(), llvm::tgtok::Def, llvm::MachineDominatorTree::dominates(), llvm::MachineBasicBlock::end(), llvm::LoopBase< BlockT, LoopT >::getBlocks(), llvm::LoopBase< BlockT, LoopT >::getExitingBlocks(), llvm::MachineBasicBlock::getFirstTerminator(), llvm::LoopBase< BlockT, LoopT >::getHeader(), llvm::MachineLoopInfo::getLoopFor(), llvm::MCRegisterInfo::getNumRegs(), llvm::MachineInstr::getParent(), llvm::SmallSet< T, N, C >::insert(), llvm::MachineBasicBlock::isEHPad(), llvm::TargetInstrInfo::isLoadFromStackSlot(), llvm::TargetRegisterInfo::isPhysicalRegister(), llvm::MachineFrameInfo::isSpillSlotObjectIndex(), llvm::MCRegisterInfo::isSuperRegister(), llvm::MCRegAliasIterator::isValid(), LLVM_DEBUG, llvm::MachineInstr::mayStore(), llvm::MachineInstr::memoperands(), llvm::MachineInstr::memoperands_empty(), MI, llvm::MachineInstr::operands(), llvm::SmallVectorTemplateBase< T >::pop_back(), llvm::printMBBReference(), llvm::SmallVectorTemplateBase< T >::push_back(), Reg, llvm::BitVector::set(), llvm::BitVector::setBitsNotInMask(), llvm::MachineBasicBlock::splice(), and llvm::BitVector::test().
|
static |
Definition at line 948 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(), 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::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, HoistConstStores, I, llvm::TargetInstrInfo::isAsCheapAsAMove(), llvm::TargetRegisterInfo::isCallerPreservedPhysReg(), llvm::MachineRegisterInfo::isConstantPhysReg(), llvm::MachineInstr::isCopy(), llvm::MachineInstr::isCopyLike(), llvm::MachineOperand::isDef(), llvm::MachineInstr::isDereferenceableInvariantLoad(), isExitBlock(), llvm::MachineOperand::isImplicit(), llvm::MachineInstr::isImplicitDef(), isInvariantStore(), llvm::MachineBasicBlock::isLiveIn(), llvm::TargetRegisterInfo::isPhysicalRegister(), llvm::MachineOperand::isReg(), llvm::MachineInstr::isSafeToMove(), llvm::TargetInstrInfo::isTriviallyReMaterializable(), llvm::MachineOperand::isUse(), llvm::TargetRegisterInfo::isVirtualRegister(), LLVM_DEBUG, llvm::MachineInstr::mayLoad(), mayLoadFromGOTOrConstantPool(), llvm::MachineInstr::mayStore(), MI, llvm::MachineInstr::operands(), llvm::SmallVectorImpl< T >::pop_back_val(), llvm::printMBBReference(), llvm::TargetInstrInfo::produceSameValue(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::SmallVectorTemplateBase< T >::push_back(), Reg, llvm::MachineRegisterInfo::replaceRegWith(), llvm::NVPTX::PTXCvtMode::RP, llvm::MachineInstr::setDebugLoc(), llvm::MachineRegisterInfo::setRegClass(), llvm::SmallVectorBase::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.
|
static |
Definition at line 914 of file MachineLICM.cpp.
References llvm::MachineInstr::getMF(), llvm::MachineInstr::getNumOperands(), llvm::MachineInstr::hasUnmodeledSideEffects(), llvm::TargetRegisterInfo::isCallerPreservedPhysReg(), llvm::TargetRegisterInfo::isVirtualRegister(), llvm::TargetRegisterInfo::lookThruCopyLike(), llvm::MachineInstr::mayStore(), MRI, llvm::MachineInstr::operands(), and Reg.
Referenced by isCopyFeedingInvariantStore().
|
static |
Definition at line 802 of file MachineLICM.cpp.
References llvm::TargetInstrInfo::analyzeBranch(), llvm::SmallVectorTemplateCommon< T, typename >::begin(), llvm::SmallVectorBase::empty(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::SmallVectorTemplateCommon< T, typename >::end(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), llvm::MachineInstr::getDesc(), llvm::MCInstrDesc::getNumOperands(), llvm::MachineInstr::getOperand(), llvm::MachineOperand::getReg(), llvm::MachineRegisterInfo::getRegClass(), llvm::TargetRegisterInfo::getRegClassPressureSets(), llvm::TargetRegisterInfo::getRegClassWeight(), llvm::MachineRegisterInfo::hasOneNonDBGUse(), llvm::SmallSet< T, N, C >::insert(), llvm::MachineOperand::isDef(), llvm::MachineOperand::isImplicit(), llvm::MachineInstr::isImplicitDef(), llvm::MachineOperand::isKill(), llvm::MachineOperand::isReg(), llvm::TargetRegisterInfo::isVirtualRegister(), llvm::MachineBasicBlock::pred_begin(), llvm::MachineBasicBlock::pred_size(), llvm::RegClassWeight::RegWeight, and llvm::RISCVFenceField::W.
|
static |
Test if the given loop is the outer-most loop that has a unique predecessor.
Definition at line 294 of file MachineLICM.cpp.
References llvm::MachineLoopInfo::begin(), llvm::SmallVectorTemplateCommon< T, typename >::begin(), llvm::LoopBase< BlockT, LoopT >::begin(), llvm::DenseMapBase< DenseMap< KeyT, ValueT, KeyInfoT, BucketT >, KeyT, ValueT, KeyInfoT, BucketT >::clear(), llvm::SmallVectorImpl< T >::clear(), llvm::dbgs(), llvm::MachineLoopInfo::end(), llvm::SmallVectorTemplateCommon< T, typename >::end(), llvm::LoopBase< BlockT, LoopT >::end(), llvm::LoopBase< BlockT, LoopT >::getExitBlocks(), llvm::MachineFunction::getFrameInfo(), llvm::MachineFunction::getFunction(), llvm::LoopBase< BlockT, LoopT >::getHeader(), llvm::TargetSubtargetInfo::getInstrInfo(), llvm::MachineFunction::getName(), llvm::TargetRegisterInfo::getNumRegPressureSets(), llvm::LoopBase< BlockT, LoopT >::getParentLoop(), llvm::MachineFunction::getRegInfo(), llvm::TargetSubtargetInfo::getRegisterInfo(), llvm::TargetRegisterInfo::getRegPressureSetLimit(), llvm::MachineFunction::getSubtarget(), llvm::TargetSubtargetInfo::getTargetLowering(), llvm::TargetSchedModel::init(), llvm::MachineRegisterInfo::isSSA(), LLVM_DEBUG, N, llvm::SmallVectorImpl< T >::resize(), SinkInstsToAvoidSpills, and llvm::ARM_MB::ST.
|
static |
Return true if this machine instruction loads from global offset table or constant pool.
Definition at line 891 of file MachineLICM.cpp.
References assert(), llvm::MachineInstr::mayLoad(), llvm::MachineInstr::memoperands(), and llvm::MachineInstr::memoperands_empty().
Referenced by isCopyFeedingInvariantStore().
| 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" | |||
| ) |
|
static |
Referenced by isCopyFeedingInvariantStore().
| DEBUG_TYPE |
Definition at line 282 of file MachineLICM.cpp.
Definition at line 282 of file MachineLICM.cpp.
|
static |
Referenced by isCopyFeedingInvariantStore().
|
static |
Referenced by isCopyFeedingInvariantStore().
Definition at line 290 of file MachineLICM.cpp.
Definition at line 282 of file MachineLICM.cpp.
|
static |
Referenced by LoopIsOuterMostWithPredecessor().
1.8.13