60#define DEBUG_TYPE "machinelicm"
64 cl::desc(
"MachineLICM should avoid speculation"),
69 cl::desc(
"MachineLICM should hoist even cheap instructions"),
85 cl::desc(
"Do not hoist instructions if target"
86 "block is N times hotter than the source."),
93 cl::desc(
"Disable hoisting instructions to"
97 "disable the feature"),
99 "enable the feature when using profile data"),
101 "enable the feature with/wo profile data")));
104 "Number of machine instructions hoisted out of loops");
106 "Number of instructions hoisted in low reg pressure situation");
108 "Number of high latency instructions hoisted");
110 "Number of hoisted machine instructions CSEed");
112 "Number of machine instructions hoisted out of loops post regalloc");
114 "Number of stores of const phys reg hoisted out of loops");
116 "Number of instructions not hoisted due to block frequency");
119 enum HoistResult { NotHoisted = 1, Hoisted = 2, ErasedMI = 4 };
121 class MachineLICMImpl {
129 bool PreRegAlloc =
false;
130 bool HasProfileData =
false;
141 bool Changed =
false;
142 bool FirstInLoop =
false;
156 It->second = std::move(ExitBlocks);
186 unsigned SpeculationState = SpeculateUnknown;
189 MachineLICMImpl(
bool PreRegAlloc,
Pass *LegacyPass,
191 : PreRegAlloc(PreRegAlloc), LegacyPass(LegacyPass), MFAM(MFAM) {
192 assert((LegacyPass || MFAM) &&
"LegacyPass or MFAM must be provided");
193 assert(!(LegacyPass && MFAM) &&
194 "LegacyPass and MFAM cannot be provided at the same time");
199 void releaseMemory() {
205 ExitBlockMap.
clear();
210 struct CandidateInfo {
216 :
MI(mi),
Def(def), FI(fi) {}
258 void ExitScopeIfDone(
270 bool ConsiderUnseenAsDef);
273 bool ConsiderUnseenAsDef =
false);
278 std::vector<MachineInstr *> &PrevMIs);
282 DenseMap<
unsigned, std::vector<MachineInstr *>>::iterator &CI);
291 void InitializeLoadsHoistableLoops();
303 MachineLICMBase(
char &
ID,
bool PreRegAlloc)
319 class MachineLICM :
public MachineLICMBase {
322 MachineLICM() : MachineLICMBase(
ID,
false) {
327 class EarlyMachineLICM :
public MachineLICMBase {
330 EarlyMachineLICM() : MachineLICMBase(
ID,
true) {
338char EarlyMachineLICM::ID;
344 "Machine Loop Invariant Code Motion",
false,
false)
362 if (skipFunction(MF.getFunction()))
365 MachineLICMImpl Impl(PreRegAlloc,
this,
nullptr);
369#define GET_RESULT(RESULT, GETTER, INFIX) \
371 ? &LegacyPass->getAnalysis<RESULT##INFIX##WrapperPass>().GETTER() \
372 : &MFAM->getResult<RESULT##Analysis>(MF))
381 MachineDomTreeUpdater::UpdateStrategy::Lazy);
388 Changed = FirstInLoop =
false;
390 TII = ST.getInstrInfo();
391 TLI = ST.getTargetLowering();
392 TRI = ST.getRegisterInfo();
395 SchedModel.
init(&ST);
408 unsigned NumRPS =
TRI->getNumRegPressureSets();
409 RegPressure.resize(NumRPS);
410 std::fill(RegPressure.begin(), RegPressure.end(), 0);
412 for (
unsigned i = 0, e = NumRPS; i != e; ++i)
417 InitializeLoadsHoistableLoops();
420 while (!Worklist.
empty()) {
425 HoistRegionPostRA(CurLoop, CurPreheader);
431 HoistOutOfLoop(
N, CurLoop, CurPreheader);
447 if (
MI->memoperands_empty())
450 if (!
MemOp->isStore() || !
MemOp->getPseudoValue())
453 dyn_cast<FixedStackPseudoSourceValue>(
MemOp->getPseudoValue())) {
454 if (
Value->getFrameIndex() == FI)
495 const unsigned NumRegs =
TRI.getNumRegs();
496 const unsigned MaskWords = (NumRegs + 31) / 32;
497 for (
unsigned K = 0; K < MaskWords; ++K) {
499 for (
unsigned Bit = 0; Bit < 32; ++Bit) {
500 const unsigned PhysReg = (K * 32) + Bit;
501 if (PhysReg == NumRegs)
504 if (PhysReg && !((Word >> Bit) & 1)) {
506 RUsFromRegsNotInMask.
set(*RUI);
511 RUs |= RUsFromRegsNotInMask;
521 bool RuledOut =
false;
522 bool HasNonInvariantUse =
false;
527 int FI = MO.getIndex();
528 if (!StoredFIs.
count(FI) &&
532 HasNonInvariantUse =
true;
538 if (MO.isRegMask()) {
548 assert(
Reg.isPhysical() &&
"Not expecting virtual register!");
551 if (!HasNonInvariantUse) {
555 if (RUDefs.
test(*RUI) || RUClobbers.
test(*RUI)) {
556 HasNonInvariantUse =
true;
564 if (MO.isImplicit()) {
566 RUClobbers.
set(*RUI);
586 if (RUDefs.
test(*RUI)) {
587 RUClobbers.
set(*RUI);
589 }
else if (RUClobbers.
test(*RUI)) {
601 if (Def && !RuledOut) {
602 int FI = std::numeric_limits<int>::min();
603 if ((!HasNonInvariantUse && IsLICMCandidate(*
MI, CurLoop)) ||
611void MachineLICMImpl::HoistRegionPostRA(
MachineLoop *CurLoop,
617 unsigned NumRegUnits =
TRI->getNumRegUnits();
630 if (
ML &&
ML->getHeader()->isEHPad())
continue;
635 for (
const auto &LI : BB->liveins()) {
641 if (
const uint32_t *Mask = BB->getBeginClobberMask(
TRI))
644 SpeculationState = SpeculateUnknown;
646 ProcessMI(&
MI, RUDefs, RUClobbers, StoredFIs, Candidates, CurLoop);
652 if (TI != Preheader->
end()) {
672 for (CandidateInfo &Candidate : Candidates) {
673 if (Candidate.FI != std::numeric_limits<int>::min() &&
674 StoredFIs.
count(Candidate.FI))
677 unsigned Def = Candidate.Def;
680 if (RUClobbers.
test(*RUI) || TermRUs.test(*RUI)) {
694 if (RUDefs.
test(*RUI) || RUClobbers.
test(*RUI)) {
707 HoistPostRA(
MI, Candidate.Def, CurLoop, CurPreheader);
715 if (!BB->isLiveIn(Reg))
721 if (
TRI->regsOverlap(Reg, MO.getReg()))
748 assert(!
MI->isDebugInstr() &&
"Should not hoist debug inst");
754 AddToLiveIns(Def, CurLoop);
764 if (SpeculationState != SpeculateUnknown)
765 return SpeculationState == SpeculateFalse;
773 SpeculationState = SpeculateTrue;
778 SpeculationState = SpeculateFalse;
786bool MachineLICMImpl::isTriviallyReMaterializable(
788 if (!
TII->isTriviallyReMaterializable(
MI))
792 if (MO.getReg().isVirtual())
814void MachineLICMImpl::ExitScopeIfDone(
818 if (OpenChildren[
Node])
822 ExitScope(
Node->getBlock());
825 if (!Parent || --OpenChildren[Parent] != 0)
849 while (!WorkList.
empty()) {
857 if (
ML &&
ML->getHeader()->isEHPad())
865 unsigned NumChildren =
Node->getNumChildren();
873 OpenChildren[
Node] = NumChildren;
879 ParentMap[Child] =
Node;
891 InitRegPressure(Preheader);
900 SpeculationState = SpeculateUnknown;
902 unsigned HoistRes = HoistResult::NotHoisted;
903 HoistRes = Hoist(&
MI, Preheader, CurLoop);
904 if (HoistRes & HoistResult::NotHoisted) {
909 L =
L->getParentLoop())
912 while (!InnerLoopWorkList.
empty()) {
915 if (InnerLoopPreheader) {
916 HoistRes = Hoist(&
MI, InnerLoopPreheader, InnerLoop);
917 if (HoistRes & HoistResult::Hoisted)
923 if (HoistRes & HoistResult::ErasedMI)
926 UpdateRegPressure(&
MI);
930 ExitScopeIfDone(
Node, OpenChildren, ParentMap);
956 UpdateRegPressure(&
MI,
true);
961 bool ConsiderUnseenAsDef) {
962 auto Cost = calcRegisterCost(
MI,
true, ConsiderUnseenAsDef);
963 for (
const auto &RPIdAndCost :
Cost) {
964 unsigned Class = RPIdAndCost.first;
965 if (
static_cast<int>(RegPressure[Class]) < -RPIdAndCost.second)
979MachineLICMImpl::calcRegisterCost(
const MachineInstr *
MI,
bool ConsiderSeen,
980 bool ConsiderUnseenAsDef) {
982 if (
MI->isImplicitDef())
984 for (
unsigned i = 0, e =
MI->getDesc().getNumOperands(); i != e; ++i) {
989 if (!
Reg.isVirtual())
993 bool isNew = ConsiderSeen ? RegSeen.
insert(Reg).second :
false;
999 RCCost =
W.RegWeight;
1002 if (isNew && !isKill && ConsiderUnseenAsDef)
1004 RCCost =
W.RegWeight;
1005 else if (!isNew && isKill)
1006 RCCost = -
W.RegWeight;
1010 const int *PS =
TRI->getRegClassPressureSets(RC);
1011 for (; *PS != -1; ++PS)
1012 Cost[*PS] += RCCost;
1020 assert(
MI.mayLoad() &&
"Expected MI that loads!");
1024 if (
MI.memoperands_empty())
1029 if (PSV->isGOT() || PSV->isConstantPool())
1046 bool FoundCallerPresReg =
false;
1047 if (!
MI.mayStore() ||
MI.hasUnmodeledSideEffects() ||
1048 (
MI.getNumOperands() == 0))
1057 if (Reg.isVirtual())
1059 if (Reg.isVirtual())
1061 if (!
TRI->isCallerPreservedPhysReg(Reg.asMCReg(), *
MI.getMF()))
1064 FoundCallerPresReg =
true;
1065 }
else if (!MO.
isImm()) {
1069 return FoundCallerPresReg;
1087 Register CopySrcReg =
MI.getOperand(1).getReg();
1091 if (!
TRI->isCallerPreservedPhysReg(CopySrcReg.
asMCReg(), *MF))
1094 Register CopyDstReg =
MI.getOperand(0).getReg();
1109 bool DontMoveAcrossStore = !
HoistConstLoads || !AllowedToHoistLoads[CurLoop];
1110 if ((!
I.isSafeToMove(DontMoveAcrossStore)) &&
1123 !IsGuaranteedToExecute(
I.getParent(), CurLoop)) {
1132 if (
I.isConvergent())
1135 if (!
TII->shouldHoist(
I, CurLoop))
1144 if (!IsLICMCandidate(
I, CurLoop)) {
1145 LLVM_DEBUG(
dbgs() <<
"LICM: Instruction not a LICM candidate\n");
1157 MI = Work.pop_back_val();
1160 if (!
Reg.isVirtual())
1164 if (
UseMI.isPHI()) {
1178 Work.push_back(&
UseMI);
1181 }
while (!Work.empty());
1187bool MachineLICMImpl::HasHighOperandLatency(
MachineInstr &
MI,
unsigned DefIdx,
1190 if (
MRI->use_nodbg_empty(Reg))
1194 if (
UseMI.isCopyLike())
1198 for (
unsigned i = 0, e =
UseMI.getNumOperands(); i != e; ++i) {
1206 if (
TII->hasHighOperandLatency(SchedModel,
MRI,
MI, DefIdx,
UseMI, i))
1219bool MachineLICMImpl::IsCheapInstruction(
MachineInstr &
MI)
const {
1223 bool isCheap =
false;
1224 unsigned NumDefs =
MI.getDesc().getNumDefs();
1225 for (
unsigned i = 0, e =
MI.getNumOperands(); NumDefs && i != e; ++i) {
1231 if (
Reg.isPhysical())
1234 if (!
TII->hasLowDefLatency(SchedModel,
MI, i))
1244bool MachineLICMImpl::CanCauseHighRegPressure(
1246 for (
const auto &RPIdAndCost :
Cost) {
1247 if (RPIdAndCost.second <= 0)
1250 unsigned Class = RPIdAndCost.first;
1251 int Limit = RegLimit[
Class];
1258 for (
const auto &RP : BackTrace)
1259 if (
static_cast<int>(RP[Class]) + RPIdAndCost.second >= Limit)
1269void MachineLICMImpl::UpdateBackTraceRegPressure(
const MachineInstr *
MI) {
1272 auto Cost = calcRegisterCost(
MI,
false,
1276 for (
auto &RP : BackTrace)
1277 for (
const auto &RPIdAndCost :
Cost)
1278 RP[RPIdAndCost.first] += RPIdAndCost.second;
1285 if (
MI.isImplicitDef())
1303 bool CheapInstr = IsCheapInstruction(
MI);
1304 bool CreatesCopy = HasLoopPHIUse(&
MI, CurLoop);
1307 if (CheapInstr && CreatesCopy) {
1314 if (isTriviallyReMaterializable(
MI))
1319 for (
unsigned i = 0, e =
MI.getDesc().getNumOperands(); i != e; ++i) {
1324 if (!
Reg.isVirtual())
1326 if (MO.
isDef() && HasHighOperandLatency(
MI, i, Reg, CurLoop)) {
1339 auto Cost = calcRegisterCost(&
MI,
false,
1344 if (!CanCauseHighRegPressure(
Cost, CheapInstr)) {
1360 (!IsGuaranteedToExecute(
MI.getParent(), CurLoop) && !MayCSE(&
MI))) {
1368 if (
MI.isCopy() ||
MI.isRegSequence()) {
1373 return !UseOp.isReg() || UseOp.getReg().isVirtual() ||
1374 MRI->isConstantPhysReg(UseOp.getReg());
1376 IsLoopInvariantInst(
MI, CurLoop) &&
1377 any_of(
MRI->use_nodbg_instructions(DefReg),
1378 [&CurLoop,
this, DefReg,
1380 if (!CurLoop->contains(&UseMI))
1387 if (CanCauseHighRegPressure(Cost, false) &&
1388 !CurLoop->isLoopInvariant(UseMI, DefReg))
1398 if (!isTriviallyReMaterializable(
MI) &&
1399 !
MI.isDereferenceableInvariantLoad()) {
1413 if (
MI->canFoldAsLoad())
1419 if (!
MI->isDereferenceableInvariantLoad())
1423 unsigned LoadRegIndex;
1425 TII->getOpcodeAfterMemoryUnfold(
MI->getOpcode(),
1429 if (NewOpc == 0)
return nullptr;
1442 "unfoldMemoryOperand failed when getOpcodeAfterMemoryUnfold "
1445 "Unfolded a load into multiple instructions!");
1452 if (!IsLoopInvariantInst(*NewMIs[0], CurLoop) ||
1453 !IsProfitableToHoist(*NewMIs[0], CurLoop)) {
1454 NewMIs[0]->eraseFromParent();
1455 NewMIs[1]->eraseFromParent();
1460 UpdateRegPressure(NewMIs[1]);
1465 if (
MI->shouldUpdateCallSiteInfo())
1468 MI->eraseFromParent();
1482void MachineLICMImpl::InitializeLoadsHoistableLoops() {
1488 while (!Worklist.empty()) {
1489 auto *
L = Worklist.pop_back_val();
1490 AllowedToHoistLoads[
L] =
true;
1492 Worklist.insert(Worklist.end(),
L->getSubLoops().begin(),
1493 L->getSubLoops().end());
1506 if (!AllowedToHoistLoads[
Loop])
1508 for (
auto &
MI : *
MBB) {
1509 if (!
MI.isLoadFoldBarrier() && !
MI.mayStore() && !
MI.isCall() &&
1510 !(
MI.mayLoad() &&
MI.hasOrderedMemoryRef()))
1513 AllowedToHoistLoads[
L] =
false;
1524 std::vector<MachineInstr *> &PrevMIs) {
1526 if (
TII->produceSameValue(*
MI, *PrevMI, (PreRegAlloc ?
MRI :
nullptr)))
1536bool MachineLICMImpl::EliminateCSE(
1538 DenseMap<
unsigned, std::vector<MachineInstr *>>::iterator &CI) {
1541 if (
MI->isImplicitDef())
1546 if (
MI->mayLoad() && !
MI->isDereferenceableInvariantLoad())
1555 for (
unsigned i = 0, e =
MI->getNumOperands(); i != e; ++i) {
1560 MO.
getReg() == Dup->getOperand(i).getReg()) &&
1561 "Instructions with different phys regs are not identical!");
1568 for (
unsigned i = 0, e = Defs.
size(); i != e; ++i) {
1569 unsigned Idx = Defs[i];
1574 if (!
MRI->constrainRegClass(DupReg,
MRI->getRegClass(Reg))) {
1576 for (
unsigned j = 0;
j != i; ++
j)
1577 MRI->setRegClass(Dup->getOperand(Defs[j]).getReg(), OrigRCs[j]);
1582 for (
unsigned Idx : Defs) {
1585 MRI->replaceRegWith(Reg, DupReg);
1586 MRI->clearKillFlags(DupReg);
1588 if (!
MRI->use_nodbg_empty(DupReg))
1589 Dup->getOperand(
Idx).setIsDead(
false);
1592 MI->eraseFromParent();
1602 if (
MI->mayLoad() && !
MI->isDereferenceableInvariantLoad())
1605 unsigned Opcode =
MI->getOpcode();
1606 for (
auto &Map : CSEMap) {
1610 Map.second.find(Opcode);
1613 if (CI ==
Map.second.end() ||
MI->isImplicitDef())
1615 if (LookForDuplicate(
MI, CI->second) !=
nullptr)
1633 isTgtHotterThanSrc(SrcBlock, Preheader)) {
1634 ++NumNotHoistedDueToHotness;
1635 return HoistResult::NotHoisted;
1638 bool HasExtractHoistableLoad =
false;
1639 if (!IsLoopInvariantInst(*
MI, CurLoop) ||
1640 !IsProfitableToHoist(*
MI, CurLoop)) {
1642 MI = ExtractHoistableLoad(
MI, CurLoop);
1644 return HoistResult::NotHoisted;
1645 HasExtractHoistableLoad =
true;
1656 dbgs() <<
"Hoisting " << *
MI;
1657 if (
MI->getParent()->getBasicBlock())
1667 InitCSEMap(Preheader);
1668 FirstInLoop =
false;
1672 unsigned Opcode =
MI->getOpcode();
1673 bool HasCSEDone =
false;
1674 for (
auto &Map : CSEMap) {
1678 Map.second.find(Opcode);
1679 if (CI !=
Map.second.end()) {
1680 if (EliminateCSE(
MI, CI)) {
1695 assert(!
MI->isDebugInstr() &&
"Should not hoist debug inst");
1699 UpdateBackTraceRegPressure(
MI);
1708 CSEMap[Preheader][Opcode].push_back(
MI);
1714 if (HasCSEDone || HasExtractHoistableLoad)
1715 return HoistResult::Hoisted | HoistResult::ErasedMI;
1716 return HoistResult::Hoisted;
1721MachineLICMImpl::getCurPreheader(
MachineLoop *CurLoop,
1730 if (!CurPreheader) {
1732 if (!CurPreheader) {
1740 MFAM,
nullptr, MDTU);
1741 if (!CurPreheader) {
1747 return CurPreheader;
1762 double Ratio = (double)DstBF / SrcBF;
1768template <
typename DerivedT,
bool PreRegAlloc>
1771 bool Changed = MachineLICMImpl(PreRegAlloc,
nullptr, &MFAM).run(MF);
unsigned const MachineRegisterInfo * MRI
MachineInstrBuilder & UseMI
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)
unsigned 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
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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 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.
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.
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.
bool isValid() const
Returns true if this iterator is not yet at the end.
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)
Split the critical edge from this block to the given successor block, and return the newly created bl...
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.
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...
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 eraseCallSiteInfo(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.
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 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.
unsigned getRegPressureSetLimit(unsigned Idx) const
Get the register unit limit for the given pressure set index.
void runOnMachineFunction(const MachineFunction &MF)
runOnFunction - Prepare to answer questions about MF.
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 ...
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
Provide an instruction scheduling machine model to CodeGen passes.
void init(const TargetSubtargetInfo *TSInfo)
Initialize the machine model for instruction scheduling.
TargetSubtargetInfo - Generic base class for all target subtargets.
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.
char & EarlyMachineLICMID
This pass performs loop invariant code motion on machine instructions.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
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...
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)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
void initializeMachineLICMPass(PassRegistry &)
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
char & MachineLICMID
This pass performs loop invariant code motion on machine instructions.
void initializeEarlyMachineLICMPass(PassRegistry &)
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...