58#define DEBUG_TYPE "machinelicm"
62 cl::desc(
"MachineLICM should avoid speculation"),
67 cl::desc(
"MachineLICM should hoist even cheap instructions"),
83 cl::desc(
"Do not hoist instructions if target"
84 "block is N times hotter than the source."),
91 cl::desc(
"Disable hoisting instructions to"
95 "disable the feature"),
97 "enable the feature when using profile data"),
99 "enable the feature with/wo profile data")));
102 "Number of machine instructions hoisted out of loops");
104 "Number of instructions hoisted in low reg pressure situation");
106 "Number of high latency instructions hoisted");
108 "Number of hoisted machine instructions CSEed");
110 "Number of machine instructions hoisted out of loops post regalloc");
112 "Number of stores of const phys reg hoisted out of loops");
114 "Number of instructions not hoisted due to block frequency");
117 enum HoistResult { NotHoisted = 1, Hoisted = 2, ErasedMI = 4 };
119 class MachineLICMImpl {
126 bool PreRegAlloc =
false;
127 bool HasProfileData =
false;
138 bool Changed =
false;
139 bool FirstInLoop =
false;
153 It->second = std::move(ExitBlocks);
183 unsigned SpeculationState = SpeculateUnknown;
186 MachineLICMImpl(
bool PreRegAlloc,
Pass *LegacyPass,
188 : PreRegAlloc(PreRegAlloc), LegacyPass(LegacyPass), MFAM(MFAM) {
189 assert((LegacyPass || MFAM) &&
"LegacyPass or MFAM must be provided");
190 assert(!(LegacyPass && MFAM) &&
191 "LegacyPass and MFAM cannot be provided at the same time");
196 void releaseMemory() {
202 ExitBlockMap.
clear();
207 struct CandidateInfo {
213 :
MI(mi),
Def(def), FI(fi) {}
253 void ExitScopeIfDone(
264 bool ConsiderUnseenAsDef);
267 bool ConsiderUnseenAsDef =
false);
272 std::vector<MachineInstr *> &PrevMIs);
276 DenseMap<
unsigned, std::vector<MachineInstr *>>::iterator &CI);
285 void InitializeLoadsHoistableLoops();
296 MachineLICMBase(
char &
ID,
bool PreRegAlloc)
312 class MachineLICM :
public MachineLICMBase {
315 MachineLICM() : MachineLICMBase(
ID,
false) {
320 class EarlyMachineLICM :
public MachineLICMBase {
323 EarlyMachineLICM() : MachineLICMBase(
ID,
true) {
331char EarlyMachineLICM::ID;
337 "Machine Loop Invariant Code Motion",
false,
false)
355 if (skipFunction(MF.getFunction()))
358 MachineLICMImpl Impl(PreRegAlloc,
this,
nullptr);
362#define GET_RESULT(RESULT, GETTER, INFIX) \
364 ? &LegacyPass->getAnalysis<RESULT##INFIX##WrapperPass>().GETTER() \
365 : &MFAM->getResult<RESULT##Analysis>(MF))
374 MachineDomTreeUpdater::UpdateStrategy::Lazy);
381 Changed = FirstInLoop =
false;
383 TII = ST.getInstrInfo();
384 TLI = ST.getTargetLowering();
385 TRI = ST.getRegisterInfo();
388 SchedModel.
init(&ST);
400 unsigned NumRPS =
TRI->getNumRegPressureSets();
401 RegPressure.resize(NumRPS);
404 for (
unsigned i = 0, e = NumRPS; i != e; ++i)
405 RegLimit[i] =
TRI->getRegPressureSetLimit(MF, i);
409 InitializeLoadsHoistableLoops();
412 while (!Worklist.
empty()) {
416 HoistRegionPostRA(CurLoop);
422 HoistOutOfLoop(
N, CurLoop);
438 if (
MI->memoperands_empty())
441 if (!
MemOp->isStore() || !
MemOp->getPseudoValue())
444 dyn_cast<FixedStackPseudoSourceValue>(
MemOp->getPseudoValue())) {
445 if (
Value->getFrameIndex() == FI)
486 const unsigned NumRegs =
TRI.getNumRegs();
487 const unsigned MaskWords = (NumRegs + 31) / 32;
488 for (
unsigned K = 0; K < MaskWords; ++K) {
490 for (
unsigned Bit = 0; Bit < 32; ++Bit) {
491 const unsigned PhysReg = (K * 32) + Bit;
492 if (PhysReg == NumRegs)
495 if (PhysReg && !((Word >> Bit) & 1)) {
497 RUsFromRegsNotInMask.
set(Unit);
502 RUs |= RUsFromRegsNotInMask;
512 bool RuledOut =
false;
513 bool HasNonInvariantUse =
false;
518 int FI = MO.getIndex();
519 if (!StoredFIs.
count(FI) &&
523 HasNonInvariantUse =
true;
529 if (MO.isRegMask()) {
539 assert(
Reg.isPhysical() &&
"Not expecting virtual register!");
542 if (!HasNonInvariantUse) {
546 if (RUDefs.
test(Unit) || RUClobbers.
test(Unit)) {
547 HasNonInvariantUse =
true;
567 if (RUDefs.
test(Unit)) {
568 RUClobbers.
set(Unit);
570 }
else if (RUClobbers.
test(Unit)) {
582 if (Def && !RuledOut) {
583 int FI = std::numeric_limits<int>::min();
584 if ((!HasNonInvariantUse && IsLICMCandidate(*
MI, CurLoop)) ||
592void MachineLICMImpl::HoistRegionPostRA(
MachineLoop *CurLoop) {
597 unsigned NumRegUnits =
TRI->getNumRegUnits();
610 if (
ML &&
ML->getHeader()->isEHPad())
continue;
615 for (
const auto &LI : BB->liveins()) {
621 if (
const uint32_t *Mask = BB->getBeginClobberMask(
TRI))
631 RUClobbers.
set(Unit);
634 RUClobbers.
set(Unit);
637 SpeculationState = SpeculateUnknown;
639 ProcessMI(&
MI, RUDefs, RUClobbers, StoredFIs, Candidates, CurLoop);
645 if (TI != Preheader->
end()) {
665 for (CandidateInfo &Candidate : Candidates) {
666 if (Candidate.FI != std::numeric_limits<int>::min() &&
667 StoredFIs.
count(Candidate.FI))
673 if (RUClobbers.
test(Unit) || TermRUs.test(Unit)) {
687 if (RUDefs.
test(Unit) || RUClobbers.
test(Unit)) {
700 HoistPostRA(
MI, Candidate.Def, CurLoop);
708 if (!BB->isLiveIn(Reg))
714 if (
TRI->regsOverlap(Reg, MO.getReg()))
740 assert(!
MI->isDebugInstr() &&
"Should not hoist debug inst");
746 AddToLiveIns(Def, CurLoop);
756 if (SpeculationState != SpeculateUnknown)
757 return SpeculationState == SpeculateFalse;
765 SpeculationState = SpeculateTrue;
770 SpeculationState = SpeculateFalse;
778bool MachineLICMImpl::isTriviallyReMaterializable(
780 if (!
TII->isTriviallyReMaterializable(
MI))
784 if (MO.getReg().isVirtual())
806void MachineLICMImpl::ExitScopeIfDone(
810 if (OpenChildren[
Node])
814 ExitScope(
Node->getBlock());
817 if (!Parent || --OpenChildren[Parent] != 0)
840 while (!WorkList.
empty()) {
848 if (
ML &&
ML->getHeader()->isEHPad())
856 unsigned NumChildren =
Node->getNumChildren();
864 OpenChildren[
Node] = NumChildren;
870 ParentMap[Child] =
Node;
882 InitRegPressure(Preheader);
891 SpeculationState = SpeculateUnknown;
893 unsigned HoistRes = HoistResult::NotHoisted;
894 HoistRes = Hoist(&
MI, Preheader, CurLoop);
895 if (HoistRes & HoistResult::NotHoisted) {
900 L =
L->getParentLoop())
903 while (!InnerLoopWorkList.
empty()) {
906 if (InnerLoopPreheader) {
907 HoistRes = Hoist(&
MI, InnerLoopPreheader, InnerLoop);
908 if (HoistRes & HoistResult::Hoisted)
914 if (HoistRes & HoistResult::ErasedMI)
917 UpdateRegPressure(&
MI);
921 ExitScopeIfDone(
Node, OpenChildren, ParentMap);
947 UpdateRegPressure(&
MI,
true);
952 bool ConsiderUnseenAsDef) {
953 auto Cost = calcRegisterCost(
MI,
true, ConsiderUnseenAsDef);
954 for (
const auto &RPIdAndCost :
Cost) {
955 unsigned Class = RPIdAndCost.first;
956 if (
static_cast<int>(RegPressure[Class]) < -RPIdAndCost.second)
970MachineLICMImpl::calcRegisterCost(
const MachineInstr *
MI,
bool ConsiderSeen,
971 bool ConsiderUnseenAsDef) {
973 if (
MI->isImplicitDef())
975 for (
unsigned i = 0, e =
MI->getDesc().getNumOperands(); i != e; ++i) {
980 if (!
Reg.isVirtual())
984 bool isNew = ConsiderSeen ? RegSeen.
insert(Reg).second :
false;
990 RCCost =
W.RegWeight;
993 if (isNew && !isKill && ConsiderUnseenAsDef)
995 RCCost =
W.RegWeight;
996 else if (!isNew && isKill)
997 RCCost = -
W.RegWeight;
1001 const int *PS =
TRI->getRegClassPressureSets(RC);
1002 for (; *PS != -1; ++PS)
1003 Cost[*PS] += RCCost;
1011 assert(
MI.mayLoad() &&
"Expected MI that loads!");
1015 if (
MI.memoperands_empty())
1020 if (PSV->isGOT() || PSV->isConstantPool())
1037 bool FoundCallerPresReg =
false;
1038 if (!
MI.mayStore() ||
MI.hasUnmodeledSideEffects() ||
1039 (
MI.getNumOperands() == 0))
1048 if (Reg.isVirtual())
1050 if (Reg.isVirtual())
1052 if (!
TRI->isCallerPreservedPhysReg(Reg.asMCReg(), *
MI.getMF()))
1055 FoundCallerPresReg =
true;
1056 }
else if (!MO.
isImm()) {
1060 return FoundCallerPresReg;
1078 Register CopySrcReg =
MI.getOperand(1).getReg();
1082 if (!
TRI->isCallerPreservedPhysReg(CopySrcReg.
asMCReg(), *MF))
1085 Register CopyDstReg =
MI.getOperand(0).getReg();
1100 bool DontMoveAcrossStore = !
HoistConstLoads || !AllowedToHoistLoads[CurLoop];
1101 if ((!
I.isSafeToMove(DontMoveAcrossStore)) &&
1114 !IsGuaranteedToExecute(
I.getParent(), CurLoop)) {
1123 if (
I.isConvergent())
1126 if (!
TII->shouldHoist(
I, CurLoop))
1135 if (!IsLICMCandidate(
I, CurLoop)) {
1136 LLVM_DEBUG(
dbgs() <<
"LICM: Instruction not a LICM candidate\n");
1148 MI = Work.pop_back_val();
1151 if (!
Reg.isVirtual())
1155 if (
UseMI.isPHI()) {
1169 Work.push_back(&
UseMI);
1172 }
while (!Work.empty());
1178bool MachineLICMImpl::HasHighOperandLatency(
MachineInstr &
MI,
unsigned DefIdx,
1181 if (
MRI->use_nodbg_empty(Reg))
1185 if (
UseMI.isCopyLike())
1189 for (
unsigned i = 0, e =
UseMI.getNumOperands(); i != e; ++i) {
1197 if (
TII->hasHighOperandLatency(SchedModel,
MRI,
MI, DefIdx,
UseMI, i))
1210bool MachineLICMImpl::IsCheapInstruction(
MachineInstr &
MI)
const {
1214 bool isCheap =
false;
1215 unsigned NumDefs =
MI.getDesc().getNumDefs();
1216 for (
unsigned i = 0, e =
MI.getNumOperands(); NumDefs && i != e; ++i) {
1222 if (
Reg.isPhysical())
1225 if (!
TII->hasLowDefLatency(SchedModel,
MI, i))
1235bool MachineLICMImpl::CanCauseHighRegPressure(
1237 for (
const auto &RPIdAndCost :
Cost) {
1238 if (RPIdAndCost.second <= 0)
1241 unsigned Class = RPIdAndCost.first;
1242 int Limit = RegLimit[
Class];
1249 for (
const auto &RP : BackTrace)
1250 if (
static_cast<int>(RP[Class]) + RPIdAndCost.second >= Limit)
1260void MachineLICMImpl::UpdateBackTraceRegPressure(
const MachineInstr *
MI) {
1263 auto Cost = calcRegisterCost(
MI,
false,
1267 for (
auto &RP : BackTrace)
1268 for (
const auto &RPIdAndCost :
Cost)
1269 RP[RPIdAndCost.first] += RPIdAndCost.second;
1276 if (
MI.isImplicitDef())
1294 bool CheapInstr = IsCheapInstruction(
MI);
1295 bool CreatesCopy = HasLoopPHIUse(&
MI, CurLoop);
1298 if (CheapInstr && CreatesCopy) {
1305 if (isTriviallyReMaterializable(
MI))
1310 for (
unsigned i = 0, e =
MI.getDesc().getNumOperands(); i != e; ++i) {
1315 if (!
Reg.isVirtual())
1317 if (MO.
isDef() && HasHighOperandLatency(
MI, i, Reg, CurLoop)) {
1330 auto Cost = calcRegisterCost(&
MI,
false,
1335 if (!CanCauseHighRegPressure(
Cost, CheapInstr)) {
1351 (!IsGuaranteedToExecute(
MI.getParent(), CurLoop) && !MayCSE(&
MI))) {
1359 if (
MI.isCopy() ||
MI.isRegSequence()) {
1364 return !UseOp.isReg() || UseOp.getReg().isVirtual() ||
1365 MRI->isConstantPhysReg(UseOp.getReg());
1367 IsLoopInvariantInst(
MI, CurLoop) &&
1368 any_of(
MRI->use_nodbg_instructions(DefReg),
1369 [&CurLoop,
this, DefReg,
1371 if (!CurLoop->contains(&UseMI))
1378 if (CanCauseHighRegPressure(Cost, false) &&
1379 !CurLoop->isLoopInvariant(UseMI, DefReg))
1389 if (!isTriviallyReMaterializable(
MI) &&
1390 !
MI.isDereferenceableInvariantLoad()) {
1404 if (
MI->canFoldAsLoad())
1410 if (!
MI->isDereferenceableInvariantLoad())
1414 unsigned LoadRegIndex;
1416 TII->getOpcodeAfterMemoryUnfold(
MI->getOpcode(),
1420 if (NewOpc == 0)
return nullptr;
1433 "unfoldMemoryOperand failed when getOpcodeAfterMemoryUnfold "
1436 "Unfolded a load into multiple instructions!");
1443 if (!IsLoopInvariantInst(*NewMIs[0], CurLoop) ||
1444 !IsProfitableToHoist(*NewMIs[0], CurLoop)) {
1445 NewMIs[0]->eraseFromParent();
1446 NewMIs[1]->eraseFromParent();
1451 UpdateRegPressure(NewMIs[1]);
1456 if (
MI->shouldUpdateAdditionalCallInfo())
1459 MI->eraseFromParent();
1473void MachineLICMImpl::InitializeLoadsHoistableLoops() {
1479 while (!Worklist.empty()) {
1480 auto *
L = Worklist.pop_back_val();
1481 AllowedToHoistLoads[
L] =
true;
1496 if (!AllowedToHoistLoads[
Loop])
1498 for (
auto &
MI : *
MBB) {
1499 if (!
MI.isLoadFoldBarrier() && !
MI.mayStore() && !
MI.isCall() &&
1500 !(
MI.mayLoad() &&
MI.hasOrderedMemoryRef()))
1503 AllowedToHoistLoads[
L] =
false;
1514 std::vector<MachineInstr *> &PrevMIs) {
1516 if (
TII->produceSameValue(*
MI, *PrevMI, (PreRegAlloc ?
MRI :
nullptr)))
1526bool MachineLICMImpl::EliminateCSE(
1528 DenseMap<
unsigned, std::vector<MachineInstr *>>::iterator &CI) {
1531 if (
MI->isImplicitDef())
1536 if (
MI->mayLoad() && !
MI->isDereferenceableInvariantLoad())
1545 for (
unsigned i = 0, e =
MI->getNumOperands(); i != e; ++i) {
1550 MO.
getReg() == Dup->getOperand(i).getReg()) &&
1551 "Instructions with different phys regs are not identical!");
1558 for (
unsigned i = 0, e = Defs.
size(); i != e; ++i) {
1559 unsigned Idx = Defs[i];
1564 if (!
MRI->constrainRegClass(DupReg,
MRI->getRegClass(Reg))) {
1566 for (
unsigned j = 0;
j != i; ++
j)
1567 MRI->setRegClass(Dup->getOperand(Defs[j]).getReg(), OrigRCs[j]);
1572 for (
unsigned Idx : Defs) {
1575 MRI->replaceRegWith(Reg, DupReg);
1576 MRI->clearKillFlags(DupReg);
1578 if (!
MRI->use_nodbg_empty(DupReg))
1579 Dup->getOperand(
Idx).setIsDead(
false);
1582 MI->eraseFromParent();
1592 if (
MI->mayLoad() && !
MI->isDereferenceableInvariantLoad())
1595 unsigned Opcode =
MI->getOpcode();
1596 for (
auto &Map : CSEMap) {
1600 Map.second.find(Opcode);
1603 if (CI ==
Map.second.end() ||
MI->isImplicitDef())
1605 if (LookForDuplicate(
MI, CI->second) !=
nullptr)
1623 isTgtHotterThanSrc(SrcBlock, Preheader)) {
1624 ++NumNotHoistedDueToHotness;
1625 return HoistResult::NotHoisted;
1628 bool HasExtractHoistableLoad =
false;
1629 if (!IsLoopInvariantInst(*
MI, CurLoop) ||
1630 !IsProfitableToHoist(*
MI, CurLoop)) {
1632 MI = ExtractHoistableLoad(
MI, CurLoop);
1634 return HoistResult::NotHoisted;
1635 HasExtractHoistableLoad =
true;
1646 dbgs() <<
"Hoisting " << *
MI;
1647 if (
MI->getParent()->getBasicBlock())
1657 InitCSEMap(Preheader);
1658 FirstInLoop =
false;
1662 unsigned Opcode =
MI->getOpcode();
1663 bool HasCSEDone =
false;
1664 for (
auto &Map : CSEMap) {
1668 Map.second.find(Opcode);
1669 if (CI !=
Map.second.end()) {
1670 if (EliminateCSE(
MI, CI)) {
1685 assert(!
MI->isDebugInstr() &&
"Should not hoist debug inst");
1689 UpdateBackTraceRegPressure(
MI);
1698 CSEMap[Preheader][Opcode].push_back(
MI);
1704 if (HasCSEDone || HasExtractHoistableLoad)
1705 return HoistResult::Hoisted | HoistResult::ErasedMI;
1706 return HoistResult::Hoisted;
1720 CurLoop->
getHeader(), LegacyPass, MFAM,
nullptr, MDTU);
1723 return NewPreheader;
1741 double Ratio = (double)DstBF / SrcBF;
1747template <
typename DerivedT,
bool PreRegAlloc>
1750 bool Changed = MachineLICMImpl(PreRegAlloc,
nullptr, &MFAM).run(MF);
unsigned const MachineRegisterInfo * MRI
MachineInstrBuilder & UseMI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file implements the BitVector class.
COFF::MachineTypes Machine
Analysis containing CSE Info
#define clEnumValN(ENUMVAL, FLAGNAME, DESC)
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
This file defines the DenseMap class.
const HexagonInstrInfo * TII
static bool isExitBlock(BasicBlock *BB, const SmallVectorImpl< BasicBlock * > &ExitBlocks)
Return true if the specified block is in the list.
Machine Loop Invariant Code false early machinelicm
static cl::opt< bool > HoistConstStores("hoist-const-stores", cl::desc("Hoist invariant stores"), cl::init(true), cl::Hidden)
#define GET_RESULT(RESULT, GETTER, INFIX)
static cl::opt< UseBFI > DisableHoistingToHotterBlocks("disable-hoisting-to-hotter-blocks", cl::desc("Disable hoisting instructions to" " hotter blocks"), cl::init(UseBFI::PGO), cl::Hidden, cl::values(clEnumValN(UseBFI::None, "none", "disable the feature"), clEnumValN(UseBFI::PGO, "pgo", "enable the feature when using profile data"), clEnumValN(UseBFI::All, "all", "enable the feature with/wo profile data")))
static bool mayLoadFromGOTOrConstantPool(MachineInstr &MI)
Return true if this machine instruction loads from global offset table or constant pool.
static bool isOperandKill(const MachineOperand &MO, MachineRegisterInfo *MRI)
static cl::opt< bool > HoistConstLoads("hoist-const-loads", cl::desc("Hoist invariant loads"), cl::init(true), cl::Hidden)
Machine Loop Invariant Code Motion
static cl::opt< bool > AvoidSpeculation("avoid-speculation", cl::desc("MachineLICM should avoid speculation"), cl::init(true), cl::Hidden)
static bool InstructionStoresToFI(const MachineInstr *MI, int FI)
Return true if instruction stores to the specified frame.
static bool isCopyFeedingInvariantStore(const MachineInstr &MI, const MachineRegisterInfo *MRI, const TargetRegisterInfo *TRI)
static void applyBitsNotInRegMaskToRegUnitsMask(const TargetRegisterInfo &TRI, BitVector &RUs, const uint32_t *Mask)
static cl::opt< bool > HoistCheapInsts("hoist-cheap-insts", cl::desc("MachineLICM should hoist even cheap instructions"), cl::init(false), cl::Hidden)
static bool isInvariantStore(const MachineInstr &MI, const TargetRegisterInfo *TRI, const MachineRegisterInfo *MRI)
static cl::opt< unsigned > BlockFrequencyRatioThreshold("block-freq-ratio-threshold", cl::desc("Do not hoist instructions if target" "block is N times hotter than the source."), cl::init(100), cl::Hidden)
Register const TargetRegisterInfo * TRI
#define INITIALIZE_PASS_DEPENDENCY(depName)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
const SmallVectorImpl< MachineOperand > MachineBasicBlock * TBB
const SmallVectorImpl< MachineOperand > & Cond
This file defines the SmallVector class.
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
This file describes how to lower LLVM code to machine code.
A manager for alias analyses.
A wrapper pass to provide the legacy pass manager access to a suitably prepared AAResults object.
AAResults & getAAResults()
A private abstract base class describing the concept of an individual alias analysis implementation.
A container for analyses that lazily runs them and caches their results.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Represent the analysis usage information of a pass.
AnalysisUsage & addRequired()
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
bool test(unsigned Idx) const
uint64_t getFrequency() const
Returns the frequency as a fixpoint number scaled by the entry frequency.
This is an important base class in LLVM.
ValueT lookup(const_arg_type_t< KeyT > Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
std::pair< iterator, bool > try_emplace(KeyT &&Key, Ts &&...Args)
Base class for the actual dominator tree node.
DomTreeNodeBase< NodeT > * getNode(const NodeT *BB) const
getNode - return the (Post)DominatorTree node for the specified basic block.
A specialized PseudoSourceValue for holding FixedStack values, which must include a frame index.
Constant * getPersonalityFn() const
Get the personality function associated with this function.
bool hasProfileData(bool IncludeSynthetic=false) const
Return true if the function is annotated with profile data.
DomTreeT & getDomTree()
Flush DomTree updates and return DomTree.
Register isLoadFromStackSlot(const MachineInstr &MI, int &FrameIndex) const override
TargetInstrInfo overrides.
bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, SmallVectorImpl< MachineOperand > &Cond, bool AllowModify) const override
Analyze the branching code at the end of MBB, returning true if it cannot be understood (e....
bool isAsCheapAsAMove(const MachineInstr &MI) const override
bool contains(const LoopT *L) const
Return true if the specified loop is contained within in this loop.
void getExitBlocks(SmallVectorImpl< BlockT * > &ExitBlocks) const
Return all of the successor blocks of this loop.
void getExitingBlocks(SmallVectorImpl< BlockT * > &ExitingBlocks) const
Return all blocks inside the loop that have successors outside of the loop.
BlockT * getHeader() const
iterator_range< block_iterator > blocks() const
BlockT * getLoopPredecessor() const
If the given loop's header has exactly one unique predecessor outside the loop, return it.
BlockT * getLoopPreheader() const
If there is a preheader for this loop, return it.
ArrayRef< BlockT * > getBlocks() const
Get a list of the basic blocks which make up this loop.
LoopT * getLoopFor(const BlockT *BB) const
Return the inner most loop that BB lives in.
Represents a single loop in the control flow graph.
Describe properties that are true of each instruction in the target description file.
Wrapper class representing physical registers. Should be passed by value.
unsigned pred_size() const
MachineBasicBlock * SplitCriticalEdge(MachineBasicBlock *Succ, Pass &P, std::vector< SparseBitVector<> > *LiveInSets=nullptr, MachineDomTreeUpdater *MDTU=nullptr)
LLVM_ABI instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
const BasicBlock * getBasicBlock() const
Return the LLVM basic block that this instance corresponded to originally.
LLVM_ABI iterator getFirstTerminator()
Returns an iterator to the first terminator instruction of this basic block.
unsigned succ_size() const
pred_iterator pred_begin()
void splice(iterator Where, MachineBasicBlock *Other, iterator From)
Take an instruction from MBB 'Other' at the position From, and insert it into this MBB right before '...
MachineBlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate machine basic b...
LLVM_ABI BlockFrequency getBlockFreq(const MachineBasicBlock *MBB) const
getblockFreq - Return block frequency.
Analysis pass which computes a MachineDominatorTree.
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...
bool dominates(const MachineInstr *A, const MachineInstr *B) const
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
bool isSpillSlotObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a spill slot.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
virtual bool runOnMachineFunction(MachineFunction &MF)=0
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Function & getFunction()
Return the LLVM function that this machine code represents.
void eraseAdditionalCallInfo(const MachineInstr *MI)
Following functions update call site info.
Representation of each machine instruction.
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
Analysis pass that exposes the MachineLoopInfo for a machine function.
LLVM_ABI bool isLoopInvariant(MachineInstr &I, const Register ExcludeReg=0) const
Returns true if the instruction is loop invariant.
A description of a memory reference used in the backend.
MachineOperand class - Representation of each machine instruction operand.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
Register getReg() const
getReg - Returns the register number.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
static LLVM_ABI PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Pass interface - Implemented by all 'passes'.
AnalysisType & getAnalysis() const
getAnalysis<AnalysisType>() - This function is used by subclasses to get to the analysis information ...
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Special value supplied for machine level alias analysis.
Wrapper class representing virtual and physical registers.
MCRegister asMCReg() const
Utility to check-convert this value to a MCRegister.
constexpr bool isVirtual() const
Return true if the specified register number is in the virtual register namespace.
constexpr bool isPhysical() const
Return true if the specified register number is in the physical register namespace.
Implements a dense probed hash-table based set with some number of buckets stored inline.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
TargetInstrInfo - Interface to description of machine instruction set.
This base class for TargetLowering contains the SelectionDAG-independent parts that can be used from ...
virtual Register getExceptionPointerRegister(const Constant *PersonalityFn) const
If a physical register, this returns the register that receives the exception address on entry to an ...
virtual Register getExceptionSelectorRegister(const Constant *PersonalityFn) const
If a physical register, this returns the register that receives the exception typeid on entry to a la...
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
Provide an instruction scheduling machine model to CodeGen passes.
LLVM_ABI void init(const TargetSubtargetInfo *TSInfo, bool EnableSModel=true, bool EnableSItins=true)
Initialize the machine model for instruction scheduling.
TargetSubtargetInfo - Generic base class for all target subtargets.
virtual const TargetLowering * getTargetLowering() const
LLVM Value Representation.
std::pair< iterator, bool > insert(const ValueT &V)
size_type count(const_arg_type_t< ValueT > V) const
Return 1 if the specified key is in the set, 0 otherwise.
Reg
All possible values of the reg field in the ModR/M byte.
ValuesClass values(OptsTy... Options)
Helper to build a ValuesClass by forwarding a variable number of arguments as an initializer list to ...
initializer< Ty > init(const Ty &Val)
PointerTypeMap run(const Module &M)
Compute the PointerTypeMap for the module M.
NodeAddr< DefNode * > Def
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI char & EarlyMachineLICMID
This pass performs loop invariant code motion on machine instructions.
void fill(R &&Range, T &&Value)
Provide wrappers to std::fill which take ranges instead of having to pass begin/end explicitly.
LLVM_ABI void initializeMachineLICMPass(PassRegistry &)
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
LLVM_ABI void initializeEarlyMachineLICMPass(PassRegistry &)
void append_range(Container &C, Range &&R)
Wrapper function to append range R to container C.
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
LLVM_ABI PreservedAnalyses getMachineFunctionPassPreservedAnalyses()
Returns the minimum set of Analyses that all machine function passes must preserve.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
auto reverse(ContainerTy &&C)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
LLVM_ABI char & MachineLICMID
This pass performs loop invariant code motion on machine instructions.
LLVM_ABI Printable printMBBReference(const MachineBasicBlock &MBB)
Prints a machine basic block reference.
Each TargetRegisterClass has a per register weight, and weight limit which must be less than the limi...