63 #define DEBUG_TYPE "regalloc" 65 STATISTIC(numJoins ,
"Number of interval joins performed");
66 STATISTIC(numCrossRCs ,
"Number of cross class joins performed");
67 STATISTIC(numCommutes ,
"Number of instruction commuting performed");
68 STATISTIC(numExtends ,
"Number of copies extended");
69 STATISTIC(NumReMats ,
"Number of instructions re-materialized");
70 STATISTIC(NumInflated ,
"Number of register classes inflated");
71 STATISTIC(NumLaneConflicts,
"Number of dead lane conflicts tested");
72 STATISTIC(NumLaneResolves,
"Number of dead lane conflicts resolved");
73 STATISTIC(NumShrinkToUses,
"Number of shrinkToUses called");
76 cl::desc(
"Coalesce copies (default=true)"),
91 cl::desc(
"Coalesce copies that span blocks (default=subtarget)"),
96 cl::desc(
"Verify machine instrs before and after register coalescing"),
101 cl::desc(
"During rematerialization for a copy, if the def instruction has " 102 "many other copy uses to be rematerialized, delay the multiple " 103 "separate live interval update work and do them all at once after " 104 "all those rematerialization are done. It will save a lot of " 110 cl::desc(
"If the valnos size of an interval is larger than the threshold, " 111 "it is regarded as a large interval. "),
116 cl::desc(
"For a large interval, if it is coalesed with other live " 117 "intervals many times more than the threshold, stop its " 118 "coalescing to control the compile time. "),
139 using DbgValueLoc = std::pair<SlotIndex, MachineInstr*>;
154 bool ShrinkMainRange =
false;
158 bool JoinGlobalCopies =
false;
162 bool JoinSplitEdges =
false;
188 void eliminateDeadDefs();
194 void coalesceLocals();
197 void joinAllIntervals();
212 void lateLiveIntervalUpdate();
288 void updateRegDefsUses(
unsigned SrcReg,
unsigned DstReg,
unsigned SubIdx);
354 void checkMergingChangesDbgValuesImpl(
unsigned Reg,
LiveRange &OtherRange,
366 void releaseMemory()
override;
382 "Simple Register Coalescing",
false,
false)
392 unsigned &Dst,
unsigned &SrcSub,
395 Dst = MI->getOperand(0).getReg();
396 DstSub = MI->getOperand(0).getSubReg();
397 Src = MI->getOperand(1).getReg();
398 SrcSub = MI->getOperand(1).getSubReg();
399 }
else if (MI->isSubregToReg()) {
400 Dst = MI->getOperand(0).getReg();
401 DstSub = tri.composeSubRegIndices(MI->getOperand(0).getSubReg(),
402 MI->getOperand(3).getImm());
403 Src = MI->getOperand(2).getReg();
404 SrcSub = MI->getOperand(2).getSubReg();
419 for (
const auto &MI : *MBB) {
430 Flipped = CrossClass =
false;
432 unsigned Src, Dst, SrcSub, DstSub;
433 if (!
isMoveInstr(TRI, MI, Src, Dst, SrcSub, DstSub))
435 Partial = SrcSub || DstSub;
452 if (!Dst)
return false;
459 if (!Dst)
return false;
469 if (SrcSub && DstSub) {
471 if (Src == Dst && SrcSub != DstSub)
497 if (DstIdx && !SrcIdx) {
503 CrossClass = NewRC != DstRC || NewRC != SrcRC;
508 "Cannot have a physical SubIdx");
526 unsigned Src, Dst, SrcSub, DstSub;
527 if (!
isMoveInstr(TRI, MI, Src, Dst, SrcSub, DstSub))
534 }
else if (Src != SrcReg) {
542 assert(!DstIdx && !SrcIdx &&
"Inconsistent CoalescerPair state.");
548 return DstReg == Dst;
550 return TRI.
getSubReg(DstReg, SrcSub) == Dst;
561 void RegisterCoalescer::getAnalysisUsage(
AnalysisUsage &AU)
const {
573 void RegisterCoalescer::eliminateDeadDefs() {
579 void RegisterCoalescer::LRE_WillEraseInstruction(
MachineInstr *MI) {
587 assert(!CP.
isPhys() &&
"This doesn't work for physreg copies.");
612 if (BS == IntB.
end())
return false;
613 VNInfo *BValNo = BS->valno;
618 if (BValNo->
def != CopyIdx)
return false;
624 if (AS == IntA.end())
return false;
625 VNInfo *AValNo = AS->valno;
637 if (ValS == IntB.
end())
650 if (ValS+1 != BS)
return false;
654 SlotIndex FillerStart = ValS->end, FillerEnd = BS->start;
658 BValNo->
def = FillerStart;
666 if (BValNo != ValS->valno)
675 S.removeSegment(*SS,
true);
678 VNInfo *SubBValNo = S.getVNInfoAt(CopyIdx);
681 if (SubBValNo != SubValSNo)
682 S.MergeValueNumberInto(SubBValNo, SubValSNo);
698 bool RecomputeLiveRange = AS->end == CopyIdx;
699 if (!RecomputeLiveRange) {
702 if (SS != S.end() && SS->end == CopyIdx) {
703 RecomputeLiveRange =
true;
708 if (RecomputeLiveRange)
715 bool RegisterCoalescer::hasOtherReachingDefs(
LiveInterval &IntA,
725 if (ASeg.
valno != AValNo)
continue;
727 if (BI != IntB.
begin())
729 for (; BI != IntB.
end() && ASeg.
end >= BI->start; ++BI) {
730 if (BI->valno == BValNo)
732 if (BI->start <= ASeg.
start && BI->end > ASeg.
start)
734 if (BI->start > ASeg.
start && BI->start < ASeg.
end)
743 static std::pair<bool,bool>
746 bool Changed =
false;
747 bool MergedWithDead =
false;
749 if (S.
valno != SrcValNo)
760 MergedWithDead =
true;
763 return std::make_pair(Changed, MergedWithDead);
767 RegisterCoalescer::removeCopyByCommutingDef(
const CoalescerPair &CP,
800 assert(BValNo !=
nullptr && BValNo->
def == CopyIdx);
806 return {
false,
false };
809 return {
false,
false };
811 return {
false,
false };
818 return {
false,
false };
831 return {
false,
false };
836 return {
false,
false };
840 if (hasOtherReachingDefs(IntA, IntB, AValNo, BValNo))
841 return {
false,
false };
850 if (US == IntA.end() || US->valno != AValNo)
854 return {
false,
false };
866 return {
false,
false };
870 return {
false,
false };
871 if (NewMI != DefMI) {
904 assert(US != IntA.end() &&
"Use must be live");
905 if (US->valno != AValNo)
931 VNInfo *SubDVNI = S.getVNInfoAt(DefIdx);
934 VNInfo *SubBValNo = S.getVNInfoAt(CopyIdx);
936 S.MergeValueNumberInto(SubDVNI, SubBValNo);
944 bool ShrinkB =
false;
947 if (!IntA.hasSubRanges()) {
949 IntA.createSubRangeFrom(Allocator, Mask, IntA);
958 VNInfo *ASubValNo = SA.getVNInfoAt(AIdx);
967 MaskA |= SA.LaneMask;
970 Allocator, SA.LaneMask,
971 [&Allocator, &SA, CopyIdx, ASubValNo,
973 VNInfo *BSubValNo = SR.empty() ? SR.getNextValue(CopyIdx, Allocator)
974 : SR.getVNInfoAt(CopyIdx);
975 assert(BSubValNo != nullptr);
976 auto P = addSegmentsWithValNo(SR, BSubValNo, SA, ASubValNo);
979 BSubValNo->def = ASubValNo->def;
987 if ((SB.LaneMask & MaskA).any())
991 SB.removeSegment(*S,
true);
995 BValNo->
def = AValNo->
def;
1004 return {
true, ShrinkB };
1054 bool RegisterCoalescer::removePartialRedundancy(
const CoalescerPair &CP,
1085 bool FoundReverseCopy =
false;
1104 bool ValB_Changed =
false;
1105 for (
auto VNI : IntB.
valnos) {
1106 if (VNI->isUnused())
1109 ValB_Changed =
true;
1117 FoundReverseCopy =
true;
1121 if (!FoundReverseCopy)
1131 if (CopyLeftBB && CopyLeftBB->
succ_size() > 1)
1142 if (InsPos != CopyLeftBB->
end()) {
1148 LLVM_DEBUG(
dbgs() <<
"\tremovePartialRedundancy: Move the copy to " 1153 TII->
get(TargetOpcode::COPY), IntB.
reg)
1164 ErasedInstrs.
erase(NewCopyMI);
1166 LLVM_DEBUG(
dbgs() <<
"\tremovePartialRedundancy: Remove the copy from " 1175 deleteInstr(&CopyMI);
1189 VNInfo *BValNo = SR.Query(CopyIdx).valueOutOrDead();
1190 assert(BValNo &&
"All sublanes should be live");
1199 for (
unsigned I = 0;
I != EndPoints.
size(); ) {
1201 EndPoints[
I] = EndPoints.
back();
1221 "This code cannot handle physreg aliasing");
1223 if (!
Op.isReg() || !
Op.isDef() ||
Op.getReg() !=
Reg)
1227 if (
Op.getSubReg() == 0 ||
Op.isUndef())
1233 bool RegisterCoalescer::reMaterializeTrivialDef(
const CoalescerPair &CP,
1264 bool SawStore =
false;
1281 if (SrcIdx && DstIdx)
1287 unsigned NewDstReg = DstReg;
1292 NewDstReg = TRI->
getSubReg(DstReg, NewDstIdx);
1302 "Only expect to deal with virtual or physical registers");
1310 TII->
reMaterialize(*MBB, MII, DstReg, SrcIdx, *DefMI, *TRI);
1324 &&
"Shouldn't have SrcIdx+DstIdx at this point");
1328 if (CommonRC !=
nullptr) {
1347 assert(MO.
isImplicit() &&
"No explicit operands after implicit operands.");
1356 ErasedInstrs.
insert(CopyMI);
1376 if (DefRC !=
nullptr) {
1381 assert(NewRC &&
"subreg chosen for remat incompatible with instruction");
1391 updateRegDefsUses(DstReg, DstReg, DstIdx);
1419 if (!SR.liveAt(DefIndex))
1420 SR.createDeadDef(DefIndex, Alloc);
1421 MaxMask &= ~SR.LaneMask;
1423 if (MaxMask.
any()) {
1441 bool UpdatedSubRanges =
false;
1443 if ((SR.LaneMask & DstMask).none()) {
1445 <<
"Removing undefined SubRange " 1449 SR.removeValNo(RmValNo);
1450 UpdatedSubRanges =
true;
1454 if (UpdatedSubRanges)
1461 "Only expect virtual or physical registers in remat");
1464 CopyDstReg,
true ,
true ,
false ));
1496 for (
unsigned i = 0,
e = NewMIImplDefs.
size(); i !=
e; ++i) {
1497 unsigned Reg = NewMIImplDefs[i];
1513 UseMO.substPhysReg(DstReg, *TRI);
1515 UseMO.setReg(DstReg);
1524 if (ToBeUpdated.
count(SrcReg))
1527 unsigned NumCopyUses = 0;
1529 if (UseMO.getParent()->isCopyLike())
1535 if (!DeadDefs.
empty())
1536 eliminateDeadDefs();
1538 ToBeUpdated.
insert(SrcReg);
1555 unsigned SrcReg, DstReg, SrcSubIdx, DstSubIdx;
1556 if(!
isMoveInstr(*TRI, CopyMI, SrcReg, DstReg, SrcSubIdx, DstSubIdx))
1565 if ((SR.LaneMask & SrcMask).none())
1570 }
else if (SrcLI.
liveAt(Idx))
1578 assert(Seg !=
nullptr &&
"No segment for defining instruction");
1580 if (V->isPHIDef()) {
1581 CopyMI->
setDesc(TII->
get(TargetOpcode::IMPLICIT_DEF));
1604 if ((SR.LaneMask & DstMask).none())
1607 VNInfo *SVNI = SR.getVNInfoAt(RegIndex);
1609 SR.removeValNo(SVNI);
1626 if ((SR.LaneMask & UseMask).none())
1628 if (SR.liveAt(UseIdx)) {
1634 isLive = DstLI.
liveAt(UseIdx);
1637 MO.setIsUndef(
true);
1647 if (MO.isReg() && MO.isDef() && MO.getReg() == DstReg)
1648 MO.setIsUndef(
true);
1659 bool IsUndef =
true;
1661 if ((S.LaneMask & Mask).none())
1663 if (S.liveAt(UseIdx)) {
1676 ShrinkMainRange =
true;
1680 void RegisterCoalescer::updateRegDefsUses(
unsigned SrcReg,
unsigned DstReg,
1685 if (DstInt && DstInt->
hasSubRanges() && DstReg != SrcReg) {
1688 if (SubReg == 0 || MO.
isUndef())
1694 addUndefFlag(*DstInt, UseIdx, MO, SubReg);
1709 if (SrcReg == DstReg && !Visited.
insert(UseMI).second)
1718 if (DstInt && !Reads && SubIdx && !UseMI->
isDebugValue())
1722 for (
unsigned i = 0,
e = Ops.
size(); i !=
e; ++i) {
1728 if (SubIdx && MO.
isDef())
1750 addUndefFlag(*DstInt, UseIdx, MO, SubIdx);
1760 dbgs() <<
"\t\tupdated: ";
1768 bool RegisterCoalescer::canJoinPhys(
const CoalescerPair &CP) {
1773 LLVM_DEBUG(
dbgs() <<
"\tCan only merge into reserved registers.\n");
1782 dbgs() <<
"\tCannot join complex intervals into reserved register.\n");
1786 bool RegisterCoalescer::joinCopy(
MachineInstr *CopyMI,
bool &Again) {
1791 if (!CP.setRegisters(CopyMI)) {
1796 if (CP.getNewRC()) {
1799 unsigned SrcIdx = CP.getSrcIdx();
1800 unsigned DstIdx = CP.getDstIdx();
1801 if (CP.isFlipped()) {
1806 CP.getNewRC(), *LIS)) {
1818 eliminateDeadDefs();
1825 if (
MachineInstr *UndefMI = eliminateUndefCopy(CopyMI)) {
1826 if (UndefMI->isImplicitDef())
1828 deleteInstr(CopyMI);
1836 if (CP.getSrcReg() == CP.getDstReg()) {
1838 LLVM_DEBUG(
dbgs() <<
"\tCopy already coalesced: " << LI <<
'\n');
1843 assert(ReadVNI &&
"No value before copy and no <undef> flag.");
1844 assert(ReadVNI != DefVNI &&
"Cannot read and define the same value.");
1852 S.MergeValueNumberInto(SDefVNI, SReadVNI);
1857 deleteInstr(CopyMI);
1865 <<
printReg(CP.getDstReg(),
TRI, CP.getSrcIdx()) <<
'\n');
1866 if (!canJoinPhys(CP)) {
1870 if (reMaterializeTrivialDef(CP, CopyMI, IsDefCopy))
1883 dbgs() <<
"\tConsidering merging to " 1885 if (CP.getDstIdx() && CP.getSrcIdx())
1888 <<
printReg(CP.getSrcReg()) <<
" in " 1892 <<
printReg(CP.getDstReg(),
TRI, CP.getSrcIdx()) <<
'\n';
1897 ShrinkMainRange =
false;
1903 if (!joinIntervals(CP)) {
1909 if (reMaterializeTrivialDef(CP, CopyMI, IsDefCopy))
1914 if (!CP.isPartial() && !CP.isPhys()) {
1915 bool Changed = adjustCopiesBackFrom(CP, CopyMI);
1916 bool Shrink =
false;
1918 std::tie(Changed, Shrink) = removeCopyByCommutingDef(CP, CopyMI);
1920 deleteInstr(CopyMI);
1922 unsigned DstReg = CP.isFlipped() ? CP.getSrcReg() : CP.getDstReg();
1934 if (!CP.isPartial() && !CP.isPhys())
1935 if (removePartialRedundancy(CP, *CopyMI))
1946 if (CP.isCrossClass()) {
1959 ErasedInstrs.
erase(CopyMI);
1964 updateRegDefsUses(CP.getDstReg(), CP.getDstReg(), CP.getDstIdx());
1965 updateRegDefsUses(CP.getSrcReg(), CP.getDstReg(), CP.getSrcIdx());
1968 if (ShrinkMask.any()) {
1971 if ((S.LaneMask & ShrinkMask).none())
1983 if (ToBeUpdated.
count(CP.getSrcReg()))
1984 ShrinkMainRange =
true;
1986 if (ShrinkMainRange) {
1999 dbgs() <<
"\tSuccess: " <<
printReg(CP.getSrcReg(),
TRI, CP.getSrcIdx())
2000 <<
" -> " <<
printReg(CP.getDstReg(),
TRI, CP.getDstIdx()) <<
'\n';
2001 dbgs() <<
"\tResult = ";
2013 bool RegisterCoalescer::joinReservedPhysReg(
CoalescerPair &CP) {
2021 assert(RHS.containsOneValue() &&
"Invalid join with reserved register");
2047 !RegMaskUsable.
test(DstReg)) {
2110 <<
printReg(DstReg, TRI) <<
" at " << CopyRegIdx <<
"\n");
2120 deleteInstr(CopyMI);
2208 const unsigned SubIdx;
2216 const bool SubRangeJoin;
2219 const bool TrackSubRegLiveness;
2235 enum ConflictResolution {
2267 ConflictResolution Resolution = CR_Keep;
2277 VNInfo *RedefVNI =
nullptr;
2280 VNInfo *OtherVNI =
nullptr;
2293 bool ErasableImplicitDef =
false;
2297 bool Pruned =
false;
2300 bool PrunedComputed =
false;
2307 bool Identical =
false;
2311 bool isAnalyzed()
const {
return WriteLanes.
any(); }
2323 std::pair<const VNInfo*,unsigned> followCopyChain(
const VNInfo *VNI)
const;
2325 bool valuesIdentical(
VNInfo *Value0,
VNInfo *Value1,
const JoinVals &
Other)
const;
2334 ConflictResolution analyzeValue(
unsigned ValNo, JoinVals &Other);
2339 void computeAssignment(
unsigned ValNo, JoinVals &Other);
2357 taintExtent(
unsigned ValNo,
LaneBitmask TaintedLanes, JoinVals &Other,
2370 bool isPrunedValue(
unsigned ValNo, JoinVals &Other);
2376 bool TrackSubRegLiveness)
2377 : LR(LR),
Reg(Reg), SubIdx(SubIdx), LaneMask(LaneMask),
2378 SubRangeJoin(SubRangeJoin), TrackSubRegLiveness(TrackSubRegLiveness),
2384 bool mapValues(JoinVals &Other);
2388 bool resolveConflicts(JoinVals &Other);
2408 void pruneMainSegments(
LiveInterval &LI,
bool &ShrinkMainRange);
2419 void removeImplicitDefs();
2422 const int *getAssignments()
const {
return Assignments.
data(); }
2425 ConflictResolution getResolution(
unsigned Num)
const {
2426 return Vals[Num].Resolution;
2446 std::pair<const VNInfo*, unsigned> JoinVals::followCopyChain(
2447 const VNInfo *VNI)
const {
2448 unsigned TrackReg =
Reg;
2452 MachineInstr *MI = Indexes->getInstructionFromIndex(Def);
2453 assert(MI &&
"No defining instruction");
2455 return std::make_pair(VNI, TrackReg);
2458 return std::make_pair(VNI, TrackReg);
2473 if ((SMask & LaneMask).none())
2481 return std::make_pair(VNI, TrackReg);
2484 if (ValueIn ==
nullptr) {
2491 return std::make_pair(
nullptr, SrcReg);
2496 return std::make_pair(VNI, TrackReg);
2499 bool JoinVals::valuesIdentical(
VNInfo *Value0,
VNInfo *Value1,
2500 const JoinVals &
Other)
const {
2503 std::tie(Orig0, Reg0) = followCopyChain(Value0);
2504 if (Orig0 == Value1 && Reg0 == Other.Reg)
2509 std::tie(Orig1, Reg1) = Other.followCopyChain(Value1);
2513 if (Orig0 ==
nullptr || Orig1 ==
nullptr)
2514 return Orig0 == Orig1 && Reg0 == Reg1;
2520 return Orig0->
def == Orig1->
def && Reg0 == Reg1;
2523 JoinVals::ConflictResolution
2524 JoinVals::analyzeValue(
unsigned ValNo, JoinVals &Other) {
2525 Val &V = Vals[ValNo];
2526 assert(!V.isAnalyzed() &&
"Value has already been analyzed!");
2527 VNInfo *VNI = LR.getValNumInfo(ValNo);
2528 if (VNI->isUnused()) {
2535 if (VNI->isPHIDef()) {
2539 V.ValidLanes = V.WriteLanes = Lanes;
2541 DefMI = Indexes->getInstructionFromIndex(VNI->def);
2542 assert(DefMI !=
nullptr);
2548 V.ErasableImplicitDef =
true;
2552 V.ValidLanes = V.WriteLanes = computeWriteLanes(DefMI, Redef);
2570 V.RedefVNI = LR.Query(VNI->def).valueIn();
2571 assert((TrackSubRegLiveness || V.RedefVNI) &&
2572 "Instruction is reading nonexistent value");
2573 if (V.RedefVNI !=
nullptr) {
2574 computeAssignment(V.RedefVNI->id, Other);
2575 V.ValidLanes |= Vals[V.RedefVNI->id].ValidLanes;
2587 V.ErasableImplicitDef =
true;
2604 if (OtherVNI->def < VNI->def)
2605 Other.computeAssignment(OtherVNI->id, *
this);
2606 else if (VNI->def < OtherVNI->def && OtherLRQ.
valueIn()) {
2609 V.OtherVNI = OtherLRQ.
valueIn();
2610 return CR_Impossible;
2612 V.OtherVNI = OtherVNI;
2613 Val &OtherV = Other.Vals[OtherVNI->id];
2615 if (!OtherV.isAnalyzed())
2620 if (VNI->isPHIDef())
2622 if ((V.ValidLanes & OtherV.ValidLanes).any())
2624 return CR_Impossible;
2630 V.OtherVNI = OtherLRQ.
valueIn();
2639 Other.computeAssignment(V.OtherVNI->id, *
this);
2640 Val &OtherV = Other.Vals[V.OtherVNI->id];
2642 if (OtherV.ErasableImplicitDef) {
2651 DefMI->
getParent() != Indexes->getMBBFromIndex(V.OtherVNI->def)) {
2652 LLVM_DEBUG(
dbgs() <<
"IMPLICIT_DEF defined at " << V.OtherVNI->def
2655 <<
", keeping it.\n");
2656 OtherV.ErasableImplicitDef =
false;
2659 OtherV.ValidLanes &= ~OtherV.WriteLanes;
2665 if (VNI->isPHIDef())
2672 if (TrackSubRegLiveness
2673 && (V.WriteLanes & (OtherV.ValidLanes | OtherV.WriteLanes)).none())
2683 V.ValidLanes &= ~V.WriteLanes | OtherV.ValidLanes;
2698 valuesIdentical(VNI, V.OtherVNI, Other)) {
2721 if ((V.WriteLanes & OtherV.ValidLanes).none())
2733 assert(VNI->def.isEarlyClobber() &&
2734 "Only early clobber defs can overlap a kill");
2735 return CR_Impossible;
2743 return CR_Impossible;
2749 if (OtherLRQ.
endPoint() >= Indexes->getMBBEndIdx(MBB))
2750 return CR_Impossible;
2759 return CR_Unresolved;
2762 void JoinVals::computeAssignment(
unsigned ValNo, JoinVals &Other) {
2763 Val &V = Vals[ValNo];
2764 if (V.isAnalyzed()) {
2767 assert(Assignments[ValNo] != -1 &&
"Bad recursion?");
2770 switch ((V.Resolution = analyzeValue(ValNo, Other))) {
2774 assert(V.OtherVNI &&
"OtherVNI not assigned, can't merge.");
2775 assert(Other.Vals[V.OtherVNI->id].isAnalyzed() &&
"Missing recursion");
2776 Assignments[ValNo] = Other.Assignments[V.OtherVNI->id];
2778 << LR.getValNumInfo(ValNo)->def <<
" into " 2779 <<
printReg(Other.Reg) <<
':' << V.OtherVNI->id <<
'@' 2780 << V.OtherVNI->def <<
" --> @" 2781 << NewVNInfo[Assignments[ValNo]]->def <<
'\n');
2784 case CR_Unresolved: {
2786 assert(V.OtherVNI &&
"OtherVNI not assigned, can't prune");
2787 Val &OtherV = Other.Vals[V.OtherVNI->id];
2790 if (OtherV.ErasableImplicitDef &&
2791 TrackSubRegLiveness &&
2792 (OtherV.WriteLanes & ~V.ValidLanes).any()) {
2793 LLVM_DEBUG(
dbgs() <<
"Cannot erase implicit_def with missing values\n");
2795 OtherV.ErasableImplicitDef =
false;
2802 OtherV.Pruned =
true;
2807 Assignments[ValNo] = NewVNInfo.size();
2808 NewVNInfo.push_back(LR.getValNumInfo(ValNo));
2813 bool JoinVals::mapValues(JoinVals &Other) {
2814 for (
unsigned i = 0,
e = LR.getNumValNums(); i !=
e; ++i) {
2815 computeAssignment(i, Other);
2816 if (Vals[i].Resolution == CR_Impossible) {
2818 <<
'@' << LR.getValNumInfo(i)->def <<
'\n');
2826 taintExtent(
unsigned ValNo,
LaneBitmask TaintedLanes, JoinVals &Other,
2828 VNInfo *VNI = LR.getValNumInfo(ValNo);
2830 SlotIndex MBBEnd = Indexes->getMBBEndIdx(MBB);
2834 assert(OtherI != Other.LR.end() &&
"No conflict?");
2839 if (End >= MBBEnd) {
2841 << OtherI->valno->id <<
'@' << OtherI->start <<
'\n');
2845 << OtherI->valno->id <<
'@' << OtherI->start <<
" to " 2850 TaintExtent.push_back(std::make_pair(End, TaintedLanes));
2853 if (++OtherI == Other.LR.end() || OtherI->start >= MBBEnd)
2857 const Val &OV = Other.Vals[OtherI->valno->id];
2858 TaintedLanes &= ~OV.WriteLanes;
2861 }
while (TaintedLanes.
any());
2865 bool JoinVals::usesLanes(
const MachineInstr &MI,
unsigned Reg,
unsigned SubIdx,
2881 bool JoinVals::resolveConflicts(JoinVals &Other) {
2882 for (
unsigned i = 0,
e = LR.getNumValNums(); i !=
e; ++i) {
2884 assert(V.Resolution != CR_Impossible &&
"Unresolvable conflict");
2885 if (V.Resolution != CR_Unresolved)
2888 << LR.getValNumInfo(i)->def <<
'\n');
2893 assert(V.OtherVNI &&
"Inconsistent conflict resolution.");
2894 VNInfo *VNI = LR.getValNumInfo(i);
2895 const Val &OtherV = Other.Vals[V.OtherVNI->id];
2900 LaneBitmask TaintedLanes = V.WriteLanes & OtherV.ValidLanes;
2902 if (!taintExtent(i, TaintedLanes, Other, TaintExtent))
2906 assert(!TaintExtent.
empty() &&
"There should be at least one conflict.");
2912 MI = Indexes->getInstructionFromIndex(VNI->
def);
2917 "Interference ends on VNI->def. Should have been handled earlier");
2919 Indexes->getInstructionFromIndex(TaintExtent.
front().first);
2920 assert(LastMI &&
"Range must end at a proper instruction");
2921 unsigned TaintNum = 0;
2923 assert(MI != MBB->end() &&
"Bad LastMI");
2924 if (usesLanes(*MI, Other.Reg, Other.SubIdx, TaintedLanes)) {
2929 if (&*MI == LastMI) {
2930 if (++TaintNum == TaintExtent.
size())
2932 LastMI = Indexes->getInstructionFromIndex(TaintExtent[TaintNum].
first);
2933 assert(LastMI &&
"Range must end at a proper instruction");
2934 TaintedLanes = TaintExtent[TaintNum].second;
2940 V.Resolution = CR_Replace;
2946 bool JoinVals::isPrunedValue(
unsigned ValNo, JoinVals &Other) {
2947 Val &V = Vals[ValNo];
2948 if (V.Pruned || V.PrunedComputed)
2951 if (V.Resolution != CR_Erase && V.Resolution != CR_Merge)
2956 V.PrunedComputed =
true;
2957 V.Pruned = Other.isPrunedValue(V.OtherVNI->id, *
this);
2961 void JoinVals::pruneValues(JoinVals &Other,
2963 bool changeInstrs) {
2964 for (
unsigned i = 0,
e = LR.getNumValNums(); i !=
e; ++i) {
2966 switch (Vals[i].Resolution) {
2976 Val &OtherV = Other.Vals[Vals[i].OtherVNI->id];
2977 bool EraseImpDef = OtherV.ErasableImplicitDef &&
2978 OtherV.Resolution == CR_Keep;
2985 Indexes->getInstructionFromIndex(Def)->operands()) {
2999 <<
": " << Other.LR <<
'\n');
3004 if (isPrunedValue(i, Other)) {
3011 << Def <<
": " << LR <<
'\n');
3062 bool DidPrune =
false;
3063 for (
unsigned i = 0,
e = LR.getNumValNums(); i !=
e; ++i) {
3067 if (V.Resolution != CR_Erase &&
3068 (V.Resolution != CR_Keep || !V.ErasableImplicitDef || !V.Pruned))
3075 OtherDef = V.OtherVNI->def;
3078 LLVM_DEBUG(
dbgs() <<
"\t\tExpecting instruction removal at " << Def
3086 if (ValueOut !=
nullptr && (Q.
valueIn() ==
nullptr ||
3087 (V.Identical && V.Resolution == CR_Erase &&
3088 ValueOut->
def ==
Def))) {
3090 <<
" at " << Def <<
"\n");
3097 if (V.Identical && S.Query(OtherDef).valueOutOrDead()) {
3111 ShrinkMask |= S.LaneMask;
3122 if (
VNInfo *VNI = SR.Query(Def).valueOutOrDead())
3123 if (VNI->
def == Def)
3129 void JoinVals::pruneMainSegments(
LiveInterval &LI,
bool &ShrinkMainRange) {
3130 assert(&static_cast<LiveRange&>(LI) == &LR);
3132 for (
unsigned i = 0,
e = LR.getNumValNums(); i !=
e; ++i) {
3133 if (Vals[i].Resolution != CR_Keep)
3135 VNInfo *VNI = LR.getValNumInfo(i);
3138 Vals[i].Pruned =
true;
3139 ShrinkMainRange =
true;
3143 void JoinVals::removeImplicitDefs() {
3144 for (
unsigned i = 0,
e = LR.getNumValNums(); i !=
e; ++i) {
3146 if (V.Resolution != CR_Keep || !V.ErasableImplicitDef || !V.Pruned)
3149 VNInfo *VNI = LR.getValNumInfo(i);
3151 LR.removeValNo(VNI);
3158 for (
unsigned i = 0,
e = LR.getNumValNums(); i !=
e; ++i) {
3160 VNInfo *VNI = LR.getValNumInfo(i);
3162 switch (Vals[i].Resolution) {
3167 if (!Vals[i].ErasableImplicitDef || !Vals[i].Pruned)
3179 if (LI !=
nullptr) {
3188 LR.removeValNo(VNI);
3194 assert(static_cast<LiveRange*>(LI) == &LR);
3204 ED = ED.
isValid() ? std::min(ED, I->start) : I->start;
3209 NewEnd = std::min(NewEnd, LE);
3211 NewEnd = std::min(NewEnd, ED);
3217 if (S != LR.begin())
3218 std::prev(S)->end = NewEnd;
3222 dbgs() <<
"\t\tremoved " << i <<
'@' << Def <<
": " << LR <<
'\n';
3224 dbgs() <<
"\t\t LHS = " << *LI <<
'\n';
3230 MachineInstr *MI = Indexes->getInstructionFromIndex(Def);
3231 assert(MI &&
"No instruction to erase");
3255 NewVNInfo,
CP, LIS,
TRI,
true,
true);
3256 JoinVals LHSVals(LRange, CP.getDstReg(), CP.getDstIdx(), LaneMask,
3257 NewVNInfo,
CP, LIS,
TRI,
true,
true);
3264 if (!LHSVals.mapValues(RHSVals) || !RHSVals.mapValues(LHSVals)) {
3269 if (!LHSVals.resolveConflicts(RHSVals) ||
3270 !RHSVals.resolveConflicts(LHSVals)) {
3281 LHSVals.pruneValues(RHSVals, EndPoints,
false);
3282 RHSVals.pruneValues(LHSVals, EndPoints,
false);
3284 LHSVals.removeImplicitDefs();
3285 RHSVals.removeImplicitDefs();
3291 LRange.
join(RRange, LHSVals.getAssignments(), RHSVals.getAssignments(),
3295 <<
' ' << LRange <<
"\n");
3296 if (EndPoints.
empty())
3302 dbgs() <<
"\t\trestoring liveness to " << EndPoints.
size() <<
" points: ";
3303 for (
unsigned i = 0, n = EndPoints.
size(); i != n; ++i) {
3304 dbgs() << EndPoints[i];
3308 dbgs() <<
": " << LRange <<
'\n';
3310 LIS->extendToIndices(LRange, EndPoints);
3313 void RegisterCoalescer::mergeSubRangeInto(
LiveInterval &LI,
3317 unsigned ComposeSubRegIdx) {
3320 Allocator, LaneMask,
3323 SR.
assign(ToMerge, Allocator);
3326 LiveRange RangeCopy(ToMerge, Allocator);
3327 joinSubRegRanges(SR, RangeCopy, SR.
LaneMask, CP);
3333 bool RegisterCoalescer::isHighCostLiveInterval(
LiveInterval &LI) {
3336 auto &Counter = LargeLIVisitCounter[LI.
reg];
3350 NewVNInfo,
CP, LIS,
TRI,
false, TrackSubRegLiveness);
3352 NewVNInfo,
CP, LIS,
TRI,
false, TrackSubRegLiveness);
3354 LLVM_DEBUG(
dbgs() <<
"\t\tRHS = " << RHS <<
"\n\t\tLHS = " << LHS <<
'\n');
3356 if (isHighCostLiveInterval(LHS) || isHighCostLiveInterval(RHS))
3361 if (!LHSVals.mapValues(RHSVals) || !RHSVals.mapValues(LHSVals))
3365 if (!LHSVals.resolveConflicts(RHSVals) || !RHSVals.resolveConflicts(LHSVals))
3374 unsigned DstIdx = CP.getDstIdx();
3377 : TRI->getSubRegIndexLaneMask(DstIdx);
3381 }
else if (DstIdx != 0) {
3384 LaneBitmask Mask = TRI->composeSubRegIndexLaneMask(DstIdx, R.LaneMask);
3392 unsigned SrcIdx = CP.getSrcIdx();
3395 : TRI->getSubRegIndexLaneMask(SrcIdx);
3396 mergeSubRangeInto(LHS, RHS, Mask, CP, DstIdx);
3400 LaneBitmask Mask = TRI->composeSubRegIndexLaneMask(SrcIdx, R.LaneMask);
3401 mergeSubRangeInto(LHS, R, Mask, CP, DstIdx);
3408 LHSVals.pruneMainSegments(LHS, ShrinkMainRange);
3410 LHSVals.pruneSubRegValues(LHS, ShrinkMask);
3411 RHSVals.pruneSubRegValues(LHS, ShrinkMask);
3419 LHSVals.pruneValues(RHSVals, EndPoints,
true);
3420 RHSVals.pruneValues(LHSVals, EndPoints,
true);
3425 LHSVals.eraseInstrs(ErasedInstrs, ShrinkRegs, &LHS);
3426 RHSVals.eraseInstrs(ErasedInstrs, ShrinkRegs);
3427 while (!ShrinkRegs.
empty())
3431 checkMergingChangesDbgValues(CP, LHS, LHSVals, RHS, RHSVals);
3434 LHS.
join(RHS, LHSVals.getAssignments(), RHSVals.getAssignments(), NewVNInfo);
3442 if (!EndPoints.
empty()) {
3446 dbgs() <<
"\t\trestoring liveness to " << EndPoints.
size() <<
" points: ";
3447 for (
unsigned i = 0, n = EndPoints.
size(); i != n; ++i) {
3448 dbgs() << EndPoints[i];
3452 dbgs() <<
": " << LHS <<
'\n';
3454 LIS->extendToIndices((
LiveRange&)LHS, EndPoints);
3461 return CP.
isPhys() ? joinReservedPhysReg(CP) : joinVirtRegs(CP);
3471 auto CloseNewDVRange = [
this, &ToInsert](
SlotIndex Slot) {
3472 for (
auto *
X : ToInsert)
3473 DbgVRegToValues[
X->getOperand(0).getReg()].push_back({Slot,
X});
3481 for (
auto &MBB : MF) {
3484 for (
auto &MI : MBB) {
3490 CloseNewDVRange(CurrentSlot);
3499 for (
auto &Pair : DbgVRegToValues)
3503 void RegisterCoalescer::checkMergingChangesDbgValues(
CoalescerPair &CP,
3507 JoinVals &RHSVals) {
3508 auto ScanForDstReg = [&](
unsigned Reg) {
3509 checkMergingChangesDbgValuesImpl(Reg, RHS, LHS, LHSVals);
3512 auto ScanForSrcReg = [&](
unsigned Reg) {
3513 checkMergingChangesDbgValuesImpl(Reg, LHS, RHS, RHSVals);
3518 auto PerformScan = [
this](
unsigned Reg, std::function<void(unsigned)> Func) {
3520 if (DbgMergedVRegNums.
count(Reg))
3521 for (
unsigned X : DbgMergedVRegNums[Reg])
3526 PerformScan(CP.
getSrcReg(), ScanForSrcReg);
3527 PerformScan(CP.
getDstReg(), ScanForDstReg);
3530 void RegisterCoalescer::checkMergingChangesDbgValuesImpl(
unsigned Reg,
3533 JoinVals &RegVals) {
3535 auto VRegMapIt = DbgVRegToValues.
find(Reg);
3536 if (VRegMapIt == DbgVRegToValues.
end())
3539 auto &DbgValueSet = VRegMapIt->second;
3540 auto DbgValueSetIt = DbgValueSet.begin();
3541 auto SegmentIt = OtherLR.
begin();
3543 bool LastUndefResult =
false;
3548 auto ShouldUndef = [&RegVals, &RegLR, &LastUndefResult,
3553 if (LastUndefIdx == Idx)
3554 return LastUndefResult;
3560 auto OtherIt = RegLR.find(Idx);
3561 if (OtherIt == RegLR.end())
3570 auto Resolution = RegVals.getResolution(OtherIt->valno->id);
3571 LastUndefResult = Resolution != JoinVals::CR_Keep &&
3572 Resolution != JoinVals::CR_Erase;
3574 return LastUndefResult;
3580 while (DbgValueSetIt != DbgValueSet.end() && SegmentIt != OtherLR.
end()) {
3581 if (DbgValueSetIt->first < SegmentIt->end) {
3584 if (DbgValueSetIt->first >= SegmentIt->start &&
3585 DbgValueSetIt->second->getOperand(0).getReg() != 0 &&
3586 ShouldUndef(DbgValueSetIt->first)) {
3588 DbgValueSetIt->second->getOperand(0).setReg(0);
3601 struct MBBPriorityInfo {
3607 : MBB(mbb),
Depth(depth), IsSplit(issplit) {}
3617 const MBBPriorityInfo *RHS) {
3619 if (LHS->Depth != RHS->Depth)
3620 return LHS->Depth > RHS->Depth ? -1 : 1;
3623 if (LHS->IsSplit != RHS->IsSplit)
3624 return LHS->IsSplit ? -1 : 1;
3628 unsigned cl = LHS->MBB->pred_size() + LHS->MBB->succ_size();
3629 unsigned cr = RHS->MBB->pred_size() + RHS->MBB->succ_size();
3631 return cl > cr ? -1 : 1;
3634 return LHS->MBB->getNumber() < RHS->MBB->getNumber() ? -1 : 1;
3655 void RegisterCoalescer::lateLiveIntervalUpdate() {
3656 for (
unsigned reg : ToBeUpdated) {
3661 if (!DeadDefs.
empty())
3662 eliminateDeadDefs();
3664 ToBeUpdated.clear();
3667 bool RegisterCoalescer::
3669 bool Progress =
false;
3670 for (
unsigned i = 0,
e = CurrList.
size(); i !=
e; ++i) {
3675 if (ErasedInstrs.
count(CurrList[i])) {
3676 CurrList[i] =
nullptr;
3680 bool Success = joinCopy(CurrList[i], Again);
3682 if (Success || !Again)
3683 CurrList[i] =
nullptr;
3700 bool RegisterCoalescer::applyTerminalRule(
const MachineInstr &Copy)
const {
3704 unsigned DstReg, DstSubReg, SrcReg, SrcSubReg;
3705 if (!
isMoveInstr(*TRI, &Copy, SrcReg, DstReg, SrcSubReg, DstSubReg))
3728 unsigned OtherReg, OtherSubReg, OtherSrcReg, OtherSrcSubReg;
3729 if (!
isMoveInstr(*TRI, &Copy, OtherSrcReg, OtherReg, OtherSrcSubReg,
3732 if (OtherReg == SrcReg)
3733 OtherReg = OtherSrcReg;
3754 const unsigned PrevSize = WorkList.
size();
3755 if (JoinGlobalCopies) {
3764 if (!MII->isCopyLike())
3766 bool ApplyTerminalRule = applyTerminalRule(*MII);
3768 if (ApplyTerminalRule)
3773 if (ApplyTerminalRule)
3780 LocalWorkList.
append(LocalTerminals.
begin(), LocalTerminals.
end());
3786 if (MII.isCopyLike()) {
3787 if (applyTerminalRule(MII))
3799 CurrList(WorkList.
begin() + PrevSize, WorkList.
end());
3800 if (copyCoalesceWorkList(CurrList))
3802 nullptr), WorkList.
end());
3805 void RegisterCoalescer::coalesceLocals() {
3806 copyCoalesceWorkList(LocalWorkList);
3807 for (
unsigned j = 0, je = LocalWorkList.
size(); j != je; ++j) {
3808 if (LocalWorkList[j])
3811 LocalWorkList.
clear();
3814 void RegisterCoalescer::joinAllIntervals() {
3815 LLVM_DEBUG(
dbgs() <<
"********** JOINING INTERVALS ***********\n");
3816 assert(WorkList.
empty() && LocalWorkList.
empty() &&
"Old data still around.");
3818 std::vector<MBBPriorityInfo> MBBs;
3819 MBBs.reserve(MF->
size());
3822 MBBs.push_back(MBBPriorityInfo(MBB, Loops->
getLoopDepth(MBB),
3829 for (
unsigned i = 0,
e = MBBs.size(); i !=
e; ++i) {
3831 if (JoinGlobalCopies && MBBs[i].
Depth < CurrDepth) {
3833 CurrDepth = MBBs[i].Depth;
3835 copyCoalesceInMBB(MBBs[i].MBB);
3837 lateLiveIntervalUpdate();
3842 while (copyCoalesceWorkList(WorkList))
3844 lateLiveIntervalUpdate();
3847 void RegisterCoalescer::releaseMemory() {
3848 ErasedInstrs.
clear();
3851 InflateRegs.
clear();
3852 LargeLIVisitCounter.
clear();
3861 LIS = &getAnalysis<LiveIntervals>();
3862 AA = &getAnalysis<AAResultsWrapperPass>().getAAResults();
3863 Loops = &getAnalysis<MachineLoopInfo>();
3874 LLVM_DEBUG(
dbgs() <<
"********** SIMPLE REGISTER COALESCING **********\n" 3875 <<
"********** Function: " << MF->
getName() <<
'\n');
3878 MF->
verify(
this,
"Before register coalescing");
3880 DbgVRegToValues.
clear();
3881 DbgMergedVRegNums.
clear();
3882 buildVRegToDbgValueMap(fn);
3894 InflateRegs.
erase(std::unique(InflateRegs.
begin(), InflateRegs.
end()),
3898 for (
unsigned i = 0,
e = InflateRegs.
size(); i !=
e; ++i) {
3899 unsigned Reg = InflateRegs[i];
3919 assert((S.LaneMask & ~MaxMask).none());
3929 MF->
verify(
this,
"After register coalescing");
static bool isSplitEdge(const MachineBasicBlock *MBB)
Return true if this block should be vacated by the coalescer to eliminate branches.
bool isPHIDef() const
Returns true if this value is defined by a PHI instruction (or was, PHI instructions may have been el...
iterator_range< reg_instr_nodbg_iterator > reg_nodbg_instructions(unsigned Reg) const
A common definition of LaneBitmask for use in TableGen and CodeGen.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
MachineInstr * getParent()
getParent - Return the instruction that this operand belongs to.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
bool use_nodbg_empty(unsigned RegNo) const
use_nodbg_empty - Return true if there are no non-Debug instructions using the specified register...
bool contains(unsigned Reg) const
Return true if the specified register is included in this register class.
bool isReserved(Register PhysReg) const
isReserved - Returns true when PhysReg is a reserved register.
virtual bool enableJoinGlobalCopies() const
True if the subtarget should enable joining global copies.
SlotIndex getBaseIndex() const
Returns the base index for associated with this index.
SlotIndex def
The index of the defining instruction.
void RemoveMachineInstrFromMaps(MachineInstr &MI)
const MachineFunction * getMF() const
Return the function that contains the basic block that this instruction belongs to.
LaneBitmask getMaxLaneMaskForVReg(unsigned Reg) const
Returns a mask covering all bits that can appear in lane masks of subregisters of the virtual registe...
This class represents lattice values for constants.
bool hasPHIKill(const LiveInterval &LI, const VNInfo *VNI) const
Returns true if VNI is killed by any PHI-def values in LI.
void removePhysRegDefAt(unsigned Reg, SlotIndex Pos)
Remove value numbers and related live segments starting at position Pos that are part of any liverang...
A Module instance is used to store all the information related to an LLVM module. ...
bool isCoalescable(const MachineInstr *) const
Return true if MI is a copy instruction that will become an identity copy after coalescing.
static cl::opt< bool > VerifyCoalescing("verify-coalescing", cl::desc("Verify machine instrs before and after register coalescing"), cl::Hidden)
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
std::error_code remove(const Twine &path, bool IgnoreNonExisting=true)
Remove path.
Segments::iterator iterator
void push_back(const T &Elt)
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
char & MachineDominatorsID
MachineDominators - This pass is a machine dominators analysis pass.
static bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
LiveInterval - This class represents the liveness of a register, or stack slot.
iterator_range< use_nodbg_iterator > use_nodbg_operands(unsigned Reg) const
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.
void setIsUndef(bool Val=true)
void eliminateDeadDefs(SmallVectorImpl< MachineInstr *> &Dead, ArrayRef< unsigned > RegsBeingSpilled=None, AliasAnalysis *AA=nullptr)
eliminateDeadDefs - Try to delete machine instructions that are now dead (allDefsAreDead returns true...
static cl::opt< bool > EnableJoining("join-liveintervals", cl::desc("Coalesce copies (default=true)"), cl::init(true), cl::Hidden)
iterator_range< reg_nodbg_iterator > reg_nodbg_operands(unsigned Reg) const
int findRegisterDefOperandIdx(Register Reg, bool isDead=false, bool Overlap=false, const TargetRegisterInfo *TRI=nullptr) const
Returns the operand index that is a def of the specified register or -1 if it is not found...
static bool isLocalCopy(MachineInstr *Copy, const LiveIntervals *LIS)
MachineInstr * commuteInstruction(MachineInstr &MI, bool NewMI=false, unsigned OpIdx1=CommuteAnyOperandIndex, unsigned OpIdx2=CommuteAnyOperandIndex) const
This method commutes the operands of the given machine instruction MI.
unsigned getSubReg() const
bool test(unsigned Idx) const
static bool definesFullReg(const MachineInstr &MI, unsigned Reg)
Returns true if MI defines the full vreg Reg, as opposed to just defining a subregister.
iterator_range< reg_iterator > reg_operands(unsigned Reg) const
void substVirtReg(Register Reg, unsigned SubIdx, const TargetRegisterInfo &)
substVirtReg - Substitute the current register with the virtual subregister Reg:SubReg.
char & RegisterCoalescerID
RegisterCoalescer - This pass merges live ranges to eliminate copies.
bool isDead() const
isDead - Returns true if this is a dead def kill slot.
unsigned getLoopDepth(const MachineBasicBlock *BB) const
Return the loop nesting level of the specified block.
A live range for subregisters.
bool isValid() const
Returns true if this is a valid index.
This represents a simple continuous liveness interval for a value.
STATISTIC(NumFunctions, "Total number of functions")
unsigned const TargetRegisterInfo * TRI
void setIsDead(bool Val=true)
Printable PrintLaneMask(LaneBitmask LaneMask)
Create Printable object to print LaneBitmasks on a raw_ostream.
bool isPhys() const
Return true if DstReg is a physical register.
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.
void markUnused()
Mark this value as unused.
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.
void reserve(size_type N)
SubRange * createSubRangeFrom(BumpPtrAllocator &Allocator, LaneBitmask LaneMask, const LiveRange &CopyFrom)
Like createSubRange() but the new range is filled with a copy of the liveness information in CopyFrom...
VNInfo * valueOut() const
Return the value leaving the instruction, if any.
VNInfo - Value Number Information.
void print(raw_ostream &O, const Module *=nullptr) const override
Implement the dump method.
iterator_range< mop_iterator > operands()
bool isCopyLike() const
Return true if the instruction behaves like a copy.
bool checkRegMaskInterference(LiveInterval &LI, BitVector &UsableRegs)
Test if LI is live across any register mask instructions, and compute a bit mask of physical register...
Callback methods for LiveRangeEdit owners.
void initializeRegisterCoalescerPass(PassRegistry &)
const TargetRegisterClass * getRegClass(Register Reg) const
Return the register class of the specified virtual register.
This class represents the liveness of a register, stack slot, etc.
static bool isDefInSubRange(LiveInterval &LI, SlotIndex Def)
Check if any of the subranges of LI contain a definition at Def.
bool isUnused() const
Returns true if this value is unused.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
unsigned getDstReg() const
Return the register (virtual or physical) that will remain after coalescing.
bool isEarlyClobber() const
const char * getRegClassName(const TargetRegisterClass *Class) const
Returns the name of the register class.
bool isPartial() const
Return true if the original copy instruction did not copy the full register, but was a subreg operati...
void removeEmptySubRanges()
Removes all subranges without any segments (subranges without segments are not considered valid and s...
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
bool isBlock() const
isBlock - Returns true if this is a block boundary slot.
void substPhysReg(MCRegister Reg, const TargetRegisterInfo &)
substPhysReg - Substitute the current register with the physical register Reg, taking any existing Su...
void pruneValue(LiveRange &LR, SlotIndex Kill, SmallVectorImpl< SlotIndex > *EndPoints)
If LR has a live value at Kill, prune its live range by removing any liveness reachable from Kill...
static use_iterator use_end()
void verify() const
Walk the range and assert if any invariants fail to hold.
virtual void reMaterialize(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, unsigned DestReg, unsigned SubIdx, const MachineInstr &Orig, const TargetRegisterInfo &TRI) const
Re-issue the specified 'original' instruction at the specific location targeting a new destination re...
instr_iterator erase(instr_iterator I)
Remove an instruction from the instruction list and delete it.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
unsigned getNumOperands() const
Return the number of declared MachineOperands for this MachineInstruction.
const HexagonInstrInfo * TII
void substituteRegister(Register FromReg, Register ToReg, unsigned SubIdx, const TargetRegisterInfo &RegInfo)
Replace all occurrences of FromReg with ToReg:SubIdx, properly composing subreg indices where necessa...
std::pair< bool, bool > readsWritesVirtualRegister(Register Reg, SmallVectorImpl< unsigned > *Ops=nullptr) const
Return a pair of bools (reads, writes) indicating if this instruction reads or writes Reg...
Printable printMBBReference(const MachineBasicBlock &MBB)
Prints a machine basic block reference.
unsigned getNumOperands() const
Retuns the total number of operands.
virtual const TargetRegisterClass * getRegClass(const MCInstrDesc &MCID, unsigned OpNum, const TargetRegisterInfo *TRI, const MachineFunction &MF) const
Given a machine instruction descriptor, returns the register class constraint for OpNum...
VNInfo::Allocator & getVNInfoAllocator()
A helper class for register coalescers.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
iterator_range< subrange_iterator > subranges()
void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
Result of a LiveRange query.
static cl::opt< bool > EnableJoinSplits("join-splitedges", cl::desc("Coalesce copies on split edges (default=subtarget)"), cl::Hidden)
Temporary flag to test critical edge unsplitting.
static constexpr LaneBitmask getAll()
SlotIndex getInstructionIndex(const MachineInstr &MI) const
Returns the base index for the given instruction.
bool hasSubRanges() const
Returns true if subregister liveness information is available.
static constexpr LaneBitmask getNone()
Printable printRegUnit(unsigned Unit, const TargetRegisterInfo *TRI)
Create Printable object to print register units on a raw_ostream.
SlotIndex ReplaceMachineInstrInMaps(MachineInstr &MI, MachineInstr &NewMI)
static reg_instr_iterator reg_instr_end()
SlotIndex getNextNonNullIndex(SlotIndex Index)
Returns the next non-null index, if one exists.
MachineInstr * getVRegDef(unsigned Reg) const
getVRegDef - Return the machine instr that defines the specified virtual register or null if none is ...
defusechain_iterator - This class provides iterator support for machine operands in the function that...
void extendToIndices(LiveRange &LR, ArrayRef< SlotIndex > Indices, ArrayRef< SlotIndex > Undefs)
Extend the live range LR to reach all points in Indices.
const TargetRegisterClass * getCommonSuperRegClass(const TargetRegisterClass *RCA, unsigned SubA, const TargetRegisterClass *RCB, unsigned SubB, unsigned &PreA, unsigned &PreB) const
Find a common super-register class if it exists.
MachineInstr * getInstructionFromIndex(SlotIndex index) const
Returns the instruction associated with the given index.
bool readsReg() const
readsReg - Returns true if this operand reads the previous value of its register. ...
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
bool hasInterval(Register Reg) const
SlotIndex getRegSlot(bool EC=false) const
Returns the register use/def slot in the current instruction for a normal or early-clobber def...
void clearKillFlags(unsigned Reg) const
clearKillFlags - Iterate over all the uses of the given register and clear the kill flag from the Mac...
iterator addSegment(Segment S)
Add the specified Segment to this range, merging segments as appropriate.
MCRegUnitRootIterator enumerates the root registers of a register unit.
SlotIndex InsertMachineInstrInMaps(MachineInstr &MI)
VNInfo * MergeValueNumberInto(VNInfo *V1, VNInfo *V2)
MergeValueNumberInto - This method is called when two value numbers are found to be equivalent...
Register getSubReg(MCRegister Reg, unsigned Idx) const
Returns the physical register number of sub-register "Index" for physical register RegNo...
AnalysisUsage & addPreservedID(const void *ID)
const char * getSubRegIndexName(unsigned SubIdx) const
Return the human-readable symbolic target-specific name for the specified SubRegIndex.
bool isVirtual() const
Return true if the specified register number is in the virtual register namespace.
void setReg(Register Reg)
Change the register this operand corresponds to.
virtual const TargetInstrInfo * getInstrInfo() const
instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
static cl::opt< unsigned > LargeIntervalFreqThreshold("large-interval-freq-threshold", cl::Hidden, cl::desc("For a large interval, if it is coalesed with other live " "intervals many times more than the threshold, stop its " "coalescing to control the compile time. "), cl::init(100))
bool isKill() const
Return true if the live-in value is killed by this instruction.
bool setRegisters(const MachineInstr *)
Set registers to match the copy instruction MI.
VNInfo * createDeadDef(SlotIndex Def, VNInfo::Allocator &VNIAlloc)
createDeadDef - Make sure the range has a value defined at Def.
const TargetRegisterClass * constrainRegClass(unsigned Reg, const TargetRegisterClass *RC, unsigned MinNumRegs=0)
constrainRegClass - Constrain the register class of the specified virtual register to be a common sub...
bool allDefsAreDead() const
Return true if all the defs of this instruction are dead.
LiveRange * getCachedRegUnit(unsigned Unit)
Return the live range for register unit Unit if it has already been computed, or nullptr if it hasn't...
static constexpr LaneBitmask getLane(unsigned Lane)
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
static cl::opt< unsigned > LateRematUpdateThreshold("late-remat-update-threshold", cl::Hidden, cl::desc("During rematerialization for a copy, if the def instruction has " "many other copy uses to be rematerialized, delay the multiple " "separate live interval update work and do them all at once after " "all those rematerialization are done. It will save a lot of " "repeated work. "), cl::init(100))
VNInfo * valueIn() const
Return the value that is live-in to the instruction.
LiveQueryResult Query(SlotIndex Idx) const
Query Liveness at Idx.
bool containsOneValue() const
TargetInstrInfo - Interface to description of machine instruction set.
iterator find(const_arg_type_t< KeyT > Val)
VNInfo * getVNInfoAt(SlotIndex Idx) const
getVNInfoAt - Return the VNInfo that is live at Idx, or NULL.
static const unsigned CommuteAnyOperandIndex
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
initializer< Ty > init(const Ty &Val)
void array_pod_sort(IteratorTy Start, IteratorTy End)
array_pod_sort - This sorts an array with the specified start and end extent.
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
SubRange * createSubRange(BumpPtrAllocator &Allocator, LaneBitmask LaneMask)
Creates a new empty subregister live range.
unsigned const MachineRegisterInfo * MRI
StringRef getName() const
Return the name of the corresponding LLVM basic block, or an empty string.
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
static int compareMBBPriority(const MBBPriorityInfo *LHS, const MBBPriorityInfo *RHS)
C-style comparator that sorts first based on the loop depth of the basic block (the unsigned)...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
Allocate memory in an ever growing pool, as if by bump-pointer.
void removeInterval(unsigned Reg)
Interval removal.
bool liveAt(SlotIndex index) const
MachineInstrBuilder & UseMI
size_t size() const
size - Get the array size.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
void splitSeparateComponents(LiveInterval &LI, SmallVectorImpl< LiveInterval *> &SplitLIs)
Split separate components in LiveInterval LI into separate intervals.
unsigned composeSubRegIndices(unsigned a, unsigned b) const
Return the subregister index you get from composing two subregister indices.
std::pair< iterator, bool > insert(const ValueT &V)
SlotIndex getIndexBefore(const MachineInstr &MI) const
getIndexBefore - Returns the index of the last indexed instruction before MI, or the start index of i...
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
static void shrinkToUses(LiveInterval &LI, LiveIntervals &LIS)
SlotIndex getMBBStartIdx(unsigned Num) const
Returns the first index in the given basic block number.
Represent the analysis usage information of a pass.
bool shrinkToUses(LiveInterval *li, SmallVectorImpl< MachineInstr *> *dead=nullptr)
After removing some uses of a register, shrink its live range to just the remaining uses...
bool reg_nodbg_empty(Register RegNo) const
reg_nodbg_empty - Return true if the only instructions using or defining Reg are Debug instructions...
bool isRegTiedToDefOperand(unsigned UseOpIdx, unsigned *DefOpIdx=nullptr) const
Return true if the use operand of the specified index is tied to a def operand.
virtual const TargetRegisterClass * getMatchingSuperRegClass(const TargetRegisterClass *A, const TargetRegisterClass *B, unsigned Idx) const
Return a subclass of the specified register class A so that each register in it has a sub-register of...
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
static bool isTerminalReg(unsigned DstReg, const MachineInstr &Copy, const MachineRegisterInfo *MRI)
Check if DstReg is a terminal node.
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
self_iterator getIterator()
LiveInterval & getInterval(Register Reg)
constexpr bool all() const
void join(LiveRange &Other, const int *ValNoAssignments, const int *RHSValNoAssignments, SmallVectorImpl< VNInfo *> &NewVNInfo)
join - Join two live ranges (this, and other) together.
iterator_range< pred_iterator > predecessors()
void runOnMachineFunction(const MachineFunction &MF)
runOnFunction - Prepare to answer questions about MF.
bool isFlipped() const
Return true when getSrcReg is the register being defined by the original copy instruction.
SlotIndex getMBBStartIdx(const MachineBasicBlock *mbb) const
Return the first index in the given basic block.
unsigned getSrcReg() const
Return the virtual register that will be coalesced away.
static MachineOperand CreateReg(Register Reg, bool isDef, bool isImp=false, bool isKill=false, bool isDead=false, bool isUndef=false, bool isEarlyClobber=false, unsigned SubReg=0, bool isDebug=false, bool isInternalRead=false, bool isRenamable=false)
SlotIndex getMBBEndIdx(unsigned Num) const
Returns the last index in the given basic block number.
virtual void updateRegAllocHint(unsigned Reg, unsigned NewReg, MachineFunction &MF) const
A callback to allow target a chance to update register allocation hints when a register is "changed" ...
bool isImplicitDef() const
iterator erase(const_iterator CI)
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
bool isDebugInstr() const
SlotIndex endPoint() const
Return the end point of the last live range segment to interact with the instruction, if any.
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE, "Assign register bank of generic virtual registers", false, false) RegBankSelect
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
bool isConstantPhysReg(unsigned PhysReg) const
Returns true if PhysReg is unallocatable and constant throughout the function.
INITIALIZE_PASS_BEGIN(RegisterCoalescer, "simple-register-coalescing", "Simple Register Coalescing", false, false) INITIALIZE_PASS_END(RegisterCoalescer
static cl::opt< cl::boolOrDefault > EnableGlobalCopies("join-globalcopies", cl::desc("Coalesce copies that span blocks (default=subtarget)"), cl::init(cl::BOU_UNSET), cl::Hidden)
Temporary flag to test global copy optimization.
unsigned getSrcIdx() const
Return the subregister index that SrcReg will be coalesced into, or 0.
void setIsKill(bool Val=true)
void sort(IteratorTy Start, IteratorTy End)
virtual bool isAsCheapAsAMove(const MachineInstr &MI) const
Return true if the instruction is as cheap as a move instruction.
bool readsRegister(Register Reg, const TargetRegisterInfo *TRI=nullptr) const
Return true if the MachineInstr reads the specified register.
Iterator for intrusive lists based on ilist_node.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
virtual bool shouldCoalesce(MachineInstr *MI, const TargetRegisterClass *SrcRC, unsigned SubReg, const TargetRegisterClass *DstRC, unsigned DstSubReg, const TargetRegisterClass *NewRC, LiveIntervals &LIS) const
Subtarget Hooks.
void setDesc(const MCInstrDesc &tid)
Replace the instruction descriptor (thus opcode) of the current instruction with a new one...
auto size(R &&Range, typename std::enable_if< std::is_same< typename std::iterator_traits< decltype(Range.begin())>::iterator_category, std::random_access_iterator_tag >::value, void >::type *=nullptr) -> decltype(std::distance(Range.begin(), Range.end()))
Get the size of a range.
void addOperand(MachineFunction &MF, const MachineOperand &Op)
Add the specified operand to the instruction.
Align max(MaybeAlign Lhs, Align Rhs)
bool erase(PtrType Ptr)
erase - If the set contains the specified pointer, remove it and return true, otherwise return false...
static bool isSameInstr(SlotIndex A, SlotIndex B)
isSameInstr - Return true if A and B refer to the same instruction.
unsigned getDstIdx() const
Return the subregister index that DstReg will be coalesced into, or 0.
iterator_range< use_iterator > use_operands(unsigned Reg) const
simple register coalescing
bool isDebugValue() const
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...
MachineInstrBuilder MachineInstrBuilder & DefMI
LLVM_NODISCARD T pop_back_val()
LaneBitmask getSubRegIndexLaneMask(unsigned SubIdx) const
Return a bitmask representing the parts of a register that are covered by SubIdx. ...
unsigned getNumDefs() const
Return the number of MachineOperands that are register definitions.
void setPreservesCFG()
This function should be called by the pass, iff they do not:
bool recomputeRegClass(unsigned Reg)
recomputeRegClass - Try to find a legal super-class of Reg's register class that still satisfies the ...
unsigned pred_size() const
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
void clearSubRanges()
Removes all subregister liveness information.
LaneBitmask composeSubRegIndexLaneMask(unsigned IdxA, LaneBitmask Mask) const
Transforms a LaneMask computed for one subregister to the lanemask that would have been computed when...
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
VNInfo * getVNInfoBefore(SlotIndex Idx) const
getVNInfoBefore - Return the VNInfo that is live up to but not necessarilly including Idx...
void setDebugLoc(DebugLoc dl)
Replace current source information with new such.
bool isValid() const
isValid - returns true if this iterator is not yet at the end.
VNInfo * valueOutOrDead() const
Returns the value alive at the end of the instruction, if any.
SlotIndex getMBBEndIdx(const MachineBasicBlock *mbb) const
Return the last index in the given basic block.
int findRegisterUseOperandIdx(Register Reg, bool isKill=false, const TargetRegisterInfo *TRI=nullptr) const
Returns the operand index that is a use of the specific register or -1 if it is not found...
bool isUnconditionalBranch(QueryType Type=AnyInBundle) const
Return true if this is a branch which always transfers control flow to some other block...
unsigned succ_size() const
void append(in_iter in_start, in_iter in_end)
Add the specified range to the end of the SmallVector.
SlotIndex getInstructionIndex(const MachineInstr &Instr) const
Returns the base index of the given instruction.
const MachineBasicBlock * getParent() const
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
TargetSubtargetInfo - Generic base class for all target subtargets.
simple register Simple Register false static LLVM_NODISCARD bool isMoveInstr(const TargetRegisterInfo &tri, const MachineInstr *MI, unsigned &Src, unsigned &Dst, unsigned &SrcSub, unsigned &DstSub)
const TargetRegisterClass * getCommonSubClass(const TargetRegisterClass *A, const TargetRegisterClass *B) const
Find the largest common subclass of A and B.
static cl::opt< unsigned > LargeIntervalSizeThreshold("large-interval-size-threshold", cl::Hidden, cl::desc("If the valnos size of an interval is larger than the threshold, " "it is regarded as a large interval. "), cl::init(100))
unsigned getNumValNums() const
Representation of each machine instruction.
static cl::opt< bool > UseTerminalRule("terminal-rule", cl::desc("Apply the terminal rule"), cl::init(false), cl::Hidden)
pointer data()
Return a pointer to the vector's buffer, even if empty().
void splice(iterator Where, MachineBasicBlock *Other, iterator From)
Take an instruction from MBB 'Other' at the position From, and insert it into this MBB right before '...
bool overlaps(const LiveRange &other) const
overlaps - Return true if the intersection of the two live ranges is not empty.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
use_iterator use_begin(unsigned RegNo) const
void assign(const LiveRange &Other, BumpPtrAllocator &Allocator)
Copies values numbers and live segments from Other into this range.
SlotIndex getPrevSlot() const
Returns the previous slot in the index list.
bool isEHPad() const
Returns true if the block is a landing pad.
bool verify(Pass *p=nullptr, const char *Banner=nullptr, bool AbortOnError=true) const
Run the current MachineFunction through the machine code verifier, useful for debugger use...
LLVM_NODISCARD bool empty() const
unsigned getMatchingSuperReg(unsigned Reg, unsigned SubIdx, const TargetRegisterClass *RC) const
Return a super-register of the specified register Reg so its sub-register of index SubIdx is Reg...
virtual bool findCommutedOpIndices(const MachineInstr &MI, unsigned &SrcOpIdx1, unsigned &SrcOpIdx2) const
Returns true iff the routine could find two commutable operands in the given machine instruction...
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
constexpr bool any() const
void setSubReg(unsigned subReg)
size_type count(const_arg_type_t< ValueT > V) const
Return 1 if the specified key is in the set, 0 otherwise.
bool flip()
Swap SrcReg and DstReg.
bool hasOneNonDBGUse(unsigned RegNo) const
hasOneNonDBGUse - Return true if there is exactly one non-Debug use of the specified register...
bool shouldTrackSubRegLiveness(const TargetRegisterClass &RC) const
Returns true if liveness for register class RC should be tracked at the subregister level...
size_type count(const_arg_type_t< KeyT > Val) const
Return 1 if the specified key is in the map, 0 otherwise.
bool isRegTiedToUseOperand(unsigned DefOpIdx, unsigned *UseOpIdx=nullptr) const
Given the index of a register def operand, check if the register def is tied to a source operand...
SlotIndexes * getSlotIndexes() const
bool isReg() const
isReg - Tests if this is a MO_Register operand.
#define LLVM_NODISCARD
LLVM_NODISCARD - Warn if a type or return value is discarded.
const Segment * getSegmentContaining(SlotIndex Idx) const
Return the segment that contains the specified index, or null if there is none.
MachineBasicBlock * intervalIsInOneMBB(const LiveInterval &LI) const
If LI is confined to a single basic block, return a pointer to that block.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool isSafeToMove(AAResults *AA, bool &SawStore) const
Return true if it is safe to move this instruction.
const TargetRegisterClass * getNewRC() const
Return the register class of the coalesced register.
use_instr_nodbg_iterator use_instr_nodbg_begin(unsigned RegNo) const
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
simple register Simple Register Coalescing
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
bool isTriviallyReMaterializable(const MachineInstr &MI, AAResults *AA=nullptr) const
Return true if the instruction is trivially rematerializable, meaning it has no side effects and requ...
This class implements an extremely fast bulk output stream that can only output to a stream...
void setRegClass(unsigned Reg, const TargetRegisterClass *RC)
setRegClass - Set the register class of the specified virtual register.
void RemoveOperand(unsigned OpNo)
Erase an operand from an instruction, leaving it with one fewer operand than it started with...
iterator FindSegmentContaining(SlotIndex Idx)
Return an iterator to the segment that contains the specified index, or end() if there is none...
bool isValid() const
Check if the iterator is at the end of the list.
VNInfo * valueDefined() const
Return the value defined by this instruction, if any.
Register getReg() const
getReg - Returns the register number.
A wrapper pass to provide the legacy pass manager access to a suitably prepared AAResults object...
const MachineOperand & getOperand(unsigned i) const
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...
reg_instr_iterator reg_instr_begin(unsigned RegNo) const
bool isCommutable(QueryType Type=IgnoreBundle) const
Return true if this may be a 2- or 3-address instruction (of the form "X = op Y, Z, ..."), which produces the same result if Y and Z are exchanged.
LiveRange & getRegUnit(unsigned Unit)
Return the live range for register unit Unit.
bool isProperSubClass(const TargetRegisterClass *RC) const
isProperSubClass - Returns true if RC has a legal super-class with more allocatable registers...
Wrapper class representing virtual and physical registers.
static std::pair< bool, bool > addSegmentsWithValNo(LiveRange &Dst, VNInfo *DstValNo, const LiveRange &Src, const VNInfo *SrcValNo)
Copy segments with value number SrcValNo from liverange Src to live range and use value number DstVa...
auto upper_bound(R &&Range, T &&Value) -> decltype(adl_begin(Range))
Provide wrappers to std::upper_bound which take ranges instead of having to pass begin/end explicitly...
void removeVRegDefAt(LiveInterval &LI, SlotIndex Pos)
Remove value number and related live segments of LI and its subranges that start at position Pos...
A single location or constant.