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