49#include "llvm/Config/llvm-config.h"
64#define DEBUG_TYPE "regalloc"
66STATISTIC(NumSpilledRanges,
"Number of spilled live ranges");
67STATISTIC(NumSnippets,
"Number of spilled snippets");
69STATISTIC(NumSpillsRemoved,
"Number of spills removed");
71STATISTIC(NumReloadsRemoved,
"Number of reloads removed");
72STATISTIC(NumFolded,
"Number of folded stack accesses");
74STATISTIC(NumRemats,
"Number of rematerialized defs for spilling");
79 cl::desc(
"Restrict remat for statepoint operands"));
104 using MergeableSpillsMap =
106 MergeableSpillsMap MergeableSpills;
119 void rmRedundantSpills(
143 : MF(mf), LIS(Analyses.LIS), LSS(Analyses.LSS), MDT(Analyses.MDT),
144 VRM(vrm),
MRI(mf.getRegInfo()),
TII(*mf.getSubtarget().getInstrInfo()),
145 MBFI(Analyses.MBFI),
Matrix(matrix), IPA(LIS, mf.getNumBlockIDs()) {}
147 void addToMergeableSpills(MachineInstr &Spill,
int StackSlot,
149 bool rmFromMergeableSpills(MachineInstr &Spill,
int StackSlot);
150 void addDeadSpillCandidate(
const MachineInstr &Spill,
int StackSlot);
151 void hoistAllSpills();
152 void LRE_WillShrinkVirtReg(
Register)
override;
153 bool LRE_CanEraseVirtReg(
Register)
override;
159 DenseMap<Register, MCRegister> PendingReassignments;
162class InlineSpiller :
public Spiller {
167 MachineRegisterInfo &MRI;
168 const TargetInstrInfo &TII;
169 const TargetRegisterInfo &TRI;
170 LiveRegMatrix *Matrix =
nullptr;
171 LiveDebugVariables *DebugVars =
nullptr;
174 LiveRangeEdit *Edit =
nullptr;
175 LiveInterval *StackInt =
nullptr;
178 AllocationOrder *Order =
nullptr;
190 SmallPtrSet<MachineInstr*, 8> SnippetCopies;
193 SmallPtrSet<VNInfo*, 8> UsedValues;
196 SmallVector<MachineInstr*, 8> DeadDefs;
199 DenseMap<int, SmallVector<Register, 4>> ForwardedStoreRegs;
202 HoistSpillHelper HSpiller;
205 VirtRegAuxInfo &VRAI;
207 ~InlineSpiller()
override =
default;
210 InlineSpiller(
const Spiller::RequiredAnalyses &Analyses,
MachineFunction &MF,
211 VirtRegMap &VRM, VirtRegAuxInfo &VRAI, LiveRegMatrix *Matrix)
212 : MF(MF), LIS(Analyses.LIS), LSS(Analyses.LSS), VRM(VRM),
213 MRI(MF.getRegInfo()), TII(*MF.getSubtarget().getInstrInfo()),
214 TRI(*MF.getSubtarget().getRegisterInfo()), Matrix(Matrix),
215 DebugVars(Analyses.DebugVars), HSpiller(Analyses, MF, VRM, Matrix),
218 void spill(LiveRangeEdit &, AllocationOrder *Order =
nullptr)
override;
221 void postOptimization()
override;
224 bool isSnippet(
const LiveInterval &SnipLI);
225 void collectRegsToSpill();
230 bool hoistSpillInsideBB(LiveInterval &SpillLI, MachineInstr &CopyMI);
231 void eliminateRedundantSpills(LiveInterval &LI, VNInfo *VNI);
232 void eliminateRedundantRestores();
233 bool tryForwardFromStoreToRestore(MachineInstr &
Store, MachineInstr &Restore);
235 void markValueUsed(LiveInterval *, VNInfo *);
236 bool hasPhysRegAvailable(
const MachineInstr &
MI);
237 bool reMaterializeFor(LiveInterval &, MachineInstr &
MI);
238 void reMaterializeAll();
241 bool foldMemoryOperand(
ArrayRef<std::pair<MachineInstr *, unsigned>>,
242 MachineInstr *LoadMI =
nullptr);
254void Spiller::anchor() {}
260 return new InlineSpiller(Analyses, MF, VRM, VRAI,
Matrix);
279 if (!
TII.isCopyInstr(
MI))
302 "expected to see first instruction in bundle");
306 while (
I->isBundledWithSucc()) {
308 auto CopyInst =
TII.isCopyInstr(
MI);
334 if (MO.getReg().isVirtual())
341bool InlineSpiller::isSnippet(
const LiveInterval &SnipLI) {
355 if (!LIS.intervalIsInOneMBB(SnipLI))
361 for (
auto *VNI : SnipLI.
vnis()) {
363 if (
MI->getOpcode() == TargetOpcode::STATEPOINT)
404void InlineSpiller::collectRegsToSpill() {
408 RegsToSpill.assign(1,
Reg);
409 SnippetCopies.clear();
410 RegsReplaced.clear();
419 if (!isSibling(SnipReg))
422 if (!isSnippet(SnipLI))
424 SnippetCopies.insert(&
MI);
425 if (isRegToSpill(SnipReg))
427 RegsToSpill.push_back(SnipReg);
456bool InlineSpiller::hoistSpillInsideBB(
LiveInterval &SpillLI,
461 assert(VNI && VNI->
def ==
Idx.getRegSlot() &&
"Not defined by copy");
478 assert(
DefMI &&
"Defining instruction disappeared");
492 ? LIS.getMBBEndIdx(
MBB)
493 : LIS.getInstructionIndex(*MII).getBaseIndex();
496 VRM.getPhys(SrcReg)))
503 assert(StackInt &&
"No stack slot assigned yet.");
506 StackInt->MergeValueInAsValue(OrigLI, OrigVNI, StackInt->getValNumInfo(0));
508 << *StackInt <<
'\n');
512 eliminateRedundantSpills(SrcLI, SrcVNI);
518 LIS.InsertMachineInstrRangeInMaps(MIS.begin(), MII);
535 if (MIS.begin() == MII)
536 HSpiller.addToMergeableSpills(*MII, StackSlot, Original);
550 Register Reg = MO.getReg();
551 return !Reg.isPhysical() || Reg == Ignore ||
552 Other.readsRegister(Reg, nullptr);
570 if (!LoadOperand || LoadOperand->
getSubReg())
583 if (StoreFI != LoadFI || !MF.getFrameInfo().isSpillSlotObjectIndex(LoadFI))
586 if (StoreSize.
isZero() || StoreSize != LoadSize)
588 if (StoreSize * 8 !=
TRI.getRegSizeInBits(StoreReg,
MRI) ||
589 LoadSize * 8 !=
TRI.getRegSizeInBits(LoadReg,
MRI))
606 SlotIndex Use = LIS.getInstructionIndex(Restore).getRegSlot();
608 StoreReg.
isVirtual() ? &LIS.getInterval(StoreReg) :
nullptr;
618 if (DefReg && (
TRI.regsOverlap(DefReg, PhysReg) ||
624 return !VNI->isUnused() && StoreIdx < VNI->def && VNI->def < Use;
628 Matrix->unassign(*StoreLI);
637 LLVM_DEBUG(
dbgs() <<
"Forwarding restore " << Restore <<
" from save "
641 TII.get(TargetOpcode::COPY), LoadReg)
644 Store.clearRegisterKills(StoreReg, &
TRI);
648 if (MO.getReg().isPhysical())
649 for (MCRegUnit Unit :
TRI.regunits(MO.getReg().asMCReg()))
651 LIS.removeRegUnit(Unit);
652 LIS.ReplaceMachineInstrInMaps(Restore, *Copy);
653 MF.substituteDebugValuesForInst(Restore, *Copy, 1);
659 for (MCRegUnit Unit :
TRI.regunits(StoreReg.
asMCReg())) {
662 if (
LiveRange *LR = LIS.getCachedRegUnit(Unit))
663 LR->extendInBlock(BlockStart,
Use);
670 HSpiller.addDeadSpillCandidate(
Store, StoreFI);
671 ForwardedStoreRegs[StoreFI].push_back(StoreReg);
676 Matrix->unassign(*StoreLI);
679 if (SubLI.getVNInfoBefore(StoreIdx))
680 SubLI.extendInBlock(BlockStart,
Use);
686void InlineSpiller::eliminateRedundantRestores() {
690 if (
MI.isDebugInstr())
696 if (tryForwardFromStoreToRestore(*
Store,
MI))
702 PreviousSlotAccess[MO.getIndex()] = &
MI;
706 if (ForwardedStoreRegs.empty())
711 auto It = ForwardedStoreRegs.find(VRM.getStackSlot(
Reg));
712 if (It != ForwardedStoreRegs.end())
713 DebugVars->splitRegister(
Reg, It->second, LIS);
715 ForwardedStoreRegs.clear();
721 assert(VNI &&
"Missing value");
723 WorkList.
push_back(std::make_pair(&SLI, VNI));
724 assert(StackInt &&
"No stack slot assigned yet.");
731 << VNI->
def <<
" in " << *LI <<
'\n');
734 if (isRegToSpill(
Reg))
738 StackInt->MergeValueInAsValue(*LI, VNI, StackInt->getValNumInfo(0));
739 LLVM_DEBUG(
dbgs() <<
"Merged to stack int: " << *StackInt <<
'\n');
744 if (!
MI.mayStore() && !
TII.isCopyInstr(
MI))
752 if (isSibling(DstReg)) {
755 assert(DstVNI &&
"Missing defined value");
756 assert(DstVNI->
def ==
Idx.getRegSlot() &&
"Wrong copy def slot");
758 WorkList.
push_back(std::make_pair(&DstLI, DstVNI));
768 MI.setDesc(
TII.get(TargetOpcode::KILL));
769 DeadDefs.push_back(&
MI);
771 if (HSpiller.rmFromMergeableSpills(
MI, StackSlot))
775 }
while (!WorkList.
empty());
786 WorkList.
push_back(std::make_pair(LI, VNI));
789 if (!UsedValues.insert(VNI).second)
797 WorkList.
push_back(std::make_pair(LI, PVNI));
804 if (!SnippetCopies.count(
MI))
806 LiveInterval &SnipLI = LIS.getInterval(
MI->getOperand(1).getReg());
807 assert(isRegToSpill(SnipLI.
reg()) &&
"Unexpected register in copy");
809 assert(SnipVNI &&
"Snippet undefined before copy");
810 WorkList.
push_back(std::make_pair(&SnipLI, SnipVNI));
811 }
while (!WorkList.
empty());
833 if (
MI.getOpcode() != TargetOpcode::STATEPOINT)
839 EndIdx =
MI.getNumOperands();
840 Idx < EndIdx; ++Idx) {
858 if (!
Matrix->checkInterference(PrevIdx, UseIdx, PhysReg))
884 if (MO.getReg() == VirtReg.
reg())
892 if (SnippetCopies.count(&
MI)) {
893 LLVM_DEBUG(
dbgs() <<
"\tskipping remat snippet copy for " << UseIdx <<
'\t'
900 assert(OrigVNI &&
"corrupted sub-interval");
918 CurDef = LIS.getInstructionFromIndex(CurVNI->
def);
935 if (CurDef &&
TII.isReMaterializable(*CurDef)) {
937 LLVM_DEBUG(
dbgs() <<
"\tFound remat possibility through COPY chain: "
941 markValueUsed(&VirtReg, ParentVNI);
942 LLVM_DEBUG(
dbgs() <<
"\tcannot remat missing def for " << UseIdx <<
'\t'
950 if (!Edit->canRematerializeAt(RM, UseIdx)) {
951 markValueUsed(&VirtReg, ParentVNI);
959 markValueUsed(&VirtReg, ParentVNI);
966 if (
RM.OrigMI->canFoldAsLoad() &&
967 (
RM.OrigMI->mayLoad() || !hasPhysRegAvailable(
MI)) &&
968 foldMemoryOperand(
Ops,
RM.OrigMI)) {
969 Edit->markRematerialized(
RM.ParentVNI);
977 markValueUsed(&VirtReg, ParentVNI);
983 Register NewVReg = Edit->createFrom(Original);
993 if (SR.liveAt(UseIdx))
994 UsedLanes |= SR.LaneMask;
998 SlotIndex DefIdx = Edit->rematerializeAt(*
MI.getParent(),
MI, NewVReg, RM,
999 TRI,
false, 0,
nullptr, UsedLanes);
1003 auto *NewMI = LIS.getInstructionFromIndex(DefIdx);
1004 NewMI->setDebugLoc(
MI.getDebugLoc());
1008 << *LIS.getInstructionFromIndex(DefIdx));
1011 for (
const auto &OpPair :
Ops) {
1024void InlineSpiller::reMaterializeAll() {
1028 bool anyRemat =
false;
1033 if (
MI.isDebugValue())
1036 assert(!
MI.isDebugInstr() &&
"Did not expect to find a use in debug "
1037 "instruction that isn't a DBG_VALUE");
1039 anyRemat |= reMaterializeFor(LI,
MI);
1053 if (!
MI->allDefsAreDead())
1056 DeadDefs.push_back(
MI);
1060 if (
MI->isBundledWithSucc() && !
MI->isBundledWithPred()) {
1062 EndIt =
MI->getParent()->instr_end();
1065 bool OnlyDeadCopies =
true;
1067 It != EndIt && It->isBundledWithPred(); ++It) {
1069 auto DestSrc =
TII.isCopyInstr(*It);
1070 bool IsCopyToDeadReg =
1071 DestSrc && DestSrc->Destination->getReg() ==
Reg;
1072 if (!IsCopyToDeadReg) {
1073 OnlyDeadCopies =
false;
1077 if (OnlyDeadCopies) {
1079 It != EndIt && It->isBundledWithPred(); ++It) {
1080 It->addRegisterDead(
Reg, &
TRI);
1082 DeadDefs.push_back(&*It);
1091 if (DeadDefs.empty())
1093 LLVM_DEBUG(
dbgs() <<
"Remat created " << DeadDefs.size() <<
" dead defs.\n");
1094 Edit->eliminateDeadDefs(DeadDefs, RegsToSpill);
1102 unsigned ResultPos = 0;
1105 Edit->eraseVirtReg(
Reg);
1106 RegsReplaced.push_back(
Reg);
1112 "Empty and not used live-range?!");
1114 RegsToSpill[ResultPos++] =
Reg;
1116 RegsToSpill.erase(RegsToSpill.begin() + ResultPos, RegsToSpill.end());
1118 <<
" registers to spill after remat.\n");
1129 bool IsLoad = InstrReg.
isValid();
1134 if (InstrReg !=
Reg || FI != StackSlot)
1138 HSpiller.rmFromMergeableSpills(*
MI, StackSlot);
1141 LIS.RemoveMachineInstrFromMaps(*
MI);
1142 MI->eraseFromParent();
1145 ++NumReloadsRemoved;
1155#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1161 const char *
const header,
1163 char NextLine =
'\n';
1164 char SlotIndent =
'\t';
1166 if (std::next(
B) ==
E) {
1171 dbgs() <<
'\t' << header <<
": " << NextLine;
1182 Idx = Idx.getRegSlot(
true);
1185 dbgs() << SlotIndent << Idx <<
'\t' << *
I;
1197foldMemoryOperand(
ArrayRef<std::pair<MachineInstr *, unsigned>>
Ops,
1203 if (
Ops.back().first !=
MI ||
MI->isBundled())
1206 bool WasCopy =
TII.isCopyInstr(*MI).has_value();
1215 bool UntieRegs =
MI->getOpcode() == TargetOpcode::STATEPOINT;
1220 MI->getOpcode() == TargetOpcode::STATEPOINT ||
1221 MI->getOpcode() == TargetOpcode::PATCHPOINT ||
1222 MI->getOpcode() == TargetOpcode::STACKMAP;
1227 for (
const auto &OpPair :
Ops) {
1228 unsigned Idx = OpPair.second;
1229 assert(
MI == OpPair.first &&
"Instruction conflict during operand folding");
1246 if (LoadMI && MO.
isDef())
1249 if (UntieRegs || !
MI->isRegTiedToDefOperand(Idx))
1255 if (FoldOps.
empty())
1262 for (
unsigned Idx : FoldOps) {
1266 unsigned Tied =
MI->findTiedOperandIdx(Idx);
1273 MI->untieRegOperand(Idx);
1279 ?
TII.foldMemoryOperand(*
MI, FoldOps, *LoadMI, CopyMI, &LIS, &VRM)
1280 :
TII.foldMemoryOperand(*
MI, FoldOps, StackSlot, CopyMI, &LIS, &VRM);
1283 for (
auto Tied : TiedOps)
1284 MI->tieOperands(Tied.first, Tied.second);
1310 HSpiller.rmFromMergeableSpills(*
MI, FI))
1326 bool NeedMatrixReassign =
1329 if (NeedMatrixReassign) {
1330 PhysReg = VRM.getPhys(CopyDstReg);
1337 if (NeedMatrixReassign)
1338 Matrix->assign(LI, PhysReg);
1343 assert(VRM.getOriginal(CopyDstReg) == CopyDstReg &&
1344 "COPY destination should be an original register");
1348 if (
MI->isCandidateForAdditionalCallInfo())
1349 MI->getMF()->moveAdditionalCallInfo(
MI, FoldMI);
1356 if (
MI->peekDebugInstrNum() &&
Ops[0].second == 0) {
1358 auto MakeSubstitution = [
this,FoldMI,
MI,&
Ops]() {
1360 unsigned OldOperandNum =
Ops[0].second;
1362 unsigned OldNum =
MI->getDebugInstrNum();
1363 MF.makeDebugValueSubstitution({OldNum, OldOperandNum},
1368 if (
Ops.size() == 1 && Op0.
isDef()) {
1370 }
else if (
Ops.size() == 2 && Op0.
isDef() &&
MI->getOperand(1).isTied() &&
1371 Op0.
getReg() ==
MI->getOperand(1).getReg()) {
1374 }
else if (
MI->peekDebugInstrNum()) {
1380 MF.substituteDebugValuesForInst(*
MI, *FoldMI,
Ops[0].second);
1383 MI->eraseFromParent();
1386 assert(!MIS.empty() &&
"Unexpected empty span of instructions!");
1388 if (&
MI != FoldMI && &
MI != CopyMI)
1393 if (
R.isVirtual()) {
1408 if (MO.
getReg() == ImpReg)
1417 else if (
Ops.front().second == 0) {
1422 if (std::distance(MIS.begin(), MIS.end()) <= 1)
1423 HSpiller.addToMergeableSpills(*FoldMI, StackSlot, Original);
1429void InlineSpiller::insertReload(
Register NewVReg,
1449 if (!Def.isImplicitDef())
1455 return MO.getReg() == Reg && MO.readsReg();
1460void InlineSpiller::insertSpill(
Register NewVReg,
1464 assert(!
MI->isTerminator() &&
"Inserting a spill after a terminator");
1479 BuildMI(
MBB, SpillBefore,
MI->getDebugLoc(),
TII.get(TargetOpcode::KILL))
1493 if (IsRealSpill && std::distance(Spill, MIS.end()) <= 1)
1494 HSpiller.addToMergeableSpills(*Spill, StackSlot, Original);
1498void InlineSpiller::spillAroundUses(
Register Reg) {
1505 if (
MI.isDebugValue()) {
1514 assert(!
MI.isDebugInstr() &&
"Did not expect to find a use in debug "
1515 "instruction that isn't a DBG_VALUE");
1518 if (SnippetCopies.count(&
MI))
1522 if (coalesceStackAccess(&
MI,
Reg))
1538 if (SibReg && isSibling(SibReg)) {
1540 if (isRegToSpill(SibReg)) {
1542 SnippetCopies.insert(&
MI);
1546 if (hoistSpillInsideBB(OldLI,
MI)) {
1548 MI.getOperand(0).setIsDead();
1549 DeadDefs.push_back(&
MI);
1555 eliminateRedundantSpills(SibLI, SibLI.
getVNInfoAt(Idx));
1561 if (foldMemoryOperand(
Ops))
1569 insertReload(NewVReg, Idx, &
MI);
1572 bool hasLiveDef =
false;
1573 for (
const auto &OpPair :
Ops) {
1584 insertSpill(NewVReg, &
MI);
1589void InlineSpiller::spillAll() {
1592 StackSlot = VRM.assignVirt2StackSlot(Original);
1593 StackInt = &LSS.getOrCreateInterval(StackSlot,
MRI.
getRegClass(Original));
1594 StackInt->getNextValue(
SlotIndex(), LSS.getVNInfoAllocator());
1596 StackInt = &LSS.getInterval(StackSlot);
1598 if (Original != Edit->getReg())
1599 VRM.assignVirt2StackSlot(Edit->getReg(), StackSlot);
1601 assert(StackInt->getNumValNums() == 1 &&
"Bad stack interval values");
1605 LLVM_DEBUG(
dbgs() <<
"Merged spilled regs: " << *StackInt <<
'\n');
1609 spillAroundUses(
Reg);
1613 VRM.assignVirt2StackSlot(
Reg, StackSlot);
1617 if (!DeadDefs.empty()) {
1618 LLVM_DEBUG(
dbgs() <<
"Eliminating " << DeadDefs.size() <<
" dead defs\n");
1619 Edit->eliminateDeadDefs(DeadDefs, RegsToSpill);
1626 assert(SnippetCopies.count(&
MI) &&
"Remaining use wasn't a snippet copy");
1629 MI.eraseFromBundle();
1635 Edit->eraseVirtReg(
Reg);
1644 Original = VRM.getOriginal(edit.
getReg());
1645 StackSlot = VRM.getStackSlot(Original);
1650 <<
':' << edit.
getParent() <<
"\nFrom original "
1653 "Attempting to spill already spilled value.");
1654 assert(DeadDefs.empty() &&
"Previous spill didn't remove dead defs");
1656 collectRegsToSpill();
1660 if (!RegsToSpill.empty())
1663 Edit->calculateRegClassAndHint(MF, VRAI);
1667void InlineSpiller::postOptimization() {
1668 eliminateRedundantRestores();
1669 HSpiller.hoistAllSpills();
1673void HoistSpillHelper::addToMergeableSpills(
MachineInstr &Spill,
int StackSlot,
1680 auto [Place,
Inserted] = StackSlotToOrigLI.try_emplace(StackSlot);
1682 auto LI = std::make_unique<LiveInterval>(OrigLI.
reg(), OrigLI.
weight());
1684 Place->second = std::move(LI);
1688 VNInfo *OrigVNI = Place->second->getVNInfoAt(
Idx.getRegSlot());
1689 std::pair<int, VNInfo *> MIdx = std::make_pair(StackSlot, OrigVNI);
1690 MergeableSpills[MIdx].insert(&Spill);
1695bool HoistSpillHelper::rmFromMergeableSpills(
MachineInstr &Spill,
1697 auto It = StackSlotToOrigLI.find(StackSlot);
1698 if (It == StackSlotToOrigLI.end())
1701 VNInfo *OrigVNI = It->second->getVNInfoAt(
Idx.getRegSlot());
1702 std::pair<int, VNInfo *> MIdx = std::make_pair(StackSlot, OrigVNI);
1703 return MergeableSpills[MIdx].erase(&Spill);
1708void HoistSpillHelper::addDeadSpillCandidate(
const MachineInstr &Spill,
1710 auto It = StackSlotToOrigLI.find(StackSlot);
1711 if (It == StackSlotToOrigLI.end())
1714 if (
VNInfo *OrigVNI = It->second->getVNInfoAt(Idx))
1715 DeadSpillCandidates.insert(OrigVNI);
1719bool HoistSpillHelper::isFullSlotStore(
const MachineInstr &
MI,
int FI)
const {
1720 if (
MI.peekDebugInstrNum() ||
MI.mayLoad() || !
MI.all_defs().empty())
1725 if (!
Reg || StoreFI != FI ||
Size.isScalable() ||
Size.isZero() ||
1726 Size.getFixedValue() !=
uint64_t(MF.getFrameInfo().getObjectSize(FI)))
1732 Register Use = MO.getReg();
1733 return !Use || Use == Reg ||
1734 (Use.isPhysical() && MRI.isConstantPhysReg(Use.asMCReg()));
1740void HoistSpillHelper::removeSlotsWithoutAccesses(
1749 if (
MI.isDebugValue())
1756 if (DeadSlots.
empty())
1770 int Slot = VRM.getStackSlot(
Reg);
1772 VRM.clearStackSlot(
Reg);
1776 for (
int Slot : DeadSlots) {
1789 if (
MI.isDebugInstr())
1795 auto It = StackSlotToOrigLI.find(FI);
1796 if (It == StackSlotToOrigLI.end() || isFullSlotStore(
MI, FI))
1815 while (!Worklist.
empty()) {
1834 if (Idx < OrigVNI.
def) {
1837 LLVM_DEBUG(
dbgs() <<
"can't spill in root block - def after LIP\n");
1844 for (
const Register &SibReg : Siblings) {
1852 return SR.getVNInfoAt(Idx) != nullptr;
1863void HoistSpillHelper::rmRedundantSpills(
1870 for (
auto *
const CurrentSpill : Spills) {
1877 MachineInstr *SpillToRm = (CIdx > PIdx) ? CurrentSpill : PrevSpill;
1878 MachineInstr *SpillToKeep = (CIdx > PIdx) ? PrevSpill : CurrentSpill;
1880 SpillBBToSpill[MDT.getNode(
Block)] = SpillToKeep;
1882 SpillBBToSpill[MDT.getNode(
Block)] = CurrentSpill;
1885 for (
auto *
const SpillToRm : SpillsToRm)
1886 Spills.erase(SpillToRm);
1895void HoistSpillHelper::getVisitOrders(
1919 for (
auto *
const Spill : Spills) {
1923 while (Node != RootIDomNode) {
1926 if (Node != MDT[
Block] && SpillBBToSpill[Node]) {
1927 SpillToRm = SpillBBToSpill[MDT[
Block]];
1932 }
else if (WorkSet.
count(Node)) {
1935 NodesOnPath.
insert(Node);
1950 NodesOnPath.
clear();
1960 if (WorkSet.
count(Child))
1963 }
while (idx != Orders.
size());
1965 "Orders have different size with WorkSet");
1970 for (; RIt != Orders.
rend(); RIt++)
1971 LLVM_DEBUG(
dbgs() <<
"BB" << (*RIt)->getBlock()->getNumber() <<
",");
1979void HoistSpillHelper::runHoistSpills(
1995 rmRedundantSpills(Spills, SpillsToRm, SpillBBToSpill);
1998 getVisitOrders(Root, Spills, Orders, SpillsToRm, SpillsToKeep,
2005 using NodesCostPair =
2006 std::pair<SmallPtrSet<MachineDomTreeNode *, 16>,
BlockFrequency>;
2014 for (; RIt != Orders.
rend(); RIt++) {
2018 if (
auto It = SpillsToKeep.
find(*RIt);
2019 It != SpillsToKeep.
end() && !It->second) {
2020 auto &SIt = SpillsInSubTreeMap[*RIt];
2023 SIt.second = MBFI.getBlockFreq(
Block);
2030 if (!SpillsInSubTreeMap.
contains(Child))
2038 auto &[SpillsInSubTree, SubTreeCost] = SpillsInSubTreeMap[*RIt];
2039 auto ChildIt = SpillsInSubTreeMap.
find(Child);
2040 SubTreeCost += ChildIt->second.second;
2041 auto BI = ChildIt->second.first.begin();
2042 auto EI = ChildIt->second.first.end();
2043 SpillsInSubTree.insert(BI, EI);
2044 SpillsInSubTreeMap.
erase(ChildIt);
2047 auto &[SpillsInSubTree, SubTreeCost] = SpillsInSubTreeMap[*RIt];
2049 if (SpillsInSubTree.empty())
2054 if (!isSpillCandBB(OrigLI, OrigVNI, *
Block, LiveReg))
2062 if (SubTreeCost > MBFI.getBlockFreq(
Block) * MarginProb) {
2064 for (auto *const SpillBB : SpillsInSubTree) {
2067 if (auto It = SpillsToKeep.find(SpillBB);
2068 It != SpillsToKeep.end() && !It->second) {
2069 MachineInstr *SpillToRm = SpillBBToSpill[SpillBB];
2070 SpillsToRm.push_back(SpillToRm);
2073 SpillsToKeep.erase(SpillBB);
2077 SpillsToKeep[*RIt] = LiveReg;
2079 dbgs() <<
"spills in BB: ";
2080 for (
const auto Rspill : SpillsInSubTree)
2081 dbgs() << Rspill->getBlock()->getNumber() <<
" ";
2082 dbgs() <<
"were promoted to BB" << (*RIt)->getBlock()->getNumber()
2085 SpillsInSubTree.clear();
2086 SpillsInSubTree.insert(*RIt);
2087 SubTreeCost = MBFI.getBlockFreq(
Block);
2092 for (
const auto &Ent : SpillsToKeep) {
2094 SpillsToIns[Ent.first->getBlock()] = Ent.second;
2114void HoistSpillHelper::hoistAllSpills() {
2122 Virt2SiblingsMap[Original].insert(
Reg);
2126 if (!DeadSpillCandidates.empty())
2127 UsedValues = collectUsedSpillValues();
2132 for (
auto &Ent : MergeableSpills) {
2133 int Slot = Ent.first.first;
2135 VNInfo *OrigVNI = Ent.first.second;
2137 if (Ent.second.empty())
2141 dbgs() <<
"\nFor Slot" <<
Slot <<
" and VN" << OrigVNI->
id <<
":\n"
2142 <<
"Equal spills in BB: ";
2143 for (
const auto spill : EqValSpills)
2144 dbgs() << spill->getParent()->getNumber() <<
" ";
2153 if (DeadSpillCandidates.contains(OrigVNI) &&
2158 SpillsToRm.append(EqValSpills.begin(), EqValSpills.end());
2159 EqValSpills.clear();
2160 NumSpillsRemoved += SpillsToRm.size();
2161 SlotsWithRemovedSpills.
insert(Slot);
2163 runHoistSpills(OrigLI, *OrigVNI, EqValSpills, SpillsToRm, SpillsToIns);
2167 dbgs() <<
"Finally inserted spills in BB: ";
2168 for (
const auto &Ispill : SpillsToIns)
2169 dbgs() << Ispill.first->getNumber() <<
" ";
2170 dbgs() <<
"\nFinally removed spills in BB: ";
2171 for (
const auto Rspill : SpillsToRm)
2172 dbgs() << Rspill->getParent()->getNumber() <<
" ";
2178 if (!SpillsToIns.empty() || !SpillsToRm.empty())
2180 StackIntvl.getValNumInfo(0));
2183 for (
auto const &Insert : SpillsToIns) {
2197 NumSpills -= SpillsToRm.size();
2198 for (
auto *
const RMEnt : SpillsToRm) {
2199 RMEnt->setDesc(
TII.get(TargetOpcode::KILL));
2200 for (
unsigned i = RMEnt->getNumOperands(); i; --i) {
2203 RMEnt->removeOperand(i - 1);
2206 Edit.eliminateDeadDefs(SpillsToRm, {});
2209 if (!SlotsWithRemovedSpills.
empty())
2210 removeSlotsWithoutAccesses(SlotsWithRemovedSpills);
2214 for (
auto &[VReg, PhysReg] : PendingReassignments) {
2216 "Pending reassignment without matrix or live interval");
2219 PendingReassignments.clear();
2226void HoistSpillHelper::LRE_WillShrinkVirtReg(
Register VirtReg) {
2232 Matrix->unassign(LI,
true);
2233 PendingReassignments[VirtReg] = PhysReg;
2239bool HoistSpillHelper::LRE_CanEraseVirtReg(
Register VirtReg) {
2240 PendingReassignments.erase(VirtReg);
2241 if (
Matrix && VRM.hasPhys(VirtReg)) {
2243 Matrix->unassign(LI,
true);
2255 auto PendingIt = PendingReassignments.find(Old);
2256 if (PendingIt != PendingReassignments.end()) {
2260 "Pending reassignment without matrix or live interval");
2262 PendingReassignments.erase(PendingIt);
2267 }
else if (VRM.hasPhys(Old)) {
2273 Matrix->unassign(LI,
true);
2274 Matrix->assign(LI, PhysReg);
2278 VRM.assignVirt2Phys(New, PhysReg);
2281 VRM.assignVirt2StackSlot(New, VRM.getStackSlot(Old));
2285 if (VRM.hasShape(Old))
2286 VRM.assignVirt2Shape(New, VRM.getShape(Old));
MachineInstrBuilder & UseMI
MachineInstrBuilder MachineInstrBuilder & DefMI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
const AArch64InstrInfo & TII
ReachingDefInfo InstSet InstSet & Ignore
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
This file defines the DenseMap class.
static LLVM_DUMP_METHOD void dumpMachineInstrRangeWithSlotIndex(MachineBasicBlock::iterator B, MachineBasicBlock::iterator E, LiveIntervals const &LIS, const char *const header, Register VReg=Register())
static Register isCopyOfBundle(const MachineInstr &FirstMI, Register Reg, const TargetInstrInfo &TII)
Check for a copy bundle as formed by SplitKit.
static bool isRealSpill(const MachineInstr &Def, Register Reg)
Check if Def defines Reg with an undefined value.
static bool readsPhysRegsOf(const MachineInstr &Other, const MachineInstr &MI, Register Ignore)
Return true if Other reads every physical register that MI reads, except Ignore.
static cl::opt< bool > RestrictStatepointRemat("restrict-statepoint-remat", cl::init(false), cl::Hidden, cl::desc("Restrict remat for statepoint operands"))
static Register isCopyOf(const MachineInstr &MI, Register Reg, const TargetInstrInfo &TII)
isFullCopyOf - If MI is a COPY to or from Reg, return the other register, otherwise return 0.
static void getVDefInterval(const MachineInstr &MI, LiveIntervals &LIS)
static Register getAssignedReg(const VirtRegMap &VRM, Register Reg)
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
Register const TargetRegisterInfo * TRI
This file implements a map that provides insertion order iteration.
Promote Memory to Register
MachineRegisterInfo & MRI
This file implements a set that has insertion order iteration characteristics.
This file defines the SmallPtrSet 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)
bool isSubregFoldable() const override
void loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, Register DestReg, int FrameIndex, const TargetRegisterClass *RC, Register VReg, unsigned SubReg=0, MachineInstr::MIFlag Flags=MachineInstr::NoFlags) const override
void storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, Register SrcReg, bool isKill, int FrameIndex, const TargetRegisterClass *RC, Register VReg, MachineInstr::MIFlag Flags=MachineInstr::NoFlags) const override
Register isLoadFromStackSlot(const MachineInstr &MI, int &FrameIndex) const override
Register isStoreToStackSlot(const MachineInstr &MI, int &FrameIndex) const override
Represent a constant reference to an array (0 or more elements consecutively in memory),...
bool contains(const_arg_type_t< KeyT > Val) const
Return true if the specified key is in the map, false otherwise.
iterator find(const_arg_type_t< KeyT > Val)
bool erase(const KeyT &Val)
ValueT lookup(const_arg_type_t< KeyT > Val) const
Return the entry for the specified key, or a default constructed value if no such entry exists.
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
Determines the latest safe point in a block in which we can insert a split, spill or other instructio...
A live range for subregisters.
LiveInterval - This class represents the liveness of a register, or stack slot.
bool isSpillable() const
isSpillable - Can this interval be spilled?
bool hasSubRanges() const
Returns true if subregister liveness information is available.
iterator_range< subrange_iterator > subranges()
bool hasInterval(Register Reg) const
SlotIndex InsertMachineInstrInMaps(MachineInstr &MI)
SlotIndexes * getSlotIndexes() const
SlotIndex getInstructionIndex(const MachineInstr &Instr) const
Returns the base index of the given instruction.
VNInfo::Allocator & getVNInfoAllocator()
SlotIndex getMBBEndIdx(const MachineBasicBlock *mbb) const
Return the last index in the given basic block.
LiveInterval & getInterval(Register Reg)
void InsertMachineInstrRangeInMaps(MachineBasicBlock::iterator B, MachineBasicBlock::iterator E)
LLVM_ABI bool shrinkToUses(LiveInterval *li, SmallVectorImpl< MachineInstr * > *dead=nullptr, LaneBitmask SubRangeMask=LaneBitmask::getAll())
After removing some uses of a register, shrink its live range to just the remaining uses.
LLVM_ABI void removePhysRegDefAt(MCRegister Reg, SlotIndex Pos)
Remove value numbers and related live segments starting at position Pos that are part of any liverang...
MachineBasicBlock * getMBBFromIndex(SlotIndex index) const
SlotIndex ReplaceMachineInstrInMaps(MachineInstr &MI, MachineInstr &NewMI)
Result of a LiveRange query.
SlotIndex endPoint() const
Return the end point of the last live range segment to interact with the instruction,...
bool isKill() const
Return true if the live-in value is killed by this instruction.
Callback methods for LiveRangeEdit owners.
const LiveInterval & getParent() const
This class represents the liveness of a register, stack slot, etc.
VNInfo * getValNumInfo(unsigned ValNo)
getValNumInfo - Returns pointer to the specified val#.
LLVM_ABI iterator addSegment(Segment S)
Add the specified Segment to this range, merging segments as appropriate.
LLVM_ABI void MergeValueInAsValue(const LiveRange &RHS, const VNInfo *RHSValNo, VNInfo *LHSValNo)
MergeValueInAsValue - Merge all of the segments of a specific val# in RHS into this live range as the...
iterator_range< vni_iterator > vnis()
LiveQueryResult Query(SlotIndex Idx) const
Query Liveness at Idx.
VNInfo * getVNInfoBefore(SlotIndex Idx) const
getVNInfoBefore - Return the VNInfo that is live up to but not necessarily including Idx,...
LLVM_ABI std::pair< VNInfo *, bool > extendInBlock(ArrayRef< SlotIndex > Undefs, SlotIndex StartIdx, SlotIndex Kill)
Attempt to extend a value defined after StartIdx to include Use.
unsigned getNumValNums() const
VNInfo * getNextValue(SlotIndex Def, VNInfo::Allocator &VNInfoAllocator)
getNextValue - Create a new value number and return it.
void assign(const LiveRange &Other, BumpPtrAllocator &Allocator)
Copies values numbers and live segments from Other into this range.
VNInfo * getVNInfoAt(SlotIndex Idx) const
getVNInfoAt - Return the VNInfo that is live at Idx, or NULL.
Wrapper class representing physical registers and target specific virtual registers.
MIBundleOperands - Iterate over all operands in a bundle of machine instructions.
LLVM_ABI iterator SkipPHIsLabelsAndDebug(iterator I, Register Reg=Register(), bool SkipPseudoOp=true)
Return the first instruction in MBB after I that is not a PHI, label or debug.
Instructions::iterator instr_iterator
Instructions::const_iterator const_instr_iterator
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
LLVM_ABI instr_iterator erase(instr_iterator I)
Remove an instruction from the instruction list and delete it.
iterator_range< pred_iterator > predecessors()
MachineInstrBundleIterator< MachineInstr > iterator
MachineBlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate machine basic b...
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
void RemoveStackObject(int ObjectIdx)
Remove or mark dead a statically sized stack object.
static const unsigned int DebugOperandMemNumber
A reserved operand number representing the instructions memory operand, for instructions that have a ...
const MachineInstrBuilder & addReg(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a new virtual register operand.
MachineInstr * getInstr() const
If conversion operators fail, use this method to get the MachineInstr explicitly.
MachineInstrSpan provides an interface to get an iteration range containing the instruction it was in...
Representation of each machine instruction.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
const MachineBasicBlock * getParent() const
filtered_mop_range all_defs()
Returns an iterator range over all operands that are (explicit or implicit) register defs.
bool isDebugInstr() const
unsigned getNumOperands() const
Retuns the total number of operands.
bool isBundledWithPred() const
Return true if this instruction is part of a bundle, and it is not the first instruction in the bundl...
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
LLVM_ABI void removeOperand(unsigned OpNo)
Erase an operand from an instruction, leaving it with one fewer operand than it started with.
filtered_mop_range all_uses()
Returns an iterator range over all operands that are (explicit or implicit) register uses.
bool isBundledWithSucc() const
Return true if this instruction is part of a bundle, and it is not the last instruction in the bundle...
LLVM_ABI unsigned getDebugInstrNum()
Fetch the instruction number of this MachineInstr.
const MachineOperand & getOperand(unsigned i) const
LLVM_ABI MachineInstrBundleIterator< MachineInstr > eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
MachineOperand * findRegisterDefOperand(Register Reg, const TargetRegisterInfo *TRI, bool isDead=false, bool Overlap=false)
Wrapper for findRegisterDefOperandIdx, it returns a pointer to the MachineOperand rather than an inde...
bool isBundled() const
Return true if this instruction part of a bundle.
LLVM_ABI bool addRegisterDead(Register Reg, const TargetRegisterInfo *RegInfo, bool AddIfNotFound=false)
We have determined MI defined a register without a use.
MachineOperand class - Representation of each machine instruction operand.
unsigned getSubReg() const
bool readsReg() const
readsReg - Returns true if this operand reads the previous value of its register.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
LLVM_ABI void setReg(Register Reg)
Change the register this operand corresponds to.
LLVM_ABI void ChangeToRegister(Register Reg, bool isDef, bool isImp=false, bool isKill=false, bool isDead=false, bool isUndef=false, bool isDebug=false)
ChangeToRegister - Replace this operand with a new register operand of the specified value.
bool isEarlyClobber() const
Register getReg() const
getReg - Returns the register number.
bool isFI() const
isFI - Tests if this is a MO_FrameIndex operand.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
iterator_range< reg_bundle_iterator > reg_bundles(Register Reg) const
const TargetRegisterClass * getRegClass(Register Reg) const
Return the register class of the specified virtual register.
reg_bundle_nodbg_iterator reg_bundle_nodbg_begin(Register RegNo) const
defusechain_instr_iterator< true, true, true, false > reg_bundle_nodbg_iterator
reg_bundle_nodbg_iterator/reg_bundle_nodbg_begin/reg_bundle_nodbg_end - Walk all defs and uses of the...
bool isReserved(MCRegister PhysReg) const
isReserved - Returns true when PhysReg is a reserved register.
iterator_range< use_bundle_nodbg_iterator > use_nodbg_bundles(Register Reg) const
bool def_empty(Register RegNo) const
def_empty - Return true if there are no instructions defining the specified register (it may be live-...
bool reg_nodbg_empty(Register RegNo) const
reg_nodbg_empty - Return true if the only instructions using or defining Reg are Debug instructions.
static reg_bundle_nodbg_iterator reg_bundle_nodbg_end()
LLVM_ABI bool isReservedRegUnit(MCRegUnit Unit) const
Returns true when the given register unit is considered reserved.
iterator_range< reg_instr_iterator > reg_instructions(Register Reg) const
LLVM_ABI const TargetRegisterClass * constrainRegClass(Register Reg, const TargetRegisterClass *RC, unsigned MinNumRegs=0)
constrainRegClass - Constrain the register class of the specified virtual register to be a common sub...
unsigned getNumVirtRegs() const
getNumVirtRegs - Return the number of virtual registers created.
This class implements a map that also provides access to all stored values in a deterministic order.
Wrapper class representing virtual and physical registers.
constexpr bool isStack() const
Return true if this is a stack slot.
static Register index2VirtReg(unsigned Index)
Convert a 0-based index to a virtual register number.
MCRegister asMCReg() const
Utility to check-convert this value to a MCRegister.
constexpr bool isValid() const
constexpr bool isVirtual() const
Return true if the specified register number is in the virtual register namespace.
bool remove(const value_type &X)
Remove an item from the set vector.
bool contains(const_arg_type key) const
Check if the SetVector contains the given key.
bool empty() const
Determine if the SetVector is empty or not.
bool insert(const value_type &X)
Insert a new element into the SetVector.
SlotIndex - An opaque wrapper around machine indexes.
static bool isSameInstr(SlotIndex A, SlotIndex B)
isSameInstr - Return true if A and B refer to the same instruction.
SlotIndex getBaseIndex() const
Returns the base index for associated with this index.
SlotIndex getPrevSlot() const
Returns the previous slot in the index list.
SlotIndex getRegSlot(bool EC=false) const
Returns the register use/def slot in the current instruction for a normal or early-clobber def.
LLVM_ABI void removeSingleMachineInstrFromMaps(MachineInstr &MI)
Removes a single machine instruction MI from the mapping.
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
void insert_range(Range &&R)
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
bool contains(ConstPtrType Ptr) const
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
A SetVector that performs no allocations if smaller than a certain size.
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)
reverse_iterator rbegin()
std::reverse_iterator< iterator > reverse_iterator
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
MI-level Statepoint operands.
LLVM_ABI bool isFoldableReg(Register Reg) const
Return true if Reg is used only in operands which can be folded to stack usage.
TargetInstrInfo - Interface to description of machine instruction set.
static constexpr TypeSize getZero()
A Use represents the edge between a Value definition and its users.
VNInfo - Value Number Information.
bool isUnused() const
Returns true if this value is unused.
unsigned id
The ID number of this value.
SlotIndex def
The index of the defining instruction.
bool isPHIDef() const
Returns true if this value is defined by a PHI instruction (or was, PHI instructions may have been el...
Calculate auxiliary information for a virtual register such as its spill weight and allocation hint.
MCRegister getPhys(Register virtReg) const
returns the physical register mapped to the specified virtual register
static constexpr int NO_STACK_SLOT
constexpr bool isZero() const
self_iterator getIterator()
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
initializer< Ty > init(const Ty &Val)
NodeAddr< DefNode * > Def
NodeAddr< NodeBase * > Node
This is an optimization pass for GlobalISel generic memory operations.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
@ Store
The extracted value is stored (ExtractElement only).
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
LLVM_ABI PhysRegInfo AnalyzePhysRegInBundle(const MachineInstr &MI, Register Reg, const TargetRegisterInfo *TRI)
AnalyzePhysRegInBundle - Analyze how the current instruction or bundle uses a physical register.
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.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_ABI Spiller * createInlineSpiller(const Spiller::RequiredAnalyses &Analyses, MachineFunction &MF, VirtRegMap &VRM, VirtRegAuxInfo &VRAI, LiveRegMatrix *Matrix=nullptr)
Create and return a spiller that will insert spill code directly instead of deferring though VirtRegM...
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
LLVM_ABI VirtRegInfo AnalyzeVirtRegInBundle(MachineInstr &MI, Register Reg, SmallVectorImpl< std::pair< MachineInstr *, unsigned > > *Ops=nullptr)
AnalyzeVirtRegInBundle - Analyze how the current instruction or bundle uses a virtual register.
DomTreeNodeBase< MachineBasicBlock > MachineDomTreeNode
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
ArrayRef(const T &OneElt) -> ArrayRef< T >
bool canGuaranteeAssignmentAfterRemat(Register VReg, const MachineInstr &MI)
Return whether we can guarantee physical register assignment if VReg's value is rematerialized immedi...
LLVM_ABI MachineInstr * buildDbgValueForSpill(MachineBasicBlock &BB, MachineBasicBlock::iterator I, const MachineInstr &Orig, int FrameIndex, Register SpillReg)
Clone a DBG_VALUE whose value has been spilled to FrameIndex.
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
BumpPtrAllocatorImpl<> BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
LLVM_ABI Printable printReg(Register Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubIdx=0, const MachineRegisterInfo *MRI=nullptr)
Prints virtual and physical registers with or without a TRI instance.
static constexpr LaneBitmask getAll()
static constexpr LaneBitmask getNone()
Remat - Information needed to rematerialize at a specific location.
This represents a simple continuous liveness interval for a value.
Information about how a physical register Reg is used by a set of operands.
bool FullyDefined
Reg or a super-register is defined.
VirtRegInfo - Information about a virtual register used by a set of operands.
bool Reads
Reads - One of the operands read the virtual register.
bool Tied
Tied - Uses and defs must use the same register.
bool Writes
Writes - One of the operands writes the virtual register.