LLVM 23.0.0git
InstrRefBasedImpl.h
Go to the documentation of this file.
1//===- InstrRefBasedImpl.h - Tracking Debug Value MIs ---------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_LIB_CODEGEN_LIVEDEBUGVALUES_INSTRREFBASEDLDV_H
10#define LLVM_LIB_CODEGEN_LIVEDEBUGVALUES_INSTRREFBASEDLDV_H
11
12#include "llvm/ADT/DenseMap.h"
13#include "llvm/ADT/IndexedMap.h"
23#include <optional>
24
25#include "LiveDebugValues.h"
26
27class TransferTracker;
28
29// Forward dec of unit test class, so that we can peer into the LDV object.
30class InstrRefLDVTest;
31
32namespace LiveDebugValues {
33
34class MLocTracker;
35class DbgOpIDMap;
36
37using namespace llvm;
38
40using VarAndLoc = std::pair<DebugVariable, const DILocation *>;
41
42/// Mapping from DebugVariable to/from a unique identifying number. Each
43/// DebugVariable consists of three pointers, and after a small amount of
44/// work to identify overlapping fragments of variables we mostly only use
45/// DebugVariables as identities of variables. It's much more compile-time
46/// efficient to use an ID number instead, which this class provides.
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});
63 return Size;
64 }
65
66 return ItPair.first->second;
67 }
68
69 const VarAndLoc &lookupDVID(DebugVariableID ID) const { return IdxToVar[ID]; }
70
71 void clear() {
72 VarToIdx.clear();
73 IdxToVar.clear();
74 }
75};
76
77/// Handle-class for a particular "location". This value-type uniquely
78/// symbolises a register or stack location, allowing manipulation of locations
79/// without concern for where that location is. Practically, this allows us to
80/// treat the state of the machine at a particular point as an array of values,
81/// rather than a map of values.
82class LocIdx {
83 unsigned Location;
84
85 // Default constructor is private, initializing to an illegal location number.
86 // Use only for "not an entry" elements in IndexedMaps.
87 LocIdx() : Location(UINT_MAX) {}
88
89public:
90#define NUM_LOC_BITS 24
91 LocIdx(unsigned L) : Location(L) {
92 assert(L < (1 << NUM_LOC_BITS) && "Machine locations must fit in 24 bits");
93 }
94
95 static LocIdx MakeIllegalLoc() { return LocIdx(); }
96
97 bool isIllegal() const { return Location == UINT_MAX; }
98
99 uint64_t asU64() const { return Location; }
100
101 bool operator==(unsigned L) const { return Location == L; }
102
103 bool operator==(const LocIdx &L) const { return Location == L.Location; }
104
105 bool operator!=(unsigned L) const { return !(*this == L); }
106
107 bool operator!=(const LocIdx &L) const { return !(*this == L); }
108
109 bool operator<(const LocIdx &Other) const {
110 return Location < Other.Location;
111 }
112};
113
114// The location at which a spilled value resides. It consists of a register and
115// an offset.
116struct SpillLoc {
117 unsigned SpillBase;
119 bool operator==(const SpillLoc &Other) const {
120 return std::make_pair(SpillBase, SpillOffset) ==
121 std::make_pair(Other.SpillBase, Other.SpillOffset);
122 }
123 bool operator<(const SpillLoc &Other) const {
124 return std::make_tuple(SpillBase, SpillOffset.getFixed(),
125 SpillOffset.getScalable()) <
126 std::make_tuple(Other.SpillBase, Other.SpillOffset.getFixed(),
127 Other.SpillOffset.getScalable());
128 }
129};
130
131/// Unique identifier for a value defined by an instruction, as a value type.
132/// Casts back and forth to a uint64_t. Probably replacable with something less
133/// bit-constrained. Each value identifies the instruction and machine location
134/// where the value is defined, although there may be no corresponding machine
135/// operand for it (ex: regmasks clobbering values). The instructions are
136/// one-based, and definitions that are PHIs have instruction number zero.
137///
138/// The obvious limits of a 1M block function or 1M instruction blocks are
139/// problematic; but by that point we should probably have bailed out of
140/// trying to analyse the function.
142 union {
143 struct {
144 uint64_t BlockNo : 20; /// The block where the def happens.
145 uint64_t InstNo : 20; /// The Instruction where the def happens.
146 /// One based, is distance from start of block.
148 : NUM_LOC_BITS; /// The machine location where the def happens.
149 } s;
151 } u;
152
153 static_assert(sizeof(u) == 8, "Badly packed ValueIDNum?");
154
155public:
156 // Default-initialize to EmptyValue. This is necessary to make IndexedMaps
157 // of values to work.
158 ValueIDNum() { u.Value = EmptyValue.asU64(); }
159
161 u.s = {Block, Inst, Loc};
162 }
163
165 u.s = {Block, Inst, Loc.asU64()};
166 }
167
168 uint64_t getBlock() const { return u.s.BlockNo; }
169 uint64_t getInst() const { return u.s.InstNo; }
170 uint64_t getLoc() const { return u.s.LocNo; }
171 bool isPHI() const { return u.s.InstNo == 0; }
172
173 uint64_t asU64() const { return u.Value; }
174
176 ValueIDNum Val;
177 Val.u.Value = v;
178 return Val;
179 }
180
181 bool operator<(const ValueIDNum &Other) const {
182 return asU64() < Other.asU64();
183 }
184
185 bool operator==(const ValueIDNum &Other) const {
186 return u.Value == Other.u.Value;
187 }
188
189 bool operator!=(const ValueIDNum &Other) const { return !(*this == Other); }
190
191 std::string asString(const std::string &mlocname) const {
192 return Twine("Value{bb: ")
193 .concat(Twine(u.s.BlockNo)
194 .concat(Twine(", inst: ")
195 .concat((u.s.InstNo ? Twine(u.s.InstNo)
196 : Twine("live-in"))
197 .concat(Twine(", loc: ").concat(
198 Twine(mlocname)))
199 .concat(Twine("}")))))
200 .str();
201 }
202
204};
205
206} // End namespace LiveDebugValues
207
208namespace llvm {
209using namespace LiveDebugValues;
210
211template <> struct DenseMapInfo<LocIdx> {
212 static inline LocIdx getEmptyKey() { return LocIdx::MakeIllegalLoc(); }
213
214 static unsigned getHashValue(const LocIdx &Loc) { return Loc.asU64(); }
215
216 static bool isEqual(const LocIdx &A, const LocIdx &B) { return A == B; }
217};
218
219template <> struct DenseMapInfo<ValueIDNum> {
221
222 static unsigned getHashValue(const ValueIDNum &Val) {
223 return hash_value(Val.asU64());
224 }
225
226 static bool isEqual(const ValueIDNum &A, const ValueIDNum &B) {
227 return A == B;
228 }
229};
230
231} // end namespace llvm
232
233namespace LiveDebugValues {
234using namespace llvm;
235
236/// Type for a table of values in a block.
238
239/// A collection of ValueTables, one per BB in a function, with convenient
240/// accessor methods.
242 FuncValueTable(int NumBBs, int NumLocs) {
243 Storage.reserve(NumBBs);
244 for (int i = 0; i != NumBBs; ++i)
245 Storage.push_back(
246 std::make_unique<ValueTable>(NumLocs, ValueIDNum::EmptyValue));
247 }
248
249 /// Returns the ValueTable associated with MBB.
251 return (*this)[MBB.getNumber()];
252 }
253
254 /// Returns the ValueTable associated with the MachineBasicBlock whose number
255 /// is MBBNum.
256 ValueTable &operator[](int MBBNum) const {
257 auto &TablePtr = Storage[MBBNum];
258 assert(TablePtr && "Trying to access a deleted table");
259 return *TablePtr;
260 }
261
262 /// Returns the ValueTable associated with the entry MachineBasicBlock.
263 ValueTable &tableForEntryMBB() const { return (*this)[0]; }
264
265 /// Returns true if the ValueTable associated with MBB has not been freed.
267 return Storage[MBB.getNumber()] != nullptr;
268 }
269
270 /// Frees the memory of the ValueTable associated with MBB.
272 Storage[MBB.getNumber()].reset();
273 }
274
275private:
276 /// ValueTables are stored as unique_ptrs to allow for deallocation during
277 /// LDV; this was measured to have a significant impact on compiler memory
278 /// usage.
280};
281
282/// Thin wrapper around an integer -- designed to give more type safety to
283/// spill location numbers.
285public:
286 explicit SpillLocationNo(unsigned SpillNo) : SpillNo(SpillNo) {}
287 unsigned SpillNo;
288 unsigned id() const { return SpillNo; }
289
290 bool operator<(const SpillLocationNo &Other) const {
291 return SpillNo < Other.SpillNo;
292 }
293
294 bool operator==(const SpillLocationNo &Other) const {
295 return SpillNo == Other.SpillNo;
296 }
297 bool operator!=(const SpillLocationNo &Other) const {
298 return !(*this == Other);
299 }
300};
301
302/// Meta qualifiers for a value. Pair of whatever expression is used to qualify
303/// the value, and Boolean of whether or not it's indirect.
305public:
308
309 /// Extract properties from an existing DBG_VALUE instruction.
311 assert(MI.isDebugValue());
312 assert(MI.getDebugExpression()->getNumLocationOperands() == 0 ||
313 MI.isDebugValueList() || MI.isUndefDebugValue());
314 IsVariadic = MI.isDebugValueList();
315 DIExpr = MI.getDebugExpression();
316 Indirect = MI.isDebugOffsetImm();
317 }
318
321 Other.Indirect);
322 }
323
325 return std::tie(DIExpr, Indirect, IsVariadic) ==
326 std::tie(Other.DIExpr, Other.Indirect, Other.IsVariadic);
327 }
328
330 return !(*this == Other);
331 }
332
333 unsigned getLocationOpCount() const {
334 return IsVariadic ? DIExpr->getNumLocationOperands() : 1;
335 }
336
340};
341
342/// TODO: Might pack better if we changed this to a Struct of Arrays, since
343/// MachineOperand is width 32, making this struct width 33. We could also
344/// potentially avoid storing the whole MachineOperand (sizeof=32), instead
345/// choosing to store just the contents portion (sizeof=8) and a Kind enum,
346/// since we already know it is some type of immediate value.
347/// Stores a single debug operand, which can either be a MachineOperand for
348/// directly storing immediate values, or a ValueIDNum representing some value
349/// computed at some point in the program. IsConst is used as a discriminator.
350struct DbgOp {
351 union {
354 };
356
357 DbgOp() : ID(ValueIDNum::EmptyValue), IsConst(false) {}
360
361 bool isUndef() const { return !IsConst && ID == ValueIDNum::EmptyValue; }
362
363#ifndef NDEBUG
364 void dump(const MLocTracker *MTrack) const;
365#endif
366};
367
368/// A DbgOp whose ID (if any) has resolved to an actual location, LocIdx. Used
369/// when working with concrete debug values, i.e. when joining MLocs and VLocs
370/// in the TransferTracker or emitting DBG_VALUE/DBG_VALUE_LIST instructions in
371/// the MLocTracker.
373 union {
376 };
378
381
382 bool operator==(const ResolvedDbgOp &Other) const {
383 if (IsConst != Other.IsConst)
384 return false;
385 if (IsConst)
386 return MO.isIdenticalTo(Other.MO);
387 return Loc == Other.Loc;
388 }
389
390#ifndef NDEBUG
391 void dump(const MLocTracker *MTrack) const;
392#endif
393};
394
395/// An ID used in the DbgOpIDMap (below) to lookup a stored DbgOp. This is used
396/// in place of actual DbgOps inside of a DbgValue to reduce its size, as
397/// DbgValue is very frequently used and passed around, and the actual DbgOp is
398/// over 8x larger than this class, due to storing a MachineOperand. This ID
399/// should be equal for all equal DbgOps, and also encodes whether the mapped
400/// DbgOp is a constant, meaning that for simple equality or const-ness checks
401/// it is not necessary to lookup this ID.
402struct DbgOpID {
407
408 union {
411 };
412
414 static_assert(sizeof(DbgOpID) == 4, "DbgOpID should fit within 4 bytes.");
415 }
417 DbgOpID(bool IsConst, uint32_t Index) : ID({IsConst, Index}) {}
418
420
421 bool operator==(const DbgOpID &Other) const { return RawID == Other.RawID; }
422 bool operator!=(const DbgOpID &Other) const { return !(*this == Other); }
423
424 uint32_t asU32() const { return RawID; }
425
426 bool isUndef() const { return *this == UndefID; }
427 bool isConst() const { return ID.IsConst && !isUndef(); }
428 uint32_t getIndex() const { return ID.Index; }
429
430#ifndef NDEBUG
431 void dump(const MLocTracker *MTrack, const DbgOpIDMap *OpStore) const;
432#endif
433};
434
435/// Class storing the complete set of values that are observed by DbgValues
436/// within the current function. Allows 2-way lookup, with `find` returning the
437/// Op for a given ID and `insert` returning the ID for a given Op (creating one
438/// if none exists).
440
443
446
447public:
448 /// If \p Op does not already exist in this map, it is inserted and the
449 /// corresponding DbgOpID is returned. If Op already exists in this map, then
450 /// no change is made and the existing ID for Op is returned.
451 /// Calling this with the undef DbgOp will always return DbgOpID::UndefID.
453 if (Op.isUndef())
454 return DbgOpID::UndefID;
455 if (Op.IsConst)
456 return insertConstOp(Op.MO);
457 return insertValueOp(Op.ID);
458 }
459 /// Returns the DbgOp associated with \p ID. Should only be used for IDs
460 /// returned from calling `insert` from this map or DbgOpID::UndefID.
462 if (ID == DbgOpID::UndefID)
463 return DbgOp();
464 if (ID.isConst())
465 return DbgOp(ConstOps[ID.getIndex()]);
466 return DbgOp(ValueOps[ID.getIndex()]);
467 }
468
469 void clear() {
470 ValueOps.clear();
471 ConstOps.clear();
472 ValueOpToID.clear();
473 ConstOpToID.clear();
474 }
475
476private:
477 DbgOpID insertConstOp(MachineOperand &MO) {
478 auto [It, Inserted] = ConstOpToID.try_emplace(MO, true, ConstOps.size());
479 if (Inserted)
480 ConstOps.push_back(MO);
481 return It->second;
482 }
483 DbgOpID insertValueOp(ValueIDNum VID) {
484 auto [It, Inserted] = ValueOpToID.try_emplace(VID, false, ValueOps.size());
485 if (Inserted)
486 ValueOps.push_back(VID);
487 return It->second;
488 }
489};
490
491// We set the maximum number of operands that we will handle to keep DbgValue
492// within a reasonable size (64 bytes), as we store and pass a lot of them
493// around.
494#define MAX_DBG_OPS 8
495
496/// Class recording the (high level) _value_ of a variable. Identifies the value
497/// of the variable as a list of ValueIDNums and constant MachineOperands, or as
498/// an empty list for undef debug values or VPHI values which we have not found
499/// valid locations for.
500/// This class also stores meta-information about how the value is qualified.
501/// Used to reason about variable values when performing the second
502/// (DebugVariable specific) dataflow analysis.
503class DbgValue {
504private:
505 /// If Kind is Def or VPHI, the set of IDs corresponding to the DbgOps that
506 /// are used. VPHIs set every ID to EmptyID when we have not found a valid
507 /// machine-value for every operand, and sets them to the corresponding
508 /// machine-values when we have found all of them.
509 DbgOpID DbgOps[MAX_DBG_OPS];
510 unsigned OpCount;
511
512public:
513 /// For a NoVal or VPHI DbgValue, which block it was generated in.
515
516 /// Qualifiers for the ValueIDNum above.
518
519 typedef enum {
520 Undef, // Represents a DBG_VALUE $noreg in the transfer function only.
521 Def, // This value is defined by some combination of constants,
522 // instructions, or PHI values.
523 VPHI, // Incoming values to BlockNo differ, those values must be joined by
524 // a PHI in this block.
525 NoVal, // Empty DbgValue indicating an unknown value. Used as initializer,
526 // before dominating blocks values are propagated in.
527 } KindT;
528 /// Discriminator for whether this is a constant or an in-program value.
530
532 : OpCount(DbgOps.size()), BlockNo(0), Properties(Prop), Kind(Def) {
533 static_assert(sizeof(DbgValue) <= 64,
534 "DbgValue should fit within 64 bytes.");
535 assert(DbgOps.size() == Prop.getLocationOpCount());
536 if (DbgOps.size() > MAX_DBG_OPS ||
537 any_of(DbgOps, [](DbgOpID ID) { return ID.isUndef(); })) {
538 Kind = Undef;
539 OpCount = 0;
540#define DEBUG_TYPE "LiveDebugValues"
541 if (DbgOps.size() > MAX_DBG_OPS) {
542 LLVM_DEBUG(dbgs() << "Found DbgValue with more than maximum allowed "
543 "operands.\n");
544 }
545#undef DEBUG_TYPE
546 } else {
547 for (unsigned Idx = 0; Idx < DbgOps.size(); ++Idx)
548 this->DbgOps[Idx] = DbgOps[Idx];
549 }
550 }
551
553 : OpCount(0), BlockNo(BlockNo), Properties(Prop), Kind(Kind) {
554 assert(Kind == NoVal || Kind == VPHI);
555 }
556
558 : OpCount(0), BlockNo(0), Properties(Prop), Kind(Kind) {
559 assert(Kind == Undef &&
560 "Empty DbgValue constructor must pass in Undef kind");
561 }
562
563#ifndef NDEBUG
564 void dump(const MLocTracker *MTrack = nullptr,
565 const DbgOpIDMap *OpStore = nullptr) const;
566#endif
567
568 bool operator==(const DbgValue &Other) const {
569 if (std::tie(Kind, Properties) != std::tie(Other.Kind, Other.Properties))
570 return false;
571 else if (Kind == Def && !equal(getDbgOpIDs(), Other.getDbgOpIDs()))
572 return false;
573 else if (Kind == NoVal && BlockNo != Other.BlockNo)
574 return false;
575 else if (Kind == VPHI && BlockNo != Other.BlockNo)
576 return false;
577 else if (Kind == VPHI && !equal(getDbgOpIDs(), Other.getDbgOpIDs()))
578 return false;
579
580 return true;
581 }
582
583 bool operator!=(const DbgValue &Other) const { return !(*this == Other); }
584
585 // Returns an array of all the machine values used to calculate this variable
586 // value, or an empty list for an Undef or unjoined VPHI.
587 ArrayRef<DbgOpID> getDbgOpIDs() const { return {DbgOps, OpCount}; }
588
589 // Returns either DbgOps[Index] if this DbgValue has Debug Operands, or
590 // the ID for ValueIDNum::EmptyValue otherwise (i.e. if this is an Undef,
591 // NoVal, or an unjoined VPHI).
592 DbgOpID getDbgOpID(unsigned Index) const {
593 if (!OpCount)
594 return DbgOpID::UndefID;
595 assert(Index < OpCount);
596 return DbgOps[Index];
597 }
598 // Replaces this DbgValue's existing DbgOpIDs (if any) with the contents of
599 // \p NewIDs. The number of DbgOpIDs passed must be equal to the number of
600 // arguments expected by this DbgValue's properties (the return value of
601 // `getLocationOpCount()`).
603 // We can go from no ops to some ops, but not from some ops to no ops.
604 assert(NewIDs.size() == getLocationOpCount() &&
605 "Incorrect number of Debug Operands for this DbgValue.");
606 OpCount = NewIDs.size();
607 for (unsigned Idx = 0; Idx < NewIDs.size(); ++Idx)
608 DbgOps[Idx] = NewIDs[Idx];
609 }
610
611 // The number of debug operands expected by this DbgValue's expression.
612 // getDbgOpIDs() should return an array of this length, unless this is an
613 // Undef or an unjoined VPHI.
614 unsigned getLocationOpCount() const {
615 return Properties.getLocationOpCount();
616 }
617
618 // Returns true if this or Other are unjoined PHIs, which do not have defined
619 // Loc Ops, or if the `n`th Loc Op for this has a different constness to the
620 // `n`th Loc Op for Other.
621 bool hasJoinableLocOps(const DbgValue &Other) const {
622 if (isUnjoinedPHI() || Other.isUnjoinedPHI())
623 return true;
624 for (unsigned Idx = 0; Idx < getLocationOpCount(); ++Idx) {
625 if (getDbgOpID(Idx).isConst() != Other.getDbgOpID(Idx).isConst())
626 return false;
627 }
628 return true;
629 }
630
631 bool isUnjoinedPHI() const { return Kind == VPHI && OpCount == 0; }
632
634 if (!OpCount)
635 return false;
636 return equal(getDbgOpIDs(), Other.getDbgOpIDs());
637 }
638};
639
641public:
643 unsigned operator()(const LocIdx &L) const { return L.asU64(); }
644};
645
646/// Tracker for what values are in machine locations. Listens to the Things
647/// being Done by various instructions, and maintains a table of what machine
648/// locations have what values (as defined by a ValueIDNum).
649///
650/// There are potentially a much larger number of machine locations on the
651/// target machine than the actual working-set size of the function. On x86 for
652/// example, we're extremely unlikely to want to track values through control
653/// or debug registers. To avoid doing so, MLocTracker has several layers of
654/// indirection going on, described below, to avoid unnecessarily tracking
655/// any location.
656///
657/// Here's a sort of diagram of the indexes, read from the bottom up:
658///
659/// Size on stack Offset on stack
660/// \ /
661/// Stack Idx (Where in slot is this?)
662/// /
663/// /
664/// Slot Num (%stack.0) /
665/// FrameIdx => SpillNum /
666/// \ /
667/// SpillID (int) Register number (int)
668/// \ /
669/// LocationID => LocIdx
670/// |
671/// LocIdx => ValueIDNum
672///
673/// The aim here is that the LocIdx => ValueIDNum vector is just an array of
674/// values in numbered locations, so that later analyses can ignore whether the
675/// location is a register or otherwise. To map a register / spill location to
676/// a LocIdx, you have to use the (sparse) LocationID => LocIdx map. And to
677/// build a LocationID for a stack slot, you need to combine identifiers for
678/// which stack slot it is and where within that slot is being described.
679///
680/// Register mask operands cause trouble by technically defining every register;
681/// various hacks are used to avoid tracking registers that are never read and
682/// only written by regmasks.
684public:
689
690 /// IndexedMap type, mapping from LocIdx to ValueIDNum.
692
693 /// Map of LocIdxes to the ValueIDNums that they store. This is tightly
694 /// packed, entries only exist for locations that are being tracked.
696
697 /// "Map" of machine location IDs (i.e., raw register or spill number) to the
698 /// LocIdx key / number for that location. There are always at least as many
699 /// as the number of registers on the target -- if the value in the register
700 /// is not being tracked, then the LocIdx value will be zero. New entries are
701 /// appended if a new spill slot begins being tracked.
702 /// This, and the corresponding reverse map persist for the analysis of the
703 /// whole function, and is necessarying for decoding various vectors of
704 /// values.
705 std::vector<LocIdx> LocIDToLocIdx;
706
707 /// Inverse map of LocIDToLocIdx.
709
710 /// When clobbering register masks, we chose to not believe the machine model
711 /// and don't clobber SP. Do the same for SP aliases, and for efficiency,
712 /// keep a set of them here.
714
715 /// Unique-ification of spill. Used to number them -- their LocID number is
716 /// the index in SpillLocs minus one plus NumRegs.
718
719 // If we discover a new machine location, assign it an mphi with this
720 // block number.
721 unsigned CurBB = -1;
722
723 /// Cached local copy of the number of registers the target has.
724 unsigned NumRegs;
725
726 /// Number of slot indexes the target has -- distinct segments of a stack
727 /// slot that can take on the value of a subregister, when a super-register
728 /// is written to the stack.
729 unsigned NumSlotIdxes;
730
731 /// Collection of register mask operands that have been observed. Second part
732 /// of pair indicates the instruction that they happened in. Used to
733 /// reconstruct where defs happened if we start tracking a location later
734 /// on.
736
737 /// Pair for describing a position within a stack slot -- first the size in
738 /// bits, then the offset.
739 typedef std::pair<unsigned short, unsigned short> StackSlotPos;
740
741 /// Map from a size/offset pair describing a position in a stack slot, to a
742 /// numeric identifier for that position. Allows easier identification of
743 /// individual positions.
745
746 /// Inverse of StackSlotIdxes.
748
749 /// Iterator for locations and the values they contain. Dereferencing
750 /// produces a struct/pair containing the LocIdx key for this location,
751 /// and a reference to the value currently stored. Simplifies the process
752 /// of seeking a particular location.
754 LocToValueType &ValueMap;
755 LocIdx Idx;
756
757 public:
759 public:
761 const LocIdx Idx; /// Read-only index of this location.
762 ValueIDNum &Value; /// Reference to the stored value at this location.
763 };
764
766 : ValueMap(ValueMap), Idx(Idx) {}
767
768 bool operator==(const MLocIterator &Other) const {
769 assert(&ValueMap == &Other.ValueMap);
770 return Idx == Other.Idx;
771 }
772
773 bool operator!=(const MLocIterator &Other) const {
774 return !(*this == Other);
775 }
776
777 void operator++() { Idx = LocIdx(Idx.asU64() + 1); }
778
779 value_type operator*() { return value_type(Idx, ValueMap[LocIdx(Idx)]); }
780 };
781
783 const TargetRegisterInfo &TRI,
784 const TargetLowering &TLI);
785
786 /// Produce location ID number for a Register. Provides some small amount of
787 /// type safety.
788 /// \param Reg The register we're looking up.
789 unsigned getLocID(Register Reg) { return Reg.id(); }
790
791 /// Produce location ID number for a spill position.
792 /// \param Spill The number of the spill we're fetching the location for.
793 /// \param SpillSubReg Subregister within the spill we're addressing.
794 unsigned getLocID(SpillLocationNo Spill, unsigned SpillSubReg) {
795 unsigned short Size = TRI.getSubRegIdxSize(SpillSubReg);
796 unsigned short Offs = TRI.getSubRegIdxOffset(SpillSubReg);
797 return getLocID(Spill, {Size, Offs});
798 }
799
800 /// Produce location ID number for a spill position.
801 /// \param Spill The number of the spill we're fetching the location for.
802 /// \apram SpillIdx size/offset within the spill slot to be addressed.
803 unsigned getLocID(SpillLocationNo Spill, StackSlotPos Idx) {
804 unsigned SlotNo = Spill.id() - 1;
805 SlotNo *= NumSlotIdxes;
806 assert(StackSlotIdxes.contains(Idx));
807 SlotNo += StackSlotIdxes[Idx];
808 SlotNo += NumRegs;
809 return SlotNo;
810 }
811
812 /// Given a spill number, and a slot within the spill, calculate the ID number
813 /// for that location.
814 unsigned getSpillIDWithIdx(SpillLocationNo Spill, unsigned Idx) {
815 unsigned SlotNo = Spill.id() - 1;
816 SlotNo *= NumSlotIdxes;
817 SlotNo += Idx;
818 SlotNo += NumRegs;
819 return SlotNo;
820 }
821
822 /// Return the spill number that a location ID corresponds to.
824 assert(ID >= NumRegs);
825 ID -= NumRegs;
826 // Truncate away the index part, leaving only the spill number.
827 ID /= NumSlotIdxes;
828 return SpillLocationNo(ID + 1); // The UniqueVector is one-based.
829 }
830
831 /// Returns the spill-slot size/offs that a location ID corresponds to.
833 assert(ID >= NumRegs);
834 ID -= NumRegs;
835 unsigned Idx = ID % NumSlotIdxes;
836 return StackIdxesToPos.find(Idx)->second;
837 }
838
839 unsigned getNumLocs() const { return LocIdxToIDNum.size(); }
840
841 /// Reset all locations to contain a PHI value at the designated block. Used
842 /// sometimes for actual PHI values, othertimes to indicate the block entry
843 /// value (before any more information is known).
844 void setMPhis(unsigned NewCurBB) {
845 CurBB = NewCurBB;
846 for (auto Location : locations())
847 Location.Value = {CurBB, 0, Location.Idx};
848 }
849
850 /// Load values for each location from array of ValueIDNums. Take current
851 /// bbnum just in case we read a value from a hitherto untouched register.
852 void loadFromArray(ValueTable &Locs, unsigned NewCurBB) {
853 CurBB = NewCurBB;
854 // Iterate over all tracked locations, and load each locations live-in
855 // value into our local index.
856 for (auto Location : locations())
857 Location.Value = Locs[Location.Idx.asU64()];
858 }
859
860 /// Wipe any un-necessary location records after traversing a block.
861 void reset() {
862 // We could reset all the location values too; however either loadFromArray
863 // or setMPhis should be called before this object is re-used. Just
864 // clear Masks, they're definitely not needed.
865 Masks.clear();
866 }
867
868 /// Clear all data. Destroys the LocID <=> LocIdx map, which makes most of
869 /// the information in this pass uninterpretable.
870 void clear() {
871 reset();
872 LocIDToLocIdx.clear();
873 LocIdxToLocID.clear();
874 LocIdxToIDNum.clear();
875 // SpillLocs.reset(); XXX UniqueVector::reset assumes a SpillLoc casts from
876 // 0
877 SpillLocs = decltype(SpillLocs)();
878 StackSlotIdxes.clear();
879 StackIdxesToPos.clear();
880
882 }
883
884 /// Set a locaiton to a certain value.
885 void setMLoc(LocIdx L, ValueIDNum Num) {
886 assert(L.asU64() < LocIdxToIDNum.size());
887 LocIdxToIDNum[L] = Num;
888 }
889
890 /// Read the value of a particular location
892 assert(L.asU64() < LocIdxToIDNum.size());
893 return LocIdxToIDNum[L];
894 }
895
896 /// Create a LocIdx for an untracked register ID. Initialize it to either an
897 /// mphi value representing a live-in, or a recent register mask clobber.
899
901 LocIdx &Index = LocIDToLocIdx[ID];
902 if (Index.isIllegal())
903 Index = trackRegister(ID);
904 return Index;
905 }
906
907 /// Is register R currently tracked by MLocTracker?
909 LocIdx &Index = LocIDToLocIdx[R];
910 return !Index.isIllegal();
911 }
912
913 /// Record a definition of the specified register at the given block / inst.
914 /// This doesn't take a ValueIDNum, because the definition and its location
915 /// are synonymous.
916 void defReg(Register R, unsigned BB, unsigned Inst) {
917 unsigned ID = getLocID(R);
919 ValueIDNum ValueID = {BB, Inst, Idx};
920 LocIdxToIDNum[Idx] = ValueID;
921 }
922
923 /// Set a register to a value number. To be used if the value number is
924 /// known in advance.
925 void setReg(Register R, ValueIDNum ValueID) {
926 unsigned ID = getLocID(R);
928 LocIdxToIDNum[Idx] = ValueID;
929 }
930
932 unsigned ID = getLocID(R);
934 return LocIdxToIDNum[Idx];
935 }
936
937 /// Reset a register value to zero / empty. Needed to replicate the
938 /// VarLoc implementation where a copy to/from a register effectively
939 /// clears the contents of the source register. (Values can only have one
940 /// machine location in VarLocBasedImpl).
942 unsigned ID = getLocID(R);
943 LocIdx Idx = LocIDToLocIdx[ID];
945 }
946
947 /// Determine the LocIdx of an existing register.
949 unsigned ID = getLocID(R);
950 assert(ID < LocIDToLocIdx.size());
951 assert(LocIDToLocIdx[ID] != UINT_MAX); // Sentinel for IndexedMap.
952 return LocIDToLocIdx[ID];
953 }
954
955 /// Record a RegMask operand being executed. Defs any register we currently
956 /// track, stores a pointer to the mask in case we have to account for it
957 /// later.
958 void writeRegMask(const MachineOperand *MO, unsigned CurBB, unsigned InstID);
959
960 /// Find LocIdx for SpillLoc \p L, creating a new one if it's not tracked.
961 /// Returns std::nullopt when in scenarios where a spill slot could be
962 /// tracked, but we would likely run into resource limitations.
963 LLVM_ABI_FOR_TEST std::optional<SpillLocationNo>
965
966 // Get LocIdx of a spill ID.
967 LocIdx getSpillMLoc(unsigned SpillID) {
968 assert(LocIDToLocIdx[SpillID] != UINT_MAX); // Sentinel for IndexedMap.
969 return LocIDToLocIdx[SpillID];
970 }
971
972 /// Return true if Idx is a spill machine location.
973 bool isSpill(LocIdx Idx) const { return LocIdxToLocID[Idx] >= NumRegs; }
974
975 /// How large is this location (aka, how wide is a value defined there?).
976 unsigned getLocSizeInBits(LocIdx L) const {
977 unsigned ID = LocIdxToLocID[L];
978 if (!isSpill(L)) {
979 return TRI.getRegSizeInBits(Register(ID), MF.getRegInfo());
980 } else {
981 // The slot location on the stack is uninteresting, we care about the
982 // position of the value within the slot (which comes with a size).
984 return Pos.first;
985 }
986 }
987
989
993
994 /// Return a range over all locations currently tracked.
998
999 std::string LocIdxToName(LocIdx Idx) const;
1000
1001 std::string IDAsString(const ValueIDNum &Num) const;
1002
1003#ifndef NDEBUG
1004 LLVM_DUMP_METHOD void dump();
1005
1007#endif
1008
1009 /// Create a DBG_VALUE based on debug operands \p DbgOps. Qualify it with the
1010 /// information in \pProperties, for variable Var. Don't insert it anywhere,
1011 /// just return the builder for it.
1013 const DebugVariable &Var, const DILocation *DILoc,
1014 const DbgValueProperties &Properties);
1015};
1016
1017/// Types for recording sets of variable fragments that overlap. For a given
1018/// local variable, we record all other fragments of that variable that could
1019/// overlap it, to reduce search time.
1021 std::pair<const DILocalVariable *, DIExpression::FragmentInfo>;
1024
1025/// Collection of DBG_VALUEs observed when traversing a block. Records each
1026/// variable and the value the DBG_VALUE refers to. Requires the machine value
1027/// location dataflow algorithm to have run already, so that values can be
1028/// identified.
1030public:
1031 /// Ref to function-wide map of DebugVariable <=> ID-numbers.
1033 /// Map DebugVariable to the latest Value it's defined to have.
1034 /// Needs to be a MapVector because we determine order-in-the-input-MIR from
1035 /// the order in this container. (FIXME: likely no longer true as the ordering
1036 /// is now provided by DebugVariableMap).
1037 /// We only retain the last DbgValue in each block for each variable, to
1038 /// determine the blocks live-out variable value. The Vars container forms the
1039 /// transfer function for this block, as part of the dataflow analysis. The
1040 /// movement of values between locations inside of a block is handled at a
1041 /// much later stage, in the TransferTracker class.
1047
1048public:
1050 const DIExpression *EmptyExpr)
1052 EmptyProperties(EmptyExpr, false, false) {}
1053
1054 void defVar(const MachineInstr &MI, const DbgValueProperties &Properties,
1055 const SmallVectorImpl<DbgOpID> &DebugOps) {
1056 assert(MI.isDebugValueLike());
1057 DebugVariable Var(MI.getDebugVariable(), MI.getDebugExpression(),
1058 MI.getDebugLoc()->getInlinedAt());
1059 // Either insert or fetch an ID number for this variable.
1060 DebugVariableID VarID = DVMap.insertDVID(Var, MI.getDebugLoc().get());
1061 DbgValue Rec = (DebugOps.size() > 0)
1062 ? DbgValue(DebugOps, Properties)
1063 : DbgValue(Properties, DbgValue::Undef);
1064
1065 // Attempt insertion; overwrite if it's already mapped.
1066 Vars.insert_or_assign(VarID, Rec);
1067 Scopes[VarID] = MI.getDebugLoc().get();
1068
1069 considerOverlaps(Var, MI.getDebugLoc().get());
1070 }
1071
1073 auto Overlaps = OverlappingFragments.find(
1074 {Var.getVariable(), Var.getFragmentOrDefault()});
1075 if (Overlaps == OverlappingFragments.end())
1076 return;
1077
1078 // Otherwise: terminate any overlapped variable locations.
1079 for (auto FragmentInfo : Overlaps->second) {
1080 // The "empty" fragment is stored as DebugVariable::DefaultFragment, so
1081 // that it overlaps with everything, however its cannonical representation
1082 // in a DebugVariable is as "None".
1083 std::optional<DIExpression::FragmentInfo> OptFragmentInfo = FragmentInfo;
1084 if (DebugVariable::isDefaultFragment(FragmentInfo))
1085 OptFragmentInfo = std::nullopt;
1086
1087 DebugVariable Overlapped(Var.getVariable(), OptFragmentInfo,
1088 Var.getInlinedAt());
1089 // Produce an ID number for this overlapping fragment of a variable.
1090 DebugVariableID OverlappedID = DVMap.insertDVID(Overlapped, Loc);
1092
1093 // Attempt insertion; overwrite if it's already mapped.
1094 Vars.insert_or_assign(OverlappedID, Rec);
1095 Scopes[OverlappedID] = Loc;
1096 }
1097 }
1098
1099 void clear() {
1100 Vars.clear();
1101 Scopes.clear();
1102 }
1103};
1104
1105// XXX XXX docs
1107public:
1108 friend class ::InstrRefLDVTest;
1109
1111 using OptFragmentInfo = std::optional<DIExpression::FragmentInfo>;
1112
1113 // Helper while building OverlapMap, a map of all fragments seen for a given
1114 // DILocalVariable.
1117
1118 /// Machine location/value transfer function, a mapping of which locations
1119 /// are assigned which new values.
1121
1122 /// Live in/out structure for the variable values: a per-block map of
1123 /// variables to their values.
1125
1126 using VarAndLoc = std::pair<DebugVariableID, DbgValue>;
1127
1128 /// Type for a live-in value: the predecessor block, and its value.
1129 using InValueT = std::pair<MachineBasicBlock *, DbgValue *>;
1130
1131 /// Vector (per block) of a collection (inner smallvector) of live-ins.
1132 /// Used as the result type for the variable value dataflow problem.
1134
1135 /// Mapping from lexical scopes to a DILocation in that scope.
1137
1138 /// Mapping from lexical scopes to variables in that scope.
1141
1142 /// Mapping from lexical scopes to blocks where variables in that scope are
1143 /// assigned. Such blocks aren't necessarily "in" the lexical scope, it's
1144 /// just a block where an assignment happens.
1146
1147private:
1148 MachineDominatorTree *DomTree;
1149 const TargetRegisterInfo *TRI;
1150 const MachineRegisterInfo *MRI;
1151 const TargetInstrInfo *TII;
1152 const TargetFrameLowering *TFI;
1153 const MachineFrameInfo *MFI;
1154 BitVector CalleeSavedRegs;
1155 LexicalScopes LS;
1156
1157 // An empty DIExpression. Used default / placeholder DbgValueProperties
1158 // objects, as we can't have null expressions.
1159 const DIExpression *EmptyExpr;
1160
1161 /// Object to track machine locations as we step through a block. Could
1162 /// probably be a field rather than a pointer, as it's always used.
1163 MLocTracker *MTracker = nullptr;
1164
1165 /// Number of the current block LiveDebugValues is stepping through.
1166 unsigned CurBB = -1;
1167
1168 /// Number of the current instruction LiveDebugValues is evaluating.
1169 unsigned CurInst;
1170
1171 /// Variable tracker -- listens to DBG_VALUEs occurring as InstrRefBasedImpl
1172 /// steps through a block. Reads the values at each location from the
1173 /// MLocTracker object.
1174 VLocTracker *VTracker = nullptr;
1175
1176 /// Tracker for transfers, listens to DBG_VALUEs and transfers of values
1177 /// between locations during stepping, creates new DBG_VALUEs when values move
1178 /// location.
1179 TransferTracker *TTracker = nullptr;
1180
1181 /// Blocks which are artificial, i.e. blocks which exclusively contain
1182 /// instructions without DebugLocs, or with line 0 locations.
1183 SmallPtrSet<MachineBasicBlock *, 16> ArtificialBlocks;
1184
1185 // Mapping of blocks to and from their RPOT order.
1189
1190 /// Pair of MachineInstr, and its 1-based offset into the containing block.
1191 using InstAndNum = std::pair<const MachineInstr *, unsigned>;
1192 /// Map from debug instruction number to the MachineInstr labelled with that
1193 /// number, and its location within the function. Used to transform
1194 /// instruction numbers in DBG_INSTR_REFs into machine value numbers.
1195 std::map<uint64_t, InstAndNum> DebugInstrNumToInstr;
1196
1197 /// Record of where we observed a DBG_PHI instruction.
1198 class DebugPHIRecord {
1199 public:
1200 /// Instruction number of this DBG_PHI.
1201 uint64_t InstrNum;
1202 /// Block where DBG_PHI occurred.
1204 /// The value number read by the DBG_PHI -- or std::nullopt if it didn't
1205 /// refer to a value.
1206 std::optional<ValueIDNum> ValueRead;
1207 /// Register/Stack location the DBG_PHI reads -- or std::nullopt if it
1208 /// referred to something unexpected.
1209 std::optional<LocIdx> ReadLoc;
1210
1211 operator unsigned() const { return InstrNum; }
1212 };
1213
1214 /// Map from instruction numbers defined by DBG_PHIs to a record of what that
1215 /// DBG_PHI read and where. Populated and edited during the machine value
1216 /// location problem -- we use LLVMs SSA Updater to fix changes by
1217 /// optimizations that destroy PHI instructions.
1218 SmallVector<DebugPHIRecord, 32> DebugPHINumToValue;
1219
1220 // Map of overlapping variable fragments.
1221 OverlapMap OverlapFragments;
1222 VarToFragments SeenFragments;
1223
1224 /// Mapping of DBG_INSTR_REF instructions to their values, for those
1225 /// DBG_INSTR_REFs that call resolveDbgPHIs. These variable references solve
1226 /// a mini SSA problem caused by DBG_PHIs being cloned, this collection caches
1227 /// the result.
1228 DenseMap<std::pair<MachineInstr *, unsigned>, std::optional<ValueIDNum>>
1229 SeenDbgPHIs;
1230
1231 DbgOpIDMap DbgOpStore;
1232
1233 /// Mapping between DebugVariables and unique ID numbers. This is a more
1234 /// efficient way to represent the identity of a variable, versus a plain
1235 /// DebugVariable.
1236 DebugVariableMap DVMap;
1237
1238 /// True if we need to examine call instructions for stack clobbers. We
1239 /// normally assume that they don't clobber SP, but stack probes on Windows
1240 /// do.
1241 bool AdjustsStackInCalls = false;
1242
1243 /// If AdjustsStackInCalls is true, this holds the name of the target's stack
1244 /// probe function, which is the function we expect will alter the stack
1245 /// pointer.
1246 StringRef StackProbeSymbolName;
1247
1248 /// Tests whether this instruction is a spill to a stack slot.
1249 std::optional<SpillLocationNo> isSpillInstruction(const MachineInstr &MI,
1250 MachineFunction *MF);
1251
1252 /// Decide if @MI is a spill instruction and return true if it is. We use 2
1253 /// criteria to make this decision:
1254 /// - Is this instruction a store to a spill slot?
1255 /// - Is there a register operand that is both used and killed?
1256 /// TODO: Store optimization can fold spills into other stores (including
1257 /// other spills). We do not handle this yet (more than one memory operand).
1258 bool isLocationSpill(const MachineInstr &MI, MachineFunction *MF,
1259 unsigned &Reg);
1260
1261 /// If a given instruction is identified as a spill, return the spill slot
1262 /// and set \p Reg to the spilled register.
1263 std::optional<SpillLocationNo> isRestoreInstruction(const MachineInstr &MI,
1264 MachineFunction *MF,
1265 unsigned &Reg);
1266
1267 /// Given a spill instruction, extract the spill slot information, ensure it's
1268 /// tracked, and return the spill number.
1269 std::optional<SpillLocationNo>
1270 extractSpillBaseRegAndOffset(const MachineInstr &MI);
1271
1272 /// For an instruction reference given by \p InstNo and \p OpNo in instruction
1273 /// \p MI returns the Value pointed to by that instruction reference if any
1274 /// exists, otherwise returns std::nullopt.
1275 std::optional<ValueIDNum> getValueForInstrRef(unsigned InstNo, unsigned OpNo,
1277 const FuncValueTable *MLiveOuts,
1278 const FuncValueTable *MLiveIns);
1279
1280 /// Observe a single instruction while stepping through a block.
1281 void process(MachineInstr &MI, const FuncValueTable *MLiveOuts,
1282 const FuncValueTable *MLiveIns);
1283
1284 /// Examines whether \p MI is a DBG_VALUE and notifies trackers.
1285 /// \returns true if MI was recognized and processed.
1286 bool transferDebugValue(const MachineInstr &MI);
1287
1288 /// Examines whether \p MI is a DBG_INSTR_REF and notifies trackers.
1289 /// \returns true if MI was recognized and processed.
1290 bool transferDebugInstrRef(MachineInstr &MI, const FuncValueTable *MLiveOuts,
1291 const FuncValueTable *MLiveIns);
1292
1293 /// Stores value-information about where this PHI occurred, and what
1294 /// instruction number is associated with it.
1295 /// \returns true if MI was recognized and processed.
1296 bool transferDebugPHI(MachineInstr &MI);
1297
1298 /// Examines whether \p MI is copy instruction, and notifies trackers.
1299 /// \returns true if MI was recognized and processed.
1300 bool transferRegisterCopy(MachineInstr &MI);
1301
1302 /// Examines whether \p MI is stack spill or restore instruction, and
1303 /// notifies trackers. \returns true if MI was recognized and processed.
1304 bool transferSpillOrRestoreInst(MachineInstr &MI);
1305
1306 /// Examines \p MI for any registers that it defines, and notifies trackers.
1307 void transferRegisterDef(MachineInstr &MI);
1308
1309 /// Copy one location to the other, accounting for movement of subregisters
1310 /// too.
1311 void performCopy(Register Src, Register Dst);
1312
1313 void accumulateFragmentMap(MachineInstr &MI);
1314
1315 /// Determine the machine value number referred to by (potentially several)
1316 /// DBG_PHI instructions. Block duplication and tail folding can duplicate
1317 /// DBG_PHIs, shifting the position where values in registers merge, and
1318 /// forming another mini-ssa problem to solve.
1319 /// \p Here the position of a DBG_INSTR_REF seeking a machine value number
1320 /// \p InstrNum Debug instruction number defined by DBG_PHI instructions.
1321 /// \returns The machine value number at position Here, or std::nullopt.
1322 std::optional<ValueIDNum> resolveDbgPHIs(MachineFunction &MF,
1323 const FuncValueTable &MLiveOuts,
1324 const FuncValueTable &MLiveIns,
1325 MachineInstr &Here,
1326 uint64_t InstrNum);
1327
1328 std::optional<ValueIDNum> resolveDbgPHIsImpl(MachineFunction &MF,
1329 const FuncValueTable &MLiveOuts,
1330 const FuncValueTable &MLiveIns,
1331 MachineInstr &Here,
1332 uint64_t InstrNum);
1333
1334 /// Step through the function, recording register definitions and movements
1335 /// in an MLocTracker. Convert the observations into a per-block transfer
1336 /// function in \p MLocTransfer, suitable for using with the machine value
1337 /// location dataflow problem.
1339 produceMLocTransferFunction(MachineFunction &MF,
1341 unsigned MaxNumBlocks);
1342
1343 /// Solve the machine value location dataflow problem. Takes as input the
1344 /// transfer functions in \p MLocTransfer. Writes the output live-in and
1345 /// live-out arrays to the (initialized to zero) multidimensional arrays in
1346 /// \p MInLocs and \p MOutLocs. The outer dimension is indexed by block
1347 /// number, the inner by LocIdx.
1349 buildMLocValueMap(MachineFunction &MF, FuncValueTable &MInLocs,
1350 FuncValueTable &MOutLocs,
1351 SmallVectorImpl<MLocTransferMap> &MLocTransfer);
1352
1353 /// Examine the stack indexes (i.e. offsets within the stack) to find the
1354 /// basic units of interference -- like reg units, but for the stack.
1355 void findStackIndexInterference(SmallVectorImpl<unsigned> &Slots);
1356
1357 /// Install PHI values into the live-in array for each block, according to
1358 /// the IDF of each register.
1359 LLVM_ABI_FOR_TEST void placeMLocPHIs(
1361 FuncValueTable &MInLocs, SmallVectorImpl<MLocTransferMap> &MLocTransfer);
1362
1363 /// Propagate variable values to blocks in the common case where there's
1364 /// only one value assigned to the variable. This function has better
1365 /// performance as it doesn't have to find the dominance frontier between
1366 /// different assignments.
1367 void placePHIsForSingleVarDefinition(
1368 const SmallPtrSetImpl<MachineBasicBlock *> &InScopeBlocks,
1370 DebugVariableID Var, LiveInsT &Output);
1371
1372 /// Calculate the iterated-dominance-frontier for a set of defs, using the
1373 /// existing LLVM facilities for this. Works for a single "value" or
1374 /// machine/variable location.
1375 /// \p AllBlocks Set of blocks where we might consume the value.
1376 /// \p DefBlocks Set of blocks where the value/location is defined.
1377 /// \p PHIBlocks Output set of blocks where PHIs must be placed.
1378 void BlockPHIPlacement(const SmallPtrSetImpl<MachineBasicBlock *> &AllBlocks,
1379 const SmallPtrSetImpl<MachineBasicBlock *> &DefBlocks,
1381
1382 /// Perform a control flow join (lattice value meet) of the values in machine
1383 /// locations at \p MBB. Follows the algorithm described in the file-comment,
1384 /// reading live-outs of predecessors from \p OutLocs, the current live ins
1385 /// from \p InLocs, and assigning the newly computed live ins back into
1386 /// \p InLocs. \returns two bools -- the first indicates whether a change
1387 /// was made, the second whether a lattice downgrade occurred. If the latter
1388 /// is true, revisiting this block is necessary.
1389 bool mlocJoin(MachineBasicBlock &MBB,
1391 FuncValueTable &OutLocs, ValueTable &InLocs);
1392
1393 /// Produce a set of blocks that are in the current lexical scope. This means
1394 /// those blocks that contain instructions "in" the scope, blocks where
1395 /// assignments to variables in scope occur, and artificial blocks that are
1396 /// successors to any of the earlier blocks. See https://llvm.org/PR48091 for
1397 /// more commentry on what "in scope" means.
1398 /// \p DILoc A location in the scope that we're fetching blocks for.
1399 /// \p Output Set to put in-scope-blocks into.
1400 /// \p AssignBlocks Blocks known to contain assignments of variables in scope.
1401 void
1402 getBlocksForScope(const DILocation *DILoc,
1404 const SmallPtrSetImpl<MachineBasicBlock *> &AssignBlocks);
1405
1406 /// Solve the variable value dataflow problem, for a single lexical scope.
1407 /// Uses the algorithm from the file comment to resolve control flow joins
1408 /// using PHI placement and value propagation. Reads the locations of machine
1409 /// values from the \p MInLocs and \p MOutLocs arrays (see buildMLocValueMap)
1410 /// and reads the variable values transfer function from \p AllTheVlocs.
1411 /// Live-in and Live-out variable values are stored locally, with the live-ins
1412 /// permanently stored to \p Output once a fixedpoint is reached.
1413 /// \p VarsWeCareAbout contains a collection of the variables in \p Scope
1414 /// that we should be tracking.
1415 /// \p AssignBlocks contains the set of blocks that aren't in \p DILoc's
1416 /// scope, but which do contain DBG_VALUEs, which VarLocBasedImpl tracks
1417 /// locations through.
1419 buildVLocValueMap(const DILocation *DILoc,
1420 const SmallSet<DebugVariableID, 4> &VarsWeCareAbout,
1422 LiveInsT &Output, FuncValueTable &MOutLocs,
1423 FuncValueTable &MInLocs,
1424 SmallVectorImpl<VLocTracker> &AllTheVLocs);
1425
1426 /// Attempt to eliminate un-necessary PHIs on entry to a block. Examines the
1427 /// live-in values coming from predecessors live-outs, and replaces any PHIs
1428 /// already present in this blocks live-ins with a live-through value if the
1429 /// PHI isn't needed.
1430 /// \p LiveIn Old live-in value, overwritten with new one if live-in changes.
1431 /// \returns true if any live-ins change value, either from value propagation
1432 /// or PHI elimination.
1434 vlocJoin(MachineBasicBlock &MBB, LiveIdxT &VLOCOutLocs,
1436 DbgValue &LiveIn);
1437
1438 /// For the given block and live-outs feeding into it, try to find
1439 /// machine locations for each debug operand where all the values feeding
1440 /// into that operand join together.
1441 /// \returns true if a joined location was found for every value that needed
1442 /// to be joined.
1444 pickVPHILoc(SmallVectorImpl<DbgOpID> &OutValues, const MachineBasicBlock &MBB,
1445 const LiveIdxT &LiveOuts, FuncValueTable &MOutLocs,
1447
1448 std::optional<ValueIDNum> pickOperandPHILoc(
1449 unsigned DbgOpIdx, const MachineBasicBlock &MBB, const LiveIdxT &LiveOuts,
1450 FuncValueTable &MOutLocs,
1452
1453 /// Take collections of DBG_VALUE instructions stored in TTracker, and
1454 /// install them into their output blocks.
1455 bool emitTransfers();
1456
1457 /// Boilerplate computation of some initial sets, artifical blocks and
1458 /// RPOT block ordering.
1459 LLVM_ABI_FOR_TEST void initialSetup(MachineFunction &MF);
1460
1461 /// Produce a map of the last lexical scope that uses a block, using the
1462 /// scopes DFSOut number. Mapping is block-number to DFSOut.
1463 /// \p EjectionMap Pre-allocated vector in which to install the built ma.
1464 /// \p ScopeToDILocation Mapping of LexicalScopes to their DILocations.
1465 /// \p AssignBlocks Map of blocks where assignments happen for a scope.
1466 void makeDepthFirstEjectionMap(SmallVectorImpl<unsigned> &EjectionMap,
1467 const ScopeToDILocT &ScopeToDILocation,
1468 ScopeToAssignBlocksT &AssignBlocks);
1469
1470 /// When determining per-block variable values and emitting to DBG_VALUEs,
1471 /// this function explores by lexical scope depth. Doing so means that per
1472 /// block information can be fully computed before exploration finishes,
1473 /// allowing us to emit it and free data structures earlier than otherwise.
1474 /// It's also good for locality.
1475 bool depthFirstVLocAndEmit(
1476 unsigned MaxNumBlocks, const ScopeToDILocT &ScopeToDILocation,
1477 const ScopeToVarsT &ScopeToVars, ScopeToAssignBlocksT &ScopeToBlocks,
1478 LiveInsT &Output, FuncValueTable &MOutLocs, FuncValueTable &MInLocs,
1480 bool ShouldEmitDebugEntryValues);
1481
1482 bool ExtendRanges(MachineFunction &MF, MachineDominatorTree *DomTree,
1483 bool ShouldEmitDebugEntryValues, unsigned InputBBLimit,
1484 unsigned InputDbgValLimit) override;
1485
1486public:
1487 /// Default construct and initialize the pass.
1489
1491 void dump_mloc_transfer(const MLocTransferMap &mloc_transfer) const;
1492
1493 bool isCalleeSaved(LocIdx L) const;
1494 bool isCalleeSavedReg(Register R) const;
1495
1497 // Instruction must have a memory operand that's a stack slot, and isn't
1498 // aliased, meaning it's a spill from regalloc instead of a variable.
1499 // If it's aliased, we can't guarantee its value.
1500 if (!MI.hasOneMemOperand())
1501 return false;
1502 auto *MemOperand = *MI.memoperands_begin();
1503 return MemOperand->isStore() &&
1504 MemOperand->getPseudoValue() &&
1505 MemOperand->getPseudoValue()->kind() == PseudoSourceValue::FixedStack
1506 && !MemOperand->getPseudoValue()->isAliased(MFI);
1507 }
1508
1509 std::optional<LocIdx> findLocationForMemOperand(const MachineInstr &MI);
1510
1511 // Utility for unit testing, don't use directly.
1513 return DVMap;
1514 }
1515};
1516
1517} // namespace LiveDebugValues
1518
1519#endif /* LLVM_LIB_CODEGEN_LIVEDEBUGVALUES_INSTRREFBASEDLDV_H */
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock & MBB
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.
Definition Compiler.h:661
#define LLVM_ABI_FOR_TEST
Definition Compiler.h:218
This file defines the DenseMap class.
const HexagonInstrInfo * TII
IRTranslator LLVM IR MI
This file implements an indexed map.
#define NUM_LOC_BITS
#define MAX_DBG_OPS
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 Reg
Register const TargetRegisterInfo * TRI
Promote Memory to Register
Definition Mem2Reg.cpp:110
This file defines the SmallPtrSet class.
This file defines the SmallVector class.
#define LLVM_DEBUG(...)
Definition Debug.h:119
Class storing the complete set of values that are observed by DbgValues within the current function.
DbgOp find(DbgOpID ID) const
Returns the DbgOp associated with ID.
DbgOpID insert(DbgOp Op)
If Op does not already exist in this map, it is inserted and the corresponding DbgOpID is returned.
Meta qualifiers for a value.
bool operator==(const DbgValueProperties &Other) const
DbgValueProperties(const DIExpression *DIExpr, bool Indirect, bool IsVariadic)
DbgValueProperties(const MachineInstr &MI)
Extract properties from an existing DBG_VALUE instruction.
bool isJoinable(const DbgValueProperties &Other) const
bool operator!=(const DbgValueProperties &Other) const
Class recording the (high level) value of a variable.
int BlockNo
For a NoVal or VPHI DbgValue, which block it was generated in.
DbgValueProperties Properties
Qualifiers for the ValueIDNum above.
ArrayRef< DbgOpID > getDbgOpIDs() const
void setDbgOpIDs(ArrayRef< DbgOpID > NewIDs)
bool hasJoinableLocOps(const DbgValue &Other) const
void dump(const MLocTracker *MTrack=nullptr, const DbgOpIDMap *OpStore=nullptr) const
DbgValue(ArrayRef< DbgOpID > DbgOps, const DbgValueProperties &Prop)
DbgOpID getDbgOpID(unsigned Index) const
DbgValue(unsigned BlockNo, const DbgValueProperties &Prop, KindT Kind)
bool operator!=(const DbgValue &Other) const
DbgValue(const DbgValueProperties &Prop, KindT Kind)
KindT Kind
Discriminator for whether this is a constant or an in-program value.
unsigned getLocationOpCount() const
bool operator==(const DbgValue &Other) const
bool hasIdenticalValidLocOps(const DbgValue &Other) const
Mapping from DebugVariable to/from a unique identifying number.
const VarAndLoc & lookupDVID(DebugVariableID ID) const
DebugVariableID insertDVID(DebugVariable &Var, const DILocation *Loc)
DebugVariableID getDVID(const DebugVariable &Var) const
DenseMap< const LexicalScope *, const DILocation * > ScopeToDILocT
Mapping from lexical scopes to a DILocation in that scope.
DenseMap< const DILocalVariable *, SmallSet< FragmentInfo, 4 > > VarToFragments
std::optional< LocIdx > findLocationForMemOperand(const MachineInstr &MI)
std::pair< MachineBasicBlock *, DbgValue * > InValueT
Type for a live-in value: the predecessor block, and its value.
std::pair< DebugVariableID, DbgValue > VarAndLoc
SmallVector< SmallVector< VarAndLoc, 8 >, 8 > LiveInsT
Vector (per block) of a collection (inner smallvector) of live-ins.
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.
DIExpression::FragmentInfo FragmentInfo
DenseMap< const LexicalScope *, SmallSet< DebugVariableID, 4 > > ScopeToVarsT
Mapping from lexical scopes to variables in that scope.
std::optional< DIExpression::FragmentInfo > OptFragmentInfo
SmallDenseMap< const MachineBasicBlock *, DbgValue *, 16 > LiveIdxT
Live in/out structure for the variable values: a per-block map of variables to their values.
SmallDenseMap< LocIdx, ValueIDNum > MLocTransferMap
Machine location/value transfer function, a mapping of which locations are assigned which new values.
bool hasFoldedStackStore(const MachineInstr &MI)
LLVM_DUMP_METHOD void dump_mloc_transfer(const MLocTransferMap &mloc_transfer) const
unsigned operator()(const LocIdx &L) const
Handle-class for a particular "location".
bool operator!=(const LocIdx &L) const
bool operator<(const LocIdx &Other) const
static LocIdx MakeIllegalLoc()
bool operator!=(unsigned L) const
bool operator==(unsigned L) const
bool operator==(const LocIdx &L) const
ValueIDNum & Value
Read-only index of this location.
Iterator for locations and the values they contain.
bool operator!=(const MLocIterator &Other) const
MLocIterator(LocToValueType &ValueMap, LocIdx Idx)
bool operator==(const MLocIterator &Other) const
Tracker for what values are in machine locations.
unsigned getLocSizeInBits(LocIdx L) const
How large is this location (aka, how wide is a value defined there?).
bool isRegisterTracked(Register R)
Is register R currently tracked by MLocTracker?
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.
IndexedMap< unsigned, LocIdxToIndexFunctor > LocIdxToLocID
Inverse map of LocIDToLocIdx.
unsigned getSpillIDWithIdx(SpillLocationNo Spill, unsigned Idx)
Given a spill number, and a slot within the spill, calculate the ID number for that location.
unsigned getLocID(SpillLocationNo Spill, unsigned SpillSubReg)
Produce location ID number for a spill position.
iterator_range< MLocIterator > locations()
Return a range over all locations currently tracked.
unsigned getLocID(SpillLocationNo Spill, StackSlotPos Idx)
Produce location ID number for a spill position.
SmallSet< Register, 8 > SPAliases
When clobbering register masks, we chose to not believe the machine model and don't clobber SP.
unsigned getLocID(Register Reg)
Produce location ID number for a Register.
const TargetRegisterInfo & TRI
unsigned NumRegs
Cached local copy of the number of registers the target has.
DenseMap< StackSlotPos, unsigned > StackSlotIdxes
Map from a size/offset pair describing a position in a stack slot, to a numeric identifier for that p...
LocIdx lookupOrTrackRegister(unsigned ID)
void setReg(Register R, ValueIDNum ValueID)
Set a register to a value number.
SpillLocationNo locIDToSpill(unsigned ID) const
Return the spill number that a location ID corresponds to.
void reset()
Wipe any un-necessary location records after traversing a block.
DenseMap< unsigned, StackSlotPos > StackIdxesToPos
Inverse of StackSlotIdxes.
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.
const TargetInstrInfo & TII
bool isSpill(LocIdx Idx) const
Return true if Idx is a spill machine location.
LocIdx getRegMLoc(Register R)
Determine the LocIdx of an existing register.
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.
void setMLoc(LocIdx L, ValueIDNum Num)
Set a locaiton to a certain value.
LocToValueType LocIdxToIDNum
Map of LocIdxes to the ValueIDNums that they store.
std::vector< LocIdx > LocIDToLocIdx
"Map" of machine location IDs (i.e., raw register or spill number) to the LocIdx key / number for tha...
IndexedMap< ValueIDNum, LocIdxToIndexFunctor > LocToValueType
IndexedMap type, mapping from LocIdx to ValueIDNum.
SmallVector< std::pair< const MachineOperand *, unsigned >, 32 > Masks
Collection of register mask operands that have been observed.
unsigned NumSlotIdxes
Number of slot indexes the target has – distinct segments of a stack slot that can take on the value ...
UniqueVector< SpillLoc > SpillLocs
Unique-ification of spill.
ValueIDNum readMLoc(LocIdx L)
Read the value of a particular location.
void setMPhis(unsigned NewCurBB)
Reset all locations to contain a PHI value at the designated block.
ValueIDNum readReg(Register R)
void defReg(Register R, unsigned BB, unsigned Inst)
Record a definition of the specified register at the given block / inst.
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)
LLVM_DUMP_METHOD void dump_mloc_map()
StackSlotPos locIDToSpillIdx(unsigned ID) const
Returns the spill-slot size/offs that a location ID corresponds to.
LocIdx getSpillMLoc(unsigned SpillID)
std::string LocIdxToName(LocIdx Idx) const
Thin wrapper around an integer – designed to give more type safety to spill location numbers.
bool operator==(const SpillLocationNo &Other) const
bool operator!=(const SpillLocationNo &Other) const
bool operator<(const SpillLocationNo &Other) const
Collection of DBG_VALUEs observed when traversing a block.
const OverlapMap & OverlappingFragments
SmallDenseMap< DebugVariableID, const DILocation *, 8 > Scopes
SmallMapVector< DebugVariableID, DbgValue, 8 > Vars
Map DebugVariable to the latest Value it's defined to have.
void defVar(const MachineInstr &MI, const DbgValueProperties &Properties, const SmallVectorImpl< DbgOpID > &DebugOps)
void considerOverlaps(const DebugVariable &Var, const DILocation *Loc)
VLocTracker(DebugVariableMap &DVMap, const OverlapMap &O, const DIExpression *EmptyExpr)
DebugVariableMap & DVMap
Ref to function-wide map of DebugVariable <=> ID-numbers.
Unique identifier for a value defined by an instruction, as a value type.
uint64_t LocNo
The Instruction where the def happens.
ValueIDNum(uint64_t Block, uint64_t Inst, uint64_t Loc)
struct LiveDebugValues::ValueIDNum::@122243371010332366363270357367014132366357004151::@211331010212204211312147341360354163043131005174 s
bool operator==(const ValueIDNum &Other) const
bool operator<(const ValueIDNum &Other) const
static ValueIDNum fromU64(uint64_t v)
std::string asString(const std::string &mlocname) const
static LLVM_ABI_FOR_TEST ValueIDNum EmptyValue
ValueIDNum(uint64_t Block, uint64_t Inst, LocIdx Loc)
bool operator!=(const ValueIDNum &Other) const
uint64_t InstNo
The block where the def happens.
Tracker for converting machine value locations and variable values into variable locations (the outpu...
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
size_t size() const
Get the array size.
Definition ArrayRef.h:141
DWARF expression.
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)
Definition DenseMap.h:301
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.
Definition Register.h:20
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...
Definition SmallSet.h:134
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.
Definition TypeSize.h:30
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
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...
Definition Twine.h:82
LLVM_ABI std::string str() const
Return the twine contents as a std::string.
Definition Twine.cpp:17
Twine concat(const Twine &Suffix) const
Definition Twine.h:497
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.
DenseMap< FragmentOfVar, SmallVector< DIExpression::FragmentInfo, 1 > > OverlapMap
SmallVector< ValueIDNum, 0 > ValueTable
Type for a table of values in a block.
std::pair< const DILocalVariable *, DIExpression::FragmentInfo > FragmentOfVar
Types for recording sets of variable fragments that overlap.
std::pair< DebugVariable, const DILocation * > VarAndLoc
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition CallingConv.h:24
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.
Definition STLExtras.h:1668
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.
Definition STLExtras.h:1151
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1745
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition Debug.cpp:209
@ Other
Any other memory.
Definition ModRef.h:68
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.
Definition STLExtras.h:2145
An ID used in the DbgOpIDMap (below) to lookup a stored DbgOp.
bool operator==(const DbgOpID &Other) const
bool operator!=(const DbgOpID &Other) const
void dump(const MLocTracker *MTrack, const DbgOpIDMap *OpStore) const
DbgOpID(bool IsConst, uint32_t Index)
static LLVM_ABI_FOR_TEST DbgOpID UndefID
struct IsConstIndexPair ID
TODO: Might pack better if we changed this to a Struct of Arrays, since MachineOperand is width 32,...
void dump(const MLocTracker *MTrack) const
DbgOp(MachineOperand MO)
A collection of ValueTables, one per BB in a function, with convenient accessor methods.
ValueTable & operator[](int MBBNum) const
Returns the ValueTable associated with the MachineBasicBlock whose number is MBBNum.
void ejectTableForBlock(const MachineBasicBlock &MBB)
Frees the memory of the ValueTable associated with MBB.
ValueTable & tableForEntryMBB() const
Returns the ValueTable associated with the entry MachineBasicBlock.
FuncValueTable(int NumBBs, int NumLocs)
ValueTable & operator[](const MachineBasicBlock &MBB) const
Returns the ValueTable associated with MBB.
bool hasTableFor(MachineBasicBlock &MBB) const
Returns true if the ValueTable associated with MBB has not been freed.
bool operator==(const ResolvedDbgOp &Other) const
void dump(const MLocTracker *MTrack) const
bool operator<(const SpillLoc &Other) const
bool operator==(const SpillLoc &Other) const
static bool isEqual(const LocIdx &A, const LocIdx &B)
static unsigned getHashValue(const LocIdx &Loc)
static unsigned getHashValue(const ValueIDNum &Val)
static bool isEqual(const ValueIDNum &A, const ValueIDNum &B)
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.
Definition MapVector.h:334