58 #define DEBUG_TYPE "machinelicm" 62 cl::desc(
"MachineLICM should avoid speculation"),
67 cl::desc(
"MachineLICM should hoist even cheap instructions"),
72 cl::desc(
"MachineLICM should sink instructions into " 73 "loops to avoid register spills"),
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");
170 unsigned SpeculationState;
173 MachineLICMBase(
char &PassID,
bool PreRegAlloc)
188 void releaseMemory()
override {
198 struct CandidateInfo {
204 :
MI(mi),
Def(def), FI(fi) {}
207 void HoistRegionPostRA();
215 void AddToLiveIns(
unsigned Reg);
223 bool HasHighOperandLatency(
MachineInstr &MI,
unsigned DefIdx,
231 void UpdateBackTraceRegPressure(
const MachineInstr *MI);
241 void ExitScopeIfDone(
256 bool ConsiderUnseenAsDef);
259 bool ConsiderUnseenAsDef =
false);
265 std::vector<const MachineInstr *> &PrevMIs);
269 DenseMap<
unsigned, std::vector<const MachineInstr *>>::iterator &CI);
282 class MachineLICM :
public MachineLICMBase {
285 MachineLICM() : MachineLICMBase(ID,
false) {
290 class EarlyMachineLICM :
public MachineLICMBase {
293 EarlyMachineLICM() : MachineLICMBase(ID,
true) {
307 "Machine Loop Invariant Code Motion",
false,
false)
316 "Early
Machine Loop Invariant Code Motion", false, false)
322 "Early
Machine Loop Invariant Code Motion", false, false)
327 if (!CurLoop->getLoopPredecessor())
331 if (L->getLoopPredecessor())
341 Changed = FirstInLoop =
false;
348 SchedModel.init(&ST);
350 PreRegAlloc =
MRI->isSSA();
361 unsigned NumRPS =
TRI->getNumRegPressureSets();
364 RegLimit.resize(NumRPS);
365 for (
unsigned i = 0,
e = NumRPS; i !=
e; ++i)
366 RegLimit[i] =
TRI->getRegPressureSetLimit(MF, i);
371 MBFI = &getAnalysis<MachineBlockFrequencyInfo>();
372 MLI = &getAnalysis<MachineLoopInfo>();
373 DT = &getAnalysis<MachineDominatorTree>();
374 AA = &getAnalysis<AAResultsWrapperPass>().getAAResults();
377 while (!Worklist.empty()) {
379 CurPreheader =
nullptr;
385 Worklist.append(CurLoop->begin(), CurLoop->end());
389 CurLoop->getExitBlocks(ExitBlocks);
420 if (!MemOp->isStore() || !MemOp->getPseudoValue())
423 dyn_cast<FixedStackPseudoSourceValue>(MemOp->getPseudoValue())) {
424 if (
Value->getFrameIndex() == FI)
438 bool RuledOut =
false;
439 bool HasNonInvariantUse =
false;
444 int FI = MO.getIndex();
445 if (!StoredFIs.
count(FI) &&
446 MFI->isSpillSlotObjectIndex(FI) &&
449 HasNonInvariantUse =
true;
455 if (MO.isRegMask()) {
466 "Not expecting virtual register!");
469 if (Reg && (PhysRegDefs.
test(Reg) || PhysRegClobbers.
test(Reg)))
472 HasNonInvariantUse =
true;
476 if (MO.isImplicit()) {
478 PhysRegClobbers.
set(*AI);
498 if (PhysRegDefs.
test(*AS))
499 PhysRegClobbers.
set(*AS);
504 PhysRegDefs.
set(*AS);
506 if (PhysRegClobbers.
test(Reg))
514 if (Def && !RuledOut) {
515 int FI = std::numeric_limits<int>::min();
516 if ((!HasNonInvariantUse && IsLICMCandidate(*MI)) ||
518 Candidates.
push_back(CandidateInfo(MI, Def, FI));
524 void MachineLICMBase::HoistRegionPostRA() {
529 unsigned NumRegs =
TRI->getNumRegs();
547 for (
const auto &LI : BB->liveins()) {
549 PhysRegDefs.
set(*AI);
552 SpeculationState = SpeculateUnknown;
554 ProcessMI(&MI, PhysRegDefs, PhysRegClobbers, StoredFIs, Candidates);
560 if (TI != Preheader->
end()) {
580 for (CandidateInfo &Candidate : Candidates) {
581 if (Candidate.FI != std::numeric_limits<int>::min() &&
582 StoredFIs.
count(Candidate.FI))
585 unsigned Def = Candidate.Def;
586 if (!PhysRegClobbers.
test(Def) && !TermRegs.
test(Def)) {
590 if (!MO.isReg() || MO.isDef() || !MO.getReg())
593 if (PhysRegDefs.
test(Reg) ||
594 PhysRegClobbers.
test(Reg)) {
602 HoistPostRA(MI, Candidate.Def);
609 void MachineLICMBase::AddToLiveIns(
unsigned Reg) {
611 if (!BB->isLiveIn(Reg))
615 if (!MO.isReg() || !MO.getReg() || MO.isDef())
continue;
616 if (MO.getReg() == Reg ||
TRI->isSuperRegister(Reg, MO.getReg()))
650 if (SpeculationState != SpeculateUnknown)
651 return SpeculationState == SpeculateFalse;
653 if (BB != CurLoop->getHeader()) {
656 CurLoop->getExitingBlocks(CurrentLoopExitingBlocks);
658 if (!DT->dominates(BB, CurrentLoopExitingBlock)) {
659 SpeculationState = SpeculateTrue;
664 SpeculationState = SpeculateFalse;
677 BackTrace.pop_back();
686 if (OpenChildren[Node])
690 ExitScope(Node->getBlock());
694 unsigned Left = --OpenChildren[Parent];
697 ExitScope(Parent->getBlock());
718 while (!WorkList.
empty()) {
720 assert(Node &&
"Null dominator tree node?");
730 if (!CurLoop->contains(BB))
734 const std::vector<MachineDomTreeNode*> &Children = Node->
getChildren();
735 unsigned NumChildren = Children.size();
743 OpenChildren[Node] = NumChildren;
747 for (
int i = (
int)NumChildren-1; i >= 0; --i) {
749 ParentMap[Child] = Node;
754 if (Scopes.
size() == 0)
760 InitRegPressure(Preheader);
769 SpeculationState = SpeculateUnknown;
771 MII = MBB->
begin(),
E = MBB->
end(); MII !=
E; ) {
774 if (!Hoist(MI, Preheader))
775 UpdateRegPressure(MI);
782 ExitScopeIfDone(Node, OpenChildren, ParentMap);
789 void MachineLICMBase::SinkIntoLoop() {
799 if (IsLoopInvariantInst(*
I) && !HasLoopPHIUse(&*
I))
824 B = DT->findNearestCommonDominator(B, MI.
getParent());
830 if (!CanSink || !B || B == Preheader)
858 UpdateRegPressure(&MI,
true);
862 void MachineLICMBase::UpdateRegPressure(
const MachineInstr *MI,
863 bool ConsiderUnseenAsDef) {
864 auto Cost = calcRegisterCost(MI,
true, ConsiderUnseenAsDef);
865 for (
const auto &RPIdAndCost : Cost) {
866 unsigned Class = RPIdAndCost.first;
867 if (static_cast<int>(
RegPressure[Class]) < -RPIdAndCost.second)
881 MachineLICMBase::calcRegisterCost(
const MachineInstr *MI,
bool ConsiderSeen,
882 bool ConsiderUnseenAsDef) {
895 bool isNew = ConsiderSeen ? RegSeen.insert(Reg).second :
false;
904 if (isNew && !isKill && ConsiderUnseenAsDef)
907 else if (!isNew && isKill)
912 const int *PS =
TRI->getRegClassPressureSets(RC);
913 for (; *PS != -1; ++PS) {
914 if (Cost.
find(*PS) == Cost.
end())
935 if (PSV->isGOT() || PSV->isConstantPool())
952 bool FoundCallerPresReg =
false;
970 FoundCallerPresReg =
true;
971 }
else if (!MO.isImm()) {
975 return FoundCallerPresReg;
1003 "copy dst is not a virtual reg");
1016 bool DontMoveAcrossStore =
true;
1039 bool MachineLICMBase::IsLoopInvariantInst(
MachineInstr &I) {
1040 if (!IsLICMCandidate(I))
1049 if (Reg == 0)
continue;
1059 if (!
MRI->isConstantPhysReg(Reg) &&
1060 !(
TRI->isCallerPreservedPhysReg(Reg, *I.
getMF())))
1064 }
else if (!MO.isDead()) {
1067 }
else if (CurLoop->getHeader()->isLiveIn(Reg)) {
1078 "Machine instr not mapped for this vreg?!");
1082 if (CurLoop->contains(
MRI->getVRegDef(Reg)))
1092 bool MachineLICMBase::HasLoopPHIUse(
const MachineInstr *
MI)
const {
1097 if (!MO.isReg() || !MO.isDef())
1104 if (
UseMI.isPHI()) {
1107 if (CurLoop->contains(&
UseMI))
1117 if (
UseMI.isCopy() && CurLoop->contains(&
UseMI))
1121 }
while (!Work.
empty());
1127 bool MachineLICMBase::HasHighOperandLatency(
MachineInstr &MI,
1129 unsigned Reg)
const {
1130 if (
MRI->use_nodbg_empty(Reg))
1134 if (
UseMI.isCopyLike())
1136 if (!CurLoop->contains(
UseMI.getParent()))
1138 for (
unsigned i = 0,
e =
UseMI.getNumOperands(); i !=
e; ++i) {
1146 if (
TII->hasHighOperandLatency(SchedModel,
MRI, MI, DefIdx,
UseMI, i))
1159 bool MachineLICMBase::IsCheapInstruction(
MachineInstr &MI)
const {
1163 bool isCheap =
false;
1174 if (!
TII->hasLowDefLatency(SchedModel, MI, i))
1187 for (
const auto &RPIdAndCost : Cost) {
1188 if (RPIdAndCost.second <= 0)
1191 unsigned Class = RPIdAndCost.first;
1192 int Limit = RegLimit[Class];
1199 for (
const auto &
RP : BackTrace)
1200 if (static_cast<int>(
RP[Class]) + RPIdAndCost.second >= Limit)
1210 void MachineLICMBase::UpdateBackTraceRegPressure(
const MachineInstr *MI) {
1213 auto Cost = calcRegisterCost(MI,
false,
1217 for (
auto &
RP : BackTrace)
1218 for (
const auto &RPIdAndCost : Cost)
1219 RP[RPIdAndCost.first] += RPIdAndCost.second;
1224 bool MachineLICMBase::IsProfitableToHoist(
MachineInstr &MI) {
1243 bool CheapInstr = IsCheapInstruction(MI);
1244 bool CreatesCopy = HasLoopPHIUse(&MI);
1247 if (CheapInstr && CreatesCopy) {
1248 LLVM_DEBUG(
dbgs() <<
"Won't hoist cheap instr with loop PHI use: " << MI);
1254 if (
TII->isTriviallyReMaterializable(MI, AA))
1266 if (MO.
isDef() && HasHighOperandLatency(MI, i, Reg)) {
1279 auto Cost = calcRegisterCost(&MI,
false,
1284 if (!CanCauseHighRegPressure(Cost, CheapInstr)) {
1292 LLVM_DEBUG(
dbgs() <<
"Won't hoist instr with loop PHI use: " << MI);
1300 (!IsGuaranteedToExecute(MI.
getParent()) && !MayCSE(&MI))) {
1307 if (!
TII->isTriviallyReMaterializable(MI, AA) &&
1331 unsigned LoadRegIndex;
1337 if (NewOpc == 0)
return nullptr;
1345 bool Success =
TII->unfoldMemoryOperand(MF, *MI, Reg,
1350 "unfoldMemoryOperand failed when getOpcodeAfterMemoryUnfold " 1353 "Unfolded a load into multiple instructions!");
1356 MBB->insert(Pos, NewMIs[0]);
1357 MBB->insert(Pos, NewMIs[1]);
1360 if (!IsLoopInvariantInst(*NewMIs[0]) || !IsProfitableToHoist(*NewMIs[0])) {
1361 NewMIs[0]->eraseFromParent();
1362 NewMIs[1]->eraseFromParent();
1367 UpdateRegPressure(NewMIs[1]);
1385 MachineLICMBase::LookForDuplicate(
const MachineInstr *MI,
1386 std::vector<const MachineInstr*> &PrevMIs) {
1388 if (
TII->produceSameValue(*MI, *PrevMI, (PreRegAlloc ?
MRI :
nullptr)))
1399 DenseMap<
unsigned, std::vector<const MachineInstr *>>::iterator &CI) {
1405 if (
const MachineInstr *Dup = LookForDuplicate(MI, CI->second)) {
1417 MO.
getReg() == Dup->getOperand(i).getReg()) &&
1418 "Instructions with different phys regs are not identical!");
1426 for (
unsigned i = 0,
e = Defs.
size(); i !=
e; ++i) {
1427 unsigned Idx = Defs[i];
1429 Register DupReg = Dup->getOperand(Idx).getReg();
1432 if (!
MRI->constrainRegClass(DupReg,
MRI->getRegClass(Reg))) {
1434 for (
unsigned j = 0; j != i; ++j)
1435 MRI->setRegClass(Dup->getOperand(Defs[j]).getReg(), OrigRCs[j]);
1440 for (
unsigned Idx : Defs) {
1442 Register DupReg = Dup->getOperand(Idx).getReg();
1443 MRI->replaceRegWith(Reg, DupReg);
1444 MRI->clearKillFlags(DupReg);
1459 CI = CSEMap.
find(Opcode);
1465 return LookForDuplicate(MI, CI->second) !=
nullptr;
1477 isTgtHotterThanSrc(SrcBlock, Preheader)) {
1478 ++NumNotHoistedDueToHotness;
1482 if (!IsLoopInvariantInst(*MI) || !IsProfitableToHoist(*MI)) {
1484 MI = ExtractHoistableLoad(MI);
1485 if (!MI)
return false;
1496 dbgs() <<
"Hoisting " << *
MI;
1507 InitCSEMap(Preheader);
1508 FirstInLoop =
false;
1514 CI = CSEMap.
find(Opcode);
1515 if (!EliminateCSE(MI, CI)) {
1525 UpdateBackTraceRegPressure(MI);
1531 if (MO.isReg() && MO.isDef() && !MO.isDead())
1532 MRI->clearKillFlags(MO.getReg());
1535 if (CI != CSEMap.
end())
1536 CI->second.push_back(MI);
1538 CSEMap[Opcode].push_back(MI);
1553 if (CurPreheader == reinterpret_cast<MachineBasicBlock *>(-1))
1556 if (!CurPreheader) {
1557 CurPreheader = CurLoop->getLoopPreheader();
1558 if (!CurPreheader) {
1566 if (!CurPreheader) {
1572 return CurPreheader;
1580 uint64_t SrcBF = MBFI->getBlockFreq(SrcBlock).getFrequency();
1581 uint64_t DstBF = MBFI->getBlockFreq(TgtBlock).getFrequency();
1587 double Ratio = (double)DstBF / SrcBF;
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
static cl::opt< UseBFI > DisableHoistingToHotterBlocks("disable-hoisting-to-hotter-blocks", cl::desc("Disable hoisting instructions to" " hotter blocks"), cl::init(UseBFI::None), 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 PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
instr_iterator instr_begin()
instr_iterator instr_end()
const MachineFunction * getMF() const
Return the function that contains the basic block that this instruction belongs to.
This class represents lattice values for constants.
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
char & MachineLICMID
This pass performs loop invariant code motion on machine instructions.
void push_back(const T &Elt)
static bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
iterator getFirstTerminator()
Returns an iterator to the first terminator instruction of this basic block.
Describe properties that are true of each instruction in the target description file.
virtual const TargetLowering * getTargetLowering() const
bool test(unsigned Idx) const
void setBitsNotInMask(const uint32_t *Mask, unsigned MaskWords=~0u)
setBitsNotInMask - Add a bit to this vector for every '0' bit in Mask.
MachineBlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate machine basic b...
STATISTIC(NumFunctions, "Total number of functions")
unsigned const TargetRegisterInfo * TRI
static bool isExitBlock(BasicBlock *BB, const SmallVectorImpl< BasicBlock *> &ExitBlocks)
Return true if the specified block is in the list.
iterator_range< mop_iterator > operands()
bool isCopyLike() const
Return true if the instruction behaves like a copy.
static bool mayLoadFromGOTOrConstantPool(MachineInstr &MI)
Return true if this machine instruction loads from global offset table or constant pool...
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...
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
A description of a memory reference used in the backend.
Each TargetRegisterClass has a per register weight, and weight limit which must be less than the limi...
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
unsigned getNumOperands() const
Return the number of declared MachineOperands for this MachineInstruction.
Provide an instruction scheduling machine model to CodeGen passes.
const HexagonInstrInfo * TII
Printable printMBBReference(const MachineBasicBlock &MBB)
Prints a machine basic block reference.
unsigned getNumOperands() const
Retuns the total number of operands.
static bool isOperandKill(const MachineOperand &MO, MachineRegisterInfo *MRI)
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
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)
static cl::opt< bool > AvoidSpeculation("avoid-speculation", cl::desc("MachineLICM should avoid speculation"), cl::init(true), cl::Hidden)
BlockT * getHeader() const
Machine Loop Invariant Code Motion
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
Base class for the actual dominator tree node.
const std::vector< DomTreeNodeBase * > & getChildren() const
COFF::MachineTypes Machine
virtual const TargetInstrInfo * getInstrInfo() const
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
TargetInstrInfo - Interface to description of machine instruction set.
iterator find(const_arg_type_t< KeyT > Val)
bool mayStore(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly modify memory.
initializer< Ty > init(const Ty &Val)
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
unsigned const MachineRegisterInfo * MRI
ArrayRef< MachineMemOperand * > memoperands() const
Access to memory operands of the instruction.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
MachineInstrBuilder & UseMI
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.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
ValuesClass values(OptsTy... Options)
Helper to build a ValuesClass by forwarding a variable number of arguments as an initializer list to ...
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
static cl::opt< bool > HoistCheapInsts("hoist-cheap-insts", cl::desc("MachineLICM should hoist even cheap instructions"), cl::init(false), cl::Hidden)
MCRegAliasIterator enumerates all registers aliasing Reg.
Represent the analysis usage information of a pass.
static bool InstructionStoresToFI(const MachineInstr *MI, int FI)
Return true if instruction stores to the specified frame.
std::pair< NoneType, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
bool hasProfileData(bool IncludeSynthetic=false) const
Return true if the function is annotated with profile data.
bool isImplicitDef() const
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
pred_iterator pred_begin()
static bool isInvariantStore(const MachineInstr &MI, const TargetRegisterInfo *TRI, const MachineRegisterInfo *MRI)
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE, "Assign register bank of generic virtual registers", false, false) RegBankSelect
void initializeMachineLICMPass(PassRegistry &)
This base class for TargetLowering contains the SelectionDAG-independent parts that can be used from ...
Iterator for intrusive lists based on ilist_node.
bool isDereferenceableInvariantLoad(AAResults *AA) const
Return true if this load instruction never traps and points to a memory location whose value doesn't ...
MachineOperand class - Representation of each machine instruction operand.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
LLVM_NODISCARD T pop_back_val()
char & EarlyMachineLICMID
This pass performs loop invariant code motion on machine instructions.
Machine Loop Invariant Code false early machinelicm
unsigned getNumDefs() const
Return the number of MachineOperands that are register definitions.
unsigned pred_size() const
const Function & getFunction() const
Return the LLVM function that this machine code represents.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
void setDebugLoc(DebugLoc dl)
Replace current source information with new such.
Special value supplied for machine level alias analysis.
unsigned isLoadFromStackSlot(const MachineInstr &MI, int &FrameIndex) const override
TargetInstrInfo overrides.
unsigned succ_size() const
#define clEnumValN(ENUMVAL, FLAGNAME, DESC)
const MachineBasicBlock * getParent() const
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
TargetSubtargetInfo - Generic base class for all target subtargets.
LoopT * getParentLoop() const
Representation of each machine instruction.
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 '...
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
bool isEHPad() const
Returns true if the block is a landing pad.
LLVM_NODISCARD bool empty() const
Represents a single loop in the control flow graph.
bool canFoldAsLoad(QueryType Type=IgnoreBundle) const
Return true for instructions that can be folded as memory operands in other instructions.
INITIALIZE_PASS_BEGIN(MachineLICM, DEBUG_TYPE, "Machine Loop Invariant Code Motion", false, false) INITIALIZE_PASS_END(MachineLICM
const BasicBlock * getBasicBlock() const
Return the LLVM basic block that this instance corresponded to originally.
virtual bool isCallerPreservedPhysReg(unsigned PhysReg, const MachineFunction &MF) const
Physical registers that may be modified within a function but are guaranteed to be restored before an...
iterator getFirstNonPHI()
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
bool hasOneNonDBGUse(unsigned RegNo) const
hasOneNonDBGUse - Return true if there is exactly one non-Debug use of the specified register...
bool isReg() const
isReg - Tests if this is a MO_Register operand.
static bool isCopyFeedingInvariantStore(const MachineInstr &MI, const MachineRegisterInfo *MRI, const TargetRegisterInfo *TRI)
iterator_range< use_instr_iterator > use_instructions(unsigned Reg) const
void initializeEarlyMachineLICMPass(PassRegistry &)
bool mayLoad(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly read memory.
bool memoperands_empty() const
Return true if we don't have any memory operands which described the memory access done by this instr...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
MachineBasicBlock * SplitCriticalEdge(MachineBasicBlock *Succ, Pass &P)
Split the critical edge from this block to the given successor block, and return the newly created bl...
static cl::opt< bool > HoistConstStores("hoist-const-stores", cl::desc("Hoist invariant stores"), cl::init(true), cl::Hidden)
bool isSafeToMove(AAResults *AA, bool &SawStore) const
Return true if it is safe to move this instruction.
LLVM Value Representation.
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 bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
bool hasUnmodeledSideEffects() const
Return true if this instruction has side effects that are not modeled by mayLoad / mayStore...
A specialized PseudoSourceValue for holding FixedStack values, which must include a frame index...
Register getReg() const
getReg - Returns the register number.
A wrapper pass to provide the legacy pass manager access to a suitably prepared AAResults object...
const MachineOperand & getOperand(unsigned i) const
virtual unsigned lookThruCopyLike(unsigned SrcReg, const MachineRegisterInfo *MRI) const
Returns the original SrcReg unless it is the target of a copy-like operation, in which case we chain ...
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...
Wrapper class representing virtual and physical registers.
This file describes how to lower LLVM code to machine code.
size_type count(const T &V) const
count - Return 1 if the element is in the set, 0 otherwise.
bool is_contained(R &&Range, const E &Element)
Wrapper function around std::find to detect if an element exists in a container.