59#define DEBUG_TYPE "machinelicm"
63 cl::desc(
"MachineLICM should avoid speculation"),
68 cl::desc(
"MachineLICM should hoist even cheap instructions"),
84 cl::desc(
"Do not hoist instructions if target"
85 "block is N times hotter than the source."),
92 cl::desc(
"Disable hoisting instructions to"
96 "disable the feature"),
98 "enable the feature when using profile data"),
100 "enable the feature with/wo profile data")));
103 "Number of machine instructions hoisted out of loops");
105 "Number of instructions hoisted in low reg pressure situation");
107 "Number of high latency instructions hoisted");
109 "Number of hoisted machine instructions CSEed");
111 "Number of machine instructions hoisted out of loops post regalloc");
113 "Number of stores of const phys reg hoisted out of loops");
115 "Number of instructions not hoisted due to block frequency");
118 enum HoistResult { NotHoisted = 1, Hoisted = 2, ErasedMI = 4 };
127 bool PreRegAlloc =
false;
128 bool HasProfileData =
false;
137 bool Changed =
false;
138 bool FirstInLoop =
false;
153 ExitBlockMap[CurLoop] = ExitBlocks;
182 unsigned SpeculationState = SpeculateUnknown;
185 MachineLICMBase(
char &PassID,
bool PreRegAlloc)
206 ExitBlockMap.
clear();
211 struct CandidateInfo {
217 :
MI(mi),
Def(def), FI(fi) {}
259 void ExitScopeIfDone(
271 bool ConsiderUnseenAsDef);
274 bool ConsiderUnseenAsDef =
false);
279 std::vector<MachineInstr *> &PrevMIs);
283 DenseMap<
unsigned, std::vector<MachineInstr *>>::iterator &CI);
292 void InitializeLoadsHoistableLoops();
300 class MachineLICM :
public MachineLICMBase {
303 MachineLICM() : MachineLICMBase(
ID,
false) {
308 class EarlyMachineLICM :
public MachineLICMBase {
311 EarlyMachineLICM() : MachineLICMBase(
ID,
true) {
319char EarlyMachineLICM::ID;
325 "Machine Loop Invariant Code Motion",
false,
false)
343 if (skipFunction(MF.getFunction()))
346 Changed = FirstInLoop =
false;
348 TII = ST.getInstrInfo();
349 TLI = ST.getTargetLowering();
350 TRI = ST.getRegisterInfo();
351 MFI = &MF.getFrameInfo();
352 MRI = &MF.getRegInfo();
353 SchedModel.
init(&ST);
355 PreRegAlloc =
MRI->isSSA();
356 HasProfileData = MF.getFunction().hasProfileData();
366 unsigned NumRPS =
TRI->getNumRegPressureSets();
367 RegPressure.resize(NumRPS);
368 std::fill(RegPressure.begin(), RegPressure.end(), 0);
370 for (
unsigned i = 0, e = NumRPS; i != e; ++i)
371 RegLimit[i] =
TRI->getRegPressureSetLimit(MF, i);
376 MBFI = &getAnalysis<MachineBlockFrequencyInfoWrapperPass>().getMBFI();
377 MLI = &getAnalysis<MachineLoopInfoWrapperPass>().getLI();
378 DT = &getAnalysis<MachineDominatorTreeWrapperPass>().getDomTree();
379 AA = &getAnalysis<AAResultsWrapperPass>().getAAResults();
382 InitializeLoadsHoistableLoops();
385 while (!Worklist.
empty()) {
390 HoistRegionPostRA(CurLoop, CurPreheader);
396 HoistOutOfLoop(
N, CurLoop, CurPreheader);
412 if (
MI->memoperands_empty())
415 if (!
MemOp->isStore() || !
MemOp->getPseudoValue())
418 dyn_cast<FixedStackPseudoSourceValue>(
MemOp->getPseudoValue())) {
419 if (
Value->getFrameIndex() == FI)
460 const unsigned NumRegs =
TRI.getNumRegs();
461 const unsigned MaskWords = (NumRegs + 31) / 32;
462 for (
unsigned K = 0; K < MaskWords; ++K) {
464 for (
unsigned Bit = 0; Bit < 32; ++Bit) {
465 const unsigned PhysReg = (K * 32) + Bit;
466 if (PhysReg == NumRegs)
469 if (PhysReg && !((Word >> Bit) & 1)) {
471 RUsFromRegsNotInMask.
set(*RUI);
476 RUs |= RUsFromRegsNotInMask;
486 bool RuledOut =
false;
487 bool HasNonInvariantUse =
false;
492 int FI = MO.getIndex();
493 if (!StoredFIs.
count(FI) &&
497 HasNonInvariantUse =
true;
503 if (MO.isRegMask()) {
513 assert(
Reg.isPhysical() &&
"Not expecting virtual register!");
516 if (!HasNonInvariantUse) {
520 if (RUDefs.
test(*RUI) || RUClobbers.
test(*RUI)) {
521 HasNonInvariantUse =
true;
529 if (MO.isImplicit()) {
531 RUClobbers.
set(*RUI);
551 if (RUDefs.
test(*RUI)) {
552 RUClobbers.
set(*RUI);
554 }
else if (RUClobbers.
test(*RUI)) {
566 if (Def && !RuledOut) {
567 int FI = std::numeric_limits<int>::min();
568 if ((!HasNonInvariantUse && IsLICMCandidate(*
MI, CurLoop)) ||
576void MachineLICMBase::HoistRegionPostRA(
MachineLoop *CurLoop,
582 unsigned NumRegUnits =
TRI->getNumRegUnits();
595 if (
ML &&
ML->getHeader()->isEHPad())
continue;
600 for (
const auto &LI : BB->liveins()) {
606 if (
const uint32_t *Mask = BB->getBeginClobberMask(
TRI))
609 SpeculationState = SpeculateUnknown;
611 ProcessMI(&
MI, RUDefs, RUClobbers, StoredFIs, Candidates, CurLoop);
617 if (TI != Preheader->
end()) {
637 for (CandidateInfo &Candidate : Candidates) {
638 if (Candidate.FI != std::numeric_limits<int>::min() &&
639 StoredFIs.
count(Candidate.FI))
642 unsigned Def = Candidate.Def;
645 if (RUClobbers.
test(*RUI) || TermRUs.test(*RUI)) {
659 if (RUDefs.
test(*RUI) || RUClobbers.
test(*RUI)) {
672 HoistPostRA(
MI, Candidate.Def, CurLoop, CurPreheader);
680 if (!BB->isLiveIn(Reg))
686 if (
TRI->regsOverlap(Reg, MO.getReg()))
713 assert(!
MI->isDebugInstr() &&
"Should not hoist debug inst");
719 AddToLiveIns(Def, CurLoop);
729 if (SpeculationState != SpeculateUnknown)
730 return SpeculationState == SpeculateFalse;
737 if (!DT->
dominates(BB, CurrentLoopExitingBlock)) {
738 SpeculationState = SpeculateTrue;
743 SpeculationState = SpeculateFalse;
751bool MachineLICMBase::isTriviallyReMaterializable(
753 if (!
TII->isTriviallyReMaterializable(
MI))
757 if (MO.getReg().isVirtual())
782 if (OpenChildren[
Node])
786 ExitScope(
Node->getBlock());
789 if (!Parent || --OpenChildren[Parent] != 0)
813 while (!WorkList.
empty()) {
821 if (
ML &&
ML->getHeader()->isEHPad())
829 unsigned NumChildren =
Node->getNumChildren();
837 OpenChildren[
Node] = NumChildren;
843 ParentMap[Child] =
Node;
855 InitRegPressure(Preheader);
864 SpeculationState = SpeculateUnknown;
866 unsigned HoistRes = HoistResult::NotHoisted;
867 HoistRes =
Hoist(&
MI, Preheader, CurLoop);
868 if (HoistRes & HoistResult::NotHoisted) {
873 L =
L->getParentLoop())
876 while (!InnerLoopWorkList.
empty()) {
879 if (InnerLoopPreheader) {
880 HoistRes =
Hoist(&
MI, InnerLoopPreheader, InnerLoop);
881 if (HoistRes & HoistResult::Hoisted)
887 if (HoistRes & HoistResult::ErasedMI)
890 UpdateRegPressure(&
MI);
894 ExitScopeIfDone(
Node, OpenChildren, ParentMap);
920 UpdateRegPressure(&
MI,
true);
925 bool ConsiderUnseenAsDef) {
926 auto Cost = calcRegisterCost(
MI,
true, ConsiderUnseenAsDef);
927 for (
const auto &RPIdAndCost :
Cost) {
928 unsigned Class = RPIdAndCost.first;
929 if (
static_cast<int>(RegPressure[Class]) < -RPIdAndCost.second)
943MachineLICMBase::calcRegisterCost(
const MachineInstr *
MI,
bool ConsiderSeen,
944 bool ConsiderUnseenAsDef) {
946 if (
MI->isImplicitDef())
948 for (
unsigned i = 0, e =
MI->getDesc().getNumOperands(); i != e; ++i) {
953 if (!
Reg.isVirtual())
957 bool isNew = ConsiderSeen ? RegSeen.
insert(Reg).second :
false;
963 RCCost =
W.RegWeight;
966 if (isNew && !isKill && ConsiderUnseenAsDef)
968 RCCost =
W.RegWeight;
969 else if (!isNew && isKill)
970 RCCost = -
W.RegWeight;
974 const int *PS =
TRI->getRegClassPressureSets(RC);
975 for (; *PS != -1; ++PS) {
976 if (!
Cost.contains(*PS))
988 assert(
MI.mayLoad() &&
"Expected MI that loads!");
992 if (
MI.memoperands_empty())
997 if (PSV->isGOT() || PSV->isConstantPool())
1014 bool FoundCallerPresReg =
false;
1015 if (!
MI.mayStore() ||
MI.hasUnmodeledSideEffects() ||
1016 (
MI.getNumOperands() == 0))
1025 if (Reg.isVirtual())
1027 if (Reg.isVirtual())
1029 if (!
TRI->isCallerPreservedPhysReg(Reg.asMCReg(), *
MI.getMF()))
1032 FoundCallerPresReg =
true;
1033 }
else if (!MO.
isImm()) {
1037 return FoundCallerPresReg;
1055 Register CopySrcReg =
MI.getOperand(1).getReg();
1059 if (!
TRI->isCallerPreservedPhysReg(CopySrcReg.
asMCReg(), *MF))
1062 Register CopyDstReg =
MI.getOperand(0).getReg();
1077 bool DontMoveAcrossStore = !
HoistConstLoads || !AllowedToHoistLoads[CurLoop];
1078 if ((!
I.isSafeToMove(DontMoveAcrossStore)) &&
1091 !IsGuaranteedToExecute(
I.getParent(), CurLoop)) {
1100 if (
I.isConvergent())
1103 if (!
TII->shouldHoist(
I, CurLoop))
1112 if (!IsLICMCandidate(
I, CurLoop)) {
1113 LLVM_DEBUG(
dbgs() <<
"LICM: Instruction not a LICM candidate\n");
1125 MI = Work.pop_back_val();
1128 if (!
Reg.isVirtual())
1132 if (
UseMI.isPHI()) {
1146 Work.push_back(&
UseMI);
1149 }
while (!Work.empty());
1155bool MachineLICMBase::HasHighOperandLatency(
MachineInstr &
MI,
unsigned DefIdx,
1158 if (
MRI->use_nodbg_empty(Reg))
1162 if (
UseMI.isCopyLike())
1166 for (
unsigned i = 0, e =
UseMI.getNumOperands(); i != e; ++i) {
1174 if (
TII->hasHighOperandLatency(SchedModel,
MRI,
MI, DefIdx,
UseMI, i))
1187bool MachineLICMBase::IsCheapInstruction(
MachineInstr &
MI)
const {
1191 bool isCheap =
false;
1192 unsigned NumDefs =
MI.getDesc().getNumDefs();
1193 for (
unsigned i = 0, e =
MI.getNumOperands(); NumDefs && i != e; ++i) {
1199 if (
Reg.isPhysical())
1202 if (!
TII->hasLowDefLatency(SchedModel,
MI, i))
1215 for (
const auto &RPIdAndCost :
Cost) {
1216 if (RPIdAndCost.second <= 0)
1219 unsigned Class = RPIdAndCost.first;
1220 int Limit = RegLimit[
Class];
1227 for (
const auto &RP : BackTrace)
1228 if (
static_cast<int>(RP[Class]) + RPIdAndCost.second >= Limit)
1238void MachineLICMBase::UpdateBackTraceRegPressure(
const MachineInstr *
MI) {
1241 auto Cost = calcRegisterCost(
MI,
false,
1245 for (
auto &RP : BackTrace)
1246 for (
const auto &RPIdAndCost :
Cost)
1247 RP[RPIdAndCost.first] += RPIdAndCost.second;
1254 if (
MI.isImplicitDef())
1272 bool CheapInstr = IsCheapInstruction(
MI);
1273 bool CreatesCopy = HasLoopPHIUse(&
MI, CurLoop);
1276 if (CheapInstr && CreatesCopy) {
1283 if (isTriviallyReMaterializable(
MI))
1288 for (
unsigned i = 0, e =
MI.getDesc().getNumOperands(); i != e; ++i) {
1293 if (!
Reg.isVirtual())
1295 if (MO.
isDef() && HasHighOperandLatency(
MI, i, Reg, CurLoop)) {
1308 auto Cost = calcRegisterCost(&
MI,
false,
1313 if (!CanCauseHighRegPressure(
Cost, CheapInstr)) {
1329 (!IsGuaranteedToExecute(
MI.getParent(), CurLoop) && !MayCSE(&
MI))) {
1337 if (
MI.isCopy() ||
MI.isRegSequence()) {
1342 return !UseOp.isReg() || UseOp.getReg().isVirtual() ||
1343 MRI->isConstantPhysReg(UseOp.getReg());
1345 IsLoopInvariantInst(
MI, CurLoop) &&
1346 any_of(
MRI->use_nodbg_instructions(DefReg),
1348 if (!CurLoop->contains(&UseMI))
1355 if (CanCauseHighRegPressure(Cost, false) &&
1356 !CurLoop->isLoopInvariant(UseMI, DefReg))
1366 if (!isTriviallyReMaterializable(
MI) &&
1367 !
MI.isDereferenceableInvariantLoad()) {
1381 if (
MI->canFoldAsLoad())
1387 if (!
MI->isDereferenceableInvariantLoad())
1391 unsigned LoadRegIndex;
1393 TII->getOpcodeAfterMemoryUnfold(
MI->getOpcode(),
1397 if (NewOpc == 0)
return nullptr;
1410 "unfoldMemoryOperand failed when getOpcodeAfterMemoryUnfold "
1413 "Unfolded a load into multiple instructions!");
1420 if (!IsLoopInvariantInst(*NewMIs[0], CurLoop) ||
1421 !IsProfitableToHoist(*NewMIs[0], CurLoop)) {
1422 NewMIs[0]->eraseFromParent();
1423 NewMIs[1]->eraseFromParent();
1428 UpdateRegPressure(NewMIs[1]);
1433 if (
MI->shouldUpdateCallSiteInfo())
1436 MI->eraseFromParent();
1450void MachineLICMBase::InitializeLoadsHoistableLoops() {
1456 while (!Worklist.empty()) {
1457 auto *
L = Worklist.pop_back_val();
1458 AllowedToHoistLoads[
L] =
true;
1460 Worklist.insert(Worklist.end(),
L->getSubLoops().begin(),
1461 L->getSubLoops().end());
1474 if (!AllowedToHoistLoads[
Loop])
1476 for (
auto &
MI : *
MBB) {
1477 if (!
MI.mayStore() && !
MI.isCall() &&
1478 !(
MI.mayLoad() &&
MI.hasOrderedMemoryRef()))
1481 AllowedToHoistLoads[
L] =
false;
1492 std::vector<MachineInstr *> &PrevMIs) {
1494 if (
TII->produceSameValue(*
MI, *PrevMI, (PreRegAlloc ?
MRI :
nullptr)))
1504bool MachineLICMBase::EliminateCSE(
1506 DenseMap<
unsigned, std::vector<MachineInstr *>>::iterator &CI) {
1509 if (
MI->isImplicitDef())
1514 if (
MI->mayLoad() && !
MI->isDereferenceableInvariantLoad())
1523 for (
unsigned i = 0, e =
MI->getNumOperands(); i != e; ++i) {
1528 MO.
getReg() == Dup->getOperand(i).getReg()) &&
1529 "Instructions with different phys regs are not identical!");
1536 for (
unsigned i = 0, e = Defs.
size(); i != e; ++i) {
1537 unsigned Idx = Defs[i];
1542 if (!
MRI->constrainRegClass(DupReg,
MRI->getRegClass(Reg))) {
1544 for (
unsigned j = 0;
j != i; ++
j)
1545 MRI->setRegClass(Dup->getOperand(Defs[j]).getReg(), OrigRCs[j]);
1550 for (
unsigned Idx : Defs) {
1553 MRI->replaceRegWith(Reg, DupReg);
1554 MRI->clearKillFlags(DupReg);
1556 if (!
MRI->use_nodbg_empty(DupReg))
1557 Dup->getOperand(
Idx).setIsDead(
false);
1560 MI->eraseFromParent();
1570 if (
MI->mayLoad() && !
MI->isDereferenceableInvariantLoad())
1573 unsigned Opcode =
MI->getOpcode();
1574 for (
auto &Map : CSEMap) {
1578 Map.second.find(Opcode);
1581 if (CI ==
Map.second.end() ||
MI->isImplicitDef())
1583 if (LookForDuplicate(
MI, CI->second) !=
nullptr)
1601 isTgtHotterThanSrc(SrcBlock, Preheader)) {
1602 ++NumNotHoistedDueToHotness;
1603 return HoistResult::NotHoisted;
1606 bool HasExtractHoistableLoad =
false;
1607 if (!IsLoopInvariantInst(*
MI, CurLoop) ||
1608 !IsProfitableToHoist(*
MI, CurLoop)) {
1610 MI = ExtractHoistableLoad(
MI, CurLoop);
1612 return HoistResult::NotHoisted;
1613 HasExtractHoistableLoad =
true;
1624 dbgs() <<
"Hoisting " << *
MI;
1625 if (
MI->getParent()->getBasicBlock())
1635 InitCSEMap(Preheader);
1636 FirstInLoop =
false;
1640 unsigned Opcode =
MI->getOpcode();
1641 bool HasCSEDone =
false;
1642 for (
auto &Map : CSEMap) {
1646 Map.second.find(Opcode);
1647 if (CI !=
Map.second.end()) {
1648 if (EliminateCSE(
MI, CI)) {
1663 assert(!
MI->isDebugInstr() &&
"Should not hoist debug inst");
1667 UpdateBackTraceRegPressure(
MI);
1676 CSEMap[Preheader][Opcode].push_back(
MI);
1682 if (HasCSEDone || HasExtractHoistableLoad)
1683 return HoistResult::Hoisted | HoistResult::ErasedMI;
1684 return HoistResult::Hoisted;
1689MachineLICMBase::getCurPreheader(
MachineLoop *CurLoop,
1698 if (!CurPreheader) {
1700 if (!CurPreheader) {
1708 if (!CurPreheader) {
1714 return CurPreheader;
1729 double Ratio = (double)DstBF / SrcBF;
unsigned const MachineRegisterInfo * MRI
MachineInstrBuilder & UseMI
This file implements the BitVector class.
COFF::MachineTypes Machine
#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)
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 SmallSet class.
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)
TLS Variable Hoist
When an instruction is found to use only loop invariant operands that are safe to hoist,...
This file describes how to lower LLVM code to machine code.
A wrapper pass to provide the legacy pass manager access to a suitably prepared AAResults object.
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...
bool contains(const_arg_type_t< KeyT > Val) const
Return true if the specified key is in the map, false otherwise.
Base class for the actual dominator tree node.
A specialized PseudoSourceValue for holding FixedStack values, which must include a frame index.
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
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 '...
MachineBasicBlock * SplitCriticalEdge(MachineBasicBlock *Succ, Pass &P, std::vector< SparseBitVector<> > *LiveInSets=nullptr)
Split the critical edge from this block to the given successor block, and return the newly created bl...
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...
MachineDomTreeNode * getNode(MachineBasicBlock *BB) const
getNode - return the (Post)DominatorTree node for the specified basic block.
bool dominates(const MachineDomTreeNode *A, const MachineDomTreeNode *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...
void eraseCallSiteInfo(const MachineInstr *MI)
Following functions update call site info.
Representation of each machine instruction.
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...
virtual void releaseMemory()
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
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 ...
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)
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...
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...