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