33 #define DEBUG_TYPE "regalloc"
35 STATISTIC(NumFinished,
"Number of splits finished");
36 STATISTIC(NumSimple,
"Number of splits that were simple");
37 STATISTIC(NumCopies,
"Number of copies inserted for splitting");
38 STATISTIC(NumRemats,
"Number of rematerialized defs for splitting");
39 STATISTIC(NumRepairs,
"Number of invalid live ranges repaired");
47 : LIS(lis), LastInsertPoint(BBNum) {}
50 InsertPointAnalysis::computeLastInsertPoint(
const LiveInterval &CurLI,
53 std::pair<SlotIndex, SlotIndex> &LIP = LastInsertPoint[Num];
63 if (!LIP.first.isValid()) {
65 if (FirstTerm == MBB.
end())
71 if (EHPadSuccessors.
empty())
74 LIP.second = LIP.first;
127 : MF(vrm.getMachineFunction()), VRM(vrm), LIS(lis),
Loops(mli),
128 TII(*MF.getSubtarget().getInstrInfo()), CurLI(nullptr),
129 IPA(lis, MF.getNumBlockIDs()) {}
134 ThroughBlocks.
clear();
136 DidRepairRange =
false;
140 void SplitAnalysis::analyzeUses() {
141 assert(UseSlots.empty() &&
"Call clear first");
147 UseSlots.push_back(VNI->
def);
159 UseSlots.erase(std::unique(UseSlots.begin(), UseSlots.end(),
164 if (!calcLiveBlockInfo()) {
167 DidRepairRange =
true;
169 DEBUG(
dbgs() <<
"*** Fixing inconsistent live interval! ***\n");
171 .shrinkToUses(const_cast<LiveInterval*>(CurLI));
173 ThroughBlocks.
clear();
174 bool fixed = calcLiveBlockInfo();
176 assert(fixed &&
"Couldn't fix broken live interval");
180 << UseSlots.size() <<
" instrs in "
181 << UseBlocks.size() <<
" blocks, through "
182 << NumThroughBlocks <<
" blocks.\n");
187 bool SplitAnalysis::calcLiveBlockInfo() {
189 NumThroughBlocks = NumGapBlocks = 0;
197 UseI = UseSlots.begin();
198 UseE = UseSlots.end();
212 if (UseI == UseE || *UseI >= Stop) {
214 ThroughBlocks.
set(BI.MBB->getNumber());
221 BI.FirstInstr = *UseI;
222 assert(BI.FirstInstr >= Start);
224 while (UseI != UseE && *UseI < Stop);
225 BI.LastInstr = UseI[-1];
226 assert(BI.LastInstr < Stop);
229 BI.LiveIn = LVI->start <= Start;
233 assert(LVI->start == LVI->valno->def &&
"Dangling Segment start");
234 assert(LVI->start == BI.FirstInstr &&
"First instr should be a def");
235 BI.FirstDef = BI.FirstInstr;
240 while (LVI->end < Stop) {
242 if (++LVI == LVE || LVI->start >= Stop) {
244 BI.LastInstr = LastStop;
248 if (LastStop < LVI->start) {
255 UseBlocks.push_back(BI);
256 UseBlocks.back().LastInstr = LastStop;
261 BI.FirstInstr = BI.FirstDef = LVI->start;
265 assert(LVI->start == LVI->valno->def &&
"Dangling Segment start");
267 BI.FirstDef = LVI->start;
270 UseBlocks.push_back(BI);
278 if (LVI->end == Stop && ++LVI == LVE)
282 if (LVI->start < Stop)
312 }
while (Stop <= LVI->start);
319 assert(!Orig.
empty() &&
"Splitting empty interval?");
323 if (I != Orig.
end() && I->start <= Idx)
324 return I->start == Idx;
327 return I != Orig.
begin() && (--
I)->
end == Idx;
346 : SA(sa), AA(aa), LIS(lis), VRM(vrm),
347 MRI(vrm.getMachineFunction().getRegInfo()), MDT(mdt),
348 TII(*vrm.getMachineFunction().getSubtarget().getInstrInfo()),
349 TRI(*vrm.getMachineFunction().getSubtarget().getRegisterInfo()),
350 MBFI(mbfi), Edit(nullptr), OpenIdx(0), SpillMode(SM_Partition),
372 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
374 if (RegAssign.
empty()) {
375 dbgs() <<
" empty\n";
380 dbgs() <<
" [" <<
I.start() <<
';' <<
I.stop() <<
"):" <<
I.value();
388 if (S.LaneMask == LM)
405 auto &
PS = getSubRangeForMask(S.LaneMask, Edit->
getParent());
407 if (PV !=
nullptr && PV->def == Def)
418 unsigned R = DefOp.getReg();
421 if (
unsigned SR = DefOp.getSubReg())
429 if ((S.LaneMask & LM).any())
434 VNInfo *SplitEditor::defValue(
unsigned RegIdx,
438 assert(ParentVNI &&
"Mapping NULL value");
446 bool Force = LI->hasSubRanges();
447 ValueForcePair FP(Force ?
nullptr : VNI, Force);
449 std::pair<ValueMap::iterator, bool> InsP =
450 Values.
insert(std::make_pair(std::make_pair(RegIdx, ParentVNI->
id), FP));
454 if (!Force && InsP.second)
458 if (
VNInfo *OldVNI = InsP.first->second.getPointer()) {
459 addDeadDef(*LI, OldVNI, Original);
463 InsP.first->second = ValueForcePair(
nullptr, Force);
467 addDeadDef(*LI, VNI, Original);
471 void SplitEditor::forceRecompute(
unsigned RegIdx,
const VNInfo *ParentVNI) {
472 assert(ParentVNI &&
"Mapping NULL value");
473 ValueForcePair &VFP = Values[std::make_pair(RegIdx, ParentVNI->
id)];
474 VNInfo *VNI = VFP.getPointer();
488 VFP = ValueForcePair(
nullptr,
true);
491 SlotIndex SplitEditor::buildSingleSubRegCopy(
unsigned FromReg,
unsigned ToReg,
495 bool FirstCopy = !Def.
isValid();
499 .
addReg(FromReg, 0, SubIdx);
516 SlotIndex SplitEditor::buildCopy(
unsigned FromReg,
unsigned ToReg,
536 unsigned BestIdx = 0;
537 unsigned BestCover = 0;
546 if (SubRegMask == LaneMask) {
552 if ((SubRegMask & ~LaneMask).any())
557 if (PopCount > BestCover) {
558 BestCover = PopCount;
567 SlotIndex Def = buildSingleSubRegCopy(FromReg, ToReg, MBB, InsertBefore,
573 while (LanesLeft.
any()) {
574 unsigned BestIdx = 0;
575 int BestCover = INT_MIN;
576 for (
unsigned Idx : PossibleIndexes) {
579 if (SubRegMask == LanesLeft) {
588 if (Cover > BestCover) {
597 buildSingleSubRegCopy(FromReg, ToReg, MBB, InsertBefore, BestIdx,
605 VNInfo *SplitEditor::defFromParent(
unsigned RegIdx,
615 bool Late = RegIdx != 0;
623 bool DidRemat =
false;
638 LaneMask |= S.LaneMask;
644 Def = buildCopy(Edit->
getReg(),
Reg, LaneMask, MBB,
I, Late, RegIdx);
648 return defValue(RegIdx, ParentVNI, Def,
false);
658 OpenIdx = Edit->
size();
664 assert(Idx != 0 &&
"Cannot select the complement interval");
665 assert(Idx < Edit->size() &&
"Can only select previously opened interval");
666 DEBUG(
dbgs() <<
" selectIntv " << OpenIdx <<
" -> " << Idx <<
'\n');
671 assert(OpenIdx &&
"openIntv not called before enterIntvBefore");
672 DEBUG(
dbgs() <<
" enterIntvBefore " << Idx);
679 DEBUG(
dbgs() <<
": valno " << ParentVNI->
id <<
'\n');
681 assert(MI &&
"enterIntvBefore called with invalid index");
688 assert(OpenIdx &&
"openIntv not called before enterIntvAfter");
689 DEBUG(
dbgs() <<
" enterIntvAfter " << Idx);
696 DEBUG(
dbgs() <<
": valno " << ParentVNI->
id <<
'\n');
698 assert(MI &&
"enterIntvAfter called with invalid index");
706 assert(OpenIdx &&
"openIntv not called before enterIntvAtEnd");
715 DEBUG(
dbgs() <<
": valno " << ParentVNI->id);
716 VNInfo *VNI = defFromParent(OpenIdx, ParentVNI, Last, MBB,
718 RegAssign.
insert(VNI->
def, End, OpenIdx);
729 assert(OpenIdx &&
"openIntv not called before useIntv");
730 DEBUG(
dbgs() <<
" useIntv [" << Start <<
';' << End <<
"):");
731 RegAssign.
insert(Start, End, OpenIdx);
736 assert(OpenIdx &&
"openIntv not called before leaveIntvAfter");
737 DEBUG(
dbgs() <<
" leaveIntvAfter " << Idx);
746 DEBUG(
dbgs() <<
": valno " << ParentVNI->
id <<
'\n');
748 assert(MI &&
"No instruction at index");
756 forceRecompute(0, ParentVNI);
757 defFromParent(0, ParentVNI, Idx, *MI->
getParent(),
MI);
767 assert(OpenIdx &&
"openIntv not called before leaveIntvBefore");
768 DEBUG(
dbgs() <<
" leaveIntvBefore " << Idx);
777 DEBUG(
dbgs() <<
": valno " << ParentVNI->
id <<
'\n');
780 assert(MI &&
"No instruction at index");
786 assert(OpenIdx &&
"openIntv not called before leaveIntvAtTop");
796 VNInfo *VNI = defFromParent(0, ParentVNI, Start, MBB,
798 RegAssign.
insert(Start, VNI->
def, OpenIdx);
804 assert(OpenIdx &&
"openIntv not called before overlapIntv");
807 "Parent changes value in extended range");
809 "Range cannot span basic blocks");
813 forceRecompute(0, ParentVNI);
814 DEBUG(
dbgs() <<
" overlapIntv [" << Start <<
';' << End <<
"):");
815 RegAssign.
insert(Start, End, OpenIdx);
825 DEBUG(
dbgs() <<
"Removing " << Copies.
size() <<
" back-copies.\n");
827 AssignI.setMap(RegAssign);
829 for (
unsigned i = 0, e = Copies.
size(); i != e; ++i) {
832 assert(MI &&
"No instruction for back-copy");
837 do AtBegin = MBBI == MBB->
begin();
838 while (!AtBegin && (--MBBI)->isDebugValue());
840 DEBUG(
dbgs() <<
"Removing " << Def <<
'\t' << *MI);
848 if (!AssignI.valid() || AssignI.start() >=
Def)
851 if (AssignI.stop() !=
Def)
853 unsigned RegIdx = AssignI.value();
854 if (AtBegin || !MBBI->readsVirtualRegister(Edit->
getReg())) {
855 DEBUG(
dbgs() <<
" cannot find simple kill of RegIdx " << RegIdx <<
'\n');
859 DEBUG(
dbgs() <<
" move kill to " << Kill <<
'\t' << *MBBI);
860 AssignI.setStop(Kill);
870 assert(MDT.
dominates(DefMBB, MBB) &&
"MBB must be dominated by the def.");
873 const MachineLoop *DefLoop = Loops.getLoopFor(DefMBB);
878 unsigned BestDepth = UINT_MAX;
892 if (Loop == DefLoop) {
894 << MBB->
getNumber() <<
" in the same loop\n");
900 if (Depth < BestDepth) {
904 << MBB->
getNumber() <<
" at depth " << Depth <<
'\n');
912 if (!IDom || !MDT.
dominates(DefDomNode, IDom))
919 void SplitEditor::computeRedundantBackCopies(
931 EqualVNs[ParentVNI->
id].insert(VNI);
936 for (
unsigned i = 0, e = Parent->
getNumValNums(); i != e; ++i) {
938 if (!NotToHoistSet.
count(ParentVNI->
id))
942 for (; It1 != EqualVNs[ParentVNI->
id].end(); ++It1) {
944 for (++It2; It2 != EqualVNs[ParentVNI->
id].end(); ++It2) {
945 if (DominatedVNIs.count(*It1) || DominatedVNIs.count(*It2))
951 DominatedVNIs.
insert((*It1)->def < (*It2)->def ? (*It2) : (*It1));
953 DominatedVNIs.
insert(*It2);
955 DominatedVNIs.
insert(*It1);
959 if (!DominatedVNIs.
empty()) {
960 forceRecompute(0, ParentVNI);
961 for (
auto VNI : DominatedVNIs) {
964 DominatedVNIs.clear();
974 void SplitEditor::hoistCopies() {
981 typedef std::pair<MachineBasicBlock*, SlotIndex> DomPair;
995 assert(ParentVNI &&
"Parent not live at complement def");
1004 DomPair &Dom = NearestDom[ParentVNI->
id];
1009 if (VNI->
def == ParentVNI->
def) {
1010 DEBUG(
dbgs() <<
"Direct complement def at " << VNI->
def <<
'\n');
1011 Dom = DomPair(ValMBB, VNI->
def);
1017 DEBUG(
dbgs() <<
"Single complement def at " << VNI->
def <<
'\n');
1023 Dom = DomPair(ValMBB, VNI->
def);
1024 }
else if (Dom.first == ValMBB) {
1026 if (!Dom.second.isValid() || VNI->
def < Dom.second)
1027 Dom.second = VNI->
def;
1034 Dom = DomPair(ValMBB, VNI->
def);
1035 else if (Near != Dom.first)
1041 DEBUG(
dbgs() <<
"Multi-mapped complement " << VNI->
id <<
'@' << VNI->
def
1042 <<
" for parent " << ParentVNI->
id <<
'@' << ParentVNI->
def
1043 <<
" hoist to BB#" << Dom.first->getNumber() <<
' '
1044 << Dom.second <<
'\n');
1048 for (
unsigned i = 0, e = Parent->
getNumValNums(); i != e; ++i) {
1049 DomPair &Dom = NearestDom[i];
1050 if (!Dom.first || Dom.second.isValid())
1056 Dom.first = findShallowDominator(Dom.first, DefMBB);
1059 NotToHoistSet.
insert(ParentVNI->
id);
1064 defFromParent(0, ParentVNI, Last, *Dom.first,
1075 const DomPair &Dom = NearestDom[ParentVNI->
id];
1076 if (!Dom.first || Dom.second == VNI->
def ||
1077 NotToHoistSet.count(ParentVNI->
id))
1080 forceRecompute(0, ParentVNI);
1086 computeRedundantBackCopies(NotToHoistSet, BackCopies);
1088 removeBackCopies(BackCopies);
1094 bool SplitEditor::transferValues() {
1095 bool Skipped =
false;
1099 VNInfo *ParentVNI = S.valno;
1102 AssignI.advanceTo(Start);
1106 if (!AssignI.valid()) {
1108 }
else if (AssignI.start() <= Start) {
1109 RegIdx = AssignI.value();
1110 if (AssignI.stop() <
End) {
1111 End = AssignI.stop();
1116 End =
std::min(End, AssignI.start());
1120 DEBUG(
dbgs() <<
" [" << Start <<
';' << End <<
")=" << RegIdx
1125 ValueForcePair VFP = Values.
lookup(std::make_pair(RegIdx, ParentVNI->
id));
1126 if (
VNInfo *VNI = VFP.getPointer()) {
1128 LI.
addSegment(LiveInterval::Segment(Start, End, VNI));
1151 if (Start != BlockStart) {
1153 assert(VNI &&
"Missing def for complex mapped value");
1154 DEBUG(
dbgs() <<
':' << VNI->
id <<
"*BB#" << MBB->getNumber());
1156 if (BlockEnd <= End)
1161 BlockStart = BlockEnd;
1165 assert(Start <= BlockStart &&
"Expected live-in block");
1166 while (BlockStart < End) {
1167 DEBUG(
dbgs() <<
">BB#" << MBB->getNumber());
1169 if (BlockStart == ParentVNI->
def) {
1171 assert(ParentVNI->
isPHIDef() &&
"Non-phi defined at block start?");
1173 assert(VNI &&
"Missing def for complex mapped parent PHI");
1174 if (End >= BlockEnd)
1187 BlockStart = BlockEnd;
1191 }
while (Start != S.end);
1224 LiveRange &PSR = !LM.
all() ? getSubRangeForMask(LM, PLI)
1227 LRC.
extend(LR, End, 0, Undefs);
1231 void SplitEditor::extendPHIKillRanges() {
1243 unsigned RegIdx = RegAssign.
lookup(V->
def);
1255 for (
const VNInfo *V :
PS.valnos) {
1258 unsigned RegIdx = RegAssign.
lookup(V->
def);
1269 extendPHIRange(B, SubLRC, S,
PS.LaneMask, Undefs);
1275 void SplitEditor::rewriteAssigned(
bool ExtendRanges) {
1278 : MO(O), RegIdx(R), Next(N) {}
1287 RE = MRI.
reg_end(); RI != RE;) {
1306 unsigned RegIdx = RegAssign.
lookup(Idx);
1310 << Idx <<
':' << RegIdx <<
'\t' << *
MI);
1313 if (!ExtendRanges || MO.
isUndef())
1335 ExtPoints.
push_back(ExtPoint(MO, RegIdx, Next));
1342 for (ExtPoint &EP : ExtPoints) {
1347 unsigned Reg = EP.MO.getReg(), Sub = EP.MO.getSubReg();
1364 SubLRC.extend(S, EP.
Next, 0, Undefs);
1368 for (
unsigned R : *Edit) {
1378 void SplitEditor::deleteRematVictims() {
1389 assert(MI &&
"Missing instruction for dead def");
1395 DEBUG(
dbgs() <<
"All defs dead: " << *MI);
1403 Edit->eliminateDeadDefs(Dead,
None, &AA);
1413 for (
const VNInfo *ParentVNI : Edit->getParent().valnos) {
1416 unsigned RegIdx = RegAssign.
lookup(ParentVNI->
def);
1417 defValue(RegIdx, ParentVNI, ParentVNI->
def,
true);
1421 if (Edit->didRematerialize(ParentVNI))
1422 for (
unsigned i = 0, e = Edit->size(); i != e; ++i)
1423 forceRecompute(i, ParentVNI);
1427 switch (SpillMode) {
1438 bool Skipped = transferValues();
1441 rewriteAssigned(Skipped);
1444 extendPHIKillRanges();
1450 deleteRematVictims();
1453 for (
unsigned Reg : *Edit) {
1462 for (
unsigned i = 0, e = Edit->size(); i != e; ++i)
1468 for (
unsigned i = 0, e = Edit->size(); i != e; ++i) {
1470 unsigned VReg = Edit->get(i);
1480 LRMap->
resize(Edit->size(), i);
1486 assert(!LRMap || LRMap->
size() == Edit->size());
1495 bool SingleInstrs)
const {
1541 unsigned IntvOut,
SlotIndex EnterAfter){
1545 DEBUG(
dbgs() <<
"BB#" << MBBNum <<
" [" << Start <<
';' << Stop
1546 <<
") intf " << LeaveBefore <<
'-' << EnterAfter
1547 <<
", live-through " << IntvIn <<
" -> " << IntvOut);
1549 assert((IntvIn || IntvOut) &&
"Use splitSingleBlock for isolated blocks");
1551 assert((!LeaveBefore || LeaveBefore < Stop) &&
"Interference after block");
1552 assert((!IntvIn || !LeaveBefore || LeaveBefore > Start) &&
"Impossible intf");
1553 assert((!EnterAfter || EnterAfter >= Start) &&
"Interference before block");
1566 assert((!LeaveBefore || Idx <= LeaveBefore) &&
"Interference");
1580 assert((!EnterAfter || Idx >= EnterAfter) &&
"Interference");
1585 if (IntvIn == IntvOut && !LeaveBefore && !EnterAfter) {
1586 DEBUG(
dbgs() <<
", straight through.\n");
1598 assert((!IntvOut || !EnterAfter || EnterAfter < LSP) &&
"Impossible intf");
1600 if (IntvIn != IntvOut && (!LeaveBefore || !EnterAfter ||
1602 DEBUG(
dbgs() <<
", switch avoiding interference.\n");
1610 if (LeaveBefore && LeaveBefore < LSP) {
1618 assert((!LeaveBefore || Idx <= LeaveBefore) &&
"Interference");
1619 assert((!EnterAfter || Idx >= EnterAfter) &&
"Interference");
1623 DEBUG(
dbgs() <<
", create local intv for interference.\n");
1629 assert(LeaveBefore <= EnterAfter &&
"Missed case");
1634 assert((!EnterAfter || Idx >= EnterAfter) &&
"Interference");
1639 assert((!LeaveBefore || Idx <= LeaveBefore) &&
"Interference");
1644 unsigned IntvIn,
SlotIndex LeaveBefore) {
1650 <<
", reg-in " << IntvIn <<
", leave before " << LeaveBefore
1651 << (BI.
LiveOut ?
", stack-out" :
", killed in block"));
1653 assert(IntvIn &&
"Must have register in");
1655 assert((!LeaveBefore || LeaveBefore > Start) &&
"Bad interference");
1658 DEBUG(
dbgs() <<
" before interference.\n");
1683 DEBUG(
dbgs() <<
", spill after last use before interference.\n");
1687 assert((!LeaveBefore || Idx <= LeaveBefore) &&
"Interference");
1689 DEBUG(
dbgs() <<
", spill before last split point.\n");
1694 assert((!LeaveBefore || Idx <= LeaveBefore) &&
"Interference");
1704 DEBUG(
dbgs() <<
", creating local interval " << LocalIntv <<
".\n");
1717 assert((!LeaveBefore || From <= LeaveBefore) &&
"Interference");
1732 assert((!LeaveBefore || From <= LeaveBefore) &&
"Interference");
1736 unsigned IntvOut,
SlotIndex EnterAfter) {
1742 <<
", reg-out " << IntvOut <<
", enter after " << EnterAfter
1743 << (BI.
LiveIn ?
", stack-in" :
", defined in block"));
1747 assert(IntvOut &&
"Must have register out");
1749 assert((!EnterAfter || EnterAfter < LSP) &&
"Bad interference");
1752 DEBUG(
dbgs() <<
" after interference.\n");
1764 DEBUG(
dbgs() <<
", reload after interference.\n");
1773 assert((!EnterAfter || Idx >= EnterAfter) &&
"Interference");
1780 DEBUG(
dbgs() <<
", interference overlaps uses.\n");
1789 assert((!EnterAfter || Idx >= EnterAfter) &&
"Interference");
void resize(unsigned N, bool t=false)
resize - Grow or shrink the bitvector.
void RenumberValues()
RenumberValues - Renumber all values in order of appearance and remove unused values.
void bundleWithPred()
Bundle this instruction with its predecessor.
ValT lookup(KeyT x, ValT NotFound=ValT()) const
lookup - Return the mapped value at x or NotFound.
void push_back(const T &Elt)
const_iterator end(StringRef path)
Get end iterator over path.
const Segment * getSegmentContaining(SlotIndex Idx) const
Return the segment that contains the specified index, or null if there is none.
MachineInstr * getParent()
getParent - Return the instruction that this operand belongs to.
ValueT lookup(const_arg_type_t< KeyT > Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
const_iterator begin() const
void refineSubRanges(BumpPtrAllocator &Allocator, LaneBitmask LaneMask, std::function< void(LiveInterval::SubRange &)> Mod)
Refines the subranges to support LaneMask.
typename SuperClass::const_iterator const_iterator
SlotIndex def
The index of the defining instruction.
STATISTIC(NumFunctions,"Total number of functions")
void RemoveMachineInstrFromMaps(MachineInstr &MI)
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
bool anyRematerializable(AliasAnalysis *)
anyRematerializable - Return true if any parent values may be rematerializable.
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds...
SlotIndex getBoundaryIndex() const
Returns the boundary index for associated with this index.
MachineFunction & getMachineFunction() const
void reset(LiveRangeEdit &, ComplementSpillMode=SM_Partition)
reset - Prepare for a new split.
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
SlotIndex getBaseIndex() const
Returns the base index for associated with this index.
bool addRegisterDead(unsigned Reg, const TargetRegisterInfo *RegInfo, bool AddIfNotFound=false)
We have determined MI defined a register without a use.
SlotIndex getLastSplitPoint(unsigned Num)
void setLiveOutValue(MachineBasicBlock *MBB, VNInfo *VNI)
setLiveOutValue - Indicate that VNI is live out from MBB.
Maximum length of the test input libFuzzer tries to guess a good value based on the corpus and reports it always prefer smaller inputs during the corpus shuffle When libFuzzer itself reports a bug this exit code will be used If indicates the maximal total time in seconds to run the fuzzer minimizes the provided crash input Use with tries to cleanse the provided crash input to make it contain fewer original bytes Use with exact_artifact_path to specify the output Experimental Use value profile to guide fuzzing Number of jobs to run If min(jobs, NumberOfCpuCores()/2)\" is used.") FUZZER_FLAG_INT(reload
Segments::iterator iterator
static LaneBitmask getAll()
LiveInterval - This class represents the liveness of a register, or stack slot.
iterator getFirstTerminator()
Returns an iterator to the first terminator instruction of this basic block.
Describe properties that are true of each instruction in the target description file.
MachineInstrBuilder MachineInstrBuilder &DefMI const MCInstrDesc & Desc
SM_Speed - Overlap intervals to minimize the expected execution frequency of the inserted copies...
iterator advanceTo(iterator I, SlotIndex Pos)
advanceTo - Advance the specified iterator to point to the Segment containing the specified position...
MachineBasicBlock * getMBBFromIndex(SlotIndex index) const
SlotIndex getMBBEndIdx(const MachineBasicBlock *mbb) const
Return the last index in the given basic block.
bool isLiveInToMBB(const LiveRange &LR, const MachineBasicBlock *mbb) const
bool readsVirtualRegister(unsigned Reg) const
Return true if the MachineInstr reads the specified virtual register.
MachineBlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate machine basic b...
const MachineLoopInfo & Loops
ComplementSpillMode
ComplementSpillMode - Select how the complement live range should be created.
SlotIndex getInstructionIndex(const MachineInstr &Instr) const
Returns the base index of the given instruction.
A live range for subregisters.
This represents a simple continuous liveness interval for a value.
unsigned getInternalReadRegState(bool B)
SplitAnalysis(const VirtRegMap &vrm, const LiveIntervals &lis, const MachineLoopInfo &mli)
void splitSeparateComponents(LiveInterval &LI, SmallVectorImpl< LiveInterval * > &SplitLIs)
Split separate components in LiveInterval LI into separate intervals.
friend class const_iterator
SlotIndex enterIntvAtEnd(MachineBasicBlock &MBB)
enterIntvAtEnd - Enter the open interval at the end of MBB.
LaneBitmask getSubRegIndexLaneMask(unsigned SubIdx) const
Return a bitmask representing the parts of a register that are covered by SubIdx. ...
VNInfo - Value Number Information.
bool didRematerialize(const VNInfo *ParentVNI) const
didRematerialize - Return true if ParentVNI was rematerialized anywhere.
unsigned getNumValNums() const
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...
VNInfo * getVNInfoAt(SlotIndex Idx) const
getVNInfoAt - Return the VNInfo that is live at Idx, or NULL.
BlockT * getHeader() const
BlockFrequency getBlockFreq(const MachineBasicBlock *MBB) const
getblockFreq - Return block frequency.
bool allDefsAreDead() const
Return true if all the defs of this instruction are dead.
iterator_range< succ_iterator > successors()
This class represents the liveness of a register, stack slot, etc.
static bool isEarlierInstr(SlotIndex A, SlotIndex B)
isEarlierInstr - Return true if A refers to an instruction earlier than B.
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
void analyze(const LiveInterval *li)
analyze - set CurLI to the specified interval, and analyze how it may be split.
void removeEmptySubRanges()
Removes all subranges without any segments (subranges without segments are not considered valid and s...
void clear()
clear - Removes all bits from the bitvector. Does not change capacity.
unsigned getNumBlockIDs() const
getNumBlockIDs - Return the number of MBB ID's allocated.
void splitSingleBlock(const SplitAnalysis::BlockInfo &BI)
splitSingleBlock - Split CurLI into a separate live interval around the uses in a single block...
const HexagonInstrInfo * TII
SlotIndex getLastInsertPoint(const LiveInterval &CurLI, const MachineBasicBlock &MBB)
Return the base index of the last valid insert point for in .
VNInfo::Allocator & getVNInfoAllocator()
iterator_range< subrange_iterator > subranges()
void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
const TargetRegisterClass * getRegClass(unsigned Reg) const
Return the register class of the specified virtual register.
bool none_of(R &&Range, UnaryPredicate P)
Provide wrappers to std::none_of which take ranges instead of having to pass begin/end explicitly...
Reg
All possible values of the reg field in the ModR/M byte.
void overlapIntv(SlotIndex Start, SlotIndex End)
overlapIntv - Indicate that all instructions in range should use the open interval, but also let the complement interval be live.
SlotIndex getDeadSlot() const
Returns the dead def kill slot for the current instruction.
constexpr bool any() const
unsigned openIntv()
Create a new virtual register and live interval.
LLVM_NODISCARD bool empty() const
bool isUnused() const
Returns true if this value is unused.
bool shouldSplitSingleBlock(const BlockInfo &BI, bool SingleInstrs) const
shouldSplitSingleBlock - Returns true if it would help to create a local live range for the instructi...
bool empty() const
empty - Return true when no intervals are mapped.
SlotIndex leaveIntvAfter(SlotIndex Idx)
leaveIntvAfter - Leave the open interval after the instruction at Idx.
SplitEditor(SplitAnalysis &SA, AliasAnalysis &AA, LiveIntervals &, VirtRegMap &, MachineDominatorTree &, MachineBlockFrequencyInfo &)
Create a new SplitEditor for editing the LiveInterval analyzed by SA.
void addLiveInBlock(LiveRange &LR, MachineDomTreeNode *DomNode, SlotIndex Kill=SlotIndex())
addLiveInBlock - Add a block with an unknown live-in value.
PointerTy getPointer() const
void constructMainRangeFromSubranges(LiveInterval &LI)
For live interval LI with correct SubRanges construct matching information for the main live range...
unsigned getNumSubRegIndices() const
Return the number of sub-register indices understood by the target.
void setIsSplitFromReg(unsigned virtReg, unsigned SReg)
records virtReg is a split live interval from SReg.
iterator addSegment(Segment S)
Add the specified Segment to this range, merging segments as appropriate.
bool canRematerializeAt(Remat &RM, VNInfo *OrigVNI, SlotIndex UseIdx, bool cheapAsAMove)
canRematerializeAt - Determine if ParentVNI can be rematerialized at UseIdx.
Base class for the actual dominator tree node.
bool isCopyLike() const
Return true if the instruction behaves like a copy.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
void clear()
clear - Remove all entries.
void extend(LiveRange &LR, SlotIndex Use, unsigned PhysReg, ArrayRef< SlotIndex > Undefs)
Extend the live range of LR to reach Use.
const LiveIntervals & LIS
void finish(SmallVectorImpl< unsigned > *LRMap=nullptr)
finish - after all the new live ranges have been created, compute the remaining live range...
MachineBasicBlock * findNearestCommonDominator(MachineBasicBlock *A, MachineBasicBlock *B)
findNearestCommonDominator - Find nearest common dominator basic block for basic block A and B...
Printable PrintReg(unsigned Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubRegIdx=0)
Prints virtual and physical registers with or without a TRI instance.
unsigned getUndefRegState(bool B)
void dump() const
dump - print the current interval mapping to dbgs().
SlotIndex LastInstr
Last instr accessing current reg.
unsigned get(unsigned idx) const
SlotIndex getPrevSlot() const
Returns the previous slot in the index list.
MachineBasicBlock::iterator getLastInsertPointIter(const LiveInterval &CurLI, MachineBasicBlock &MBB)
Returns the last insert point as an iterator for in .
const MachineBasicBlock * getParent() const
bool isDebugValue() const
bool isEarlyClobber() const
void reset(const MachineFunction *MF, SlotIndexes *, MachineDominatorTree *, VNInfo::Allocator *)
reset - Prepare caches for a new set of non-overlapping live ranges.
SlotIndex insertMachineInstrInMaps(MachineInstr &MI, bool Late=false)
Insert the given machine instruction into the mapping.
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
void array_pod_sort(IteratorTy Start, IteratorTy End)
array_pod_sort - This sorts an array with the specified start and end extent.
SlotIndexes * getSlotIndexes() const
bool isValid() const
Returns true if this is a valid index.
void useIntv(const MachineBasicBlock &MBB)
useIntv - indicate that all instructions in MBB should use OpenLI.
bool isOneInstr() const
isOneInstr - Returns true when this BlockInfo describes a single instruction.
unsigned const MachineRegisterInfo * MRI
iterator_range< use_nodbg_iterator > use_nodbg_operands(unsigned Reg) const
Allocate memory in an ever growing pool, as if by bump-pointer.
std::pair< VNInfo *, bool > extendInBlock(ArrayRef< SlotIndex > Undefs, SlotIndex StartIdx, SlotIndex Use)
Attempt to extend a value defined after StartIdx to include Use.
unsigned getOriginal(unsigned VirtReg) const
getOriginal - Return the original virtual register that VirtReg descends from through splitting...
SM_Partition(Default) - Try to create the complement interval so it doesn't overlap any other interva...
SM_Size - Overlap intervals to minimize the number of inserted COPY instructions. ...
iterator_range< mop_iterator > defs()
Returns a range over all explicit operands that are register definitions.
static const unsigned End
for(unsigned i=0, e=MI->getNumOperands();i!=e;++i)
self_iterator getIterator()
LiveInterval & getParent() const
iterator_range< pred_iterator > predecessors()
SlotIndex leaveIntvAtTop(MachineBasicBlock &MBB)
leaveIntvAtTop - Leave the interval at the top of MBB.
unsigned getSubReg() const
constexpr Type getAsInteger() const
void selectIntv(unsigned Idx)
selectIntv - Select a previously opened interval index.
bool liveAt(SlotIndex index) const
bool isPHIDef() const
Returns true if this value is defined by a PHI instruction (or was, PHI instructions may have been el...
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
void insert(KeyT a, KeyT b, ValT y)
insert - Add a mapping of [a;b] to y, coalesce with adjacent intervals.
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'...
MachineBasicBlock::iterator getLastSplitPointIter(MachineBasicBlock *BB)
iterator find(SlotIndex Pos)
find - Return an iterator pointing to the first segment that ends after Pos, or end().
SmallPtrSetIterator - This implements a const_iterator for SmallPtrSet.
unsigned id
The ID number of this value.
void removeSegment(SlotIndex Start, SlotIndex End, bool RemoveDeadValNo=false)
Remove the specified segment from this range.
Iterator for intrusive lists based on ilist_node.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
unsigned countPopulation(T Value)
Count the number of set bits in a value.
static bool isSameInstr(SlotIndex A, SlotIndex B)
isSameInstr - Return true if A and B refer to the same instruction.
const MachineFunction & MF
Segments::const_iterator const_iterator
unsigned getNumLiveBlocks() const
getNumLiveBlocks - Return the number of blocks where CurLI is live.
SlotIndex FirstInstr
First instr accessing current reg.
SlotIndex leaveIntvBefore(SlotIndex Idx)
leaveIntvBefore - Leave the open interval before the instruction at Idx.
ConnectedVNInfoEqClasses - Helper class that can divide VNInfos in a LiveInterval into equivalence cl...
MachineOperand class - Representation of each machine instruction operand.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
static LaneBitmask getNone()
Additional information about basic blocks where the current variable is live.
MachineBasicBlock * getBlockNumbered(unsigned N) const
getBlockNumbered - MachineBasicBlocks are automatically numbered when they are inserted into the mach...
SplitAnalysis - Analyze a LiveInterval, looking for live range splitting opportunities.
LiveInterval & getInterval(unsigned Reg)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool LiveOut
Current reg is live out.
iterator insert(iterator I, T &&Elt)
VNInfo * getValNumInfo(unsigned ValNo)
getValNumInfo - Returns pointer to the specified val#.
llvm_unreachable("Unknown RegBank!")
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
void clear()
clear - clear all data structures so SplitAnalysis is ready to analyze a new interval.
Representation of each machine instruction.
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...
InsertPointAnalysis(const LiveIntervals &lis, unsigned BBNum)
LaneBitmask getMaxLaneMaskForVReg(unsigned Reg) const
Returns a mask covering all bits that can appear in lane masks of subregisters of the virtual registe...
SlotIndex rematerializeAt(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, unsigned DestReg, const Remat &RM, const TargetRegisterInfo &, bool Late=false)
rematerializeAt - Rematerialize RM.ParentVNI into DestReg by inserting an instruction into MBB before...
SmallVectorImpl< unsigned >::const_iterator iterator
Iterator for accessing the new registers added by this edit.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
VNInfo * createDeadDef(SlotIndex Def, VNInfo::Allocator &VNInfoAllocator)
createDeadDef - Make sure the range has a value defined at Def.
Represents a single loop in the control flow graph.
void setReg(unsigned Reg)
Change the register this operand corresponds to.
SlotIndex enterIntvBefore(SlotIndex Idx)
enterIntvBefore - Enter the open interval before the instruction at Idx.
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
constexpr bool all() const
static bool removeDeadSegment(SlotIndex Def, LiveRange &LR)
size_type count(const_arg_type_t< ValueT > V) const
Return 1 if the specified key is in the set, 0 otherwise.
Remat - Information needed to rematerialize at a specific location.
SlotIndex getRegSlot(bool EC=false) const
Returns the register use/def slot in the current instruction for a normal or early-clobber def...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
virtual const TargetRegisterClass * getSubClassWithSubReg(const TargetRegisterClass *RC, unsigned Idx) const
Returns the largest legal sub-class of RC that supports the sub-register index Idx.
unsigned countLiveBlocks(const LiveInterval *li) const
countLiveBlocks - Return the number of blocks where li is live.
MachineInstr * getInstructionFromIndex(SlotIndex index) const
Returns the instruction associated with the given index.
LiveInterval & createEmptyInterval()
create - Create a new register with the same class and original slot as parent.
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 ...
iterator SkipPHIsLabelsAndDebug(iterator I)
Return the first instruction in MBB after I that is not a PHI, label or debug.
SlotIndex getMBBStartIdx(const MachineBasicBlock *mbb) const
Return the first index in the given basic block.
reg_iterator reg_begin(unsigned RegNo) const
SlotIndex enterIntvAfter(SlotIndex Idx)
enterIntvAfter - Enter the open interval after the instruction at Idx.
SlotIndex getNextSlot() const
Returns the next slot in the index list.
bool hasSubRanges() const
Returns true if subregister liveness information is available.
static reg_iterator reg_end()
bool LiveIn
Current reg is live in.
bool dominates(const MachineDomTreeNode *A, const MachineDomTreeNode *B) const
const MachineInstrBuilder & addReg(unsigned RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
SlotIndex - An opaque wrapper around machine indexes.
reg_begin/reg_end - Provide iteration support to walk over all definitions and uses of a register wit...
unsigned getLoopDepth() const
Return the nesting level of this loop.
void calculateValues()
calculateValues - Calculate the value that will be live-in to each block added with addLiveInBlock...
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...
bool isOriginalEndpoint(SlotIndex Idx) const
isOriginalEndpoint - Return true if the original live range was killed or (re-)defined at Idx...
VNInfo * getVNInfoBefore(SlotIndex Idx) const
getVNInfoBefore - Return the VNInfo that is live up to but not necessarilly including Idx...
void removeVRegDefAt(LiveInterval &LI, SlotIndex Pos)
Remove value number and related live segments of LI and its subranges that start at position Pos...
const std::pair< SlotIndex, SlotIndex > & getMBBRange(unsigned Num) const
Return the (start,end) range of the given basic block number.