LLVM: lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9#ifndef LLVM_LIB_CODEGEN_LIVEDEBUGVALUES_INSTRREFBASEDLDV_H
10#define LLVM_LIB_CODEGEN_LIVEDEBUGVALUES_INSTRREFBASEDLDV_H
11
23#include
24
26
28
29
30class InstrRefLDVTest;
31
33
36
37using namespace llvm;
38
40using VarAndLoc = std::pair<DebugVariable, const DILocation *>;
41
42
43
44
45
46
50
51public:
53 auto It = VarToIdx.find(Var);
54 assert(It != VarToIdx.end());
55 return It->second;
56 }
57
59 unsigned Size = VarToIdx.size();
60 auto ItPair = VarToIdx.insert({Var, Size});
61 if (ItPair.second) {
62 IdxToVar.push_back({Var, Loc});
64 }
65
66 return ItPair.first->second;
67 }
68
70
72 VarToIdx.clear();
73 IdxToVar.clear();
74 }
75};
76
77
78
79
80
81
82class LocIdx {
83 unsigned Location;
84
85
86
87 LocIdx() : Location(UINT_MAX) {}
88
89public:
90#define NUM_LOC_BITS 24
94
97 LocIdx L = LocIdx();
98 --L.Location;
99 return L;
100 }
101
102 bool isIllegal() const { return Location == UINT_MAX; }
103
105
106 bool operator==(unsigned L) const { return Location == L; }
107
108 bool operator==(const LocIdx &L) const { return Location == L.Location; }
109
110 bool operator!=(unsigned L) const { return !(*this == L); }
111
112 bool operator!=(const LocIdx &L) const { return !(*this == L); }
113
115 return Location < Other.Location;
116 }
117};
118
119
120
126 std::make_pair(Other.SpillBase, Other.SpillOffset);
127 }
131 std::make_tuple(Other.SpillBase, Other.SpillOffset.getFixed(),
132 Other.SpillOffset.getScalable());
133 }
134};
135
136
137
138
139
140
141
142
143
144
145
147 union {
148 struct {
151
153 : NUM_LOC_BITS;
156 } u;
157
158 static_assert(sizeof(u) == 8, "Badly packed ValueIDNum?");
159
160public:
161
162
164
168
170 u.s = {Block, Inst, Loc.asU64()};
171 }
172
176 bool isPHI() const { return u.s.InstNo == 0; }
177
179
185
189
191 return u.Value == Other.u.Value;
192 }
193
195
196 std::string asString(const std::string &mlocname) const {
197 return Twine("Value{bb: ")
201 : Twine("live-in"))
203 Twine(mlocname)))
206 }
207
210};
211
212}
213
214namespace llvm {
216
225
240
241}
242
244using namespace llvm;
245
246
248
249
250
253 Storage.reserve(NumBBs);
254 for (int i = 0; i != NumBBs; ++i)
255 Storage.push_back(
257 }
258
259
261 return (*this)[MBB.getNumber()];
262 }
263
264
265
267 auto &TablePtr = Storage[MBBNum];
268 assert(TablePtr && "Trying to access a deleted table");
269 return *TablePtr;
270 }
271
272
274
275
277 return Storage[MBB.getNumber()] != nullptr;
278 }
279
280
282 Storage[MBB.getNumber()].reset();
283 }
284
285private:
286
287
288
290};
291
292
293
295public:
299
303
308 return !(*this == Other);
309 }
310};
311
312
313
315public:
318
319
322 assert(MI.getDebugExpression()->getNumLocationOperands() == 0 ||
323 MI.isDebugValueList() || MI.isUndefDebugValue());
325 DIExpr = MI.getDebugExpression();
327 }
328
333
338
340 return !(*this == Other);
341 }
342
346
350};
351
352
353
354
355
356
357
358
359
361 union {
364 };
366
370
372
373#ifndef NDEBUG
375#endif
376};
377
378
379
380
381
383 union {
386 };
388
391
394 return false;
396 return MO.isIdenticalTo(Other.MO);
398 }
399
400#ifndef NDEBUG
402#endif
403};
404
405
406
407
408
409
410
411
417
418 union {
421 };
422
424 static_assert(sizeof(DbgOpID) == 4, "DbgOpID should fit within 4 bytes.");
425 }
428
430
433
435
439
440#ifndef NDEBUG
442#endif
443};
444
445
446
447
448
450
453
456
457public:
458
459
460
461
463 if (Op.isUndef())
465 if (Op.IsConst)
466 return insertConstOp(Op.MO);
467 return insertValueOp(Op.ID);
468 }
469
470
474 if (ID.isConst())
475 return DbgOp(ConstOps[ID.getIndex()]);
476 return DbgOp(ValueOps[ID.getIndex()]);
477 }
478
480 ValueOps.clear();
481 ConstOps.clear();
482 ValueOpToID.clear();
483 ConstOpToID.clear();
484 }
485
486private:
488 auto [It, Inserted] = ConstOpToID.try_emplace(MO, true, ConstOps.size());
489 if (Inserted)
491 return It->second;
492 }
494 auto [It, Inserted] = ValueOpToID.try_emplace(VID, false, ValueOps.size());
495 if (Inserted)
497 return It->second;
498 }
499};
500
501
502
503
504#define MAX_DBG_OPS 8
505
506
507
508
509
510
511
512
514private:
515
516
517
518
520 unsigned OpCount;
521
522public:
523
525
526
528
538
540
543 static_assert(sizeof(DbgValue) <= 64,
544 "DbgValue should fit within 64 bytes.");
549 OpCount = 0;
550#define DEBUG_TYPE "LiveDebugValues"
552 LLVM_DEBUG(dbgs() << "Found DbgValue with more than maximum allowed "
553 "operands.\n");
554 }
555#undef DEBUG_TYPE
556 } else {
557 for (unsigned Idx = 0; Idx < DbgOps.size(); ++Idx)
558 this->DbgOps[Idx] = DbgOps[Idx];
559 }
560 }
561
566
570 "Empty DbgValue constructor must pass in Undef kind");
571 }
572
573#ifndef NDEBUG
575 const DbgOpIDMap *OpStore = nullptr) const;
576#endif
577
580 return false;
582 return false;
584 return false;
586 return false;
588 return false;
589
590 return true;
591 }
592
594
595
596
598
599
600
601
603 if (!OpCount)
605 assert(Index < OpCount);
606 return DbgOps[Index];
607 }
608
609
610
611
613
615 "Incorrect number of Debug Operands for this DbgValue.");
616 OpCount = NewIDs.size();
617 for (unsigned Idx = 0; Idx < NewIDs.size(); ++Idx)
618 DbgOps[Idx] = NewIDs[Idx];
619 }
620
621
622
623
627
628
629
630
633 return true;
635 if (getDbgOpID(Idx).isConst() != Other.getDbgOpID(Idx).isConst())
636 return false;
637 }
638 return true;
639 }
640
642
644 if (!OpCount)
645 return false;
647 }
648};
649
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
694public:
699
700
702
703
704
706
707
708
709
710
711
712
713
714
716
717
719
720
721
722
724
725
726
728
729
730
732
733
735
736
737
738
740
741
742
743
744
746
747
748
749 typedef std::pair<unsigned short, unsigned short> StackSlotPos;
750
751
752
753
755
756
758
759
760
761
762
766
767 public:
774
776 : ValueMap(ValueMap), Idx(Idx) {}
777
780 return Idx == Other.Idx;
781 }
782
784 return !(*this == Other);
785 }
786
788
790 };
791
795
796
797
798
800
801
802
803
805 unsigned short Size = TRI.getSubRegIdxSize(SpillSubReg);
806 unsigned short Offs = TRI.getSubRegIdxOffset(SpillSubReg);
808 }
809
810
811
812
814 unsigned SlotNo = Spill.id() - 1;
819 return SlotNo;
820 }
821
822
823
825 unsigned SlotNo = Spill.id() - 1;
827 SlotNo += Idx;
829 return SlotNo;
830 }
831
832
840
841
848
850
851
852
853
855 CurBB = NewCurBB;
856 for (auto Location : locations())
857 Location.Value = {CurBB, 0, Location.Idx};
858 }
859
860
861
863 CurBB = NewCurBB;
864
865
866 for (auto Location : locations())
867 Location.Value = Locs[Location.Idx.asU64()];
868 }
869
870
877
878
879
893
894
899
900
905
906
907
909
912 if (Index.isIllegal())
914 return Index;
915 }
916
917
920 return !Index.isIllegal();
921 }
922
923
924
925
932
933
934
940
946
947
948
949
950
956
957
964
965
966
967
969
970
971
972
975
976
981
982
984
985
989 return TRI.getRegSizeInBits(Register(ID), MF.getRegInfo());
990 } else {
991
992
994 return Pos.first;
995 }
996 }
997
999
1003
1004
1008
1010
1012
1013#ifndef NDEBUG
1015
1017#endif
1018
1019
1020
1021
1025};
1026
1027
1028
1029
1031 std::pair<const DILocalVariable *, DIExpression::FragmentInfo>;
1034
1035
1036
1037
1038
1040public:
1041
1043
1044
1045
1046
1047
1048
1049
1050
1051
1057
1058public:
1063
1066 assert(MI.isDebugValueLike());
1067 DebugVariable Var(MI.getDebugVariable(), MI.getDebugExpression(),
1068 MI.getDebugLoc()->getInlinedAt());
1069
1072 ? DbgValue(DebugOps, Properties)
1074
1075
1076 Vars.insert_or_assign(VarID, Rec);
1078
1080 }
1081
1086 return;
1087
1088
1089 for (auto FragmentInfo : Overlaps->second) {
1090
1091
1092
1093 std::optionalDIExpression::FragmentInfo OptFragmentInfo = FragmentInfo;
1095 OptFragmentInfo = std::nullopt;
1096
1099
1102
1103
1104 Vars.insert_or_assign(OverlappedID, Rec);
1106 }
1107 }
1108
1110 Vars.clear();
1112 }
1113};
1114
1115
1117public:
1118 friend class ::InstrRefLDVTest;
1119
1122
1123
1124
1127
1128
1129
1131
1132
1133
1135
1136 using VarAndLoc = std::pair<DebugVariableID, DbgValue>;
1137
1138
1139 using InValueT = std::pair<MachineBasicBlock *, DbgValue *>;
1140
1141
1142
1144
1145
1147
1148
1151
1152
1153
1154
1156
1157private:
1166
1167
1168
1170
1171
1172
1174
1175
1176 unsigned CurBB = -1;
1177
1178
1179 unsigned CurInst;
1180
1181
1182
1183
1185
1186
1187
1188
1190
1191
1192
1194
1195
1199
1200
1201 using InstAndNum = std::pair<const MachineInstr *, unsigned>;
1202
1203
1204
1205 std::map<uint64_t, InstAndNum> DebugInstrNumToInstr;
1206
1207
1208 class DebugPHIRecord {
1209 public:
1210
1212
1214
1215
1216 std::optional ValueRead;
1217
1218
1219 std::optional ReadLoc;
1220
1221 operator unsigned() const { return InstrNum; }
1222 };
1223
1224
1225
1226
1227
1229
1230
1233
1234
1235
1236
1237
1239 SeenDbgPHIs;
1240
1242
1243
1244
1245
1247
1248
1249
1250
1251 bool AdjustsStackInCalls = false;
1252
1253
1254
1255
1257
1258
1259 std::optional isSpillInstruction(const MachineInstr &MI,
1261
1262
1263
1264
1265
1266
1267
1269 unsigned &Reg);
1270
1271
1272
1273 std::optional isRestoreInstruction(const MachineInstr &MI,
1275 unsigned &Reg);
1276
1277
1278
1279 std::optional
1280 extractSpillBaseRegAndOffset(const MachineInstr &MI);
1281
1282
1283
1284
1285 std::optional getValueForInstrRef(unsigned InstNo, unsigned OpNo,
1289
1290
1293
1294
1295
1297
1298
1299
1302
1303
1304
1305
1307
1308
1309
1311
1312
1313
1315
1316
1318
1319
1320
1322
1324
1325
1326
1327
1328
1329
1330
1331
1332 std::optional resolveDbgPHIs(MachineFunction &MF,
1337
1338 std::optional resolveDbgPHIsImpl(MachineFunction &MF,
1343
1344
1345
1346
1347
1352
1353
1354
1355
1356
1357
1362
1363
1364
1366
1367
1368
1372
1373
1374
1375
1376
1377 void placePHIsForSingleVarDefinition(
1381
1382
1383
1384
1385
1386
1387
1391
1392
1393
1394
1395
1396
1397
1398
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411 void
1412 getBlocksForScope(const DILocation *DILoc,
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1429 buildVLocValueMap(const DILocation *DILoc,
1435
1436
1437
1438
1439
1440
1441
1442
1447
1448
1449
1450
1451
1452
1457
1458 std::optional pickOperandPHILoc(
1462
1463
1464
1465 bool emitTransfers();
1466
1467
1468
1470
1471
1472
1473
1474
1475
1479
1480
1481
1482
1483
1484
1485 bool depthFirstVLocAndEmit(
1490 bool ShouldEmitDebugEntryValues);
1491
1493 bool ShouldEmitDebugEntryValues, unsigned InputBBLimit,
1494 unsigned InputDbgValLimit) override;
1495
1496public:
1497
1499
1502
1505
1507
1508
1509
1510 if (.hasOneMemOperand())
1511 return false;
1512 auto *MemOperand = *MI.memoperands_begin();
1513 return MemOperand->isStore() &&
1514 MemOperand->getPseudoValue() &&
1516 && !MemOperand->getPseudoValue()->isAliased(MFI);
1517 }
1518
1520
1521
1523 return DVMap;
1524 }
1525};
1526
1527}
1528
1529#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
const TargetInstrInfo & TII
static cl::opt< unsigned > MaxNumBlocks("debug-ata-max-blocks", cl::init(10000), cl::desc("Maximum num basic blocks before debug info dropped"), cl::Hidden)
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
#define LLVM_ABI_FOR_TEST
This file defines the DenseMap class.
This file implements an indexed map.
#define NUM_LOC_BITS
Definition InstrRefBasedImpl.h:90
#define MAX_DBG_OPS
Definition InstrRefBasedImpl.h:504
static cl::opt< unsigned > InputBBLimit("livedebugvalues-input-bb-limit", cl::desc("Maximum input basic blocks before DBG_VALUE limit applies"), cl::init(10000), cl::Hidden)
Register const TargetRegisterInfo * TRI
Promote Memory to Register
This file defines the SmallPtrSet class.
This file defines the SmallVector class.
Class storing the complete set of values that are observed by DbgValues within the current function.
Definition InstrRefBasedImpl.h:449
DbgOp find(DbgOpID ID) const
Returns the DbgOp associated with ID.
Definition InstrRefBasedImpl.h:471
void clear()
Definition InstrRefBasedImpl.h:479
DbgOpID insert(DbgOp Op)
If Op does not already exist in this map, it is inserted and the corresponding DbgOpID is returned.
Definition InstrRefBasedImpl.h:462
Meta qualifiers for a value.
Definition InstrRefBasedImpl.h:314
bool operator==(const DbgValueProperties &Other) const
Definition InstrRefBasedImpl.h:334
bool Indirect
Definition InstrRefBasedImpl.h:348
DbgValueProperties(const DIExpression *DIExpr, bool Indirect, bool IsVariadic)
Definition InstrRefBasedImpl.h:316
const DIExpression * DIExpr
Definition InstrRefBasedImpl.h:347
DbgValueProperties(const MachineInstr &MI)
Extract properties from an existing DBG_VALUE instruction.
Definition InstrRefBasedImpl.h:320
bool isJoinable(const DbgValueProperties &Other) const
Definition InstrRefBasedImpl.h:329
unsigned getLocationOpCount() const
Definition InstrRefBasedImpl.h:343
bool IsVariadic
Definition InstrRefBasedImpl.h:349
bool operator!=(const DbgValueProperties &Other) const
Definition InstrRefBasedImpl.h:339
Class recording the (high level) value of a variable.
Definition InstrRefBasedImpl.h:513
int BlockNo
For a NoVal or VPHI DbgValue, which block it was generated in.
Definition InstrRefBasedImpl.h:524
DbgValueProperties Properties
Qualifiers for the ValueIDNum above.
Definition InstrRefBasedImpl.h:527
ArrayRef< DbgOpID > getDbgOpIDs() const
Definition InstrRefBasedImpl.h:597
void setDbgOpIDs(ArrayRef< DbgOpID > NewIDs)
Definition InstrRefBasedImpl.h:612
bool hasJoinableLocOps(const DbgValue &Other) const
Definition InstrRefBasedImpl.h:631
void dump(const MLocTracker *MTrack=nullptr, const DbgOpIDMap *OpStore=nullptr) const
bool isUnjoinedPHI() const
Definition InstrRefBasedImpl.h:641
DbgValue(ArrayRef< DbgOpID > DbgOps, const DbgValueProperties &Prop)
Definition InstrRefBasedImpl.h:541
DbgOpID getDbgOpID(unsigned Index) const
Definition InstrRefBasedImpl.h:602
DbgValue(unsigned BlockNo, const DbgValueProperties &Prop, KindT Kind)
Definition InstrRefBasedImpl.h:562
bool operator!=(const DbgValue &Other) const
Definition InstrRefBasedImpl.h:593
KindT
Definition InstrRefBasedImpl.h:529
@ VPHI
Definition InstrRefBasedImpl.h:533
@ Undef
Definition InstrRefBasedImpl.h:530
@ Def
Definition InstrRefBasedImpl.h:531
@ NoVal
Definition InstrRefBasedImpl.h:535
DbgValue(const DbgValueProperties &Prop, KindT Kind)
Definition InstrRefBasedImpl.h:567
KindT Kind
Discriminator for whether this is a constant or an in-program value.
Definition InstrRefBasedImpl.h:539
unsigned getLocationOpCount() const
Definition InstrRefBasedImpl.h:624
bool operator==(const DbgValue &Other) const
Definition InstrRefBasedImpl.h:578
bool hasIdenticalValidLocOps(const DbgValue &Other) const
Definition InstrRefBasedImpl.h:643
Mapping from DebugVariable to/from a unique identifying number.
Definition InstrRefBasedImpl.h:47
void clear()
Definition InstrRefBasedImpl.h:71
const VarAndLoc & lookupDVID(DebugVariableID ID) const
Definition InstrRefBasedImpl.h:69
DebugVariableID insertDVID(DebugVariable &Var, const DILocation *Loc)
Definition InstrRefBasedImpl.h:58
DebugVariableID getDVID(const DebugVariable &Var) const
Definition InstrRefBasedImpl.h:52
DenseMap< const LexicalScope *, const DILocation * > ScopeToDILocT
Mapping from lexical scopes to a DILocation in that scope.
Definition InstrRefBasedImpl.h:1146
DenseMap< const DILocalVariable *, SmallSet< FragmentInfo, 4 > > VarToFragments
Definition InstrRefBasedImpl.h:1125
std::optional< LocIdx > findLocationForMemOperand(const MachineInstr &MI)
std::pair< MachineBasicBlock *, DbgValue * > InValueT
Type for a live-in value: the predecessor block, and its value.
Definition InstrRefBasedImpl.h:1139
DebugVariableMap & getDVMap()
Definition InstrRefBasedImpl.h:1522
std::pair< DebugVariableID, DbgValue > VarAndLoc
Definition InstrRefBasedImpl.h:1136
SmallVector< SmallVector< VarAndLoc, 8 >, 8 > LiveInsT
Vector (per block) of a collection (inner smallvector) of live-ins.
Definition InstrRefBasedImpl.h:1143
LLVM_ABI_FOR_TEST InstrRefBasedLDV()
Default construct and initialize the pass.
DenseMap< const LexicalScope *, SmallPtrSet< MachineBasicBlock *, 4 > > ScopeToAssignBlocksT
Mapping from lexical scopes to blocks where variables in that scope are assigned.
Definition InstrRefBasedImpl.h:1155
DIExpression::FragmentInfo FragmentInfo
Definition InstrRefBasedImpl.h:1120
DenseMap< const LexicalScope *, SmallSet< DebugVariableID, 4 > > ScopeToVarsT
Mapping from lexical scopes to variables in that scope.
Definition InstrRefBasedImpl.h:1149
std::optional< DIExpression::FragmentInfo > OptFragmentInfo
Definition InstrRefBasedImpl.h:1121
SmallDenseMap< const MachineBasicBlock *, DbgValue *, 16 > LiveIdxT
Live in/out structure for the variable values: a per-block map of variables to their values.
Definition InstrRefBasedImpl.h:1134
SmallDenseMap< LocIdx, ValueIDNum > MLocTransferMap
Machine location/value transfer function, a mapping of which locations are assigned which new values.
Definition InstrRefBasedImpl.h:1130
bool hasFoldedStackStore(const MachineInstr &MI)
Definition InstrRefBasedImpl.h:1506
bool isCalleeSaved(LocIdx L) const
bool isCalleeSavedReg(Register R) const
LLVM_DUMP_METHOD void dump_mloc_transfer(const MLocTransferMap &mloc_transfer) const
unsigned operator()(const LocIdx &L) const
Definition InstrRefBasedImpl.h:653
LocIdx argument_type
Definition InstrRefBasedImpl.h:652
Handle-class for a particular "location".
Definition InstrRefBasedImpl.h:82
bool operator!=(const LocIdx &L) const
Definition InstrRefBasedImpl.h:112
bool isIllegal() const
Definition InstrRefBasedImpl.h:102
bool operator<(const LocIdx &Other) const
Definition InstrRefBasedImpl.h:114
LocIdx(unsigned L)
Definition InstrRefBasedImpl.h:91
static LocIdx MakeTombstoneLoc()
Definition InstrRefBasedImpl.h:96
uint64_t asU64() const
Definition InstrRefBasedImpl.h:104
static LocIdx MakeIllegalLoc()
Definition InstrRefBasedImpl.h:95
bool operator!=(unsigned L) const
Definition InstrRefBasedImpl.h:110
bool operator==(unsigned L) const
Definition InstrRefBasedImpl.h:106
bool operator==(const LocIdx &L) const
Definition InstrRefBasedImpl.h:108
const LocIdx Idx
Definition InstrRefBasedImpl.h:771
value_type(LocIdx Idx, ValueIDNum &Value)
Definition InstrRefBasedImpl.h:770
ValueIDNum & Value
Read-only index of this location.
Definition InstrRefBasedImpl.h:772
Iterator for locations and the values they contain.
Definition InstrRefBasedImpl.h:763
value_type operator*()
Definition InstrRefBasedImpl.h:789
bool operator!=(const MLocIterator &Other) const
Definition InstrRefBasedImpl.h:783
void operator++()
Definition InstrRefBasedImpl.h:787
MLocIterator(LocToValueType &ValueMap, LocIdx Idx)
Definition InstrRefBasedImpl.h:775
bool operator==(const MLocIterator &Other) const
Definition InstrRefBasedImpl.h:778
Tracker for what values are in machine locations.
Definition InstrRefBasedImpl.h:693
unsigned getLocSizeInBits(LocIdx L) const
How large is this location (aka, how wide is a value defined there?).
Definition InstrRefBasedImpl.h:986
bool isRegisterTracked(Register R)
Is register R currently tracked by MLocTracker?
Definition InstrRefBasedImpl.h:918
LLVM_ABI_FOR_TEST std::optional< SpillLocationNo > getOrTrackSpillLoc(SpillLoc L)
Find LocIdx for SpillLoc L, creating a new one if it's not tracked.
void loadFromArray(ValueTable &Locs, unsigned NewCurBB)
Load values for each location from array of ValueIDNums.
Definition InstrRefBasedImpl.h:862
IndexedMap< unsigned, LocIdxToIndexFunctor > LocIdxToLocID
Inverse map of LocIDToLocIdx.
Definition InstrRefBasedImpl.h:718
unsigned getSpillIDWithIdx(SpillLocationNo Spill, unsigned Idx)
Given a spill number, and a slot within the spill, calculate the ID number for that location.
Definition InstrRefBasedImpl.h:824
unsigned getLocID(SpillLocationNo Spill, unsigned SpillSubReg)
Produce location ID number for a spill position.
Definition InstrRefBasedImpl.h:804
unsigned CurBB
Definition InstrRefBasedImpl.h:731
iterator_range< MLocIterator > locations()
Return a range over all locations currently tracked.
Definition InstrRefBasedImpl.h:1005
unsigned getLocID(SpillLocationNo Spill, StackSlotPos Idx)
Produce location ID number for a spill position.
Definition InstrRefBasedImpl.h:813
SmallSet< Register, 8 > SPAliases
When clobbering register masks, we chose to not believe the machine model and don't clobber SP.
Definition InstrRefBasedImpl.h:723
unsigned getLocID(Register Reg)
Produce location ID number for a Register.
Definition InstrRefBasedImpl.h:799
const TargetLowering & TLI
Definition InstrRefBasedImpl.h:698
MLocIterator end()
Definition InstrRefBasedImpl.h:1000
const TargetRegisterInfo & TRI
Definition InstrRefBasedImpl.h:697
MLocIterator begin()
Definition InstrRefBasedImpl.h:998
unsigned NumRegs
Cached local copy of the number of registers the target has.
Definition InstrRefBasedImpl.h:734
unsigned getNumLocs() const
Definition InstrRefBasedImpl.h:849
DenseMap< StackSlotPos, unsigned > StackSlotIdxes
Map from a size/offset pair describing a position in a stack slot, to a numeric identifier for that p...
Definition InstrRefBasedImpl.h:754
LocIdx lookupOrTrackRegister(unsigned ID)
Definition InstrRefBasedImpl.h:910
void setReg(Register R, ValueIDNum ValueID)
Set a register to a value number.
Definition InstrRefBasedImpl.h:935
SpillLocationNo locIDToSpill(unsigned ID) const
Return the spill number that a location ID corresponds to.
Definition InstrRefBasedImpl.h:833
void reset()
Wipe any un-necessary location records after traversing a block.
Definition InstrRefBasedImpl.h:871
DenseMap< unsigned, StackSlotPos > StackIdxesToPos
Inverse of StackSlotIdxes.
Definition InstrRefBasedImpl.h:757
std::string IDAsString(const ValueIDNum &Num) const
void writeRegMask(const MachineOperand *MO, unsigned CurBB, unsigned InstID)
Record a RegMask operand being executed.
std::pair< unsigned short, unsigned short > StackSlotPos
Pair for describing a position within a stack slot – first the size in bits, then the offset.
Definition InstrRefBasedImpl.h:749
const TargetInstrInfo & TII
Definition InstrRefBasedImpl.h:696
bool isSpill(LocIdx Idx) const
Return true if Idx is a spill machine location.
Definition InstrRefBasedImpl.h:983
LocIdx getRegMLoc(Register R)
Determine the LocIdx of an existing register.
Definition InstrRefBasedImpl.h:958
MachineInstrBuilder emitLoc(const SmallVectorImpl< ResolvedDbgOp > &DbgOps, const DebugVariable &Var, const DILocation *DILoc, const DbgValueProperties &Properties)
Create a DBG_VALUE based on debug operands DbgOps.
void wipeRegister(Register R)
Reset a register value to zero / empty.
Definition InstrRefBasedImpl.h:951
void setMLoc(LocIdx L, ValueIDNum Num)
Set a locaiton to a certain value.
Definition InstrRefBasedImpl.h:895
LocToValueType LocIdxToIDNum
Map of LocIdxes to the ValueIDNums that they store.
Definition InstrRefBasedImpl.h:705
std::vector< LocIdx > LocIDToLocIdx
"Map" of machine location IDs (i.e., raw register or spill number) to the LocIdx key / number for tha...
Definition InstrRefBasedImpl.h:715
void clear()
Clear all data.
Definition InstrRefBasedImpl.h:880
IndexedMap< ValueIDNum, LocIdxToIndexFunctor > LocToValueType
IndexedMap type, mapping from LocIdx to ValueIDNum.
Definition InstrRefBasedImpl.h:701
SmallVector< std::pair< const MachineOperand *, unsigned >, 32 > Masks
Collection of register mask operands that have been observed.
Definition InstrRefBasedImpl.h:745
unsigned NumSlotIdxes
Number of slot indexes the target has – distinct segments of a stack slot that can take on the value ...
Definition InstrRefBasedImpl.h:739
UniqueVector< SpillLoc > SpillLocs
Unique-ification of spill.
Definition InstrRefBasedImpl.h:727
ValueIDNum readMLoc(LocIdx L)
Read the value of a particular location.
Definition InstrRefBasedImpl.h:901
void setMPhis(unsigned NewCurBB)
Reset all locations to contain a PHI value at the designated block.
Definition InstrRefBasedImpl.h:854
ValueIDNum readReg(Register R)
Definition InstrRefBasedImpl.h:941
void defReg(Register R, unsigned BB, unsigned Inst)
Record a definition of the specified register at the given block / inst.
Definition InstrRefBasedImpl.h:926
LLVM_DUMP_METHOD void dump()
LLVM_ABI_FOR_TEST LocIdx trackRegister(unsigned ID)
Create a LocIdx for an untracked register ID.
LLVM_ABI_FOR_TEST MLocTracker(MachineFunction &MF, const TargetInstrInfo &TII, const TargetRegisterInfo &TRI, const TargetLowering &TLI)
MachineFunction & MF
Definition InstrRefBasedImpl.h:695
LLVM_DUMP_METHOD void dump_mloc_map()
StackSlotPos locIDToSpillIdx(unsigned ID) const
Returns the spill-slot size/offs that a location ID corresponds to.
Definition InstrRefBasedImpl.h:842
LocIdx getSpillMLoc(unsigned SpillID)
Definition InstrRefBasedImpl.h:977
std::string LocIdxToName(LocIdx Idx) const
Thin wrapper around an integer – designed to give more type safety to spill location numbers.
Definition InstrRefBasedImpl.h:294
unsigned id() const
Definition InstrRefBasedImpl.h:298
bool operator==(const SpillLocationNo &Other) const
Definition InstrRefBasedImpl.h:304
unsigned SpillNo
Definition InstrRefBasedImpl.h:297
bool operator!=(const SpillLocationNo &Other) const
Definition InstrRefBasedImpl.h:307
bool operator<(const SpillLocationNo &Other) const
Definition InstrRefBasedImpl.h:300
SpillLocationNo(unsigned SpillNo)
Definition InstrRefBasedImpl.h:296
Collection of DBG_VALUEs observed when traversing a block.
Definition InstrRefBasedImpl.h:1039
const OverlapMap & OverlappingFragments
Definition InstrRefBasedImpl.h:1055
SmallDenseMap< DebugVariableID, const DILocation *, 8 > Scopes
Definition InstrRefBasedImpl.h:1053
MachineBasicBlock * MBB
Definition InstrRefBasedImpl.h:1054
SmallMapVector< DebugVariableID, DbgValue, 8 > Vars
Map DebugVariable to the latest Value it's defined to have.
Definition InstrRefBasedImpl.h:1052
void defVar(const MachineInstr &MI, const DbgValueProperties &Properties, const SmallVectorImpl< DbgOpID > &DebugOps)
Definition InstrRefBasedImpl.h:1064
void clear()
Definition InstrRefBasedImpl.h:1109
void considerOverlaps(const DebugVariable &Var, const DILocation *Loc)
Definition InstrRefBasedImpl.h:1082
VLocTracker(DebugVariableMap &DVMap, const OverlapMap &O, const DIExpression *EmptyExpr)
Definition InstrRefBasedImpl.h:1059
DebugVariableMap & DVMap
Ref to function-wide map of DebugVariable <=> ID-numbers.
Definition InstrRefBasedImpl.h:1042
DbgValueProperties EmptyProperties
Definition InstrRefBasedImpl.h:1056
Unique identifier for a value defined by an instruction, as a value type.
Definition InstrRefBasedImpl.h:146
uint64_t LocNo
The Instruction where the def happens.
Definition InstrRefBasedImpl.h:153
ValueIDNum(uint64_t Block, uint64_t Inst, uint64_t Loc)
Definition InstrRefBasedImpl.h:165
bool isPHI() const
Definition InstrRefBasedImpl.h:176
uint64_t getInst() const
Definition InstrRefBasedImpl.h:174
uint64_t Value
Definition InstrRefBasedImpl.h:155
struct LiveDebugValues::ValueIDNum::@122243371010332366363270357367014132366357004151::@211331010212204211312147341360354163043131005174 s
bool operator==(const ValueIDNum &Other) const
Definition InstrRefBasedImpl.h:190
bool operator<(const ValueIDNum &Other) const
Definition InstrRefBasedImpl.h:186
ValueIDNum()
Definition InstrRefBasedImpl.h:163
static ValueIDNum fromU64(uint64_t v)
Definition InstrRefBasedImpl.h:180
std::string asString(const std::string &mlocname) const
Definition InstrRefBasedImpl.h:196
static LLVM_ABI_FOR_TEST ValueIDNum EmptyValue
Definition InstrRefBasedImpl.h:208
ValueIDNum(uint64_t Block, uint64_t Inst, LocIdx Loc)
Definition InstrRefBasedImpl.h:169
uint64_t asU64() const
Definition InstrRefBasedImpl.h:178
bool operator!=(const ValueIDNum &Other) const
Definition InstrRefBasedImpl.h:194
uint64_t BlockNo
Definition InstrRefBasedImpl.h:149
static LLVM_ABI_FOR_TEST ValueIDNum TombstoneValue
Definition InstrRefBasedImpl.h:209
uint64_t getBlock() const
Definition InstrRefBasedImpl.h:173
uint64_t getLoc() const
Definition InstrRefBasedImpl.h:175
uint64_t InstNo
The block where the def happens.
Definition InstrRefBasedImpl.h:150
Tracker for converting machine value locations and variable values into variable locations (the outpu...
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
DbgVariableFragmentInfo FragmentInfo
static LLVM_ABI bool isEqualExpression(const DIExpression *FirstExpr, bool FirstIndirect, const DIExpression *SecondExpr, bool SecondIndirect)
Determines whether two debug values should produce equivalent DWARF expressions, using their DIExpres...
Identifies a unique instance of a variable.
static bool isDefaultFragment(const FragmentInfo F)
const DILocation * getInlinedAt() const
FragmentInfo getFragmentOrDefault() const
const DILocalVariable * getVariable() const
std::pair< iterator, bool > try_emplace(KeyT &&Key, Ts &&...Args)
This class provides interface to collect and use lexical scoping information from machine instruction...
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
Representation of each machine instruction.
MachineOperand class - Representation of each machine instruction operand.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
Wrapper class representing virtual and physical registers.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StackOffset holds a fixed and a scalable offset in bytes.
StringRef - Represent a constant reference to a string, i.e.
Information about stack frame layout on the target.
TargetInstrInfo - Interface to description of machine instruction set.
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
LLVM_ABI std::string str() const
Return the twine contents as a std::string.
Twine concat(const Twine &Suffix) const
UniqueVector - This class produces a sequential ID number (base 1) for each unique entry that is adde...
A range adaptor for a pair of iterators.
Definition InstrRefBasedImpl.h:32
unsigned DebugVariableID
Definition InstrRefBasedImpl.h:39
DenseMap< FragmentOfVar, SmallVector< DIExpression::FragmentInfo, 1 > > OverlapMap
Definition InstrRefBasedImpl.h:1032
SmallVector< ValueIDNum, 0 > ValueTable
Type for a table of values in a block.
Definition InstrRefBasedImpl.h:247
std::pair< const DILocalVariable *, DIExpression::FragmentInfo > FragmentOfVar
Types for recording sets of variable fragments that overlap.
Definition InstrRefBasedImpl.h:1030
std::pair< DebugVariable, const DILocation * > VarAndLoc
Definition InstrRefBasedImpl.h:40
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.
std::tuple< const DIScope *, const DIScope *, const DILocalVariable * > VarID
A unique key that represents a debug variable.
hash_code hash_value(const FixedPointSemantics &Val)
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
detail::concat_range< ValueT, RangeTs... > concat(RangeTs &&...Ranges)
Returns a concatenated range across two or more ranges.
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.
DWARFExpression::Operation Op
bool equal(L &&LRange, R &&RRange)
Wrapper function around std::equal to detect if pair-wise elements between two ranges are the same.
uint32_t IsConst
Definition InstrRefBasedImpl.h:414
uint32_t Index
Definition InstrRefBasedImpl.h:415
An ID used in the DbgOpIDMap (below) to lookup a stored DbgOp.
Definition InstrRefBasedImpl.h:412
bool operator==(const DbgOpID &Other) const
Definition InstrRefBasedImpl.h:431
uint32_t asU32() const
Definition InstrRefBasedImpl.h:434
DbgOpID()
Definition InstrRefBasedImpl.h:423
bool operator!=(const DbgOpID &Other) const
Definition InstrRefBasedImpl.h:432
void dump(const MLocTracker *MTrack, const DbgOpIDMap *OpStore) const
uint32_t getIndex() const
Definition InstrRefBasedImpl.h:438
DbgOpID(bool IsConst, uint32_t Index)
Definition InstrRefBasedImpl.h:427
static LLVM_ABI_FOR_TEST DbgOpID UndefID
Definition InstrRefBasedImpl.h:429
bool isConst() const
Definition InstrRefBasedImpl.h:437
struct IsConstIndexPair ID
Definition InstrRefBasedImpl.h:419
bool isUndef() const
Definition InstrRefBasedImpl.h:436
uint32_t RawID
Definition InstrRefBasedImpl.h:420
DbgOpID(uint32_t RawID)
Definition InstrRefBasedImpl.h:426
TODO: Might pack better if we changed this to a Struct of Arrays, since MachineOperand is width 32,...
Definition InstrRefBasedImpl.h:360
ValueIDNum ID
Definition InstrRefBasedImpl.h:362
DbgOp()
Definition InstrRefBasedImpl.h:367
bool isUndef() const
Definition InstrRefBasedImpl.h:371
void dump(const MLocTracker *MTrack) const
DbgOp(MachineOperand MO)
Definition InstrRefBasedImpl.h:369
DbgOp(ValueIDNum ID)
Definition InstrRefBasedImpl.h:368
bool IsConst
Definition InstrRefBasedImpl.h:365
MachineOperand MO
Definition InstrRefBasedImpl.h:363
A collection of ValueTables, one per BB in a function, with convenient accessor methods.
Definition InstrRefBasedImpl.h:251
ValueTable & operator[](int MBBNum) const
Returns the ValueTable associated with the MachineBasicBlock whose number is MBBNum.
Definition InstrRefBasedImpl.h:266
void ejectTableForBlock(const MachineBasicBlock &MBB)
Frees the memory of the ValueTable associated with MBB.
Definition InstrRefBasedImpl.h:281
ValueTable & tableForEntryMBB() const
Returns the ValueTable associated with the entry MachineBasicBlock.
Definition InstrRefBasedImpl.h:273
FuncValueTable(int NumBBs, int NumLocs)
Definition InstrRefBasedImpl.h:252
ValueTable & operator[](const MachineBasicBlock &MBB) const
Returns the ValueTable associated with MBB.
Definition InstrRefBasedImpl.h:260
bool hasTableFor(MachineBasicBlock &MBB) const
Returns true if the ValueTable associated with MBB has not been freed.
Definition InstrRefBasedImpl.h:276
LocIdx Loc
Definition InstrRefBasedImpl.h:384
ResolvedDbgOp(MachineOperand MO)
Definition InstrRefBasedImpl.h:390
MachineOperand MO
Definition InstrRefBasedImpl.h:385
ResolvedDbgOp(LocIdx Loc)
Definition InstrRefBasedImpl.h:389
bool IsConst
Definition InstrRefBasedImpl.h:387
bool operator==(const ResolvedDbgOp &Other) const
Definition InstrRefBasedImpl.h:392
void dump(const MLocTracker *MTrack) const
StackOffset SpillOffset
Definition InstrRefBasedImpl.h:123
bool operator<(const SpillLoc &Other) const
Definition InstrRefBasedImpl.h:128
bool operator==(const SpillLoc &Other) const
Definition InstrRefBasedImpl.h:124
unsigned SpillBase
Definition InstrRefBasedImpl.h:122
static LocIdx getTombstoneKey()
Definition InstrRefBasedImpl.h:219
static bool isEqual(const LocIdx &A, const LocIdx &B)
Definition InstrRefBasedImpl.h:223
static unsigned getHashValue(const LocIdx &Loc)
Definition InstrRefBasedImpl.h:221
static LocIdx getEmptyKey()
Definition InstrRefBasedImpl.h:218
static ValueIDNum getTombstoneKey()
Definition InstrRefBasedImpl.h:228
static ValueIDNum getEmptyKey()
Definition InstrRefBasedImpl.h:227
static unsigned getHashValue(const ValueIDNum &Val)
Definition InstrRefBasedImpl.h:232
static bool isEqual(const ValueIDNum &A, const ValueIDNum &B)
Definition InstrRefBasedImpl.h:236
An information struct used to provide DenseMap with the various necessary components for a given valu...
A MapVector that performs no allocations if smaller than a certain size.