30#include "llvm/Config/llvm-config.h"
45#define DEBUG_TYPE "regalloc"
49 cl::desc(
"Enable loop iv regalloc heuristic"),
53STATISTIC(NumSimple,
"Number of splits that were simple");
54STATISTIC(NumCopies,
"Number of copies inserted for splitting");
55STATISTIC(NumRemats,
"Number of rematerialized defs for splitting");
63 : LIS(lis), LastInsertPoint(BBNum) {}
66InsertPointAnalysis::computeLastInsertPoint(
const LiveInterval &CurLI,
68 unsigned Num =
MBB.getNumber();
69 std::pair<SlotIndex, SlotIndex> &LIP = LastInsertPoint[Num];
73 bool EHPadSuccessor =
false;
75 if (SMBB->isEHPad()) {
77 EHPadSuccessor =
true;
78 }
else if (SMBB->isInlineAsmBrIndirectTarget())
84 if (!LIP.first.isValid()) {
86 if (FirstTerm ==
MBB.
end())
89 LIP.first = LIS.getInstructionIndex(*FirstTerm);
97 if (ExceptionalSuccessors.
empty())
100 if ((EHPadSuccessor &&
MI.isCall()) ||
101 MI.getOpcode() == TargetOpcode::INLINEASM_BR) {
102 LIP.second = LIS.getInstructionIndex(
MI);
113 if (
none_of(ExceptionalSuccessors, [&](
const MachineBasicBlock *EHPad) {
114 return LIS.isLiveInToMBB(CurLI, EHPad);
126 if (
auto *
I = LIS.getInstructionFromIndex(LIP.second))
127 if (
I->getOpcode() == TargetOpcode::STATEPOINT)
145 if (LIP == LIS.getMBBEndIdx(&
MBB))
147 return LIS.getInstructionFromIndex(LIP);
156 :
MF(vrm.getMachineFunction()),
VRM(vrm),
LIS(lis),
Loops(mli),
157 TII(*
MF.getSubtarget().getInstrInfo()), IPA(lis,
MF.getNumBlockIDs()) {}
162 ThroughBlocks.clear();
167void SplitAnalysis::analyzeUses() {
168 assert(UseSlots.empty() &&
"Call clear first");
174 UseSlots.push_back(VNI->
def);
192 LLVM_DEBUG(
dbgs() <<
"Analyze counted " << UseSlots.size() <<
" instrs in "
193 << UseBlocks.
size() <<
" blocks, through "
194 << NumThroughBlocks <<
" blocks.\n");
199void SplitAnalysis::calcLiveBlockInfo() {
201 NumThroughBlocks = NumGapBlocks = 0;
209 UseI = UseSlots.begin();
210 UseE = UseSlots.end();
224 if (UseI == UseE || *UseI >= Stop) {
226 ThroughBlocks.
set(BI.MBB->getNumber());
229 assert(LVI->end >= Stop &&
"range ends mid block with no uses");
232 BI.FirstInstr = *UseI;
233 assert(BI.FirstInstr >= Start);
235 while (UseI != UseE && *UseI < Stop);
236 BI.LastInstr = UseI[-1];
237 assert(BI.LastInstr < Stop);
240 BI.LiveIn = LVI->start <=
Start;
244 assert(LVI->start == LVI->valno->def &&
"Dangling Segment start");
245 assert(LVI->start == BI.FirstInstr &&
"First instr should be a def");
246 BI.FirstDef = BI.FirstInstr;
251 while (LVI->end < Stop) {
252 SlotIndex LastStop = LVI->end;
253 if (++LVI == LVE || LVI->start >= Stop) {
255 BI.LastInstr = LastStop;
259 if (LastStop < LVI->start) {
266 UseBlocks.push_back(BI);
267 UseBlocks.back().LastInstr = LastStop;
272 BI.FirstInstr = BI.FirstDef = LVI->start;
276 assert(LVI->start == LVI->valno->def &&
"Dangling Segment start");
278 BI.FirstDef = LVI->start;
281 UseBlocks.push_back(BI);
289 if (LVI->end == Stop && ++LVI == LVE)
293 if (LVI->start < Stop)
296 MFI =
LIS.getMBBFromIndex(LVI->start)->getIterator();
301 MachineLoop *
L =
Loops.getLoopFor(BI.MBB);
302 return BI.LiveIn && BI.LiveOut && BI.FirstDef &&
L &&
303 L->isLoopLatch(BI.MBB);
319 LIS.getMBBFromIndex(LVI->start)->getIterator();
328 Stop =
LIS.getMBBEndIdx(&*MFI);
329 }
while (Stop <= LVI->start);
336 assert(!Orig.
empty() &&
"Splitting empty interval?");
340 if (
I != Orig.
end() &&
I->start <= Idx)
341 return I->start == Idx;
344 return I != Orig.
begin() && (--
I)->end == Idx;
361 : SA(SA), LIS(LIS), VRM(VRM), MRI(VRM.getMachineFunction().getRegInfo()),
362 MDT(MDT), TII(*VRM.getMachineFunction().getSubtarget().getInstrInfo()),
363 TRI(*VRM.getMachineFunction().getSubtarget().getRegisterInfo()),
364 MBFI(MBFI), VRAI(VRAI), RegAssign(Allocator) {}
374 LICalc[0].reset(&VRM.getMachineFunction(), LIS.getSlotIndexes(), &MDT,
375 &LIS.getVNInfoAllocator());
377 LICalc[1].reset(&VRM.getMachineFunction(), LIS.getSlotIndexes(), &MDT,
378 &LIS.getVNInfoAllocator());
381#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
383 if (RegAssign.empty()) {
384 dbgs() <<
" empty\n";
388 for (RegAssignMap::const_iterator
I = RegAssign.begin();
I.valid(); ++
I)
389 dbgs() <<
" [" <<
I.start() <<
';' <<
I.stop() <<
"):" <<
I.value();
399 for (
auto &S : LI.subranges())
400 if (S.LaneMask == LM)
421 if ((S.LaneMask & LM) == LM)
434 LaneMask |= S.LaneMask;
449 for (LiveInterval::SubRange &S : LI.
subranges()) {
450 const LiveInterval::SubRange *PS =
455 if (PV !=
nullptr && PV->
def == Def)
456 S.createDeadDef(Def, LIS.getVNInfoAllocator());
462 const MachineInstr *
DefMI = LIS.getInstructionFromIndex(Def);
465 for (
const MachineOperand &DefOp :
DefMI->
defs()) {
469 if (
unsigned SR = DefOp.getSubReg())
470 LM |= TRI.getSubRegIndexLaneMask(SR);
472 LM = MRI.getMaxLaneMaskForVReg(R);
476 for (LiveInterval::SubRange &S : LI.
subranges())
477 if ((S.LaneMask & LM).any())
478 S.createDeadDef(Def, LIS.getVNInfoAllocator());
482VNInfo *SplitEditor::defValue(
unsigned RegIdx,
486 assert(ParentVNI &&
"Mapping NULL value");
488 assert(Edit->getParent().getVNInfoAt(Idx) == ParentVNI &&
"Bad Parent VNI");
489 LiveInterval *LI = &LIS.getInterval(Edit->get(RegIdx));
492 VNInfo *VNI = LI->
getNextValue(Idx, LIS.getVNInfoAllocator());
495 ValueForcePair
FP(Force ?
nullptr : VNI, Force);
497 std::pair<ValueMap::iterator, bool> InsP =
498 Values.insert(std::make_pair(std::make_pair(RegIdx, ParentVNI->
id),
FP));
502 if (!Force && InsP.second)
506 if (VNInfo *OldVNI = InsP.first->second.getPointer()) {
507 addDeadDef(*LI, OldVNI, Original);
511 InsP.first->second = ValueForcePair(
nullptr, Force);
515 addDeadDef(*LI, VNI, Original);
519void SplitEditor::forceRecompute(
unsigned RegIdx,
const VNInfo &ParentVNI) {
520 ValueForcePair &VFP = Values[std::make_pair(RegIdx, ParentVNI.
id)];
521 VNInfo *VNI = VFP.getPointer();
532 addDeadDef(LIS.getInterval(Edit->get(RegIdx)), VNI,
false);
535 VFP = ValueForcePair(
nullptr,
true);
538SlotIndex SplitEditor::buildSingleSubRegCopy(
542 bool FirstCopy = !
Def.isValid();
543 MachineInstr *CopyMI =
549 .
addReg(FromReg, {}, SubIdx);
552 SlotIndexes &Indexes = *LIS.getSlotIndexes();
564 const MCInstrDesc &
Desc =
565 TII.get(TII.getLiveRangeSplitOpcode(FromReg, *
MBB.
getParent()));
566 SlotIndexes &Indexes = *LIS.getSlotIndexes();
567 if (LaneMask.
all() || LaneMask == MRI.getMaxLaneMaskForVReg(FromReg)) {
569 MachineInstr *CopyMI =
578 LiveInterval &DestLI = LIS.getInterval(Edit->get(RegIdx));
582 const TargetRegisterClass *RC = MRI.getRegClass(FromReg);
583 assert(RC == MRI.getRegClass(ToReg) &&
"Should have same reg class");
585 SmallVector<unsigned, 8> SubIndexes;
588 if (!TRI.getCoveringSubRegIndexes(RC, LaneMask, SubIndexes))
592 for (
unsigned BestIdx : SubIndexes) {
593 Def = buildSingleSubRegCopy(FromReg, ToReg,
MBB, InsertBefore, BestIdx,
594 DestLI, Late, Def,
Desc);
600 [Def, &Allocator](LiveInterval::SubRange &SR) {
611 const MachineInstr *
UseMI = LIS.getInstructionFromIndex(UseIdx);
616 const unsigned DefOperandIdx = 0;
620 const TargetRegisterClass *DefConstrainRC =
625 const TargetRegisterClass *RC = MRI.getRegClass(Edit->getReg());
629 const TargetRegisterClass *SuperRC =
633 const TargetRegisterClass *UseConstrainRC =
636 return UseConstrainRC->
hasSubClass(DefConstrainRC);
639VNInfo *SplitEditor::defFromParent(
unsigned RegIdx,
const VNInfo *ParentVNI,
642 LiveInterval *LI = &LIS.getInterval(Edit->get(RegIdx));
646 bool Late = RegIdx != 0;
649 Register Original = VRM.getOriginal(Edit->get(RegIdx));
650 LiveInterval &OrigLI = LIS.getInterval(Original);
655 if (OrigVNI && LaneMask.
any()) {
656 LiveRangeEdit::Remat
RM(ParentVNI);
657 RM.OrigMI = LIS.getInstructionFromIndex(OrigVNI->
def);
658 if (
RM.OrigMI && TII.isAsCheapAsAMove(*
RM.OrigMI) &&
659 Edit->canRematerializeAt(RM, UseIdx)) {
660 if (!rematWillIncreaseRestriction(
RM.OrigMI,
MBB, UseIdx)) {
661 SlotIndex
Def = Edit->rematerializeAt(
MBB,
I,
Reg, RM, TRI, Late, 0,
665 return defValue(RegIdx, ParentVNI, Def,
false);
670 <<
" since it will increase register class restrictions\n");
675 if (LaneMask.
none()) {
676 const MCInstrDesc &
Desc = TII.get(TargetOpcode::IMPLICIT_DEF);
678 SlotIndexes &Indexes = *LIS.getSlotIndexes();
682 Def = buildCopy(Edit->getReg(),
Reg, LaneMask,
MBB,
I, Late, RegIdx);
686 return defValue(RegIdx, ParentVNI, Def,
false);
693 Edit->createEmptyInterval();
696 OpenIdx = Edit->size();
697 Edit->createEmptyInterval();
702 assert(Idx != 0 &&
"Cannot select the complement interval");
703 assert(Idx < Edit->
size() &&
"Can only select previously opened interval");
704 LLVM_DEBUG(
dbgs() <<
" selectIntv " << OpenIdx <<
" -> " << Idx <<
'\n');
709 assert(OpenIdx &&
"openIntv not called before enterIntvBefore");
712 VNInfo *ParentVNI = Edit->getParent().getVNInfoAt(Idx);
719 assert(
MI &&
"enterIntvBefore called with invalid index");
721 VNInfo *VNI = defFromParent(OpenIdx, ParentVNI, Idx, *
MI->getParent(),
MI);
726 assert(OpenIdx &&
"openIntv not called before enterIntvAfter");
729 VNInfo *ParentVNI = Edit->getParent().getVNInfoAt(Idx);
736 assert(
MI &&
"enterIntvAfter called with invalid index");
738 VNInfo *VNI = defFromParent(OpenIdx, ParentVNI, Idx, *
MI->getParent(),
744 assert(OpenIdx &&
"openIntv not called before enterIntvAtEnd");
749 VNInfo *ParentVNI = Edit->getParent().getVNInfoAt(
Last);
763 ParentVNI = Edit->getParent().getVNInfoAt(
Last);
773 SA.getLastSplitPointIter(&
MBB));
774 RegAssign.insert(VNI->
def, End, OpenIdx);
785 assert(OpenIdx &&
"openIntv not called before useIntv");
786 LLVM_DEBUG(
dbgs() <<
" useIntv [" << Start <<
';' << End <<
"):");
787 RegAssign.insert(Start, End, OpenIdx);
792 assert(OpenIdx &&
"openIntv not called before leaveIntvAfter");
797 VNInfo *ParentVNI = Edit->getParent().getVNInfoAt(Boundary);
804 assert(
MI &&
"No instruction at index");
811 MI->readsVirtualRegister(Edit->getReg())) {
812 forceRecompute(0, *ParentVNI);
813 defFromParent(0, ParentVNI, Idx, *
MI->getParent(),
MI);
817 VNInfo *VNI = defFromParent(0, ParentVNI, Boundary, *
MI->getParent(),
823 assert(OpenIdx &&
"openIntv not called before leaveIntvBefore");
828 VNInfo *ParentVNI = Edit->getParent().getVNInfoAt(Idx);
836 assert(
MI &&
"No instruction at index");
837 VNInfo *VNI = defFromParent(0, ParentVNI, Idx, *
MI->getParent(),
MI);
842 assert(OpenIdx &&
"openIntv not called before leaveIntvAtTop");
847 VNInfo *ParentVNI = Edit->getParent().getVNInfoAt(Start);
854 Register Reg = LIS.getInterval(Edit->get(RegIdx)).reg();
855 VNInfo *VNI = defFromParent(RegIdx, ParentVNI, Start,
MBB,
856 MBB.SkipPHIsLabelsAndDebug(
MBB.begin(), Reg));
857 RegAssign.insert(Start, VNI->
def, OpenIdx);
864 return MO.isReg() && MO.isTied() && MO.getReg() == Reg;
869 assert(OpenIdx &&
"openIntv not called before overlapIntv");
870 const VNInfo *ParentVNI = Edit->getParent().getVNInfoAt(Start);
871 assert(ParentVNI == Edit->getParent().getVNInfoBefore(End) &&
872 "Parent changes value in extended range");
873 assert(LIS.getMBBFromIndex(Start) == LIS.getMBBFromIndex(End) &&
874 "Range cannot span basic blocks");
878 forceRecompute(0, *ParentVNI);
883 if (
auto *
MI = LIS.getInstructionFromIndex(End))
889 LLVM_DEBUG(
dbgs() <<
" overlapIntv [" << Start <<
';' << End <<
"):");
890 RegAssign.insert(Start, End, OpenIdx);
902 AssignI.setMap(RegAssign);
907 assert(
MI &&
"No instruction for back-copy");
912 do AtBegin =
MBBI ==
MBB->begin();
913 while (!AtBegin && (--
MBBI)->isDebugOrPseudoInstr());
918 MI->eraseFromParent();
922 AssignI.find(Def.getPrevSlot());
923 if (!AssignI.valid() || AssignI.start() >= Def)
926 if (AssignI.stop() != Def)
928 unsigned RegIdx = AssignI.value();
934 AtBegin ?
SlotIndex() : LIS.getInstructionIndex(*
MBBI).getRegSlot();
935 if (AtBegin || !
MBBI->readsVirtualRegister(Edit->
getReg()) ||
936 Kill <= AssignI.start()) {
937 LLVM_DEBUG(dbgs() <<
" cannot find simple kill of RegIdx " << RegIdx
939 forceRecompute(RegIdx, *Edit->getParent().getVNInfoAt(Def));
941 LLVM_DEBUG(dbgs() <<
" move kill to " << Kill <<
'\t' << *MBBI);
942 AssignI.setStop(Kill);
952 assert(MDT.dominates(DefMBB,
MBB) &&
"MBB must be dominated by the def.");
954 const MachineLoopInfo &
Loops = SA.Loops;
955 const MachineLoop *DefLoop =
Loops.getLoopFor(DefMBB);
959 MachineBasicBlock *BestMBB =
MBB;
960 unsigned BestDepth = std::numeric_limits<unsigned>::max();
963 const MachineLoop *Loop =
Loops.getLoopFor(
MBB);
975 if (Loop == DefLoop) {
978 <<
" in the same loop\n");
984 if (
Depth < BestDepth) {
989 <<
" at depth " <<
Depth <<
'\n');
997 if (!IDom || !MDT.dominates(DefDomNode, IDom))
1004void SplitEditor::computeRedundantBackCopies(
1006 LiveInterval *LI = &LIS.getInterval(Edit->get(0));
1007 const LiveInterval *Parent = &Edit->getParent();
1009 SmallPtrSet<VNInfo *, 8> DominatedVNIs;
1012 for (VNInfo *VNI : LI->
valnos) {
1015 VNInfo *ParentVNI = Edit->getParent().getVNInfoAt(VNI->
def);
1016 EqualVNs[ParentVNI->
id].insert(VNI);
1021 for (
unsigned i = 0, e = Parent->
getNumValNums(); i != e; ++i) {
1023 if (!NotToHoistSet.
count(ParentVNI->
id))
1025 SmallPtrSetIterator<VNInfo *> It1 = EqualVNs[ParentVNI->
id].begin();
1026 SmallPtrSetIterator<VNInfo *> It2 = It1;
1027 for (; It1 != EqualVNs[ParentVNI->
id].end(); ++It1) {
1029 for (++It2; It2 != EqualVNs[ParentVNI->
id].end(); ++It2) {
1030 if (DominatedVNIs.
count(*It1) || DominatedVNIs.
count(*It2))
1033 MachineBasicBlock *MBB1 = LIS.getMBBFromIndex((*It1)->def);
1034 MachineBasicBlock *MBB2 = LIS.getMBBFromIndex((*It2)->def);
1036 DominatedVNIs.
insert((*It1)->def < (*It2)->def ? (*It2) : (*It1));
1037 }
else if (MDT.dominates(MBB1, MBB2)) {
1038 DominatedVNIs.
insert(*It2);
1039 }
else if (MDT.dominates(MBB2, MBB1)) {
1040 DominatedVNIs.
insert(*It1);
1044 if (!DominatedVNIs.
empty()) {
1045 forceRecompute(0, *ParentVNI);
1047 DominatedVNIs.
clear();
1057void SplitEditor::hoistCopies() {
1059 LiveInterval *LI = &LIS.getInterval(Edit->get(0));
1060 const LiveInterval *Parent = &Edit->getParent();
1064 using DomPair = std::pair<MachineBasicBlock *, SlotIndex>;
1070 DenseSet<unsigned> NotToHoistSet;
1074 for (VNInfo *VNI : LI->
valnos) {
1077 VNInfo *ParentVNI = Edit->getParent().getVNInfoAt(VNI->
def);
1078 assert(ParentVNI &&
"Parent not live at complement def");
1082 if (Edit->didRematerialize(ParentVNI))
1085 MachineBasicBlock *ValMBB = LIS.getMBBFromIndex(VNI->
def);
1087 DomPair &Dom = NearestDom[ParentVNI->
id];
1092 if (VNI->
def == ParentVNI->
def) {
1094 Dom = DomPair(ValMBB, VNI->
def);
1099 if (Values.lookup(std::make_pair(0, ParentVNI->
id)).getPointer()) {
1106 Dom = DomPair(ValMBB, VNI->
def);
1107 }
else if (Dom.first == ValMBB) {
1109 if (!Dom.second.isValid() || VNI->
def < Dom.second)
1110 Dom.second = VNI->
def;
1113 MachineBasicBlock *
Near =
1114 MDT.findNearestCommonDominator(Dom.first, ValMBB);
1117 Dom = DomPair(ValMBB, VNI->
def);
1118 else if (Near != Dom.first)
1120 Dom = DomPair(Near, SlotIndex());
1121 Costs[ParentVNI->
id] += MBFI.getBlockFreq(ValMBB);
1125 << VNI->
def <<
" for parent " << ParentVNI->
id <<
'@'
1126 << ParentVNI->
def <<
" hoist to "
1132 for (
unsigned i = 0, e = Parent->
getNumValNums(); i != e; ++i) {
1133 DomPair &Dom = NearestDom[i];
1134 if (!Dom.first || Dom.second.isValid())
1138 MachineBasicBlock *DefMBB = LIS.getMBBFromIndex(ParentVNI->
def);
1140 Dom.first = findShallowDominator(Dom.first, DefMBB);
1142 MBFI.getBlockFreq(Dom.first) > Costs[ParentVNI->
id]) {
1143 NotToHoistSet.
insert(ParentVNI->
id);
1146 SlotIndex LSP = SA.getLastSplitPoint(Dom.first);
1147 if (LSP <= ParentVNI->def) {
1148 NotToHoistSet.
insert(ParentVNI->
id);
1151 Dom.second = defFromParent(0, ParentVNI, LSP, *Dom.first,
1152 SA.getLastSplitPointIter(Dom.first))->def;
1158 for (VNInfo *VNI : LI->
valnos) {
1161 VNInfo *ParentVNI = Edit->getParent().getVNInfoAt(VNI->
def);
1162 const DomPair &Dom = NearestDom[ParentVNI->
id];
1163 if (!Dom.first || Dom.second == VNI->
def ||
1164 NotToHoistSet.
count(ParentVNI->
id))
1167 forceRecompute(0, *ParentVNI);
1173 computeRedundantBackCopies(NotToHoistSet, BackCopies);
1175 removeBackCopies(BackCopies);
1180bool SplitEditor::transferValues() {
1182 RegAssignMap::const_iterator AssignI = RegAssign.begin();
1183 for (
const LiveRange::Segment &S : Edit->getParent()) {
1185 VNInfo *ParentVNI = S.valno;
1187 SlotIndex
Start = S.start;
1188 AssignI.advanceTo(Start);
1191 SlotIndex End = S.end;
1192 if (!AssignI.valid()) {
1194 }
else if (AssignI.start() <= Start) {
1195 RegIdx = AssignI.value();
1196 if (AssignI.stop() < End) {
1197 End = AssignI.stop();
1202 End = std::min(End, AssignI.start());
1206 LLVM_DEBUG(
dbgs() <<
" [" << Start <<
';' << End <<
")=" << RegIdx <<
'('
1207 <<
printReg(Edit->get(RegIdx)) <<
')');
1208 LiveInterval &LI = LIS.getInterval(Edit->get(RegIdx));
1211 ValueForcePair VFP = Values.lookup(std::make_pair(RegIdx, ParentVNI->
id));
1212 if (VNInfo *VNI = VFP.getPointer()) {
1214 LI.
addSegment(LiveInterval::Segment(Start, End, VNI));
1227 LiveIntervalCalc &LIC = getLICalc(RegIdx);
1233 SlotIndex BlockStart, BlockEnd;
1234 std::tie(BlockStart, BlockEnd) = LIS.getSlotIndexes()->getMBBRange(&*
MBB);
1237 if (Start != BlockStart) {
1238 VNInfo *VNI = LI.
extendInBlock(BlockStart, std::min(BlockEnd, End));
1239 assert(VNI &&
"Missing def for complex mapped value");
1242 if (BlockEnd <= End)
1247 BlockStart = BlockEnd;
1251 assert(Start <= BlockStart &&
"Expected live-in block");
1252 while (BlockStart < End) {
1254 BlockEnd = LIS.getMBBEndIdx(&*
MBB);
1255 if (BlockStart == ParentVNI->
def) {
1257 assert(ParentVNI->
isPHIDef() &&
"Non-phi defined at block start?");
1258 VNInfo *VNI = LI.
extendInBlock(BlockStart, std::min(BlockEnd, End));
1259 assert(VNI &&
"Missing def for complex mapped parent PHI");
1260 if (End >= BlockEnd)
1273 BlockStart = BlockEnd;
1277 }
while (Start != S.end);
1281 LICalc[0].calculateValues();
1283 LICalc[1].calculateValues();
1292 if (Seg->
end != Def.getDeadSlot())
1302 for (MachineBasicBlock *
P :
B.predecessors()) {
1303 SlotIndex End = LIS.getMBBEndIdx(
P);
1307 const LiveInterval &PLI = Edit->getParent();
1313 LIC.
extend(LR, End, 0, Undefs);
1317void SplitEditor::extendPHIKillRanges() {
1324 const LiveInterval &ParentLI = Edit->getParent();
1325 for (
const VNInfo *V : ParentLI.
valnos) {
1326 if (
V->isUnused() || !
V->isPHIDef())
1329 unsigned RegIdx = RegAssign.lookup(
V->def);
1330 LiveInterval &LI = LIS.getInterval(Edit->get(RegIdx));
1331 LiveIntervalCalc &LIC = getLICalc(RegIdx);
1332 MachineBasicBlock &
B = *LIS.getMBBFromIndex(
V->def);
1338 LiveIntervalCalc SubLIC;
1340 for (
const LiveInterval::SubRange &PS : ParentLI.
subranges()) {
1341 for (
const VNInfo *V : PS.
valnos) {
1342 if (
V->isUnused() || !
V->isPHIDef())
1344 unsigned RegIdx = RegAssign.lookup(
V->def);
1345 LiveInterval &LI = LIS.getInterval(Edit->get(RegIdx));
1350 MachineBasicBlock &
B = *LIS.getMBBFromIndex(
V->def);
1351 SubLIC.
reset(&VRM.getMachineFunction(), LIS.getSlotIndexes(), &MDT,
1352 &LIS.getVNInfoAllocator());
1355 extendPHIRange(
B, SubLIC, S, PS.
LaneMask, Undefs);
1361void SplitEditor::rewriteAssigned(
bool ExtendRanges) {
1363 ExtPoint(
const MachineOperand &O,
unsigned R, SlotIndex
N)
1364 : MO(
O), RegIdx(
R),
Next(
N) {}
1373 for (MachineOperand &MO :
1375 MachineInstr *MI = MO.getParent();
1377 if (MI->isDebugValue()) {
1378 LLVM_DEBUG(dbgs() <<
"Zapping " << *MI);
1386 SlotIndex Idx = LIS.getInstructionIndex(*
MI);
1387 if (MO.isDef() || MO.isUndef())
1391 unsigned RegIdx = RegAssign.lookup(Idx);
1392 LiveInterval &LI = LIS.getInterval(Edit->get(RegIdx));
1393 MO.setReg(LI.
reg());
1395 <<
'\t' << Idx <<
':' << RegIdx <<
'\t' << *
MI);
1398 if (!ExtendRanges || MO.isUndef())
1403 if (!MO.getSubReg() && !MO.isEarlyClobber())
1407 if (!Edit->getParent().liveAt(Idx.getPrevSlot()))
1411 bool IsEarlyClobber = false;
1425 unsigned OpIdx = MO.getOperandNo();
1426 unsigned DefOpIdx = MI->findTiedOperandIdx(OpIdx);
1427 const MachineOperand &DefOp = MI->getOperand(DefOpIdx);
1428 IsEarlyClobber = DefOp.isEarlyClobber();
1441 ExtPoints.push_back(ExtPoint(MO, RegIdx, Next));
1443 LiveIntervalCalc &LIC = getLICalc(RegIdx);
1444 LIC.extend(LI, Next, 0, ArrayRef<SlotIndex>());
1448 for (ExtPoint &EP : ExtPoints) {
1449 LiveInterval &LI = LIS.getInterval(Edit->get(EP.RegIdx));
1454 unsigned Sub = EP.MO.getSubReg();
1467 SubLIC.
reset(&VRM.getMachineFunction(), LIS.getSlotIndexes(), &MDT,
1468 &LIS.getVNInfoAllocator());
1471 SubLIC.
extend(S, EP.Next, 0, Undefs);
1481 LIS.constructMainRangeFromSubranges(LI);
1485void SplitEditor::deleteRematVictims() {
1486 SmallVector<MachineInstr*, 8>
Dead;
1488 LiveInterval *LI = &LIS.getInterval(R);
1489 for (
const LiveRange::Segment &S : LI->
segments) {
1495 MachineInstr *
MI = LIS.getInstructionFromIndex(S.
valno->
def);
1496 assert(
MI &&
"Missing instruction for dead def");
1497 MI->addRegisterDead(LI->
reg(), &TRI);
1499 if (!
MI->allDefsAreDead())
1510 Edit->eliminateDeadDefs(
Dead, {});
1513void SplitEditor::forceRecomputeVNI(
const VNInfo &ParentVNI) {
1516 for (
unsigned I = 0,
E = Edit->size();
I !=
E; ++
I)
1517 forceRecompute(
I, ParentVNI);
1523 SmallPtrSet<const VNInfo *, 8> Visited = {&ParentVNI};
1526 const LiveInterval &ParentLI = Edit->getParent();
1527 const SlotIndexes &Indexes = *LIS.getSlotIndexes();
1530 for (
unsigned I = 0,
E = Edit->size();
I !=
E; ++
I)
1531 forceRecompute(
I, VNI);
1539 assert(PredVNI &&
"Value available in PhiVNI predecessor");
1540 if (Visited.
insert(PredVNI).second)
1543 }
while(!WorkList.
empty());
1553 for (
const VNInfo *ParentVNI : Edit->getParent().valnos) {
1556 unsigned RegIdx = RegAssign.lookup(ParentVNI->
def);
1557 defValue(RegIdx, ParentVNI, ParentVNI->
def,
true);
1561 if (Edit->didRematerialize(ParentVNI))
1562 forceRecomputeVNI(*ParentVNI);
1566 switch (SpillMode) {
1577 bool Skipped = transferValues();
1580 rewriteAssigned(Skipped);
1583 extendPHIKillRanges();
1589 deleteRematVictims();
1601 LRMap->
assign(Seq.begin(), Seq.end());
1606 for (
unsigned i = 0, e = Edit->size(); i != e; ++i) {
1611 LIS.splitSeparateComponents(LI, SplitLIs);
1612 Register Original = VRM.getOriginal(VReg);
1614 VRM.setIsSplitFromReg(SplitLI->reg(), Original);
1618 LRMap->
resize(Edit->size(), i);
1622 Edit->calculateRegClassAndHint(VRM.getMachineFunction(), VRAI);
1624 assert(!LRMap || LRMap->
size() == Edit->size());
1632 bool SingleInstrs)
const {
1644 bool copyLike =
TII.isCopyInstr(*
MI) ||
MI->isSubregToReg();
1653 SlotIndex LastSplitPoint = SA.getLastSplitPoint(BI.
MBB);
1679 unsigned IntvOut,
SlotIndex EnterAfter){
1681 std::tie(Start, Stop) = LIS.getSlotIndexes()->getMBBRange(MBBNum);
1683 LLVM_DEBUG(
dbgs() <<
"%bb." << MBBNum <<
" [" << Start <<
';' << Stop
1684 <<
") intf " << LeaveBefore <<
'-' << EnterAfter
1685 <<
", live-through " << IntvIn <<
" -> " << IntvOut);
1687 assert((IntvIn || IntvOut) &&
"Use splitSingleBlock for isolated blocks");
1689 assert((!LeaveBefore || LeaveBefore < Stop) &&
"Interference after block");
1690 assert((!IntvIn || !LeaveBefore || LeaveBefore > Start) &&
"Impossible intf");
1691 assert((!EnterAfter || EnterAfter >= Start) &&
"Interference before block");
1704 assert((!LeaveBefore || Idx <= LeaveBefore) &&
"Interference");
1718 assert((!EnterAfter || Idx >= EnterAfter) &&
"Interference");
1723 if (IntvIn == IntvOut && !LeaveBefore && !EnterAfter) {
1735 SlotIndex LSP = SA.getLastSplitPoint(MBBNum);
1736 assert((!IntvOut || !EnterAfter || EnterAfter < LSP) &&
"Impossible intf");
1738 if (IntvIn != IntvOut && (!LeaveBefore || !EnterAfter ||
1748 if (LeaveBefore && LeaveBefore < LSP) {
1756 assert((!LeaveBefore || Idx <= LeaveBefore) &&
"Interference");
1757 assert((!EnterAfter || Idx >= EnterAfter) &&
"Interference");
1767 assert(LeaveBefore <= EnterAfter &&
"Missed case");
1772 assert((!EnterAfter || Idx >= EnterAfter) &&
"Interference");
1777 assert((!LeaveBefore || Idx <= LeaveBefore) &&
"Interference");
1781 unsigned IntvIn,
SlotIndex LeaveBefore) {
1783 std::tie(Start, Stop) = LIS.getSlotIndexes()->getMBBRange(BI.
MBB);
1786 << Stop <<
"), uses " << BI.
FirstInstr <<
'-'
1787 << BI.
LastInstr <<
", reg-in " << IntvIn
1788 <<
", leave before " << LeaveBefore
1789 << (BI.
LiveOut ?
", stack-out" :
", killed in block"));
1791 assert(IntvIn &&
"Must have register in");
1793 assert((!LeaveBefore || LeaveBefore > Start) &&
"Bad interference");
1821 LLVM_DEBUG(
dbgs() <<
", spill after last use before interference.\n");
1825 assert((!LeaveBefore || Idx <= LeaveBefore) &&
"Interference");
1832 assert((!LeaveBefore || Idx <= LeaveBefore) &&
"Interference");
1842 LLVM_DEBUG(
dbgs() <<
", creating local interval " << LocalIntv <<
".\n");
1855 assert((!LeaveBefore || From <= LeaveBefore) &&
"Interference");
1870 assert((!LeaveBefore || From <= LeaveBefore) &&
"Interference");
1874 unsigned IntvOut,
SlotIndex EnterAfter) {
1876 std::tie(Start, Stop) = LIS.getSlotIndexes()->getMBBRange(BI.
MBB);
1879 << Stop <<
"), uses " << BI.
FirstInstr <<
'-'
1880 << BI.
LastInstr <<
", reg-out " << IntvOut
1881 <<
", enter after " << EnterAfter
1882 << (BI.
LiveIn ?
", stack-in" :
", defined in block"));
1886 assert(IntvOut &&
"Must have register out");
1888 assert((!EnterAfter || EnterAfter < LSP) &&
"Bad interference");
1912 assert((!EnterAfter || Idx >= EnterAfter) &&
"Interference");
1928 assert((!EnterAfter || Idx >= EnterAfter) &&
"Interference");
1939 << (
LiveIn ?
"live in" :
"dead in") <<
", "
1940 << (
LiveOut ?
"live out" :
"dead out") <<
"}";
MachineInstrBuilder & UseMI
MachineInstrBuilder MachineInstrBuilder & DefMI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator MBBI
This file defines the BumpPtrAllocator interface.
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.
Register const TargetRegisterInfo * TRI
Promote Memory to Register
static constexpr unsigned SM(unsigned Version)
SI Optimize VGPR LiveRange
LiveInterval::SubRange & getSubRangeForMaskExact(LaneBitmask LM, LiveInterval &LI)
static bool removeDeadSegment(SlotIndex Def, LiveRange &LR)
LaneBitmask getLiveLaneMaskAt(const LiveInterval &LI, SlotIndex Idx, const MachineRegisterInfo &MRI)
auto & getSubrangeImpl(LaneBitmask LM, T &LI)
Find a subrange corresponding to the exact lane mask LM in the live interval LI.
static bool hasTiedUseOf(MachineInstr &MI, Register Reg)
const LiveInterval::SubRange * findSubRangeForMask(LaneBitmask LM, const LiveInterval &LI)
Find a subrange corresponding to the lane mask LM, or a superset of it, in the live interval LI.
static cl::opt< bool > EnableLoopIVHeuristic("enable-split-loopiv-heuristic", cl::desc("Enable loop iv regalloc heuristic"), cl::init(true))
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
Represent a constant reference to an array (0 or more elements consecutively in memory),...
void resize(unsigned N, bool t=false)
Grow or shrink the bitvector.
BitVector & set()
Set all bits in the bitvector.
ConnectedVNInfoEqClasses - Helper class that can divide VNInfos in a LiveInterval into equivalence cl...
Implements a dense probed hash-table based set.
DomTreeNodeBase * getIDom() const
MachineBasicBlock::iterator getLastInsertPointIter(const LiveInterval &CurLI, MachineBasicBlock &MBB)
Returns the last insert point as an iterator for \pCurLI in \pMBB.
SlotIndex getLastInsertPoint(const LiveInterval &CurLI, const MachineBasicBlock &MBB)
Return the base index of the last valid insert point for \pCurLI in \pMBB.
InsertPointAnalysis(const LiveIntervals &lis, unsigned BBNum)
A live range for subregisters.
LiveInterval - This class represents the liveness of a register, or stack slot.
LLVM_ABI void removeEmptySubRanges()
Removes all subranges without any segments (subranges without segments are not considered valid and s...
bool hasSubRanges() const
Returns true if subregister liveness information is available.
iterator_range< subrange_iterator > subranges()
LLVM_ABI void refineSubRanges(BumpPtrAllocator &Allocator, LaneBitmask LaneMask, std::function< void(LiveInterval::SubRange &)> Apply, const SlotIndexes &Indexes, const TargetRegisterInfo &TRI, unsigned ComposeSubRegIdx=0)
Refines the subranges to support LaneMask.
LLVM_ABI void computeSubRangeUndefs(SmallVectorImpl< SlotIndex > &Undefs, LaneBitmask LaneMask, const MachineRegisterInfo &MRI, const SlotIndexes &Indexes) const
For a given lane mask LaneMask, compute indexes at which the lane is marked undefined by subregister ...
MachineInstr * getInstructionFromIndex(SlotIndex index) const
Returns the instruction associated with the given index.
SlotIndexes * getSlotIndexes() const
SlotIndex getInstructionIndex(const MachineInstr &Instr) const
Returns the base index of the given instruction.
void RemoveMachineInstrFromMaps(MachineInstr &MI)
SlotIndex getMBBEndIdx(const MachineBasicBlock *mbb) const
Return the last index in the given basic block.
LiveInterval & getInterval(Register Reg)
LLVM_ABI void removeVRegDefAt(LiveInterval &LI, SlotIndex Pos)
Remove value number and related live segments of LI and its subranges that start at position Pos.
MachineBasicBlock * getMBBFromIndex(SlotIndex index) const
void addLiveInBlock(LiveRange &LR, MachineDomTreeNode *DomNode, SlotIndex Kill=SlotIndex())
addLiveInBlock - Add a block with an unknown live-in value.
LLVM_ABI void reset(const MachineFunction *mf, SlotIndexes *SI, MachineDominatorTree *MDT, VNInfo::Allocator *VNIA)
reset - Prepare caches for a new set of non-overlapping live ranges.
LLVM_ABI void extend(LiveRange &LR, SlotIndex Use, Register PhysReg, ArrayRef< SlotIndex > Undefs)
Extend the live range of LR to reach Use.
void setLiveOutValue(MachineBasicBlock *MBB, VNInfo *VNI)
setLiveOutValue - Indicate that VNI is live out from MBB.
Register get(unsigned idx) 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.
Segments::iterator iterator
const Segment * getSegmentContaining(SlotIndex Idx) const
Return the segment that contains the specified index, or null if there is none.
Segments::const_iterator const_iterator
bool liveAt(SlotIndex index) const
LLVM_ABI VNInfo * createDeadDef(SlotIndex Def, VNInfo::Allocator &VNIAlloc)
createDeadDef - Make sure the range has a value defined at Def.
iterator advanceTo(iterator I, SlotIndex Pos)
advanceTo - Advance the specified iterator to point to the Segment containing the specified position,...
LLVM_ABI void RenumberValues()
RenumberValues - Renumber all values in order of appearance and remove unused values.
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.
LLVM_ABI void removeSegment(SlotIndex Start, SlotIndex End, bool RemoveDeadValNo=false)
Remove the specified interval from this live range.
VNInfo * getVNInfoAt(SlotIndex Idx) const
getVNInfoAt - Return the VNInfo that is live at Idx, or NULL.
LLVM_ABI iterator find(SlotIndex Pos)
find - Return an iterator pointing to the first segment that ends after Pos, or end().
BlockT * getHeader() const
unsigned getLoopDepth() const
Return the nesting level of this loop.
Describe properties that are true of each instruction in the target description file.
MachineInstrBundleIterator< const MachineInstr > const_iterator
LLVM_ABI iterator getFirstTerminator()
Returns an iterator to the first terminator instruction of this basic block.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
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...
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
unsigned getNumBlockIDs() const
getNumBlockIDs - Return the number of MBB ID's allocated.
BasicBlockListType::iterator iterator
BasicBlockListType::const_iterator const_iterator
const MachineInstrBuilder & addReg(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a new virtual register operand.
Representation of each machine instruction.
mop_range defs()
Returns all explicit operands that are register definitions.
LLVM_ABI void bundleWithPred()
Bundle this instruction with its predecessor.
LLVM_ABI const TargetRegisterClass * getRegClassConstraintEffectForVReg(Register Reg, const TargetRegisterClass *CurRC, const TargetInstrInfo *TII, const TargetRegisterInfo *TRI, bool ExploreBundle=false) const
Applies the constraints (def/use) implied by this MI on Reg to the given CurRC.
void setFlag(MIFlag Flag)
Set a MI flag.
const MachineOperand & getOperand(unsigned i) const
LLVM_ABI const TargetRegisterClass * getRegClassConstraint(unsigned OpIdx, const TargetInstrInfo *TII, const TargetRegisterInfo *TRI) const
Compute the static register class constraint for operand OpIdx.
MachineOperand class - Representation of each machine instruction operand.
Register getReg() const
getReg - Returns the register number.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
iterator_range< use_nodbg_iterator > use_nodbg_operands(Register Reg) const
LLVM_ABI LaneBitmask getMaxLaneMaskForVReg(Register Reg) const
Returns a mask covering all bits that can appear in lane masks of subregisters of the virtual registe...
Wrapper class representing virtual and physical registers.
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 getDeadSlot() const
Returns the dead def kill slot for the current instruction.
static bool isEarlierInstr(SlotIndex A, SlotIndex B)
isEarlierInstr - Return true if A refers to an instruction earlier than B.
bool isValid() const
Returns true if this is a valid index.
SlotIndex getBoundaryIndex() const
Returns the boundary index for associated with this index.
SlotIndex getBaseIndex() const
Returns the base index for associated with this index.
SlotIndex getNextSlot() const
Returns the next slot in the index list.
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.
SlotIndex insertMachineInstrInMaps(MachineInstr &MI, bool Late=false)
Insert the given machine instruction into the mapping.
MachineBasicBlock * getMBBFromIndex(SlotIndex index) const
Returns the basic block which the given index falls in.
const std::pair< SlotIndex, SlotIndex > & getMBBRange(unsigned Num) const
Return the (start,end) range of the given basic block number.
SlotIndex getMBBEndIdx(unsigned Num) const
Returns the index past the last valid index in the given basic block.
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.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void assign(size_type NumElts, ValueParamT Elt)
typename SuperClass::const_iterator const_iterator
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
SplitAnalysis - Analyze a LiveInterval, looking for live range splitting opportunities.
SplitAnalysis(const VirtRegMap &vrm, const LiveIntervals &lis, const MachineLoopInfo &mli)
const MachineFunction & MF
bool isOriginalEndpoint(SlotIndex Idx) const
isOriginalEndpoint - Return true if the original live range was killed or (re-)defined at Idx.
unsigned countLiveBlocks(const LiveInterval *li) const
countLiveBlocks - Return the number of blocks where li is live.
const LiveIntervals & LIS
void analyze(const LiveInterval *li)
analyze - set CurLI to the specified interval, and analyze how it may be split.
void clear()
clear - clear all data structures so SplitAnalysis is ready to analyze a new interval.
const MachineLoopInfo & Loops
const TargetInstrInfo & TII
unsigned getNumLiveBlocks() const
getNumLiveBlocks - Return the number of blocks where CurLI is live.
bool shouldSplitSingleBlock(const BlockInfo &BI, bool SingleInstrs) const
shouldSplitSingleBlock - Returns true if it would help to create a local live range for the instructi...
void overlapIntv(SlotIndex Start, SlotIndex End)
overlapIntv - Indicate that all instructions in range should use the open interval if End does not ha...
unsigned openIntv()
Create a new virtual register and live interval.
SplitEditor(SplitAnalysis &SA, LiveIntervals &LIS, VirtRegMap &VRM, MachineDominatorTree &MDT, MachineBlockFrequencyInfo &MBFI, VirtRegAuxInfo &VRAI)
Create a new SplitEditor for editing the LiveInterval analyzed by SA.
void splitRegOutBlock(const SplitAnalysis::BlockInfo &BI, unsigned IntvOut, SlotIndex EnterAfter)
splitRegOutBlock - Split CurLI in the given block such that it enters the block on the stack (or isn'...
SlotIndex enterIntvAfter(SlotIndex Idx)
enterIntvAfter - Enter the open interval after the instruction at Idx.
SlotIndex enterIntvBefore(SlotIndex Idx)
enterIntvBefore - Enter the open interval before the instruction at Idx.
void useIntv(const MachineBasicBlock &MBB)
useIntv - indicate that all instructions in MBB should use OpenLI.
SlotIndex leaveIntvAfter(SlotIndex Idx)
leaveIntvAfter - Leave the open interval after the instruction at Idx.
void reset(LiveRangeEdit &, ComplementSpillMode=SM_Partition)
reset - Prepare for a new split.
SlotIndex enterIntvAtEnd(MachineBasicBlock &MBB)
enterIntvAtEnd - Enter the open interval at the end of MBB.
SlotIndex leaveIntvAtTop(MachineBasicBlock &MBB)
leaveIntvAtTop - Leave the interval at the top of MBB.
SlotIndex leaveIntvBefore(SlotIndex Idx)
leaveIntvBefore - Leave the open interval before the instruction at Idx.
void finish(SmallVectorImpl< unsigned > *LRMap=nullptr)
finish - after all the new live ranges have been created, compute the remaining live range,...
void splitRegInBlock(const SplitAnalysis::BlockInfo &BI, unsigned IntvIn, SlotIndex LeaveBefore)
splitRegInBlock - Split CurLI in the given block such that it enters the block in IntvIn and leaves i...
void splitLiveThroughBlock(unsigned MBBNum, unsigned IntvIn, SlotIndex LeaveBefore, unsigned IntvOut, SlotIndex EnterAfter)
splitLiveThroughBlock - Split CurLI in the given block such that it enters the block in IntvIn and le...
ComplementSpillMode
ComplementSpillMode - Select how the complement live range should be created.
@ SM_Partition
SM_Partition(Default) - Try to create the complement interval so it doesn't overlap any other interva...
@ SM_Speed
SM_Speed - Overlap intervals to minimize the expected execution frequency of the inserted copies.
@ SM_Size
SM_Size - Overlap intervals to minimize the number of inserted COPY instructions.
void selectIntv(unsigned Idx)
selectIntv - Select a previously opened interval index.
void splitSingleBlock(const SplitAnalysis::BlockInfo &BI)
splitSingleBlock - Split CurLI into a separate live interval around the uses in a single block.
void dump() const
dump - print the current interval mapping to dbgs().
bool hasSubClass(const TargetRegisterClass *RC) const
Return true if the specified TargetRegisterClass is a proper sub-class of this TargetRegisterClass.
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.
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.
self_iterator getIterator()
This class implements an extremely fast bulk output stream that can only output to a stream.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
@ Skipped
Validation was skipped, as it was not needed.
initializer< Ty > init(const Ty &Val)
NodeAddr< DefNode * > Def
This is an optimization pass for GlobalISel generic memory operations.
Printable print(const GCNRegPressure &RP, const GCNSubtarget *ST=nullptr, unsigned DynamicVGPRBlockSize=0)
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
@ Kill
The last use of a register.
@ Define
Register definition.
constexpr RegState getInternalReadRegState(bool B)
void append_range(Container &C, Range &&R)
Wrapper function to append range R to container C.
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...
auto unique(Range &&R, Predicate P)
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 raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool none_of(R &&Range, UnaryPredicate P)
Provide wrappers to std::none_of which take ranges instead of having to pass begin/end explicitly.
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
FunctionAddr VTableAddr Count
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
DomTreeNodeBase< MachineBasicBlock > MachineDomTreeNode
@ Sub
Subtraction of integers.
FunctionAddr VTableAddr Next
auto seq(T Begin, T End)
Iterate over an integral type from Begin up to - but not including - End.
void array_pod_sort(IteratorTy Start, IteratorTy End)
array_pod_sort - This sorts an array with the specified start and end extent.
BumpPtrAllocatorImpl<> BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
constexpr RegState getUndefRegState(bool B)
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.
LLVM_ABI Printable printMBBReference(const MachineBasicBlock &MBB)
Prints a machine basic block reference.
static constexpr LaneBitmask getAll()
constexpr bool none() const
constexpr bool any() const
constexpr bool all() const
This represents a simple continuous liveness interval for a value.
Additional information about basic blocks where the current variable is live.
SlotIndex FirstDef
First non-phi valno->def, or SlotIndex().
bool LiveOut
Current reg is live out.
bool LiveIn
Current reg is live in.
bool isOneInstr() const
isOneInstr - Returns true when this BlockInfo describes a single instruction.
void print(raw_ostream &OS) const
SlotIndex LastInstr
Last instr accessing current reg.
SlotIndex FirstInstr
First instr accessing current reg.