LLVM 23.0.0git
DebugProgramInstruction.h
Go to the documentation of this file.
1//===-- llvm/DebugProgramInstruction.h - Stream of debug info ---*- C++ -*-===//
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// Data structures for storing variable assignment information in LLVM. In the
10// dbg.value design, a dbg.value intrinsic specifies the position in a block
11// a source variable take on an LLVM Value:
12//
13// %foo = add i32 1, %0
14// dbg.value(metadata i32 %foo, ...)
15// %bar = void call @ext(%foo);
16//
17// and all information is stored in the Value / Metadata hierarchy defined
18// elsewhere in LLVM. In the "DbgRecord" design, each instruction /may/ have a
19// connection with a DbgMarker, which identifies a position immediately before
20// the instruction, and each DbgMarker /may/ then have connections to DbgRecords
21// which record the variable assignment information. To illustrate:
22//
23// %foo = add i32 1, %0
24// ; foo->DebugMarker == nullptr
25// ;; There are no variable assignments / debug records "in front" of
26// ;; the instruction for %foo, therefore it has no DebugMarker.
27// %bar = void call @ext(%foo)
28// ; bar->DebugMarker = {
29// ; StoredDbgRecords = {
30// ; DbgVariableRecord(metadata i32 %foo, ...)
31// ; }
32// ; }
33// ;; There is a debug-info record in front of the %bar instruction,
34// ;; thus it points at a DbgMarker object. That DbgMarker contains a
35// ;; DbgVariableRecord in its ilist, storing the equivalent information
36// ;; to the dbg.value above: the Value, DILocalVariable, etc.
37//
38// This structure separates the two concerns of the position of the debug-info
39// in the function, and the Value that it refers to. It also creates a new
40// "place" in-between the Value / Metadata hierarchy where we can customise
41// storage and allocation techniques to better suite debug-info workloads.
42// NB: as of the initial prototype, none of that has actually been attempted
43// yet.
44//
45//===----------------------------------------------------------------------===//
46
47#ifndef LLVM_IR_DEBUGPROGRAMINSTRUCTION_H
48#define LLVM_IR_DEBUGPROGRAMINSTRUCTION_H
49
50#include "llvm/ADT/ilist.h"
51#include "llvm/ADT/ilist_node.h"
52#include "llvm/ADT/iterator.h"
54#include "llvm/IR/DebugLoc.h"
55#include "llvm/IR/Instruction.h"
59
60namespace llvm {
61
62class Instruction;
63class BasicBlock;
64class MDNode;
65class Module;
68class DbgLabelInst;
69class DIAssignID;
70class DbgMarker;
72class raw_ostream;
73
74/// A typed tracking MDNode reference that does not require a definition for its
75/// parameter type. Necessary to avoid including DebugInfoMetadata.h, which has
76/// a significant impact on compile times if included in this file.
77template <typename T> class DbgRecordParamRef {
79
80public:
81public:
82 DbgRecordParamRef() = default;
83
84 /// Construct from the templated type.
85 DbgRecordParamRef(const T *Param);
86
87 /// Construct from an \a MDNode.
88 ///
89 /// Note: if \c Param does not have the template type, a verifier check will
90 /// fail, and accessors will crash. However, construction from other nodes
91 /// is supported in order to handle forward references when reading textual
92 /// IR.
93 explicit DbgRecordParamRef(const MDNode *Param);
94
95 /// Get the underlying type.
96 ///
97 /// \pre !*this or \c isa<T>(getAsMDNode()).
98 /// @{
99 T *get() const;
100 operator T *() const { return get(); }
101 T *operator->() const { return get(); }
102 T &operator*() const { return *get(); }
103 /// @}
104
105 /// Check for null.
106 ///
107 /// Check for null in a way that is safe with broken debug info.
108 explicit operator bool() const { return Ref; }
109
110 /// Return \c this as a \a MDNode.
111 MDNode *getAsMDNode() const { return Ref; }
112
113 bool operator==(const DbgRecordParamRef &Other) const {
114 return Ref == Other.Ref;
115 }
116 bool operator!=(const DbgRecordParamRef &Other) const {
117 return Ref != Other.Ref;
118 }
119};
120
124
125/// Base class for non-instruction debug metadata records that have positions
126/// within IR. Features various methods copied across from the Instruction
127/// class to aid ease-of-use. DbgRecords should always be linked into a
128/// DbgMarker's StoredDbgRecords list. The marker connects a DbgRecord back to
129/// its position in the BasicBlock.
130///
131/// We need a discriminator for dyn/isa casts. In order to avoid paying for a
132/// vtable for "virtual" functions too, subclasses must add a new discriminator
133/// value (RecordKind) and cases to a few functions in the base class:
134/// deleteRecord
135/// clone
136/// isIdenticalToWhenDefined
137/// both print methods
138/// createDebugIntrinsic
140public:
141 /// Marker that this DbgRecord is linked into.
142 DbgMarker *Marker = nullptr;
143 /// Subclass discriminator.
145
146protected:
148 Kind RecordKind; ///< Subclass discriminator.
149
150public:
153
154 /// Methods that dispatch to subclass implementations. These need to be
155 /// manually updated when a new subclass is added.
156 ///@{
157 LLVM_ABI void deleteRecord();
158 LLVM_ABI DbgRecord *clone() const;
159 LLVM_ABI void print(raw_ostream &O, bool IsForDebug = false) const;
161 bool IsForDebug) const;
162 LLVM_ABI bool isIdenticalToWhenDefined(const DbgRecord &R) const;
163 /// Convert this DbgRecord back into an appropriate llvm.dbg.* intrinsic.
164 /// \p InsertBefore Optional position to insert this intrinsic.
165 /// \returns A new llvm.dbg.* intrinsic representing this DbgRecord.
167 createDebugIntrinsic(Module *M, Instruction *InsertBefore) const;
168 ///@}
169
170 /// Same as isIdenticalToWhenDefined but checks DebugLoc too.
171 LLVM_ABI bool isEquivalentTo(const DbgRecord &R) const;
172
173 Kind getRecordKind() const { return RecordKind; }
174
175 void setMarker(DbgMarker *M) { Marker = M; }
176
178 const DbgMarker *getMarker() const { return Marker; }
179
180 LLVM_ABI BasicBlock *getBlock();
181 LLVM_ABI const BasicBlock *getBlock() const;
182
184 LLVM_ABI const Function *getFunction() const;
185
186 LLVM_ABI Module *getModule();
187 LLVM_ABI const Module *getModule() const;
188
189 LLVM_ABI LLVMContext &getContext();
190 LLVM_ABI const LLVMContext &getContext() const;
191
192 LLVM_ABI Instruction *getInstruction();
193 LLVM_ABI const Instruction *getInstruction() const;
194
196 LLVM_ABI const BasicBlock *getParent() const;
197
198 LLVM_ABI void removeFromParent();
199 LLVM_ABI void eraseFromParent();
200
201 DbgRecord *getNextNode() { return &*std::next(getIterator()); }
202 DbgRecord *getPrevNode() { return &*std::prev(getIterator()); }
203
204 // Some generic lambdas supporting intrinsic-based debug-info mean we need
205 // to support both iterator and instruction position based insertion.
206 LLVM_ABI void insertBefore(DbgRecord *InsertBefore);
207 LLVM_ABI void insertAfter(DbgRecord *InsertAfter);
208 LLVM_ABI void moveBefore(DbgRecord *MoveBefore);
209 LLVM_ABI void moveAfter(DbgRecord *MoveAfter);
210
211 LLVM_ABI void insertBefore(self_iterator InsertBefore);
212 LLVM_ABI void insertAfter(self_iterator InsertAfter);
213 LLVM_ABI void moveBefore(self_iterator MoveBefore);
214 LLVM_ABI void moveAfter(self_iterator MoveAfter);
215
216 DebugLoc getDebugLoc() const { return DbgLoc; }
217 void setDebugLoc(DebugLoc Loc) { DbgLoc = std::move(Loc); }
218
219 LLVM_ABI void dump() const;
220
223
224protected:
225 /// Similarly to Value, we avoid paying the cost of a vtable
226 /// by protecting the dtor and having deleteRecord dispatch
227 /// cleanup.
228 /// Use deleteRecord to delete a generic record.
229 ~DbgRecord() = default;
230};
231
233 R.print(OS);
234 return OS;
235}
236
237/// Records a position in IR for a source label (DILabel). Corresponds to the
238/// llvm.dbg.label intrinsic.
239class DbgLabelRecord : public DbgRecord {
241
242 /// This constructor intentionally left private, so that it is only called via
243 /// "createUnresolvedDbgLabelRecord", which clearly expresses that it is for
244 /// parsing only.
245 DbgLabelRecord(MDNode *Label);
246
247public:
248 LLVM_ABI DbgLabelRecord(DILabel *Label, DebugLoc DL);
249
250 /// For use during parsing; creates a DbgLabelRecord from as-of-yet unresolved
251 /// MDNodes. Trying to access the resulting DbgLabelRecord's fields before
252 /// they are resolved, or if they resolve to the wrong type, will result in a
253 /// crash.
254 LLVM_ABI static DbgLabelRecord *createUnresolvedDbgLabelRecord(MDNode *Label);
255
256 LLVM_ABI DbgLabelRecord *clone() const;
257 LLVM_ABI void print(raw_ostream &O, bool IsForDebug = false) const;
259 bool IsForDebug) const;
261 Instruction *InsertBefore) const;
262
263 void setLabel(DILabel *NewLabel) { Label = NewLabel; }
264 DILabel *getLabel() const { return Label.get(); }
265 MDNode *getRawLabel() const { return Label.getAsMDNode(); };
266
267 /// Support type inquiry through isa, cast, and dyn_cast.
268 static bool classof(const DbgRecord *E) {
269 return E->getRecordKind() == LabelKind;
270 }
271};
272
273/// Record of a variable value-assignment, aka a non instruction representation
274/// of the dbg.value intrinsic.
275///
276/// This class inherits from DebugValueUser to allow LLVM's metadata facilities
277/// to update our references to metadata beneath our feet.
278class DbgVariableRecord : public DbgRecord, protected DebugValueUser {
279 friend class DebugValueUser;
280
281public:
282 enum class LocationType : uint8_t {
287
288 End, ///< Marks the end of the concrete types.
289 Any, ///< To indicate all LocationTypes in searches.
290 };
291 /// Classification of the debug-info record that this DbgVariableRecord
292 /// represents. Essentially, "does this correspond to a dbg.value,
293 /// dbg.declare, or dbg.assign?".
294 /// FIXME: We could use spare padding bits from DbgRecord for this.
296
297 // NB: there is no explicit "Value" field in this class, it's effectively the
298 // DebugValueUser superclass instead. The referred to Value can either be a
299 // ValueAsMetadata or a DIArgList.
300
304
305public:
306 /// Create a new DbgVariableRecord representing the intrinsic \p DVI, for
307 /// example the assignment represented by a dbg.value.
310 /// Directly construct a new DbgVariableRecord representing a dbg.value
311 /// intrinsic assigning \p Location to the DV / Expr / DI variable.
313 DIExpression *Expr, const DILocation *DI,
318 const DILocation *DI);
319
320private:
321 /// Private constructor for creating new instances during parsing only. Only
322 /// called through `createUnresolvedDbgVariableRecord` below, which makes
323 /// clear that this is used for parsing only, and will later return a subclass
324 /// depending on which Type is passed.
328
329public:
330 /// Used to create DbgVariableRecords during parsing, where some metadata
331 /// references may still be unresolved. Although for some fields a generic
332 /// `Metadata*` argument is accepted for forward type-references, the verifier
333 /// and accessors will reject incorrect types later on. The function is used
334 /// for all types of DbgVariableRecords for simplicity while parsing, but
335 /// asserts if any necessary fields are empty or unused fields are not empty,
336 /// i.e. if the #dbg_assign fields are used for a non-dbg-assign type.
340
345 const DILocation *DI);
347 createLinkedDVRAssign(Instruction *LinkedInstr, Value *Val,
350 const DILocation *DI);
351
354 DIExpression *Expr, const DILocation *DI);
357 DIExpression *Expr, const DILocation *DI,
358 DbgVariableRecord &InsertBefore);
360 DILocalVariable *DV,
361 DIExpression *Expr,
362 const DILocation *DI);
365 const DILocation *DI, DbgVariableRecord &InsertBefore);
366
369 const DILocation *DI);
372 const DILocation *DI, DbgVariableRecord &InsertBefore);
373
374 /// Iterator for ValueAsMetadata that internally uses direct pointer iteration
375 /// over either a ValueAsMetadata* or a ValueAsMetadata**, dereferencing to the
376 /// ValueAsMetadata .
379 std::bidirectional_iterator_tag, Value *> {
381
382 public:
383 location_op_iterator(ValueAsMetadata *SingleIter) : I(SingleIter) {}
384 location_op_iterator(ValueAsMetadata **MultiIter) : I(MultiIter) {}
385
388 I = R.I;
389 return *this;
390 }
392 return I == RHS.I;
393 }
394 const Value *operator*() const {
398 return VAM->getValue();
399 };
407 if (auto *VAM = dyn_cast<ValueAsMetadata *>(I))
408 I = VAM + 1;
409 else
410 I = cast<ValueAsMetadata **>(I) + 1;
411 return *this;
412 }
414 if (auto *VAM = dyn_cast<ValueAsMetadata *>(I))
415 I = VAM - 1;
416 else
417 I = cast<ValueAsMetadata **>(I) - 1;
418 return *this;
419 }
420 };
421
422 bool isDbgDeclare() const { return Type == LocationType::Declare; }
423 bool isDbgValue() const { return Type == LocationType::Value; }
425
426 /// Get the locations corresponding to the variable referenced by the debug
427 /// info intrinsic. Depending on the intrinsic, this could be the
428 /// variable's value or its address.
430
431 LLVM_ABI Value *getVariableLocationOp(unsigned OpIdx) const;
432
433 LLVM_ABI void replaceVariableLocationOp(Value *OldValue, Value *NewValue,
434 bool AllowEmpty = false);
435 LLVM_ABI void replaceVariableLocationOp(unsigned OpIdx, Value *NewValue);
436 /// Adding a new location operand will always result in this intrinsic using
437 /// an ArgList, and must always be accompanied by a new expression that uses
438 /// the new operand.
439 LLVM_ABI void addVariableLocationOps(ArrayRef<Value *> NewValues,
441
442 LLVM_ABI unsigned getNumVariableLocationOps() const;
443
444 bool hasArgList() const { return isa<DIArgList>(getRawLocation()); }
445 /// Returns true if this DbgVariableRecord has no empty MDNodes in its
446 /// location list.
447 bool hasValidLocation() const { return getVariableLocationOp(0) != nullptr; }
448
449 /// Does this describe the address of a local variable. True for dbg.addr
450 /// and dbg.declare, but not dbg.value or dbg.declare_value, which describes
451 /// its value.
453
454 /// Determine if this describes the value of a local variable. It is false for
455 /// dbg.declare, but true for dbg.value and dbg.declare_value, which describes
456 /// its value.
460
461 LocationType getType() const { return Type; }
462
463 LLVM_ABI void setKillLocation();
464 LLVM_ABI bool isKillLocation() const;
465
466 void setVariable(DILocalVariable *NewVar) { Variable = NewVar; }
467 DILocalVariable *getVariable() const { return Variable.get(); };
468 MDNode *getRawVariable() const { return Variable.getAsMDNode(); }
469
471 DIExpression *getExpression() const { return Expression.get(); }
472 MDNode *getRawExpression() const { return Expression.getAsMDNode(); }
473
474 /// Returns the metadata operand for the first location description. i.e.,
475 /// dbg intrinsic dbg.value,declare operand and dbg.assign 1st location
476 /// operand (the "value componenet"). Note the operand (singular) may be
477 /// a DIArgList which is a list of values.
478 Metadata *getRawLocation() const { return DebugValues[0]; }
479
480 Value *getValue(unsigned OpIdx = 0) const {
482 }
483
484 /// Use of this should generally be avoided; instead,
485 /// replaceVariableLocationOp and addVariableLocationOps should be used where
486 /// possible to avoid creating invalid state.
487 void setRawLocation(Metadata *NewLocation) {
488 assert((isa<ValueAsMetadata>(NewLocation) || isa<DIArgList>(NewLocation) ||
489 isa<MDNode>(NewLocation)) &&
490 "Location for a DbgVariableRecord must be either ValueAsMetadata or "
491 "DIArgList");
492 resetDebugValue(0, NewLocation);
493 }
494
495 LLVM_ABI std::optional<DbgVariableFragmentInfo> getFragment() const;
496 /// Get the FragmentInfo for the variable if it exists, otherwise return a
497 /// FragmentInfo that covers the entire variable if the variable size is
498 /// known, otherwise return a zero-sized fragment.
500 if (auto Frag = getFragment())
501 return *Frag;
502 if (auto Sz = getFragmentSizeInBits())
503 return {*Sz, 0};
504 return {0, 0};
505 }
506 /// Get the size (in bits) of the variable, or fragment of the variable that
507 /// is described.
508 LLVM_ABI std::optional<uint64_t> getFragmentSizeInBits() const;
509
511 return DbgLoc == Other.DbgLoc && isIdenticalToWhenDefined(Other);
512 }
513 // Matches the definition of the Instruction version, equivalent to above but
514 // without checking DbgLoc.
516 return std::tie(Type, DebugValues, Variable, Expression,
518 std::tie(Other.Type, Other.DebugValues, Other.Variable,
519 Other.Expression, Other.AddressExpression);
520 }
521
522 /// @name DbgAssign Methods
523 /// @{
524 bool isDbgAssign() const { return getType() == LocationType::Assign; }
525
526 LLVM_ABI Value *getAddress() const;
528 return isDbgAssign() ? DebugValues[1] : DebugValues[0];
529 }
530 Metadata *getRawAssignID() const { return DebugValues[2]; }
531 LLVM_ABI DIAssignID *getAssignID() const;
534 return AddressExpression.getAsMDNode();
535 }
539 LLVM_ABI void setAssignId(DIAssignID *New);
541 /// Kill the address component.
542 LLVM_ABI void setKillAddress();
543 /// Check whether this kills the address component. This doesn't take into
544 /// account the position of the intrinsic, therefore a returned value of false
545 /// does not guarantee the address is a valid location for the variable at the
546 /// intrinsic's position in IR.
547 LLVM_ABI bool isKillAddress() const;
548
549 /// @}
550
551 LLVM_ABI DbgVariableRecord *clone() const;
552 /// Convert this DbgVariableRecord back into a dbg.value intrinsic.
553 /// \p InsertBefore Optional position to insert this intrinsic.
554 /// \returns A new dbg.value intrinsic representing this DbgVariableRecord.
556 createDebugIntrinsic(Module *M, Instruction *InsertBefore) const;
557
558 /// Handle changes to the location of the Value(s) that we refer to happening
559 /// "under our feet".
561
562 LLVM_ABI void print(raw_ostream &O, bool IsForDebug = false) const;
564 bool IsForDebug) const;
565
566 /// Support type inquiry through isa, cast, and dyn_cast.
567 static bool classof(const DbgRecord *E) {
568 return E->getRecordKind() == ValueKind;
569 }
570};
571
572/// Filter the DbgRecord range to DbgVariableRecord types only and downcast.
573static inline auto
580
581/// Per-instruction record of debug-info. If an Instruction is the position of
582/// some debugging information, it points at a DbgMarker storing that info. Each
583/// marker points back at the instruction that owns it. Various utilities are
584/// provided for manipulating the DbgRecords contained within this marker.
585///
586/// This class has a rough surface area, because it's needed to preserve the
587/// one arefact that we can't yet eliminate from the intrinsic / dbg.value
588/// debug-info design: the order of records is significant, and duplicates can
589/// exist. Thus, if one has a run of debug-info records such as:
590/// dbg.value(...
591/// %foo = barinst
592/// dbg.value(...
593/// and remove barinst, then the dbg.values must be preserved in the correct
594/// order. Hence, the use of iterators to select positions to insert things
595/// into, or the occasional InsertAtHead parameter indicating that new records
596/// should go at the start of the list.
597///
598/// There are only five or six places in LLVM that truly rely on this ordering,
599/// which we can improve in the future. Additionally, many improvements in the
600/// way that debug-info is stored can be achieved in this class, at a future
601/// date.
603public:
604 DbgMarker() = default;
605 /// Link back to the Instruction that owns this marker. Can be null during
606 /// operations that move a marker from one instruction to another.
608
609 /// List of DbgRecords, the non-instruction equivalent of llvm.dbg.*
610 /// intrinsics. There is a one-to-one relationship between each debug
611 /// intrinsic in a block and each DbgRecord once the representation has been
612 /// converted, and the ordering is meaningful in the same way.
614 bool empty() const { return StoredDbgRecords.empty(); }
615
616 LLVM_ABI const BasicBlock *getParent() const;
618
619 /// Handle the removal of a marker: the position of debug-info has gone away,
620 /// but the stored debug records should not. Drop them onto the next
621 /// instruction, or otherwise work out what to do with them.
622 LLVM_ABI void removeMarker();
623 LLVM_ABI void dump() const;
624
627
628 /// Implement operator<< on DbgMarker.
629 LLVM_ABI void print(raw_ostream &O, bool IsForDebug = false) const;
631 bool IsForDebug) const;
632
633 /// Produce a range over all the DbgRecords in this Marker.
637 getDbgRecordRange() const;
638 /// Transfer any DbgRecords from \p Src into this DbgMarker. If \p
639 /// InsertAtHead is true, place them before existing DbgRecords, otherwise
640 /// afterwards.
641 LLVM_ABI void absorbDebugValues(DbgMarker &Src, bool InsertAtHead);
642 /// Transfer the DbgRecords in \p Range from \p Src into this DbgMarker. If
643 /// \p InsertAtHead is true, place them before existing DbgRecords, otherwise
644 // afterwards.
645 LLVM_ABI void
647 DbgMarker &Src, bool InsertAtHead);
648 /// Insert a DbgRecord into this DbgMarker, at the end of the list. If
649 /// \p InsertAtHead is true, at the start.
650 LLVM_ABI void insertDbgRecord(DbgRecord *New, bool InsertAtHead);
651 /// Insert a DbgRecord prior to a DbgRecord contained within this marker.
652 LLVM_ABI void insertDbgRecord(DbgRecord *New, DbgRecord *InsertBefore);
653 /// Insert a DbgRecord after a DbgRecord contained within this marker.
654 LLVM_ABI void insertDbgRecordAfter(DbgRecord *New, DbgRecord *InsertAfter);
655 /// Clone all DbgMarkers from \p From into this marker. There are numerous
656 /// options to customise the source/destination, due to gnarliness, see class
657 /// comment.
658 /// \p FromHere If non-null, copy from FromHere to the end of From's
659 /// DbgRecords
660 /// \p InsertAtHead Place the cloned DbgRecords at the start of
661 /// StoredDbgRecords
662 /// \returns Range over all the newly cloned DbgRecords
665 std::optional<simple_ilist<DbgRecord>::iterator> FromHere,
666 bool InsertAtHead = false);
667 /// Erase all DbgRecords in this DbgMarker.
669 /// Erase a single DbgRecord from this marker. In an ideal future, we would
670 /// never erase an assignment in this way, but it's the equivalent to
671 /// erasing a debug intrinsic from a block.
673
674 /// We generally act like all llvm Instructions have a range of DbgRecords
675 /// attached to them, but in reality sometimes we don't allocate the DbgMarker
676 /// to save time and memory, but still have to return ranges of DbgRecords.
677 /// When we need to describe such an unallocated DbgRecord range, use this
678 /// static markers range instead. This will bite us if someone tries to insert
679 /// a DbgRecord in that range, but they should be using the Official (TM) API
680 /// for that.
684 return make_range(EmptyDbgMarker.StoredDbgRecords.end(),
685 EmptyDbgMarker.StoredDbgRecords.end());
686 }
687};
688
689inline raw_ostream &operator<<(raw_ostream &OS, const DbgMarker &Marker) {
690 Marker.print(OS);
691 return OS;
692}
693
694/// Inline helper to return a range of DbgRecords attached to a marker. It needs
695/// to be inlined as it's frequently called, but also come after the declaration
696/// of DbgMarker. Thus: it's pre-declared by users like Instruction, then an
697/// inlineable body defined here.
698inline iterator_range<simple_ilist<DbgRecord>::iterator>
700 if (!DebugMarker)
702 return DebugMarker->getDbgRecordRange();
703}
704
706
707} // namespace llvm
708
709#endif // LLVM_IR_DEBUGPROGRAMINSTRUCTION_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static const Function * getParent(const Value *V)
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define DEFINE_ISA_CONVERSION_FUNCTIONS(ty, ref)
#define LLVM_ABI
Definition Compiler.h:215
#define LLVM_TEMPLATE_ABI
Definition Compiler.h:216
#define T
MachineInstr unsigned OpIdx
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
bool isKillAddress(const DbgVariableRecord *DVR)
Definition SROA.cpp:5675
static SymbolRef::Type getType(const Symbol *Sym)
Definition TapiFile.cpp:39
static Function * getFunction(FunctionType *Ty, const Twine &Name, Module *M)
Value * RHS
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
LLVM Basic Block Representation.
Definition BasicBlock.h:62
DWARF expression.
This is the common base class for debug info intrinsics.
This represents the llvm.dbg.label instruction.
LLVM_ABI DbgLabelInst * createDebugIntrinsic(Module *M, Instruction *InsertBefore) const
static LLVM_ABI DbgLabelRecord * createUnresolvedDbgLabelRecord(MDNode *Label)
For use during parsing; creates a DbgLabelRecord from as-of-yet unresolved MDNodes.
static bool classof(const DbgRecord *E)
Support type inquiry through isa, cast, and dyn_cast.
void setLabel(DILabel *NewLabel)
LLVM_ABI DbgLabelRecord * clone() const
Per-instruction record of debug-info.
static iterator_range< simple_ilist< DbgRecord >::iterator > getEmptyDbgRecordRange()
LLVM_ABI void insertDbgRecordAfter(DbgRecord *New, DbgRecord *InsertAfter)
Insert a DbgRecord after a DbgRecord contained within this marker.
LLVM_ABI void removeFromParent()
LLVM_ABI void dump() const
LLVM_ABI void dropOneDbgRecord(DbgRecord *DR)
Erase a single DbgRecord from this marker.
Instruction * MarkedInstr
Link back to the Instruction that owns this marker.
LLVM_ABI void eraseFromParent()
static LLVM_ABI DbgMarker EmptyDbgMarker
We generally act like all llvm Instructions have a range of DbgRecords attached to them,...
LLVM_ABI iterator_range< simple_ilist< DbgRecord >::iterator > getDbgRecordRange()
Produce a range over all the DbgRecords in this Marker.
LLVM_ABI void print(raw_ostream &O, bool IsForDebug=false) const
Implement operator<< on DbgMarker.
LLVM_ABI const BasicBlock * getParent() const
LLVM_ABI iterator_range< simple_ilist< DbgRecord >::iterator > cloneDebugInfoFrom(DbgMarker *From, std::optional< simple_ilist< DbgRecord >::iterator > FromHere, bool InsertAtHead=false)
Clone all DbgMarkers from From into this marker.
LLVM_ABI void insertDbgRecord(DbgRecord *New, bool InsertAtHead)
Insert a DbgRecord into this DbgMarker, at the end of the list.
simple_ilist< DbgRecord > StoredDbgRecords
List of DbgRecords, the non-instruction equivalent of llvm.dbg.
DbgMarker()=default
LLVM_ABI void absorbDebugValues(DbgMarker &Src, bool InsertAtHead)
Transfer any DbgRecords from Src into this DbgMarker.
LLVM_ABI void removeMarker()
Handle the removal of a marker: the position of debug-info has gone away, but the stored debug record...
LLVM_ABI void dropDbgRecords()
Erase all DbgRecords in this DbgMarker.
A typed tracking MDNode reference that does not require a definition for its parameter type.
T * get() const
Get the underlying type.
bool operator!=(const DbgRecordParamRef &Other) const
MDNode * getAsMDNode() const
Return this as a MDNode.
bool operator==(const DbgRecordParamRef &Other) const
Base class for non-instruction debug metadata records that have positions within IR.
DbgRecord(Kind RecordKind, DebugLoc DL)
simple_ilist< DbgRecord >::iterator self_iterator
DebugLoc getDebugLoc() const
Kind RecordKind
Subclass discriminator.
~DbgRecord()=default
Similarly to Value, we avoid paying the cost of a vtable by protecting the dtor and having deleteReco...
simple_ilist< DbgRecord >::const_iterator const_self_iterator
Kind
Subclass discriminator.
void setDebugLoc(DebugLoc Loc)
const DbgMarker * getMarker() const
DbgMarker * Marker
Marker that this DbgRecord is linked into.
void setMarker(DbgMarker *M)
This is the common base class for debug info intrinsics for variables.
bool operator==(const location_op_iterator &RHS) const
location_op_iterator & operator=(const location_op_iterator &R)
Record of a variable value-assignment, aka a non instruction representation of the dbg....
LLVM_ABI std::optional< DbgVariableFragmentInfo > getFragment() const
bool isEquivalentTo(const DbgVariableRecord &Other) const
DbgRecordParamRef< DIExpression > Expression
static LLVM_ABI DbgVariableRecord * createUnresolvedDbgVariableRecord(LocationType Type, Metadata *Val, MDNode *Variable, MDNode *Expression, MDNode *AssignID, Metadata *Address, MDNode *AddressExpression)
Used to create DbgVariableRecords during parsing, where some metadata references may still be unresol...
bool isValueOfVariable() const
Determine if this describes the value of a local variable.
bool hasValidLocation() const
Returns true if this DbgVariableRecord has no empty MDNodes in its location list.
LocationType Type
Classification of the debug-info record that this DbgVariableRecord represents.
DbgRecordParamRef< DILocalVariable > Variable
void setAddressExpression(DIExpression *NewExpr)
DbgVariableFragmentInfo getFragmentOrEntireVariable() const
Get the FragmentInfo for the variable if it exists, otherwise return a FragmentInfo that covers the e...
LLVM_ABI Value * getVariableLocationOp(unsigned OpIdx) const
bool isAddressOfVariable() const
Does this describe the address of a local variable.
Value * getValue(unsigned OpIdx=0) const
static LLVM_ABI DbgVariableRecord * createDVRDeclareValue(Value *Address, DILocalVariable *DV, DIExpression *Expr, const DILocation *DI)
static LLVM_ABI DbgVariableRecord * createLinkedDVRAssign(Instruction *LinkedInstr, Value *Val, DILocalVariable *Variable, DIExpression *Expression, Value *Address, DIExpression *AddressExpression, const DILocation *DI)
static LLVM_ABI DbgVariableRecord * createDVRAssign(Value *Val, DILocalVariable *Variable, DIExpression *Expression, DIAssignID *AssignID, Value *Address, DIExpression *AddressExpression, const DILocation *DI)
void setRawLocation(Metadata *NewLocation)
Use of this should generally be avoided; instead, replaceVariableLocationOp and addVariableLocationOp...
LLVM_ABI void handleChangedLocation(Metadata *NewLocation)
Handle changes to the location of the Value(s) that we refer to happening "under our feet".
void setVariable(DILocalVariable *NewVar)
void setExpression(DIExpression *NewExpr)
DIExpression * getExpression() const
static LLVM_ABI DbgVariableRecord * createDVRDeclare(Value *Address, DILocalVariable *DV, DIExpression *Expr, const DILocation *DI)
static LLVM_ABI DbgVariableRecord * createDbgVariableRecord(Value *Location, DILocalVariable *DV, DIExpression *Expr, const DILocation *DI)
LLVM_ABI std::optional< uint64_t > getFragmentSizeInBits() const
Get the size (in bits) of the variable, or fragment of the variable that is described.
DILocalVariable * getVariable() const
static bool classof(const DbgRecord *E)
Support type inquiry through isa, cast, and dyn_cast.
Metadata * getRawLocation() const
Returns the metadata operand for the first location description.
LLVM_ABI DbgVariableRecord(const DbgVariableIntrinsic *DVI)
Create a new DbgVariableRecord representing the intrinsic DVI, for example the assignment represented...
@ End
Marks the end of the concrete types.
@ Any
To indicate all LocationTypes in searches.
bool isIdenticalToWhenDefined(const DbgVariableRecord &Other) const
DbgRecordParamRef< DIExpression > AddressExpression
DIExpression * getAddressExpression() const
A debug info location.
Definition DebugLoc.h:126
std::array< Metadata *, 3 > DebugValues
Definition Metadata.h:227
void resetDebugValue(size_t Idx, Metadata *DebugValue)
Definition Metadata.h:282
This is an important class for using LLVM in a threaded context.
Definition LLVMContext.h:68
Metadata node.
Definition Metadata.h:1069
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition Metadata.h:1554
Root of the metadata hierarchy.
Definition Metadata.h:64
Manage lifetime of a slot tracker for printing IR.
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:67
A discriminated union of two or more pointer types, with the discriminator in the low bits of the poi...
Value wrapper in the Metadata hierarchy.
Definition Metadata.h:459
static LLVM_ABI ValueAsMetadata * get(Value *V)
Definition Metadata.cpp:509
Value * getValue() const
Definition Metadata.h:499
LLVM Value Representation.
Definition Value.h:75
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
Definition iterator.h:80
A range adaptor for a pair of iterators.
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
A simple intrusive list implementation.
ilist_select_iterator_type< OptionsT, false, false > iterator
ilist_select_iterator_type< OptionsT, false, true > const_iterator
struct LLVMOpaqueDbgRecord * LLVMDbgRecordRef
Definition Types.h:175
This file defines classes to implement an intrusive doubly linked list class (i.e.
This file defines the ilist_node class template, which is a convenient base class for creating classe...
This is an optimization pass for GlobalISel generic memory operations.
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
TypedTrackingMDRef< MDNode > TrackingMDNodeRef
Printable print(const GCNRegPressure &RP, const GCNSubtarget *ST=nullptr, unsigned DynamicVGPRBlockSize=0)
template class LLVM_TEMPLATE_ABI DbgRecordParamRef< DIExpression >
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
auto map_range(ContainerTy &&C, FuncTy F)
Return a range that applies F to the elements of C.
Definition STLExtras.h:365
iterator_range< simple_ilist< DbgRecord >::iterator > getDbgRecordRange(DbgMarker *DebugMarker)
Inline helper to return a range of DbgRecords attached to a marker.
iterator_range< filter_iterator< detail::IterOfRange< RangeT >, PredicateT > > make_filter_range(RangeT &&Range, PredicateT Pred)
Convenience function that takes a range of elements and a predicate, and return a new filter_iterator...
Definition STLExtras.h:551
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
Definition Casting.h:547
@ Other
Any other memory.
Definition ModRef.h:68
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:559
template class LLVM_TEMPLATE_ABI DbgRecordParamRef< DILocalVariable >
static auto filterDbgVars(iterator_range< simple_ilist< DbgRecord >::iterator > R)
Filter the DbgRecord range to DbgVariableRecord types only and downcast.
template class LLVM_TEMPLATE_ABI DbgRecordParamRef< DILabel >