48#include "llvm/Config/llvm-config.h"
68#define DEBUG_TYPE "livedebugvars"
74STATISTIC(NumInsertedDebugValues,
"Number of DBG_VALUEs inserted");
75STATISTIC(NumInsertedDebugLabels,
"Number of DBG_LABELs inserted");
76STATISTIC(NumStaleIndexes,
"Number of stale SlotIndexes repaired");
78 "Number of debug value intervals merged while repairing indexes");
83 "Debug Variable Analysis",
false,
false)
103class DbgVariableValue {
105 DbgVariableValue(ArrayRef<unsigned> NewLocs,
bool WasIndirect,
bool WasList,
106 const DIExpression &Expr)
107 : WasIndirect(WasIndirect), WasList(WasList), Expression(&Expr) {
108 assert(!(WasIndirect && WasList) &&
109 "DBG_VALUE_LISTs should not be indirect.");
110 SmallVector<unsigned> LocNoVec;
111 for (
unsigned LocNo : NewLocs) {
112 auto It =
find(LocNoVec, LocNo);
113 if (It == LocNoVec.
end())
118 unsigned OpIdx = LocNoVec.
size();
119 unsigned DuplicatingIdx = std::distance(LocNoVec.
begin(), It);
130 if (LocNoVec.
size() < 64) {
131 LocNoCount = LocNoVec.
size();
132 if (LocNoCount > 0) {
133 LocNos = std::make_unique<unsigned[]>(LocNoCount);
138 "locations, dropping...\n");
143 DIExpression::get(Expr.
getContext(), {dwarf::DW_OP_LLVM_arg, 0});
146 Expression, FragmentInfoOpt->OffsetInBits,
147 FragmentInfoOpt->SizeInBits);
148 LocNos = std::make_unique<unsigned[]>(LocNoCount);
153 DbgVariableValue() : LocNoCount(0), WasIndirect(
false), WasList(
false) {}
154 DbgVariableValue(
const DbgVariableValue &
Other)
155 : LocNoCount(
Other.LocNoCount), WasIndirect(
Other.getWasIndirect()),
156 WasList(
Other.getWasList()), Expression(
Other.getExpression()) {
157 if (
Other.getLocNoCount()) {
158 LocNos.reset(new unsigned[Other.getLocNoCount()]);
159 std::copy(Other.loc_nos_begin(), Other.loc_nos_end(), loc_nos_begin());
163 DbgVariableValue &operator=(
const DbgVariableValue &
Other) {
166 if (
Other.getLocNoCount()) {
167 LocNos.reset(
new unsigned[
Other.getLocNoCount()]);
168 std::copy(
Other.loc_nos_begin(),
Other.loc_nos_end(), loc_nos_begin());
172 LocNoCount =
Other.getLocNoCount();
173 WasIndirect =
Other.getWasIndirect();
174 WasList =
Other.getWasList();
175 Expression =
Other.getExpression();
179 const DIExpression *getExpression()
const {
return Expression; }
180 uint8_t getLocNoCount()
const {
return LocNoCount; }
181 bool containsLocNo(
unsigned LocNo)
const {
184 bool getWasIndirect()
const {
return WasIndirect; }
185 bool getWasList()
const {
return WasList; }
188 DbgVariableValue decrementLocNosAfterPivot(
unsigned Pivot)
const {
189 SmallVector<unsigned, 4> NewLocNos;
190 for (
unsigned LocNo : loc_nos())
193 return DbgVariableValue(NewLocNos, WasIndirect, WasList, *Expression);
196 DbgVariableValue remapLocNos(ArrayRef<unsigned> LocNoMap)
const {
197 SmallVector<unsigned> NewLocNos;
198 for (
unsigned LocNo : loc_nos())
202 return DbgVariableValue(NewLocNos, WasIndirect, WasList, *Expression);
205 DbgVariableValue changeLocNo(
unsigned OldLocNo,
unsigned NewLocNo)
const {
206 SmallVector<unsigned> NewLocNos;
207 NewLocNos.
assign(loc_nos_begin(), loc_nos_end());
208 auto OldLocIt =
find(NewLocNos, OldLocNo);
209 assert(OldLocIt != NewLocNos.
end() &&
"Old location must be present.");
210 *OldLocIt = NewLocNo;
211 return DbgVariableValue(NewLocNos, WasIndirect, WasList, *Expression);
214 bool hasLocNoGreaterThan(
unsigned LocNo)
const {
216 [LocNo](
unsigned ThisLocNo) {
return ThisLocNo > LocNo; });
219 void printLocNos(llvm::raw_ostream &OS)
const {
220 for (
const unsigned &Loc : loc_nos())
221 OS << (&Loc == loc_nos_begin() ?
" " :
", ") << Loc;
225 const DbgVariableValue &
RHS) {
226 if (std::tie(
LHS.LocNoCount,
LHS.WasIndirect,
LHS.WasList,
228 std::tie(
RHS.LocNoCount,
RHS.WasIndirect,
RHS.WasList,
RHS.Expression))
230 return std::equal(
LHS.loc_nos_begin(),
LHS.loc_nos_end(),
231 RHS.loc_nos_begin());
235 const DbgVariableValue &
RHS) {
239 unsigned *loc_nos_begin() {
return LocNos.get(); }
240 const unsigned *loc_nos_begin()
const {
return LocNos.get(); }
241 unsigned *loc_nos_end() {
return LocNos.get() + LocNoCount; }
242 const unsigned *loc_nos_end()
const {
return LocNos.get() + LocNoCount; }
243 ArrayRef<unsigned> loc_nos()
const {
244 return ArrayRef<unsigned>(LocNos.get(), LocNoCount);
253 std::unique_ptr<unsigned[]> LocNos;
254 uint8_t LocNoCount : 6;
255 bool WasIndirect : 1;
257 const DIExpression *Expression =
nullptr;
296 using LDVImpl = LiveDebugVariables::LDVImpl;
300 const std::optional<DIExpression::FragmentInfo>
Fragment;
304 UserValue *next =
nullptr;
307 SmallVector<MachineOperand, 4> locations;
314 SmallSet<SlotIndex, 2> trimmedDefs;
317 void insertDebugValue(MachineBasicBlock *
MBB, SlotIndex StartIdx,
318 SlotIndex StopIdx, DbgVariableValue DbgValue,
320 ArrayRef<unsigned> SpillOffsets, LiveIntervals &LIS,
321 const TargetInstrInfo &
TII,
322 const TargetRegisterInfo &
TRI, InsertLocCache &Cache);
331 UserValue(
const DILocalVariable *var,
338 UserValue *getLeader() {
339 UserValue *
l = leader;
340 while (l !=
l->leader)
346 UserValue *getNext()
const {
return next; }
349 static UserValue *
merge(UserValue *L1, UserValue *L2) {
350 L2 = L2->getLeader();
353 L1 = L1->getLeader();
363 End->next = L1->next;
374 unsigned getLocationNo(
const MachineOperand &LocMO) {
379 for (
unsigned i = 0, e = locations.
size(); i != e; ++i)
380 if (locations[i].
isReg() &&
382 locations[i].getSubReg() == LocMO.
getSubReg())
385 for (
unsigned i = 0, e = locations.
size(); i != e; ++i)
390 locations.
back().clearParent();
392 if (locations.
back().isReg()) {
393 if (locations.
back().isDef())
394 locations.
back().setIsDead(
false);
395 locations.
back().setIsUse();
397 return locations.
size() - 1;
402 void removeLocationIfUnused(
unsigned LocNo) {
405 const DbgVariableValue &DbgValue =
I.value();
406 if (DbgValue.containsLocNo(LocNo))
413 const DbgVariableValue &DbgValue =
I.value();
414 if (DbgValue.hasLocNoGreaterThan(LocNo))
415 I.setValueUnchecked(DbgValue.decrementLocNosAfterPivot(LocNo));
420 void mapVirtRegs(LDVImpl *LDV);
424 bool IsList,
const DIExpression &Expr) {
425 SmallVector<unsigned> Locs;
426 for (
const MachineOperand &
Op : LocMOs)
428 DbgVariableValue DbgValue(Locs, IsIndirect, IsList, Expr);
431 if (!
I.valid() ||
I.start() != Idx)
432 I.insert(Idx,
Idx.getNextSlot(), std::move(DbgValue));
435 I.setValue(std::move(DbgValue));
454 extendDef(SlotIndex Idx, DbgVariableValue DbgValue,
455 SmallDenseMap<
unsigned, std::pair<LiveRange *, const VNInfo *>>
457 std::optional<std::pair<SlotIndex, SmallVector<unsigned>>> &Kills,
469 void addDefsFromCopies(
470 DbgVariableValue DbgValue,
471 SmallVectorImpl<std::pair<unsigned, LiveInterval *>> &LocIntervals,
473 SmallVectorImpl<std::pair<SlotIndex, DbgVariableValue>> &NewDefs,
474 MachineRegisterInfo &MRI, LiveIntervals &LIS);
478 void computeIntervals(MachineRegisterInfo &MRI,
const TargetRegisterInfo &
TRI,
479 LiveIntervals &LIS, LexicalScopes &LS);
487 void canonicalizeIndexes(
const SlotIndexes &SI);
493 const TargetInstrInfo &
TII,
494 const TargetRegisterInfo &
TRI,
498 void emitDebugValues(VirtRegMap *VRM, LiveIntervals &LIS,
499 const TargetInstrInfo &
TII,
500 const TargetRegisterInfo &
TRI,
502 InsertLocCache &Cache);
507 void print(raw_ostream &,
const TargetRegisterInfo *);
512 const DILabel *
Label;
518 void insertDebugLabel(MachineBasicBlock *
MBB, SlotIndex Idx,
519 LiveIntervals &LIS,
const TargetInstrInfo &
TII,
520 InsertLocCache &Cache);
524 UserLabel(
const DILabel *label,
DebugLoc L, SlotIndex Idx)
528 bool matches(
const DILabel *L,
const DILocation *IA,
529 const SlotIndex Index)
const {
530 return Label ==
L && dl->getInlinedAt() ==
IA && loc ==
Index;
534 void emitDebugLabel(LiveIntervals &LIS,
const TargetInstrInfo &
TII,
535 InsertLocCache &Cache);
538 bool canonicalizeIndex(
const SlotIndexes &SI) {
539 bool WasStale =
SI.isStaleIndex(loc);
540 loc =
SI.canonicalizeIndex(loc);
542 "Canonicalized label still refers to an erased instruction");
549 void print(raw_ostream &,
const TargetRegisterInfo *);
570 std::map<unsigned, PHIValPos> PHIValToPos;
589 bool EmitDone =
false;
592 bool ModifiedMF =
false;
602 VRMap virtRegToEqClass;
610 std::optional<DIExpression::FragmentInfo>
Fragment,
614 UserValue *lookupVirtReg(
Register VirtReg);
657 void computeIntervals();
669 StashedDebugInstrs.clear();
672 virtRegToEqClass.clear();
675 assert((!ModifiedMF || EmitDone) &&
676 "Dbg values are not emitted in LDV");
715 CommentOS << Scope->getFilename();
716 CommentOS <<
':' <<
DL.getLine();
717 if (
DL.getCol() != 0)
718 CommentOS <<
':' <<
DL.getCol();
743 OS << Res <<
"," << Line;
744 auto *InlinedAt =
DL ?
DL->getInlinedAt() :
nullptr;
746 if (
DebugLoc InlinedAtDL = InlinedAt) {
759 for (LocMap::const_iterator
I = locInts.
begin();
I.valid(); ++
I) {
760 OS <<
" [" <<
I.start() <<
';' <<
I.stop() <<
"):";
761 if (
I.value().isUndef())
764 I.value().printLocNos(OS);
765 if (
I.value().getWasIndirect())
767 else if (
I.value().getWasList())
771 for (
unsigned i = 0, e = locations.
size(); i != e; ++i) {
772 OS <<
" Loc" << i <<
'=';
773 locations[i].print(OS,
TRI);
788 OS <<
"********** DEBUG VARIABLES **********\n";
789 for (
auto &userValue : userValues)
790 userValue->print(OS, TRI);
791 OS <<
"********** DEBUG LABELS **********\n";
792 for (
auto &userLabel : userLabels)
793 userLabel->print(OS, TRI);
798 if (MO.isReg() && MO.getReg().isVirtual())
802UserValue *LiveDebugVariables::LDVImpl::getUserValue(
808 UserValue *&UV = userVarMap[ID];
810 userValues.push_back(
812 UV = userValues.back().get();
819 UserValue *&Leader = virtRegToEqClass[VirtReg];
820 Leader = UserValue::merge(Leader, EC);
823UserValue *LiveDebugVariables::LDVImpl::lookupVirtReg(
Register VirtReg) {
824 if (UserValue *UV = virtRegToEqClass.lookup(VirtReg))
825 return UV->getLeader();
829bool LiveDebugVariables::LDVImpl::handleDebugValue(
MachineInstr &
MI,
833 if (!
MI.isDebugValue()) {
837 if (!
MI.getDebugVariableOp().isMetadata()) {
838 LLVM_DEBUG(
dbgs() <<
"Can't handle DBG_VALUE* with invalid variable: "
842 if (
MI.isNonListDebugValue() &&
843 (
MI.getNumOperands() != 4 ||
844 !(
MI.getDebugOffset().isImm() ||
MI.getDebugOffset().isReg()))) {
853 bool Discard =
false;
854 for (
const MachineOperand &
Op :
MI.debug_operands()) {
855 if (
Op.isReg() &&
Op.getReg().isVirtual()) {
857 if (!LIS->hasInterval(
Reg)) {
861 LLVM_DEBUG(
dbgs() <<
"Discarding debug info (no LIS interval): " << Idx
867 const LiveInterval &LI = LIS->getInterval(
Reg);
868 LiveQueryResult LRQ = LI.
Query(Idx);
873 LLVM_DEBUG(
dbgs() <<
"Discarding debug info (reg not live): " << Idx
881 bool IsIndirect =
MI.isDebugOffsetImm();
883 assert(
MI.getDebugOffset().getImm() == 0 &&
884 "DBG_VALUE with nonzero offset");
885 bool IsList =
MI.isDebugValueList();
886 const DILocalVariable *Var =
MI.getDebugVariable();
887 const DIExpression *Expr =
MI.getDebugExpression();
892 MI.debug_operands().end()),
893 IsIndirect, IsList, *Expr);
900 SmallVector<MachineOperand, 4> UndefMOs(
MI.getNumDebugOperands(), MO);
901 UV->addDef(Idx, UndefMOs,
false, IsList, *Expr);
907LiveDebugVariables::LDVImpl::handleDebugInstr(MachineInstr &
MI, SlotIndex Idx) {
908 assert(
MI.isDebugValueLike() ||
MI.isDebugPHI());
912 if (
MI.isDebugValueLike())
914 [](
const MachineOperand &MO) {
915 return MO.isReg() && MO.getReg().isVirtual();
917 "MIs should not refer to Virtual Registers in InstrRef mode.");
920 auto NextInst = std::next(
MI.getIterator());
922 MI.removeFromParent();
927bool LiveDebugVariables::LDVImpl::handleDebugLabel(MachineInstr &
MI,
930 if (
MI.getNumOperands() != 1 || !
MI.getOperand(0).isMetadata()) {
936 const DILabel *
Label =
MI.getDebugLabel();
939 for (
auto const &L : userLabels) {
940 if (
L->matches(Label,
DL->getInlinedAt(), Idx)) {
946 userLabels.
push_back(std::make_unique<UserLabel>(Label,
DL, Idx));
951bool LiveDebugVariables::LDVImpl::collectDebugValues(
MachineFunction &mf,
954 for (MachineBasicBlock &
MBB : mf) {
959 if (!
MBBI->isDebugOrPseudoInstr()) {
967 ? LIS->getMBBStartIdx(&
MBB)
968 : LIS->getInstructionIndex(*std::prev(
MBBI)).getRegSlot();
974 if (InstrRef && (
MBBI->isNonListDebugValue() ||
MBBI->isDebugPHI() ||
975 MBBI->isDebugRef())) {
976 MBBI = handleDebugInstr(*
MBBI, Idx);
980 }
else if ((
MBBI->isDebugValue() && handleDebugValue(*
MBBI, Idx)) ||
981 (
MBBI->isDebugLabel() && handleDebugLabel(*
MBBI, Idx))) {
986 }
while (
MBBI != MBBE &&
MBBI->isDebugOrPseudoInstr());
992void UserValue::extendDef(
993 SlotIndex Idx, DbgVariableValue DbgValue,
994 SmallDenseMap<
unsigned, std::pair<LiveRange *, const VNInfo *>>
996 std::optional<std::pair<SlotIndex, SmallVector<unsigned>>> &Kills,
997 LiveIntervals &LIS) {
1001 LocMap::iterator
I = locInts.
find(Start);
1004 for (
auto &LII : LiveIntervalInfo) {
1006 assert(LR && LII.second.second &&
"Missing range info for Idx.");
1008 assert(Segment && Segment->
valno == LII.second.second &&
1009 "Invalid VNInfo for Idx given?");
1010 if (Segment->
end < Stop) {
1011 Stop = Segment->
end;
1012 Kills = {Stop, {LII.first}};
1013 }
else if (Segment->
end == Stop && Kills) {
1016 Kills->second.push_back(LII.first);
1021 if (
I.valid() &&
I.start() <= Start) {
1024 if (
I.value() != DbgValue ||
I.stop() != Start) {
1026 Kills = std::nullopt;
1034 if (
I.valid() &&
I.start() < Stop) {
1037 Kills = std::nullopt;
1041 DbgVariableValue ExtDbgValue(DbgValue);
1042 I.insert(Start, Stop, std::move(ExtDbgValue));
1046void UserValue::addDefsFromCopies(
1047 DbgVariableValue DbgValue,
1048 SmallVectorImpl<std::pair<unsigned, LiveInterval *>> &LocIntervals,
1050 SmallVectorImpl<std::pair<SlotIndex, DbgVariableValue>> &NewDefs,
1051 MachineRegisterInfo &MRI, LiveIntervals &LIS) {
1054 [](
auto LocI) {
return !LocI.second->reg().isVirtual(); }))
1058 SmallDenseMap<unsigned,
1061 for (
auto &LocInterval : LocIntervals) {
1062 unsigned LocNo = LocInterval.first;
1063 LiveInterval *LI = LocInterval.second;
1069 Register DstReg =
MI->getOperand(0).getReg();
1081 LocMap::iterator
I = locInts.
find(
Idx.getRegSlot(
true));
1082 if (!
I.valid() ||
I.value() != DbgValue)
1089 assert(DstVNI && DstVNI->
def ==
Idx.getRegSlot() &&
"Bad copy value");
1090 CopyValues[LocNo].push_back(std::make_pair(DstLI, DstVNI));
1094 if (CopyValues.
empty())
1098 for (
auto &LocInterval : LocIntervals)
1099 LLVM_DEBUG(
dbgs() <<
"Got " << CopyValues[LocInterval.first].size()
1100 <<
" copies of " << *LocInterval.second <<
'\n');
1105 LocMap::iterator
I = locInts.
find(KilledAt);
1106 if (
I.valid() &&
I.start() <= KilledAt)
1108 DbgVariableValue NewValue(DbgValue);
1109 for (
auto &LocInterval : LocIntervals) {
1110 unsigned LocNo = LocInterval.first;
1111 bool FoundCopy =
false;
1112 for (
auto &LIAndVNI : CopyValues[LocNo]) {
1113 LiveInterval *DstLI = LIAndVNI.first;
1114 const VNInfo *DstVNI = LIAndVNI.second;
1117 LLVM_DEBUG(
dbgs() <<
"Kill at " << KilledAt <<
" covered by valno #"
1118 << DstVNI->
id <<
" in " << *DstLI <<
'\n');
1120 assert(CopyMI && CopyMI->
isCopy() &&
"Bad copy value");
1121 unsigned NewLocNo = getLocationNo(CopyMI->
getOperand(0));
1122 NewValue = NewValue.changeLocNo(LocNo, NewLocNo);
1132 NewDefs.push_back(std::make_pair(KilledAt, NewValue));
1135void UserValue::computeIntervals(MachineRegisterInfo &MRI,
1136 const TargetRegisterInfo &
TRI,
1137 LiveIntervals &LIS, LexicalScopes &LS) {
1141 for (LocMap::const_iterator
I = locInts.
begin();
I.valid(); ++
I)
1142 if (!
I.value().isUndef())
1143 Defs.
push_back(std::make_pair(
I.start(),
I.value()));
1146 for (
unsigned i = 0; i != Defs.
size(); ++i) {
1147 SlotIndex
Idx = Defs[i].first;
1148 DbgVariableValue DbgValue = Defs[i].second;
1149 SmallDenseMap<unsigned, std::pair<LiveRange *, const VNInfo *>> LIs;
1150 bool ShouldExtendDef =
false;
1151 for (
unsigned LocNo : DbgValue.loc_nos()) {
1152 const MachineOperand &LocMO = locations[LocNo];
1154 ShouldExtendDef |= !LocMO.
isReg();
1157 ShouldExtendDef =
true;
1158 LiveInterval *LI =
nullptr;
1159 const VNInfo *VNI =
nullptr;
1165 LIs[LocNo] = {LI, VNI};
1167 if (ShouldExtendDef) {
1168 std::optional<std::pair<SlotIndex, SmallVector<unsigned>>> Kills;
1169 extendDef(Idx, DbgValue, LIs, Kills, LIS);
1173 bool AnySubreg =
false;
1174 for (
unsigned LocNo : Kills->second) {
1175 const MachineOperand &LocMO = this->locations[LocNo];
1181 KilledLocIntervals.
push_back({LocNo, LI});
1193 addDefsFromCopies(DbgValue, KilledLocIntervals, Kills->first, Defs,
1216 LexicalScope *
Scope =
LS.findLexicalScope(dl);
1221 LocMap::iterator
I = locInts.
begin();
1233 if (
Range.first ==
Range.first->getParent()->begin())
1238 if (PrevEnd &&
I.start() < PrevEnd) {
1239 SlotIndex IStop =
I.stop();
1240 DbgVariableValue DbgValue =
I.value();
1244 I.setStopUnchecked(PrevEnd);
1251 I.insert(RStart, IStop, DbgValue);
1255 I.advanceTo(RStart);
1259 if (
I.start() < RStart) {
1261 I.setStartUnchecked(RStart);
1263 trimmedDefs.
insert(RStart);
1280 if (PrevEnd &&
I.start() < PrevEnd)
1281 I.setStopUnchecked(PrevEnd);
1284void LiveDebugVariables::LDVImpl::computeIntervals() {
1286 LS.scanFunction(*MF);
1288 for (
const auto &UV : userValues) {
1289 UV->computeIntervals(MF->getRegInfo(), *
TRI, *LIS, LS);
1290 UV->mapVirtRegs(
this);
1299 LLVM_DEBUG(
dbgs() <<
"********** COMPUTING LIVE DEBUG VARIABLES: "
1300 << mf.
getName() <<
" **********\n");
1302 bool Changed = collectDebugValues(mf, InstrRef);
1309 for (
const auto &PHIIt : MF->DebugPHIPositions) {
1313 unsigned SubReg = Position.SubReg;
1315 PHIValPos VP = {
SI, Reg, SubReg};
1316 PHIValToPos.insert(std::make_pair(PHIIt.first, VP));
1317 RegToPHIIdx[Reg].push_back(PHIIt.first);
1327 if (
MI.isDebugInstr())
1336 Impl = std::make_unique<LiveDebugVariables>();
1337 Impl->analyze(mf, LIS);
1350 LDV.analyze(MF, LIS);
1369 MachineFunctionAnalysisManager::Invalidator &) {
1374 return !PAC.preservedWhenStateless();
1385 PImpl.reset(
new LDVImpl(LIS));
1390 PImpl->runOnMachineFunction(MF, InstrRef);
1401 dbgs() <<
"Splitting Loc" << OldLocNo <<
'\t';
1404 bool DidChange =
false;
1405 LocMap::iterator LocMapI;
1406 LocMapI.setMap(locInts);
1417 if (!LocMapI.valid())
1421 while (LocMapI.valid() && LII != LIE) {
1423 LII = LI->
advanceTo(LII, LocMapI.start());
1428 if (LocMapI.value().containsLocNo(OldLocNo) &&
1429 LII->start < LocMapI.stop()) {
1433 MO.
setSubReg(locations[OldLocNo].getSubReg());
1434 NewLocNo = getLocationNo(MO);
1438 SlotIndex LStart = LocMapI.start();
1439 SlotIndex LStop = LocMapI.stop();
1440 DbgVariableValue OldDbgValue = LocMapI.value();
1443 if (LStart < LII->start)
1444 LocMapI.setStartUnchecked(LII->start);
1445 if (LStop > LII->end)
1446 LocMapI.setStopUnchecked(LII->end);
1449 LocMapI.setValue(OldDbgValue.changeLocNo(OldLocNo, NewLocNo));
1452 if (LStart < LocMapI.start()) {
1453 LocMapI.insert(LStart, LocMapI.start(), OldDbgValue);
1455 assert(LocMapI.valid() &&
"Unexpected coalescing");
1457 if (LStop > LocMapI.stop()) {
1459 LocMapI.insert(LII->end, LStop, OldDbgValue);
1465 if (LII->end < LocMapI.stop()) {
1468 LocMapI.advanceTo(LII->start);
1471 if (!LocMapI.valid())
1473 LII = LI->
advanceTo(LII, LocMapI.start());
1488 removeLocationIfUnused(OldLocNo);
1491 dbgs() <<
"Split result: \t";
1499 LiveIntervals &LIS) {
1500 bool DidChange =
false;
1503 for (
unsigned i = locations.size(); i ; --i) {
1504 unsigned LocNo = i-1;
1505 const MachineOperand *Loc = &locations[LocNo];
1508 DidChange |= splitLocation(LocNo, NewRegs, LIS);
1515 auto RegIt = RegToPHIIdx.find(OldReg);
1516 if (RegIt == RegToPHIIdx.end())
1519 std::vector<std::pair<Register, unsigned>> NewRegIdxes;
1521 for (
unsigned InstrID : RegIt->second) {
1522 auto PHIIt = PHIValToPos.find(InstrID);
1523 assert(PHIIt != PHIValToPos.end());
1524 const SlotIndex &Slot = PHIIt->second.SI;
1525 assert(OldReg == PHIIt->second.Reg);
1528 for (
auto NewReg : NewRegs) {
1530 auto LII = LI.
find(Slot);
1531 if (LII != LI.
end() && LII->start <= Slot) {
1533 NewRegIdxes.push_back(std::make_pair(NewReg, InstrID));
1535 PHIIt->second.Reg = NewReg;
1547 RegToPHIIdx.erase(RegIt);
1548 for (
auto &RegAndInstr : NewRegIdxes)
1549 RegToPHIIdx[RegAndInstr.first].push_back(RegAndInstr.second);
1559 bool DidChange =
false;
1560 for (UserValue *UV = lookupVirtReg(OldReg); UV; UV = UV->getNext())
1561 DidChange |= UV->splitRegister(OldReg, NewRegs, *LIS);
1567 UserValue *UV = lookupVirtReg(OldReg);
1575 PImpl->splitRegister(OldReg, NewRegs);
1583 unsigned NumStale = 0;
1584 for (LocMap::const_iterator
I = locInts.
begin();
I.valid(); ++
I)
1585 NumStale +=
SI.isStaleIndex(
I.start()) +
SI.isStaleIndex(
I.stop());
1587 NumStale +=
SI.isStaleIndex(Idx);
1588 NumStaleIndexes += NumStale;
1594 if (!trimmedDefs.empty()) {
1596 trimmedDefs.clear();
1599 if (!
SI.isBlockBoundaryIndex(Canon))
1600 trimmedDefs.insert(Canon);
1607 struct CanonicalInterval {
1610 DbgVariableValue
Value;
1614 for (LocMap::const_iterator
I = locInts.
begin();
I.valid(); ++
I) {
1615 SlotIndex
Start =
SI.canonicalizeIndex(
I.start());
1616 SlotIndex Stop =
SI.canonicalizeIndex(
I.stop());
1623 if (!Intervals.
empty()) {
1624 CanonicalInterval &Prev = Intervals.
back();
1625 if (Start <= Prev.Start) {
1628 Prev.Stop = std::max(Prev.Stop, Stop);
1629 Prev.Value =
I.value();
1630 ++NumMergedIntervals;
1633 Prev.Stop = std::min(Prev.Stop, Start);
1641 for (CanonicalInterval &
Interval : Intervals) {
1646 "No room left for a canonicalized interval");
1650 for (
const CanonicalInterval &
Interval : Intervals)
1655 for (LocMap::const_iterator
I = locInts.
begin();
I.valid(); ++
I)
1656 assert(!
SI.isStaleIndex(
I.start()) && !
SI.isStaleIndex(
I.stop()) &&
1657 "Canonicalized interval still refers to an erased instruction");
1658 for (SlotIndex Idx : trimmedDefs)
1660 "Canonicalized trimmed def still refers to an erased instruction");
1665 for (
auto &userValue : userValues)
1666 userValue->canonicalizeIndexes(
SI);
1667 for (
auto &userLabel : userLabels)
1668 NumStaleIndexes += userLabel->canonicalizeIndex(
SI);
1674 for (InstrPos &Stashed : StashedDebugInstrs) {
1675 if (!
SI.isStaleIndex(Stashed.Idx))
1678 Stashed.Idx =
SI.canonicalizeIndex(Stashed.Idx);
1679 assert(!
SI.isStaleIndex(Stashed.Idx) &&
1680 "Canonicalized debug instr still refers to an erased instruction");
1686 for (
const auto &
P : PHIValToPos)
1688 "PHI position refers to an erased instruction");
1694 PImpl->canonicalizeIndexes(
SI);
1711 for (
unsigned I = 0, E = locations.size();
I != E; ++
I) {
1712 bool Spilled =
false;
1713 unsigned SpillOffset = 0;
1716 if (
Loc.isReg() &&
Loc.getReg() &&
Loc.getReg().isVirtual()) {
1728 bool Success =
TII.getStackSlotRange(TRC,
Loc.getSubReg(), SpillSize,
1744 auto InsertResult = NewLocations.
insert({Loc, {Spilled, SpillOffset}});
1745 unsigned NewLocNo = std::distance(NewLocations.
begin(), InsertResult.first);
1746 LocNoMap[
I] = NewLocNo;
1751 SpillOffsets.
clear();
1752 for (
auto &Pair : NewLocations) {
1754 unsigned SpillOffset;
1755 std::tie(Spilled, SpillOffset) = Pair.second;
1756 locations.push_back(Pair.first);
1758 unsigned NewLocNo = std::distance(&*NewLocations.begin(), &Pair);
1759 SpillOffsets[NewLocNo] = SpillOffset;
1767 for (LocMap::iterator
I = locInts.
begin();
I.valid(); ++
I) {
1768 I.setValueUnchecked(
I.value().remapLocNos(LocNoMap));
1769 I.setStart(
I.start());
1779 Idx = Idx.getBaseIndex();
1801 auto MapIt = Cache.BlockStart.find(
MBB);
1802 if (MapIt == Cache.BlockStart.end())
1803 BeginIt =
MBB->begin();
1805 BeginIt = std::next(MapIt->second);
1806 auto I =
MBB->SkipPHIsLabelsAndDebug(BeginIt);
1808 Cache.BlockStart[
MBB] = std::prev(
I);
1811 Idx = Idx.getPrevIndex();
1815 if (
MI->isTerminator())
1816 return MBB->getFirstTerminator();
1822 if (
auto CacheIt = Cache.AfterInstr.find(
MI);
1823 CacheIt != Cache.AfterInstr.end())
1824 Prev = CacheIt->second;
1825 auto BeginIt = std::next(Prev);
1828 Cache.AfterInstr[
MI] = std::prev(
I);
1843 return MBB->instr_end();
1846 while (
I !=
MBB->end() && !
I->isTerminator()) {
1851 return I->definesRegister(
Reg, &
TRI);
1854 return std::next(
I);
1860void UserValue::insertDebugValue(MachineBasicBlock *
MBB, SlotIndex StartIdx,
1861 SlotIndex StopIdx, DbgVariableValue DbgValue,
1863 ArrayRef<unsigned> SpillOffsets,
1864 LiveIntervals &LIS,
const TargetInstrInfo &
TII,
1865 const TargetRegisterInfo &
TRI,
1866 InsertLocCache &Cache) {
1869 StopIdx = (MBBEndIdx < StopIdx) ? MBBEndIdx : StopIdx;
1874 if (DbgValue.isUndef()) {
1875 MOs.
assign(DbgValue.loc_nos().size(),
1882 for (
unsigned LocNo : DbgValue.loc_nos())
1886 ++NumInsertedDebugValues;
1890 "Expected inlined-at fields to agree");
1896 const DIExpression *Expr = DbgValue.getExpression();
1897 bool IsIndirect = DbgValue.getWasIndirect();
1898 bool IsList = DbgValue.getWasList();
1899 for (
unsigned I = 0,
E = LocSpills.
size();
I !=
E; ++
I) {
1908 SmallVector<uint64_t, 4>
Ops;
1910 Ops.push_back(dwarf::DW_OP_deref);
1915 assert((!LocSpills[
I] || MOs[
I].isFI()) &&
1916 "a spilled location must be a frame index");
1919 unsigned DbgValueOpcode =
1920 IsList ? TargetOpcode::DBG_VALUE_LIST : TargetOpcode::DBG_VALUE;
1931void UserLabel::insertDebugLabel(MachineBasicBlock *
MBB, SlotIndex Idx,
1932 LiveIntervals &LIS,
const TargetInstrInfo &
TII,
1933 InsertLocCache &Cache) {
1935 ++NumInsertedDebugLabels;
1940void UserValue::emitDebugValues(VirtRegMap *VRM, LiveIntervals &LIS,
1941 const TargetInstrInfo &
TII,
1942 const TargetRegisterInfo &
TRI,
1944 InsertLocCache &Cache) {
1947 for (LocMap::const_iterator
I = locInts.
begin();
I.valid();) {
1948 SlotIndex
Start =
I.start();
1949 SlotIndex Stop =
I.stop();
1950 DbgVariableValue DbgValue =
I.value();
1952 SmallVector<bool> SpilledLocs;
1953 SmallVector<unsigned> LocSpillOffsets;
1954 for (
unsigned LocNo : DbgValue.loc_nos()) {
1956 !DbgValue.isUndef() ? SpillOffsets.
find(LocNo) : SpillOffsets.
end();
1957 bool Spilled = SpillIt != SpillOffsets.
end();
1959 LocSpillOffsets.
push_back(Spilled ? SpillIt->second : 0);
1965 if (trimmedDefs.count(Start))
1969 DbgValue.printLocNos(dbg));
1974 insertDebugValue(&*
MBB, Start, Stop, DbgValue, SpilledLocs, LocSpillOffsets,
1978 while (Stop > MBBEnd) {
1985 insertDebugValue(&*
MBB, Start, Stop, DbgValue, SpilledLocs,
1986 LocSpillOffsets, LIS,
TII,
TRI, Cache);
1996void UserLabel::emitDebugLabel(LiveIntervals &LIS,
const TargetInstrInfo &
TII,
1997 InsertLocCache &Cache) {
2002 insertDebugLabel(&*
MBB, loc, LIS,
TII, Cache);
2008 LLVM_DEBUG(
dbgs() <<
"********** EMITTING LIVE DEBUG VARIABLES **********\n");
2018 for (
auto &userValue : userValues) {
2020 userValue->rewriteLocations(*VRM, *MF, *
TII, *TRI, SpillOffsets);
2021 userValue->emitDebugValues(VRM, *LIS, *
TII, *TRI, SpillOffsets, Cache);
2023 LLVM_DEBUG(
dbgs() <<
"********** EMITTING LIVE DEBUG LABELS **********\n");
2024 for (
auto &userLabel : userLabels) {
2026 userLabel->emitDebugLabel(*LIS, *
TII, Cache);
2029 LLVM_DEBUG(
dbgs() <<
"********** EMITTING DEBUG PHIS **********\n");
2031 auto Slots = LIS->getSlotIndexes();
2032 for (
auto &It : PHIValToPos) {
2035 unsigned InstNum = It.first;
2036 auto Slot = It.second.SI;
2038 unsigned SubReg = It.second.SubReg;
2042 unsigned PhysReg = VRM->
getPhys(Reg);
2044 PhysReg = TRI->getSubReg(PhysReg, SubReg);
2047 TII->get(TargetOpcode::DBG_PHI));
2048 Builder.addReg(PhysReg);
2049 Builder.addImm(InstNum);
2053 unsigned SpillSize, SpillOffset;
2055 unsigned regSizeInBits = TRI->getRegSizeInBits(*TRC);
2057 regSizeInBits = TRI->getSubRegIdxSize(SubReg);
2063 TII->getStackSlotRange(TRC, SubReg, SpillSize, SpillOffset, *MF);
2065 if (
Success && SpillOffset == 0) {
2067 TII->get(TargetOpcode::DBG_PHI));
2069 Builder.addImm(InstNum);
2073 Builder.addImm(regSizeInBits);
2078 <<
" has nonzero offset\n";
2084 MF->DebugPHIPositions.clear();
2086 LLVM_DEBUG(
dbgs() <<
"********** EMITTING INSTR REFERENCES **********\n");
2094 for (
auto *StashIt = StashedDebugInstrs.begin();
2095 StashIt != StashedDebugInstrs.end(); ++StashIt) {
2100 auto EmitInstsHere = [
this, &StashIt,
MBB, Idx,
2103 MBB->insert(InsertPos,
MI);
2107 auto NextItem = std::next(StashIt);
2108 while (NextItem != StashedDebugInstrs.end() && NextItem->Idx == Idx) {
2109 assert(NextItem->MBB ==
MBB &&
"Instrs with same slot index should be"
2110 "in the same block");
2111 MBB->insert(InsertPos, NextItem->MI);
2113 NextItem = std::next(StashIt);
2119 if (Idx == Slots->getMBBStartIdx(
MBB)) {
2122 EmitInstsHere(InsertPos);
2126 if (
MachineInstr *Pos = Slots->getInstructionFromIndex(Idx)) {
2130 EmitInstsHere(PostDebug);
2135 for (; Idx <
End; Idx = Slots->getNextNonNullIndex(Idx)) {
2136 Pos = Slots->getInstructionFromIndex(Idx);
2138 EmitInstsHere(Pos->getIterator());
2147 auto TermIt =
MBB->getFirstTerminator();
2148 EmitInstsHere(TermIt);
2159 PImpl->emitDebugValues(VRM);
2162#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
MachineBasicBlock MachineBasicBlock::iterator MBBI
Function Alias Analysis false
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
This file defines the DenseMap class.
This file contains constants used for implementing Dwarf debug support.
const HexagonInstrInfo * TII
This file implements a coalescing interval map for small objects.
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
static void printExtendedName(raw_ostream &OS, const DINode *Node, const DILocation *DL)
static MachineBasicBlock::iterator findNextInsertLocation(MachineBasicBlock *MBB, MachineBasicBlock::iterator I, SlotIndex StopIdx, ArrayRef< MachineOperand > LocMOs, LiveIntervals &LIS, const TargetRegisterInfo &TRI)
Find an iterator for inserting the next DBG_VALUE instruction (or end if no more insert locations fou...
IntervalMap< SlotIndex, DbgVariableValue, 4 > LocMap
Map of where a user value is live to that value.
static MachineBasicBlock::iterator findInsertLocation(MachineBasicBlock *MBB, SlotIndex Idx, LiveIntervals &LIS, InsertLocCache &Cache)
Find an iterator for inserting a DBG_VALUE instruction.
static cl::opt< bool > EnableLDV("live-debug-variables", cl::init(true), cl::desc("Enable the live debug variables pass"), cl::Hidden)
static void printDebugLoc(const DebugLoc &DL, raw_ostream &CommentOS, const LLVMContext &Ctx)
DenseMap< unsigned, unsigned > SpillOffsetMap
Map of stack slot offsets for spilled locations.
static void removeDebugInstrs(MachineFunction &mf)
static LoopDeletionResult merge(LoopDeletionResult A, LoopDeletionResult B)
static bool isUndef(const MachineInstr &MI)
Register const TargetRegisterInfo * TRI
This file implements a map that provides insertion order iteration.
std::pair< uint64_t, uint64_t > Interval
Promote Memory to Register
static MCRegister getReg(const MCDisassembler *D, unsigned RC, unsigned RegNo)
static bool isReg(const MCInst &MI, unsigned OpNo)
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
#define INITIALIZE_PASS_DEPENDENCY(depName)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
SI Optimize VGPR LiveRange
This file defines the SmallSet class.
This file defines the SmallVector class.
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Represent the analysis usage information of a pass.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
Get the array size.
static LLVM_ABI void appendOffset(SmallVectorImpl< uint64_t > &Ops, int64_t Offset)
Append Ops with operations to apply the Offset.
static LLVM_ABI DIExpression * appendOpsToArg(const DIExpression *Expr, ArrayRef< uint64_t > Ops, unsigned ArgNo, bool StackValue=false)
Create a copy of Expr by appending the given list of Ops to each instance of the operand DW_OP_LLVM_a...
static LLVM_ABI std::optional< FragmentInfo > getFragmentInfo(expr_op_iterator Start, expr_op_iterator End)
Retrieve the details of this fragment expression.
static LLVM_ABI DIExpression * replaceArg(const DIExpression *Expr, uint64_t OldArg, uint64_t NewArg)
Create a copy of Expr with each instance of DW_OP_LLVM_arg, \p OldArg replaced with DW_OP_LLVM_arg,...
static LLVM_ABI std::optional< DIExpression * > createFragmentExpression(const DIExpression *Expr, unsigned OffsetInBits, unsigned SizeInBits)
Create a DIExpression to describe one part of an aggregate variable that is fragmented across multipl...
static LLVM_ABI DIExpression * prepend(const DIExpression *Expr, uint8_t Flags, int64_t Offset=0)
Prepend DIExpr with a deref and offset operation and optionally turn it into a stack value or/and an ...
Tagged DWARF-like metadata node.
LLVM_ABI DILocation * getInlinedAt() const
Identifies a unique instance of a variable.
iterator find(const_arg_type_t< KeyT > Val)
DISubprogram * getSubprogram() const
Get the attached subprogram.
const_iterator begin() const
void insert(KeyT a, KeyT b, ValT y)
insert - Add a mapping of [a;b] to y, coalesce with adjacent intervals.
typename Sizer::Allocator Allocator
const_iterator find(KeyT x) const
find - Return an iterator pointing to the first interval ending at or after x, or end().
friend class const_iterator
void clear()
clear - Remove all entries.
This is an important class for using LLVM in a threaded context.
LLVM_ABI Result run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
LLVM_ABI PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
LiveDebugVariablesWrapperLegacy()
bool runOnMachineFunction(MachineFunction &) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
void getAnalysisUsage(AnalysisUsage &) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
LDVImpl(LiveIntervals *LIS)
void print(raw_ostream &)
void splitRegister(Register OldReg, ArrayRef< Register > NewRegs)
Replace all references to OldReg with NewRegs.
bool runOnMachineFunction(MachineFunction &mf, bool InstrRef)
void mapVirtReg(Register VirtReg, UserValue *EC)
Map virtual register to an equivalence class.
void clear()
Release all memory.
void canonicalizeIndexes(const SlotIndexes &SI)
Replace every stale index held by this analysis.
void emitDebugValues(VirtRegMap *VRM)
Recreate DBG_VALUE instruction from data structures.
void splitPHIRegister(Register OldReg, ArrayRef< Register > NewRegs)
Replace any PHI referring to OldReg with its corresponding NewReg, if present.
LLVM_ABI void canonicalizeIndexes(const SlotIndexes &SI)
canonicalizeIndexes - Replace every SlotIndex held by this analysis that refers to an erased instruct...
LLVM_ABI ~LiveDebugVariables()
void dump() const
dump - Print data structures to dbgs().
LLVM_ABI void splitRegister(Register OldReg, ArrayRef< Register > NewRegs, LiveIntervals &LIS)
splitRegister - Move any user variables in OldReg to the live ranges in NewRegs where they are live.
LLVM_ABI LiveDebugVariables()
Implementation of the LiveDebugVariables pass.
LLVM_ABI void print(raw_ostream &OS) const
LLVM_ABI void analyze(MachineFunction &MF, LiveIntervals *LIS)
LLVM_ABI void releaseMemory()
LLVM_ABI void emitDebugValues(VirtRegMap *VRM)
emitDebugValues - Emit new DBG_VALUE instructions reflecting the changes that happened during registe...
LLVM_ABI bool invalidate(MachineFunction &MF, const PreservedAnalyses &PA, MachineFunctionAnalysisManager::Invalidator &Inv)
LiveInterval - This class represents the liveness of a register, or stack slot.
bool hasInterval(Register Reg) const
SlotIndex getMBBStartIdx(const MachineBasicBlock *mbb) const
Return the first index in the given basic block.
MachineInstr * getInstructionFromIndex(SlotIndex index) const
Returns the instruction associated with the given index.
SlotIndexes * getSlotIndexes() const
SlotIndex getInstructionIndex(const MachineInstr &Instr) const
Returns the base index of the given instruction.
SlotIndex getMBBEndIdx(const MachineBasicBlock *mbb) const
Return the last index in the given basic block.
LiveInterval & getInterval(Register Reg)
bool isNotInMIMap(const MachineInstr &Instr) const
Returns true if the specified machine instr has been removed or was never entered in the map.
MachineBasicBlock * getMBBFromIndex(SlotIndex index) const
VNInfo * valueOutOrDead() const
Returns the value alive at the end of the instruction, if any.
Segments::iterator iterator
const Segment * getSegmentContaining(SlotIndex Idx) const
Return the segment that contains the specified index, or null if there is none.
iterator advanceTo(iterator I, SlotIndex Pos)
advanceTo - Advance the specified iterator to point to the Segment containing the specified position,...
LiveQueryResult Query(SlotIndex Idx) const
Query Liveness at Idx.
SlotIndex beginIndex() const
beginIndex - Return the lowest numbered slot covered.
VNInfo * getVNInfoAt(SlotIndex Idx) const
getVNInfoAt - Return the VNInfo that is live at Idx, or NULL.
LLVM_ABI iterator find(SlotIndex Pos)
find - Return an iterator pointing to the first segment that ends after Pos, or end().
LLVMContext & getContext() const
An RAII based helper class to modify MachineFunctionProperties when running pass.
void push_back(MachineInstr *MI)
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
LLVM_ABI instr_iterator erase(instr_iterator I)
Remove an instruction from the instruction list and delete it.
MachineInstrBundleIterator< MachineInstr > iterator
MachineFunctionPass(char &ID)
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
Location of a PHI instruction that is also a debug-info variable value, for the duration of register ...
bool useDebugInstrRef() const
Returns true if the function's variable locations are tracked with instruction referencing.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
void push_back(MachineBasicBlock *MBB)
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Function & getFunction()
Return the LLVM function that this machine code represents.
BasicBlockListType::iterator iterator
const MachineInstrBuilder & addMetadata(const MDNode *MD) const
Representation of each machine instruction.
const MachineOperand & getOperand(unsigned i) const
MachineOperand class - Representation of each machine instruction operand.
void setSubReg(unsigned subReg)
unsigned getSubReg() const
bool isReg() const
isReg - Tests if this is a MO_Register operand.
LLVM_ABI void setReg(Register Reg)
Change the register this operand corresponds to.
MachineInstr * getParent()
getParent - Return the instruction that this operand belongs to.
void setIsDebug(bool Val=true)
Register getReg() const
getReg - Returns the register number.
LLVM_ABI bool isIdenticalTo(const MachineOperand &Other) const
Returns true if this operand is identical to the specified operand except for liveness related flags ...
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)
static MachineOperand CreateFI(int Idx)
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
const TargetRegisterClass * getRegClass(Register Reg) const
Return the register class of the specified virtual register.
iterator_range< use_nodbg_iterator > use_nodbg_operands(Register Reg) const
This class implements a map that also provides access to all stored values in a deterministic order.
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
AnalysisType & getAnalysis() const
getAnalysis<AnalysisType>() - This function is used by subclasses to get to the analysis information ...
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
PreservedAnalysisChecker getChecker() const
Build a checker for this PreservedAnalyses and the specified analysis type.
Wrapper class representing virtual and physical registers.
constexpr bool isVirtual() const
Return true if the specified register number is in the virtual register namespace.
SlotIndex - An opaque wrapper around machine indexes.
SlotIndex getNextIndex() const
Returns the next index.
static bool isEarlierEqualInstr(SlotIndex A, SlotIndex B)
Return true if A refers to the same instruction as B or an earlier one.
SlotIndex getNextSlot() const
Returns the next slot in the index list.
SlotIndex getIndexBefore(const MachineInstr &MI) const
getIndexBefore - Returns the index of the last indexed instruction before MI, or the start index of i...
SlotIndex getMBBStartIdx(const MachineBasicBlock *mbb) const
Returns the first index in the given basic block.
std::pair< const_iterator, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
void assign(size_type NumElts, ValueParamT Elt)
iterator erase(const_iterator CI)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
constexpr bool empty() const
Check if the string is empty.
TargetInstrInfo - Interface to description of machine instruction set.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
virtual const TargetRegisterInfo * getRegisterInfo() const =0
Return the target's register information.
unsigned id
The ID number of this value.
SlotIndex def
The index of the defining instruction.
int getStackSlot(Register virtReg) const
returns the stack slot mapped to the specified virtual register
MachineFunction & getMachineFunction() const
MCRegister getPhys(Register virtReg) const
returns the physical register mapped to the specified virtual register
bool hasPhys(Register virtReg) const
returns true if the specified virtual register is mapped to a physical register
bool isAssignedReg(Register virtReg) const
returns true if the specified virtual register is not mapped to a stack slot or rematerialized.
static constexpr int NO_STACK_SLOT
self_iterator getIterator()
This class implements an extremely fast bulk output stream that can only output to a stream.
initializer< Ty > init(const Ty &Val)
Scope
Defines the scope in which this symbol should be visible: Default – Visible in the public interface o...
This is an optimization pass for GlobalISel generic memory operations.
auto find(R &&Range, const T &Val)
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly.
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
bool operator!=(uint64_t V1, const APInt &V2)
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
bool operator==(const AddressRangeValuePair &LHS, const AddressRangeValuePair &RHS)
std::pair< const MachineInstr *, const MachineInstr * > InsnRange
This is used to track range of instructions with identical lexical scope.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
IterT skipDebugInstructionsForward(IterT It, IterT End, bool SkipPseudoOp=true)
Increment It until it points to a non-debug instruction or to End and return the resulting iterator.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool none_of(R &&Range, UnaryPredicate P)
Provide wrappers to std::none_of which take ranges instead of having to pass begin/end explicitly.
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
@ Success
The lock was released successfully.
DWARFExpression::Operation Op
ArrayRef(const T &OneElt) -> ArrayRef< T >
OutputIt copy(R &&Range, OutputIt Out)
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
@ End
Run the machine verifier once, at the end of the pipeline.
LLVM_ABI Printable printReg(Register Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubIdx=0, const MachineRegisterInfo *MRI=nullptr)
Prints virtual and physical registers with or without a TRI instance.
LLVM_ABI Printable printMBBReference(const MachineBasicBlock &MBB)
Prints a machine basic block reference.
MCRegisterClass TargetRegisterClass
Caches used by findInsertLocation so that repeated insertions at the same position don't rescan the d...
DenseMap< const MachineInstr *, MachineBasicBlock::iterator > AfterInstr
Per instruction, the last debug instruction found after it, used as the starting position for the nex...
DenseMap< MachineBasicBlock *, MachineBasicBlock::iterator > BlockStart
Per block, the last PHI/Label/Debug instruction found by MachineBasicBlock::SkipPHIsLabelsAndDebug,...
A special type used by analysis passes to provide an address that identifies that particular analysis...