69#define DEBUG_TYPE "machine-sink"
73 cl::desc(
"Use block frequency info to find successors to sink"),
76STATISTIC(NumSunk,
"Number of machine instructions sunk");
77STATISTIC(NumCycleSunk,
"Number of machine instructions sunk into a cycle");
78STATISTIC(NumSplit,
"Number of critical edges split");
79STATISTIC(NumCoalesces,
"Number of copies coalesced");
80STATISTIC(NumPostRACopySink,
"Number of copies sunk after RA");
87 const CodeGenOptions &Opts;
121 using AllSuccsCache =
135 using SinkItem = std::pair<MachineInstr *, MachineBasicBlock *>;
154 CachedRegisterPressure;
156 bool EnableSinkAndFold;
159 MachineSinking(
const CodeGenOptions &Opts,
bool EnableSinkAndFold,
165 : Opts(Opts), DT(DT), PDT(PDT), CI(CI), PSI(PSI), MBFI(MBFI), MBPI(MBPI),
166 AA(
AA), RegClassInfo(RegClassInfo), MLI(MLI),
167 EnableSinkAndFold(EnableSinkAndFold) {}
171 void releaseMemory() {
172 CEBCandidates.
clear();
173 CEMergeCandidates.
clear();
203 AllSuccsCache &AllSuccessors);
213 bool &LocalUse)
const;
216 AllSuccsCache &AllSuccessors);
228 AllSuccsCache &AllSuccessors);
237 AllSuccsCache &AllSuccessors)
const;
240 bool UseCache =
true);
242 bool registerPressureSetExceedsLimit(
unsigned NRegs,
279char MachineSinkingLegacy::ID = 0;
305 if (!TII->isBasicBlockPrologue(*PI))
307 for (auto &MO : MI.operands()) {
310 Register Reg = MO.getReg();
314 if (Reg.isPhysical() &&
315 (TII->isIgnorableUse(MI, MI.getOperandNo(&MO)) ||
316 (MRI && MRI->isConstantPhysReg(Reg))))
318 if (PI->modifiesRegister(Reg, TRI))
321 if (PI->readsRegister(Reg, TRI))
324 auto *DefOp = PI->findRegisterDefOperand(Reg, TRI, false, true);
325 if (DefOp && !DefOp->isDead())
334bool MachineSinking::PerformTrivialForwardCoalescing(
MachineInstr &
MI,
356 MI.eraseFromParent();
362bool MachineSinking::PerformSinkAndFold(MachineInstr &
MI,
363 MachineBasicBlock *
MBB) {
364 if (
MI.isCopy() ||
MI.mayLoadOrStore() ||
365 MI.getOpcode() == TargetOpcode::REG_SEQUENCE)
373 bool SawStore =
true;
374 if (!
MI.isSafeToMove(SawStore))
379 if (
MI.isConvergent())
388 for (
const MachineOperand &MO :
MI.operands()) {
389 if (MO.isImm() || MO.isRegMask() || MO.isRegLiveOut() || MO.isMetadata() ||
390 MO.isMCSymbol() || MO.isDbgInstrRef() || MO.isCFIIndex() ||
391 MO.isIntrinsicID() || MO.isPredicate() || MO.isShuffleMask())
410 else if (UsedRegB == 0)
419 TII->isIgnorableUse(
MI,
MI.getOperandNo(&MO))))
429 using SinkInfo = std::pair<MachineInstr *, ExtAddrMode>;
440 while (!Worklist.
empty()) {
445 MachineInstr &UseInst = *MO.getParent();
448 if (
const MachineOperand &O = UseInst.
getOperand(0);
O.isReg())
469 return MO.isReg() && MO.getReg() == Reg;
473 if (!
TII->canFoldIntoAddrMode(UseInst,
Reg,
MI, AM))
490 if (RCA ==
nullptr) {
495 unsigned NRegs = !!RCA + !!RCB;
501 if (RCB ==
nullptr) {
502 if (registerPressureSetExceedsLimit(NRegs, RCA,
MBB))
504 }
else if (registerPressureSetExceedsLimit(1, RCA,
MBB) ||
505 registerPressureSetExceedsLimit(1, RCB,
MBB)) {
515 if (SinkInto.
empty())
519 for (
auto &[SinkDst, MaybeAM] : SinkInto) {
520 MachineInstr *
New =
nullptr;
523 if (SinkDst->isCopy()) {
536 Register DstReg = SinkDst->getOperand(0).getReg();
537 TII->reMaterialize(*SinkDst->getParent(), InsertPt, DstReg, 0,
MI);
538 New = &*std::prev(InsertPt);
539 if (!
New->getDebugLoc())
540 New->setDebugLoc(SinkDst->getDebugLoc());
543 New =
TII->emitLdStWithAddr(*SinkDst, MaybeAM);
547 if (SinkDst->mayStore() && !SinkDst->hasOrderedMemoryRef())
548 StoreInstrCache.clear();
549 SinkDst->eraseFromParent();
557 while (!Worklist.
empty()) {
561 assert((
U->isCopy() ||
U->isDebugInstr()) &&
562 "Only debug uses and copies must remain");
564 Worklist.
push_back(
U->getOperand(0).getReg());
570 for (MachineOperand *MO :
Cleanup) {
573 I->eraseFromParent();
580 MI.eraseFromParent();
588bool MachineSinking::AllUsesDominatedByBlock(
Register Reg,
589 MachineBasicBlock *
MBB,
590 MachineBasicBlock *DefMBB,
592 bool &LocalUse)
const {
614 MachineInstr *UseInst = MO.getParent();
615 unsigned OpNo = MO.getOperandNo();
616 MachineBasicBlock *UseBlock = UseInst->getParent();
617 return UseBlock == MBB && UseInst->isPHI() &&
618 UseInst->getOperand(OpNo + 1).getMBB() == DefMBB;
627 unsigned OpNo = &MO - &UseInst->
getOperand(0);
628 MachineBasicBlock *UseBlock = UseInst->
getParent();
629 if (UseInst->
isPHI()) {
633 }
else if (UseBlock == DefMBB) {
649 assert(
MI.mayLoad() &&
"Expected MI that loads!");
653 if (
MI.memoperands_empty())
658 if (PSV->isGOT() || PSV->isConstantPool())
664void MachineSinking::FindCycleSinkCandidates(
665 CycleRef Cycle, MachineBasicBlock *BB,
666 SmallVectorImpl<MachineInstr *> &Candidates) {
667 for (
auto &
MI : *BB) {
669 if (
MI.isMetaInstruction()) {
670 LLVM_DEBUG(
dbgs() <<
"CycleSink: not sinking meta instruction\n");
674 LLVM_DEBUG(
dbgs() <<
"CycleSink: Instruction not a candidate for this "
679 LLVM_DEBUG(
dbgs() <<
"CycleSink: Instruction is not cycle invariant\n");
682 bool DontMoveAcrossStore =
true;
683 if (!
MI.isSafeToMove(DontMoveAcrossStore)) {
684 LLVM_DEBUG(
dbgs() <<
"CycleSink: Instruction not safe to move.\n");
688 LLVM_DEBUG(
dbgs() <<
"CycleSink: Dont sink GOT or constant pool loads\n");
691 if (
MI.isConvergent())
694 const MachineOperand &MO =
MI.getOperand(0);
700 LLVM_DEBUG(
dbgs() <<
"CycleSink: Instruction added as candidate.\n");
712 .getCachedResult<ProfileSummaryAnalysis>(
724 CI, PSI, MBFI, MBPI,
AA, RegClassInfo);
738 OS << MapClassName2PassName(
name());
739 if (EnableSinkAndFold)
740 OS <<
"<enable-sink-fold>";
750 auto *DT = &getAnalysis<MachineDominatorTreeWrapperPass>().getDomTree();
752 &getAnalysis<MachinePostDominatorTreeWrapperPass>().getPostDomTree();
753 auto *CI = &getAnalysis<MachineCycleInfoWrapperPass>().getCycleInfo();
754 auto *PSI = &getAnalysis<ProfileSummaryInfoWrapperPass>().getPSI();
757 ? &getAnalysis<MachineBlockFrequencyInfoWrapperPass>().getMBFI()
760 &getAnalysis<MachineBranchProbabilityInfoWrapperPass>().getMBPI();
761 auto *
AA = &getAnalysis<AAResultsWrapperPass>().getAAResults();
763 auto *MLIWrapper = getAnalysisIfAvailable<MachineLoopInfoWrapperPass>();
764 auto *MLI = MLIWrapper ? &MLIWrapper->getLI() :
nullptr;
766 &getAnalysis<MachineRegisterClassInfoWrapperPass>().getRCI();
769 CI, PSI, MBFI, MBPI,
AA, RegClassInfo);
781 bool EverMadeChange =
false;
784 bool MadeChange =
false;
787 CEBCandidates.clear();
788 CEMergeCandidates.clear();
795 MachineDomTreeUpdater::UpdateStrategy::Lazy);
796 for (
const auto &Pair : ToSplit) {
797 auto NewSucc = Pair.first->SplitCriticalEdge(
798 Pair.second, {nullptr, nullptr, MLI}, &MDTU);
799 if (NewSucc !=
nullptr) {
816 EverMadeChange =
true;
819 if (Opts.sink_insts_to_avoid_spills) {
821 SchedModel.
init(STI);
822 bool HasHighPressure;
824 DenseMap<SinkItem, MachineInstr *> SunkInstrs;
826 enum CycleSinkStage { COPY, LOW_LATENCY, AGGRESSIVE, END };
827 for (
unsigned Stage = CycleSinkStage::COPY; Stage != CycleSinkStage::END;
828 ++Stage, SunkInstrs.
clear()) {
829 HasHighPressure =
false;
831 for (
auto Cycle : Cycles) {
837 SmallVector<MachineInstr *, 8> Candidates;
838 FindCycleSinkCandidates(Cycle, Preheader, Candidates);
847 if (Stage == CycleSinkStage::COPY) {
848 if (i++ == Opts.machine_sink_cycle_limit) {
850 <<
"CycleSink: Limit reached of instructions to "
861 if (Stage == CycleSinkStage::LOW_LATENCY &&
862 !
TII->hasLowDefLatency(SchedModel, *
I, 0))
865 if (!aggressivelySinkIntoCycle(Cycle, *
I, SunkInstrs))
867 EverMadeChange =
true;
872 if (!HasHighPressure)
873 HasHighPressure = registerPressureExceedsLimit(*Preheader);
875 if (!HasHighPressure)
880 HasStoreCache.clear();
881 StoreInstrCache.clear();
884 return EverMadeChange;
887bool MachineSinking::ProcessBlock(MachineBasicBlock &
MBB) {
897 bool MadeChange =
false;
900 AllSuccsCache AllSuccessors;
905 bool ProcessedBegin, SawStore =
false;
907 MachineInstr &
MI = *
I;
915 if (
MI.isDebugOrPseudoInstr() ||
MI.isFakeUse()) {
916 if (
MI.isDebugValue())
921 if (EnableSinkAndFold && PerformSinkAndFold(
MI, &
MBB)) {
930 if (PerformTrivialForwardCoalescing(
MI, &
MBB)) {
941 }
while (!ProcessedBegin);
943 SeenDbgUsers.clear();
946 CachedRegisterPressure.clear();
950void MachineSinking::ProcessDbgInst(MachineInstr &
MI) {
953 assert(
MI.isDebugValue() &&
"Expected DBG_VALUE for processing");
955 DebugVariable Var(
MI.getDebugVariable(),
MI.getDebugExpression(),
956 MI.getDebugLoc()->getInlinedAt());
957 bool SeenBefore = SeenDbgVars.contains(Var);
959 for (MachineOperand &MO :
MI.debug_operands()) {
961 SeenDbgUsers[MO.
getReg()].push_back(SeenDbgUser(&
MI, SeenBefore));
965 SeenDbgVars.insert(Var);
968bool MachineSinking::isWorthBreakingCriticalEdge(
969 MachineInstr &
MI, MachineBasicBlock *From, MachineBasicBlock *To,
970 MachineBasicBlock *&DeferredFromBlock) {
976 if (!CEBCandidates.insert(std::make_pair(From, To)).second)
987 for (
const auto &MO :
MI.all_defs()) {
992 auto Key = std::make_pair(SrcReg, To);
993 auto Res = CEMergeCandidates.try_emplace(
Key, From);
998 DeferredFromBlock = Res.first->second;
1005 BranchProbability(Opts.machine_sink_split_probability_threshold, 100))
1011 for (
const MachineOperand &MO :
MI.all_uses()) {
1036 return TII->shouldBreakCriticalEdgeToSink(
MI);
1039bool MachineSinking::isLegalToBreakCriticalEdge(MachineInstr &
MI,
1040 MachineBasicBlock *FromBB,
1041 MachineBasicBlock *ToBB,
1042 bool BreakPHIEdge) {
1044 if (!Opts.machine_sink_split || FromBB == ToBB || !FromBB->
isSuccessor(ToBB))
1047 CycleRef FromCycle = CI->
getCycle(FromBB);
1048 CycleRef ToCycle = CI->
getCycle(ToBB);
1051 if (FromCycle == ToCycle && FromCycle &&
1094 if (!BreakPHIEdge) {
1103bool MachineSinking::PostponeSplitCriticalEdge(MachineInstr &
MI,
1104 MachineBasicBlock *FromBB,
1105 MachineBasicBlock *ToBB,
1106 bool BreakPHIEdge) {
1107 bool Status =
false;
1108 MachineBasicBlock *DeferredFromBB =
nullptr;
1109 if (isWorthBreakingCriticalEdge(
MI, FromBB, ToBB, DeferredFromBB)) {
1112 if ((!DeferredFromBB ||
1113 ToSplit.count(std::make_pair(DeferredFromBB, ToBB)) ||
1114 isLegalToBreakCriticalEdge(
MI, DeferredFromBB, ToBB, BreakPHIEdge)) &&
1115 isLegalToBreakCriticalEdge(
MI, FromBB, ToBB, BreakPHIEdge)) {
1116 ToSplit.insert(std::make_pair(FromBB, ToBB));
1118 ToSplit.insert(std::make_pair(DeferredFromBB, ToBB));
1126std::vector<unsigned> &
1127MachineSinking::getBBRegisterPressure(
const MachineBasicBlock &
MBB,
1134 auto RP = CachedRegisterPressure.find(&
MBB);
1135 if (UseCache && RP != CachedRegisterPressure.end())
1138 RegionPressure Pressure;
1139 RegPressureTracker RPTracker(Pressure);
1147 MII != MIE; --MII) {
1148 const MachineInstr &
MI = *std::prev(MII);
1149 if (
MI.isDebugOrPseudoInstr())
1151 RegisterOperands RegOpers;
1153 RPTracker.recedeSkipDebugValues();
1154 assert(&*RPTracker.getPos() == &
MI &&
"RPTracker sync error!");
1155 RPTracker.recede(RegOpers);
1158 RPTracker.closeRegion();
1160 if (RP != CachedRegisterPressure.end()) {
1161 CachedRegisterPressure[&
MBB] = RPTracker.getPressure().MaxSetPressure;
1162 return CachedRegisterPressure[&
MBB];
1165 auto It = CachedRegisterPressure.insert(
1166 std::make_pair(&
MBB, RPTracker.getPressure().MaxSetPressure));
1167 return It.first->second;
1170bool MachineSinking::registerPressureSetExceedsLimit(
1172 const MachineBasicBlock &
MBB) {
1173 unsigned Weight = NRegs *
TRI->getRegClassWeight(RC).RegWeight;
1174 const int *PS =
TRI->getRegClassPressureSets(RC);
1175 std::vector<unsigned> BBRegisterPressure = getBBRegisterPressure(
MBB);
1176 for (; *PS != -1; PS++)
1177 if (Weight + BBRegisterPressure[*PS] >=
1184bool MachineSinking::registerPressureExceedsLimit(
1185 const MachineBasicBlock &
MBB) {
1186 std::vector<unsigned> BBRegisterPressure = getBBRegisterPressure(
MBB,
false);
1188 for (
unsigned PS = 0; PS < BBRegisterPressure.size(); ++PS) {
1198bool MachineSinking::isProfitableToSinkTo(
Register Reg, MachineInstr &
MI,
1199 MachineBasicBlock *
MBB,
1200 MachineBasicBlock *SuccToSinkTo,
1201 AllSuccsCache &AllSuccessors) {
1202 assert(SuccToSinkTo &&
"Invalid SinkTo Candidate BB");
1204 if (
MBB == SuccToSinkTo)
1217 bool NonPHIUse =
false;
1219 MachineBasicBlock *UseBlock = UseInst.
getParent();
1220 if (UseBlock == SuccToSinkTo && !UseInst.
isPHI())
1228 bool BreakPHIEdge =
false;
1230 if (MachineBasicBlock *MBB2 =
1231 FindSuccToSinkTo(
MI, SuccToSinkTo, BreakPHIEdge, AllSuccessors))
1232 return isProfitableToSinkTo(
Reg,
MI, SuccToSinkTo, MBB2, AllSuccessors);
1243 for (
const MachineOperand &MO :
MI.operands()) {
1254 !
TII->isIgnorableUse(
MI,
MI.getOperandNo(&MO)))
1262 bool LocalUse =
false;
1263 if (!AllUsesDominatedByBlock(
Reg, SuccToSinkTo,
MBB, BreakPHIEdge,
1275 if (Cycle != MCycle ||
1284 LLVM_DEBUG(
dbgs() <<
"register pressure exceed limit, not profitable.");
1298SmallVector<MachineBasicBlock *, 4> &
1299MachineSinking::GetAllSortedSuccessors(MachineInstr &
MI, MachineBasicBlock *
MBB,
1300 AllSuccsCache &AllSuccessors)
const {
1302 auto Succs = AllSuccessors.find(
MBB);
1303 if (Succs != AllSuccessors.end())
1304 return Succs->second;
1306 SmallVector<MachineBasicBlock *, 4> AllSuccs(
MBB->
successors());
1317 if (DTChild->getIDom()->getBlock() ==
MI.getParent() &&
1320 AllSuccs.push_back(DTChild->getBlock());
1325 AllSuccs, [&](
const MachineBasicBlock *L,
const MachineBasicBlock *R) {
1329 (!LHSFreq && !RHSFreq))
1331 return LHSFreq < RHSFreq;
1334 auto it = AllSuccessors.insert(std::make_pair(
MBB, AllSuccs));
1336 return it.first->second;
1341MachineSinking::FindSuccToSinkTo(MachineInstr &
MI, MachineBasicBlock *
MBB,
1343 AllSuccsCache &AllSuccessors) {
1344 assert(
MBB &&
"Invalid MachineBasicBlock!");
1351 MachineBasicBlock *SuccToSinkTo =
nullptr;
1352 for (
const MachineOperand &MO :
MI.operands()) {
1366 !
TII->isIgnorableUse(
MI,
MI.getOperandNo(&MO)))
1368 }
else if (!MO.
isDead()) {
1386 bool LocalUse =
false;
1387 if (!AllUsesDominatedByBlock(
Reg, SuccToSinkTo,
MBB, BreakPHIEdge,
1398 for (MachineBasicBlock *SuccBlock :
1399 GetAllSortedSuccessors(
MI,
MBB, AllSuccessors)) {
1400 bool LocalUse =
false;
1401 if (AllUsesDominatedByBlock(
Reg, SuccBlock,
MBB, BreakPHIEdge,
1403 SuccToSinkTo = SuccBlock;
1414 if (!isProfitableToSinkTo(
Reg,
MI,
MBB, SuccToSinkTo, AllSuccessors))
1421 if (
MBB == SuccToSinkTo)
1426 if (SuccToSinkTo && SuccToSinkTo->
isEHPad())
1436 if (SuccToSinkTo && !
TII->isSafeToSink(
MI, SuccToSinkTo, CI))
1439 return SuccToSinkTo;
1453 auto *
MBB =
MI.getParent();
1454 if (
MBB->pred_size() != 1)
1457 auto *PredMBB = *
MBB->pred_begin();
1458 auto *PredBB = PredMBB->getBasicBlock();
1464 !PredBB->getTerminator()->getMetadata(LLVMContext::MD_make_implicit))
1469 bool OffsetIsScalable;
1470 if (!
TII->getMemOperandWithOffset(
MI, BaseOp,
Offset, OffsetIsScalable))
1473 if (!BaseOp->
isReg())
1476 if (!(
MI.mayLoad() && !
MI.isPredicable()))
1479 MachineBranchPredicate MBP;
1480 if (
TII->analyzeBranchPredicate(*PredMBB, MBP,
false))
1483 return MBP.LHS.isReg() && MBP.RHS.isImm() && MBP.RHS.getImm() == 0 &&
1484 (MBP.Predicate == MachineBranchPredicate::PRED_NE ||
1485 MBP.Predicate == MachineBranchPredicate::PRED_EQ) &&
1486 MBP.LHS.getReg() == BaseOp->
getReg();
1503 auto CopyOperands =
TII.isCopyInstr(SinkInst);
1506 SrcMO = CopyOperands->Source;
1507 DstMO = CopyOperands->Destination;
1510 bool PostRA =
MRI.getNumVirtRegs() == 0;
1518 bool arePhysRegs = !
Reg.isVirtual();
1519 if (arePhysRegs != PostRA)
1526 if (DbgMO.getSubReg() != SrcMO->
getSubReg() ||
1527 DbgMO.getSubReg() != DstMO->getSubReg())
1533 if (PostRA &&
Reg != DstMO->getReg())
1537 DbgMO.setReg(SrcMO->
getReg());
1543using MIRegs = std::pair<MachineInstr *, SmallVector<Register, 2>>;
1551 if (SuccToSinkTo.
empty())
1559 SuccToSinkTo.
splice(InsertPos, ParentBlock,
MI,
1566 for (
const auto &DbgValueToSink : DbgValuesToSink) {
1569 SuccToSinkTo.
insert(InsertPos, NewDbgMI);
1571 bool PropagatedAllSunkOps =
true;
1575 PropagatedAllSunkOps =
false;
1580 if (!PropagatedAllSunkOps)
1587bool MachineSinking::hasStoreBetween(MachineBasicBlock *From,
1588 MachineBasicBlock *To, MachineInstr &
MI) {
1594 auto BlockPair = std::make_pair(From, To);
1598 if (
auto It = HasStoreCache.find(BlockPair); It != HasStoreCache.end())
1601 if (
auto It = StoreInstrCache.find(BlockPair); It != StoreInstrCache.end())
1603 return I->mayAlias(AA, MI, false);
1606 bool SawStore =
false;
1607 bool HasAliasedStore =
false;
1608 DenseSet<MachineBasicBlock *> HandledBlocks;
1609 DenseSet<MachineBasicBlock *> HandledDomBlocks;
1616 if (BB == To || BB == From)
1620 if (HandledBlocks.
count(BB))
1623 HandledBlocks.
insert(BB);
1626 if (!HandledDomBlocks.
count(BB))
1627 HandledDomBlocks.
insert(BB);
1631 if (BB->sizeWithoutDebugLargerThan(
1632 Opts.machine_sink_load_instrs_threshold) ||
1633 HandledDomBlocks.
size() > Opts.machine_sink_load_blocks_threshold) {
1634 for (
auto *DomBB : HandledDomBlocks) {
1635 if (DomBB != BB && DT->
dominates(DomBB, BB))
1636 HasStoreCache[std::make_pair(DomBB, To)] =
true;
1637 else if (DomBB != BB && DT->
dominates(BB, DomBB))
1638 HasStoreCache[std::make_pair(From, DomBB)] =
true;
1640 HasStoreCache[BlockPair] =
true;
1644 for (MachineInstr &
I : *BB) {
1647 if (
I.isCall() ||
I.hasOrderedMemoryRef()) {
1648 for (
auto *DomBB : HandledDomBlocks) {
1649 if (DomBB != BB && DT->
dominates(DomBB, BB))
1650 HasStoreCache[std::make_pair(DomBB, To)] =
true;
1651 else if (DomBB != BB && DT->
dominates(BB, DomBB))
1652 HasStoreCache[std::make_pair(From, DomBB)] =
true;
1654 HasStoreCache[BlockPair] =
true;
1664 if (
I.mayAlias(AA,
MI,
false))
1665 HasAliasedStore =
true;
1666 StoreInstrCache[BlockPair].push_back(&
I);
1673 HasStoreCache[BlockPair] =
false;
1674 return HasAliasedStore;
1682bool MachineSinking::aggressivelySinkIntoCycle(
1683 CycleRef Cycle, MachineInstr &
I,
1684 DenseMap<SinkItem, MachineInstr *> &SunkInstrs) {
1686 if (
I.getNumDefs() > 1)
1689 LLVM_DEBUG(
dbgs() <<
"AggressiveCycleSink: Finding sink block for: " <<
I);
1693 MachineOperand &DefMO =
I.getOperand(0);
1698 for (std::pair<RegSubRegPair, MachineInstr *> Entry :
Uses) {
1699 MachineInstr *
MI =
Entry.second;
1703 dbgs() <<
"AggressiveCycleSink: Not attempting to sink for PHI.\n");
1707 if (
MI->isPosition() ||
TII->isBasicBlockPrologue(*
MI)) {
1708 LLVM_DEBUG(
dbgs() <<
"AggressiveCycleSink: Use is BasicBlock prologue, "
1714 dbgs() <<
"AggressiveCycleSink: Use not in cycle, can't sink.\n");
1718 MachineBasicBlock *SinkBlock =
MI->getParent();
1719 MachineInstr *NewMI =
nullptr;
1720 SinkItem MapEntry(&
I, SinkBlock);
1722 auto SI = SunkInstrs.
find(MapEntry);
1726 if (SI != SunkInstrs.
end()) {
1727 LLVM_DEBUG(
dbgs() <<
"AggressiveCycleSink: Already sunk to block: "
1734 LLVM_DEBUG(
dbgs() <<
"AggressiveCycleSink: Sinking instruction to block: "
1737 NewMI =
I.
getMF()->CloneMachineInstr(&
I);
1746 SunkInstrs.
insert({MapEntry, NewMI});
1761 I.eraseFromParent();
1767bool MachineSinking::SinkInstruction(MachineInstr &
MI,
bool &SawStore,
1768 AllSuccsCache &AllSuccessors) {
1774 if (!
MI.isSafeToMove(SawStore))
1779 if (
MI.isConvergent())
1795 bool BreakPHIEdge =
false;
1796 MachineBasicBlock *ParentBlock =
MI.getParent();
1797 MachineBasicBlock *SuccToSinkTo =
1798 FindSuccToSinkTo(
MI, ParentBlock, BreakPHIEdge, AllSuccessors);
1807 for (
const MachineOperand &MO :
MI.all_defs()) {
1815 LLVM_DEBUG(
dbgs() <<
"Sink instr " <<
MI <<
"\tinto block " << *SuccToSinkTo);
1822 bool TryBreak =
false;
1824 MI.mayLoad() ? hasStoreBetween(ParentBlock, SuccToSinkTo,
MI) :
true;
1825 if (!
MI.isSafeToMove(
Store)) {
1826 LLVM_DEBUG(
dbgs() <<
" *** NOTE: Won't sink load along critical edge.\n");
1832 if (!TryBreak && !DT->
dominates(ParentBlock, SuccToSinkTo)) {
1838 if (!TryBreak && CI->
getCycle(SuccToSinkTo) &&
1852 bool Status = PostponeSplitCriticalEdge(
MI, ParentBlock, SuccToSinkTo,
1856 "break critical edge\n");
1867 PostponeSplitCriticalEdge(
MI, ParentBlock, SuccToSinkTo, BreakPHIEdge);
1870 "break critical edge\n");
1879 LLVM_DEBUG(
dbgs() <<
" *** Not sinking: prologue interference\n");
1885 for (
auto &MO :
MI.all_defs()) {
1888 auto It = SeenDbgUsers.find(MO.
getReg());
1889 if (It == SeenDbgUsers.end())
1893 auto &
Users = It->second;
1894 for (
auto &User :
Users) {
1895 MachineInstr *DbgMI =
User.getPointer();
1896 if (
User.getInt()) {
1911 if (
MI.getMF()->getFunction().getSubprogram() &&
MI.isCopy())
1912 SalvageUnsunkDebugUsersOfCopy(
MI, SuccToSinkTo);
1919void MachineSinking::SalvageUnsunkDebugUsersOfCopy(
1920 MachineInstr &
MI, MachineBasicBlock *TargetBlock) {
1927 SmallVector<MachineInstr *, 4> DbgDefUsers;
1930 for (
auto &MO :
MI.all_defs()) {
1939 if (
User.getParent() ==
MI.getParent())
1943 "DBG_VALUE user of vreg, but has no operand for it?");
1950 for (
auto *User : DbgDefUsers) {
1951 for (
auto &
Reg : DbgUseRegs) {
1952 for (
auto &DbgOp :
User->getDebugOperandsForReg(
Reg)) {
1953 DbgOp.setReg(
MI.getOperand(1).getReg());
1954 DbgOp.setSubReg(
MI.getOperand(1).getSubReg());
1996class PostRAMachineSinkingImpl {
1998 LiveRegUnits ModifiedRegUnits, UsedRegUnits;
2004 DenseMap<MCRegUnit, SmallVector<MIRegs, 2>> SeenDbgInstrs;
2009 const TargetRegisterInfo *
TRI,
const TargetInstrInfo *
TII);
2015class PostRAMachineSinkingLegacy :
public MachineFunctionPass {
2020 PostRAMachineSinkingLegacy() : MachineFunctionPass(
ID) {}
2021 StringRef getPassName()
const override {
return "PostRA Machine Sink"; }
2023 void getAnalysisUsage(AnalysisUsage &AU)
const override {
2028 MachineFunctionProperties getRequiredProperties()
const override {
2029 return MachineFunctionProperties().setNoVRegs();
2035char PostRAMachineSinkingLegacy::ID = 0;
2039 "PostRA Machine Sink",
false,
false)
2048static MachineBasicBlock *
2054 for (
auto *
SI : SinkableBBs) {
2055 if (aliasWithRegsInLiveIn(*
SI,
Reg,
TRI)) {
2075static MachineBasicBlock *
2081 for (
auto DefReg : DefedRegsInCopy) {
2084 if (!BB || (SingleBB && SingleBB != BB))
2095 for (
auto U : UsedOpsInCopy) {
2101 if (UI.killsRegister(SrcReg,
TRI)) {
2102 UI.clearRegisterKills(SrcReg,
TRI);
2114 for (
Register DefReg : DefedRegsInCopy)
2117 for (
auto U : UsedOpsInCopy)
2127 bool HasRegDependency =
false;
2128 for (
unsigned i = 0, e =
MI->getNumOperands(); i != e; ++i) {
2137 HasRegDependency =
true;
2146 }
else if (MO.
isUse()) {
2148 HasRegDependency =
true;
2154 return HasRegDependency;
2157bool PostRAMachineSinkingImpl::tryToSinkCopy(MachineBasicBlock &CurBB,
2159 const TargetRegisterInfo *
TRI,
2160 const TargetInstrInfo *
TII) {
2161 SmallPtrSet<MachineBasicBlock *, 2> SinkableBBs;
2165 for (MachineBasicBlock *SI : CurBB.
successors())
2166 if (!
SI->livein_empty() &&
SI->pred_size() == 1 && !
SI->isEHPad())
2169 if (SinkableBBs.
empty())
2176 ModifiedRegUnits.
clear();
2177 UsedRegUnits.
clear();
2178 SeenDbgInstrs.clear();
2182 SmallVector<unsigned, 2> UsedOpsInCopy;
2188 if (
MI.isDebugValue() && !
MI.isDebugRef()) {
2189 SmallDenseMap<MCRegUnit, SmallVector<Register, 2>, 4> MIUnits;
2190 bool IsValid =
true;
2191 for (MachineOperand &MO :
MI.debug_operands()) {
2196 ModifiedRegUnits, UsedRegUnits)) {
2202 for (MCRegUnit Unit :
TRI->regunits(MO.
getReg()))
2207 for (
auto &RegOps : MIUnits)
2208 SeenDbgInstrs[RegOps.first].emplace_back(&
MI,
2209 std::move(RegOps.second));
2215 if (!
TII->shouldPostRASink(
MI)) {
2221 if (
MI.isDebugOrPseudoInstr())
2228 if (!
MI.isCopy() || !
MI.getOperand(0).isRenamable()) {
2236 ModifiedRegUnits, UsedRegUnits)) {
2242 "Unexpect SrcReg or DefReg");
2243 MachineBasicBlock *SuccBB =
2253 "Unexpected predecessor");
2258 MapVector<MachineInstr *, MIRegs::second_type> DbgValsToSinkMap;
2259 for (
auto &MO :
MI.all_defs()) {
2260 for (MCRegUnit Unit :
TRI->regunits(MO.
getReg())) {
2261 for (
const auto &
MIRegs : SeenDbgInstrs.lookup(Unit)) {
2262 auto &Regs = DbgValsToSinkMap[
MIRegs.first];
2267 auto DbgValsToSink = DbgValsToSinkMap.
takeVector();
2276 LLVM_DEBUG(
dbgs() <<
" *** Not sinking: prologue interference\n");
2287 ++NumPostRACopySink;
2305bool PostRAMachineSinkingLegacy::runOnMachineFunction(
MachineFunction &MF) {
2309 return PostRAMachineSinkingImpl().run(MF);
2317 if (!PostRAMachineSinkingImpl().
run(MF))
MachineInstrBuilder MachineInstrBuilder & DefMI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the DenseSet and SmallDenseSet classes.
This file builds on the ADT/GraphTraits.h file to build generic depth first graph iterator.
ManagedStatic< HTTPClientCleanup > Cleanup
static Register UseReg(const MachineOperand &MO)
const HexagonInstrInfo * TII
iv Induction Variable Users
static bool mayLoadFromGOTOrConstantPool(MachineInstr &MI)
Return true if this machine instruction loads from global offset table or constant pool.
TargetInstrInfo::RegSubRegPair RegSubRegPair
static void clearKillFlags(MachineInstr *MI, MachineBasicBlock &CurBB, const SmallVectorImpl< unsigned > &UsedOpsInCopy, const LiveRegUnits &UsedRegUnits, const TargetRegisterInfo *TRI)
static void performSink(MachineInstr &MI, MachineBasicBlock &SuccToSinkTo, MachineBasicBlock::iterator InsertPos, ArrayRef< MIRegs > DbgValuesToSink)
Sink an instruction and its associated debug instructions.
static bool SinkingPreventsImplicitNullCheck(MachineInstr &MI, const TargetInstrInfo *TII)
Return true if MI is likely to be usable as a memory operation by the implicit null check optimizatio...
static void updateLiveIn(MachineInstr *MI, MachineBasicBlock *SuccBB, const SmallVectorImpl< unsigned > &UsedOpsInCopy, const SmallVectorImpl< Register > &DefedRegsInCopy)
static bool hasRegisterDependency(MachineInstr *MI, SmallVectorImpl< unsigned > &UsedOpsInCopy, SmallVectorImpl< Register > &DefedRegsInCopy, LiveRegUnits &ModifiedRegUnits, LiveRegUnits &UsedRegUnits)
Register const TargetRegisterInfo * TRI
std::pair< MachineInstr *, SmallVector< Register, 2 > > MIRegs
Machine code static false bool blockPrologueInterferes(const MachineBasicBlock *BB, MachineBasicBlock::const_iterator End, const MachineInstr &MI, const TargetRegisterInfo *TRI, const TargetInstrInfo *TII, const MachineRegisterInfo *MRI)
Return true if a target defined block prologue instruction interferes with a sink candidate.
static bool attemptDebugCopyProp(MachineInstr &SinkInst, MachineInstr &DbgMI, Register Reg)
If the sunk instruction is a copy, try to forward the copy instead of leaving an 'undef' DBG_VALUE in...
static cl::opt< bool > UseBlockFreqInfo("machine-sink-bfi", cl::desc("Use block frequency info to find successors to sink"), cl::init(true), cl::Hidden)
static MachineBasicBlock * getSingleLiveInSuccBB(MachineBasicBlock &CurBB, const SmallPtrSetImpl< MachineBasicBlock * > &SinkableBBs, Register Reg, const TargetRegisterInfo *TRI)
This file implements a map that provides insertion order iteration.
Promote Memory to Register
#define INITIALIZE_PASS_DEPENDENCY(depName)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
This file defines the PointerIntPair class.
MachineRegisterInfo & MRI
Remove Loads Into Fake Uses
This file implements a set that has insertion order iteration characteristics.
static bool ProcessBlock(BasicBlock &BB, DominatorTree &DT, LoopInfo &LI, AAResults &AA)
static bool SinkInstruction(Instruction *Inst, SmallPtrSetImpl< Instruction * > &Stores, DominatorTree &DT, LoopInfo &LI, AAResults &AA)
SinkInstruction - Determine whether it is safe to sink the specified machine instruction out of its c...
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)
Target-Independent Code Generator Pass Configuration Options pass.
A manager for alias analyses.
A wrapper pass to provide the legacy pass manager access to a suitably prepared AAResults object.
PassT::Result * getCachedResult(IRUnitT &IR) const
Get the cached result of an analysis pass for a given IR unit.
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.
LLVM_ABI void setPreservesCFG()
This function should be called by the pass, iff they do not:
Represent a constant reference to an array (0 or more elements consecutively in memory),...
uint64_t getFrequency() const
Returns the frequency as a fixpoint number scaled by the entry frequency.
Represents analyses that only rely on functions' control flow.
Opaque handle to a cycle within a GenericCycleInfo that wraps the cycle's preorder index.
static LLVM_ABI DebugLoc getMergedLocation(DebugLoc LocA, DebugLoc LocB)
When two instructions are combined into a single instruction we also need to combine the original loc...
static DebugLoc getDropped()
iterator find(const_arg_type_t< KeyT > Val)
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
Implements a dense probed hash-table based set.
bool dominates(const DomTreeNodeBase< NodeT > *A, const DomTreeNodeBase< NodeT > *B) const
dominates - Returns true iff A dominates B.
bool isReachableFromEntry(const NodeT *A) const
isReachableFromEntry - Return true if A is dominated by the entry block of the function containing it...
DomTreeNodeBase< NodeT > * getNode(const NodeT *BB) const
getNode - return the (Post)DominatorTree node for the specified basic block.
iterator_range< const_toplevel_iterator > toplevel_cycles() const
bool isReducible(CycleRef C) const
BlockT * getCyclePreheader(CycleRef C) const
Return the preheader block for C.
void splitCriticalEdge(BlockT *Pred, BlockT *Succ, BlockT *New)
bool contains(CycleRef Outer, CycleRef Inner) const
Returns true iff Outer contains Inner. O(1). Non-strict.
unsigned getCycleDepth(const BlockT *Block) const
Return the depth of the innermost cycle containing Block, or 0 if it is not contained in any cycle.
BlockT * getHeader(CycleRef C) const
CycleRef getCycle(const BlockT *Block) const
Find the innermost cycle containing Block.
Module * getParent()
Get the module that this global value is contained inside of...
bool isAsCheapAsAMove(const MachineInstr &MI) const override
bool shouldSink(const MachineInstr &MI) const override
A set of register units used to track register liveness.
static void accumulateUsedDefed(const MachineInstr &MI, LiveRegUnits &ModifiedRegUnits, LiveRegUnits &UsedRegUnits, const TargetRegisterInfo *TRI)
For a machine instruction MI, adds all register units used in UsedRegUnits and defined or clobbered i...
bool available(MCRegister Reg) const
Returns true if no part of physical register Reg is live.
void init(const TargetRegisterInfo &TRI)
Initialize and clear the set.
LLVM_ABI void addLiveIns(const MachineBasicBlock &MBB)
Adds registers living into block MBB.
void clear()
Clears the set.
bool hasSuperClassEq(const MCRegisterClass *RC) const
Returns true if RC is a super-class of or equal to this class.
bool contains(MCRegister Reg) const
contains - Return true if the specified register is included in this register class.
An RAII based helper class to modify MachineFunctionProperties when running pass.
bool isInlineAsmBrIndirectTarget() const
Returns true if this is the indirect dest of an INLINEASM_BR.
unsigned pred_size() const
bool isEHPad() const
Returns true if the block is a landing pad.
instr_iterator instr_begin()
MachineInstrBundleIterator< const MachineInstr > const_iterator
LLVM_ABI instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
LLVM_ABI iterator SkipPHIsAndLabels(iterator I)
Return the first instruction in MBB after I that is not a PHI or a label.
unsigned succ_size() const
LLVM_ABI void sortUniqueLiveIns()
Sorts and uniques the LiveIns vector.
LLVM_ABI DebugLoc findDebugLoc(instr_iterator MBBI)
Find the next valid DebugLoc starting at MBBI, skipping any debug instructions.
pred_iterator pred_begin()
LLVM_ABI void removeLiveInOverlappedWith(MCRegister Reg)
Remove the specified register from any overlapped live in.
instr_iterator instr_end()
void addLiveIn(MCRegister PhysReg, LaneBitmask LaneMask=LaneBitmask::getAll())
Adds the specified register as a live in.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
iterator_range< succ_iterator > successors()
LLVM_ABI bool isSuccessor(const MachineBasicBlock *MBB) const
Return true if the specified MBB is a successor of this block.
iterator_range< pred_iterator > predecessors()
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 '...
MachineInstrBundleIterator< MachineInstr > iterator
LLVM_ABI bool isLiveIn(MCRegister Reg, LaneBitmask LaneMask=LaneBitmask::getAll()) const
Return true if the specified register is in the live in set.
MachineBlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate machine basic b...
LLVM_ABI BlockFrequency getBlockFreq(const MachineBasicBlock *MBB) const
getblockFreq - Return block frequency.
LLVM_ABI void onEdgeSplit(const MachineBasicBlock &NewPredecessor, const MachineBasicBlock &NewSuccessor, const MachineBranchProbabilityInfo &MBPI)
incrementally calculate block frequencies when we split edges, to avoid full CFG traversal.
LLVM_ABI BranchProbability getEdgeProbability(const MachineBasicBlock *Src, const MachineBasicBlock *Dst) const
Legacy analysis pass which computes a MachineCycleInfo.
Analysis pass which computes a MachineDominatorTree.
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
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.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Function & getFunction()
Return the LLVM function that this machine code represents.
Representation of each machine instruction.
bool hasDebugOperandForReg(Register Reg) const
Returns whether this debug value has at least one debug operand with the register Reg.
void setDebugValueUndef()
Sets all register debug operands in this debug value instruction to be undef.
LLVM_ABI iterator_range< filter_iterator< const MachineOperand *, std::function< bool(const MachineOperand &Op)> > > getDebugOperandsForReg(Register Reg) const
Returns a range of all of the operands that correspond to a debug use of Reg.
bool mayLoadOrStore(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly read or modify memory.
const MachineBasicBlock * getParent() const
bool isCopyLike() const
Return true if the instruction behaves like a copy.
bool isDebugInstr() const
LLVM_ABI void substituteRegister(Register FromReg, Register ToReg, unsigned SubIdx, const TargetRegisterInfo &RegInfo)
Replace all occurrences of FromReg with ToReg:SubIdx, properly composing subreg indices where necessa...
LLVM_ABI const MachineFunction * getMF() const
Return the function that contains the basic block that this instruction belongs to.
const MachineOperand & getOperand(unsigned i) const
void setDebugLoc(DebugLoc DL)
Replace current source information with new such.
Analysis pass that exposes the MachineLoopInfo for a machine function.
A description of a memory reference used in the backend.
MachineOperand class - Representation of each machine instruction operand.
void setSubReg(unsigned subReg)
unsigned getSubReg() const
bool isReg() const
isReg - Tests if this is a MO_Register operand.
MachineBasicBlock * getMBB() const
LLVM_ABI void setReg(Register Reg)
Change the register this operand corresponds to.
void setIsKill(bool Val=true)
MachineInstr * getParent()
getParent - Return the instruction that this operand belongs to.
Register getReg() const
getReg - Returns the register number.
MachinePostDominatorTree - an analysis pass wrapper for DominatorTree used to compute the post-domina...
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
LLVM_ABI bool hasOneNonDBGUse(Register RegNo) const
hasOneNonDBGUse - Return true if there is exactly one non-Debug use of the specified register.
const TargetRegisterClass * getRegClass(Register Reg) const
Return the register class of the specified virtual register.
LLVM_ABI LLVM_READONLY MachineInstr * getVRegDef(Register Reg) const
getVRegDef - Return the machine instr that defines the specified virtual register or null if none is ...
iterator_range< use_nodbg_iterator > use_nodbg_operands(Register Reg) const
bool use_nodbg_empty(Register RegNo) const
use_nodbg_empty - Return true if there are no non-Debug instructions using the specified register.
MachineBasicBlock * getDefBlock(Register Reg) const
Return the machine basic block in which the specified virtual register is defined,...
LLVM_ABI Register createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
iterator_range< use_instr_nodbg_iterator > use_nodbg_instructions(Register Reg) const
const MachineFunction & getMF() const
bool hasOneDef(Register RegNo) const
Return true if there is exactly one operand defining the specified register.
iterator_range< use_instr_iterator > use_instructions(Register Reg) const
LLVM_ABI bool isConstantPhysReg(MCRegister PhysReg) const
Returns true if PhysReg is unallocatable and constant throughout the function.
iterator_range< use_iterator > use_operands(Register Reg) const
LLVM_ABI void replaceRegWith(Register FromReg, Register ToReg)
replaceRegWith - Replace all instances of FromReg with ToReg in the machine function.
LLVM_ABI PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &)
LLVM_ABI void printPipeline(raw_ostream &OS, function_ref< StringRef(StringRef)> MapClassName2PassName)
VectorType takeVector()
Clear the MapVector and return the underlying vector.
PointerIntPair - This class implements a pair of a pointer and small integer.
LLVM_ABI PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
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.
PreservedAnalyses & preserveSet()
Mark an analysis set as preserved.
An analysis pass based on legacy pass manager to deliver ProfileSummaryInfo.
Analysis providing profile information.
Special value supplied for machine level alias analysis.
unsigned getRegPressureSetLimit(unsigned Idx) const
Get the register unit limit for the given pressure set index.
LLVM_ABI void collect(const MachineInstr &MI, const TargetRegisterInfo &TRI, const MachineRegisterInfo &MRI, bool TrackLaneMasks, bool IgnoreDead)
Analyze the given instruction MI and fill in the Uses, Defs and DeadDefs list based on the MachineOpe...
Wrapper class representing virtual and physical registers.
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.
A vector that has set insertion semantics.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
reference emplace_back(ArgTypes &&... Args)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
TargetInstrInfo - Interface to description of machine instruction set.
Target-Independent Code Generator Pass Configuration Options.
bool getEnableSinkAndFold() const
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 TargetInstrInfo * getInstrInfo() const
virtual const TargetRegisterInfo * getRegisterInfo() const =0
Return the target's register information.
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.
An efficient, type-erasing, non-owning reference to a callable.
This class implements an extremely fast bulk output stream that can only output to a stream.
Abstract Attribute helper functions.
initializer< Ty > init(const Ty &Val)
PointerTypeMap run(const Module &M)
Compute the PointerTypeMap for the module M.
@ User
could "use" a pointer
This is an optimization pass for GlobalISel generic memory operations.
void stable_sort(R &&Range)
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
OuterAnalysisManagerProxy< ModuleAnalysisManager, MachineFunction > ModuleAnalysisManagerMachineFunctionProxy
Provide the ModuleAnalysisManager to Function proxy.
@ Store
The extracted value is stored (ExtractElement only).
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
void append_range(Container &C, Range &&R)
Wrapper function to append range R to container C.
LLVM_ABI bool shouldOptimizeForSize(const MachineFunction *MF, ProfileSummaryInfo *PSI, const MachineBlockFrequencyInfo *BFI, PGSOQueryType QueryType=PGSOQueryType::Other)
Returns true if machine function MF is suggested to be size-optimized based on the profile.
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...
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
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 bool isCycleInvariant(const MachineCycleInfo &CI, CycleRef Cycle, MachineInstr &I)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_ABI char & PostRAMachineSinkingID
This pass perform post-ra machine sink for COPY instructions.
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
DomTreeNodeBase< MachineBasicBlock > MachineDomTreeNode
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
auto count_if(R &&Range, UnaryPredicate P)
Wrapper function around std::count_if to count the number of times an element satisfying a given pred...
LLVM_ABI char & MachineSinkingLegacyID
MachineSinking - This pass performs sinking on machine instructions.
iterator_range< df_iterator< T > > depth_first(const T &G)
@ End
Run the machine verifier once, at the end of the pipeline.
AAResults AliasAnalysis
Temporary typedef for legacy code that uses a generic AliasAnalysis pointer or reference.
LLVM_ABI Printable printMBBReference(const MachineBasicBlock &MBB)
Prints a machine basic block reference.
const CodeGenOptions & getCodeGenOptions(const LLVMContext &C)
MCRegisterClass TargetRegisterClass
Represents a predicate at the MachineFunction level.
A pair composed of a register and a sub-register index.