LLVM 24.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/STLExtras.h"
51#include "llvm/ADT/ilist.h"
52#include "llvm/ADT/ilist_node.h"
53#include "llvm/ADT/iterator.h"
55#include "llvm/IR/DebugLoc.h"
56#include "llvm/IR/Instruction.h"
60
61namespace llvm {
62
63class Instruction;
64class BasicBlock;
65class MDNode;
66class Module;
69class DbgLabelInst;
70class DIAssignID;
71class DbgMarker;
73class raw_ostream;
74
75/// A typed tracking MDNode reference that does not require a definition for its
76/// parameter type. Necessary to avoid including DebugInfoMetadata.h, which has
77/// a significant impact on compile times if included in this file.
78template <typename T> class DbgRecordParamRef {
80
81public:
82public:
83 DbgRecordParamRef() = default;
84
85 /// Construct from the templated type.
86 DbgRecordParamRef(const T *Param);
87
88 /// Construct from an \a MDNode.
89 ///
90 /// Note: if \c Param does not have the template type, a verifier check will
91 /// fail, and accessors will crash. However, construction from other nodes
92 /// is supported in order to handle forward references when reading textual
93 /// IR.
94 explicit DbgRecordParamRef(const MDNode *Param);
95
96 /// Get the underlying type.
97 ///
98 /// \pre !*this or \c isa<T>(getAsMDNode()).
99 /// @{
100 T *get() const;
101 operator T *() const { return get(); }
102 T *operator->() const { return get(); }
103 T &operator*() const { return *get(); }
104 /// @}
105
106 /// Check for null.
107 ///
108 /// Check for null in a way that is safe with broken debug info.
109 explicit operator bool() const { return Ref; }
110
111 /// Return \c this as a \a MDNode.
112 MDNode *getAsMDNode() const { return Ref; }
113
114 bool operator==(const DbgRecordParamRef &Other) const {
115 return Ref == Other.Ref;
116 }
117 bool operator!=(const DbgRecordParamRef &Other) const {
118 return Ref != Other.Ref;
119 }
120};
121
125
126/// Base class for non-instruction debug metadata records that have positions
127/// within IR. Features various methods copied across from the Instruction
128/// class to aid ease-of-use. DbgRecords should always be linked into a
129/// DbgMarker's StoredDbgRecords list. The marker connects a DbgRecord back to
130/// its position in the BasicBlock.
131///
132/// We need a discriminator for dyn/isa casts. In order to avoid paying for a
133/// vtable for "virtual" functions too, subclasses must add a new discriminator
134/// value (RecordKind) and cases to a few functions in the base class:
135/// deleteRecord
136/// clone
137/// isIdenticalToWhenDefined
138/// both print methods
139/// createDebugIntrinsic
141public:
142 /// Marker that this DbgRecord is linked into.
143 DbgMarker *Marker = nullptr;
144 /// Subclass discriminator.
146
147protected:
149 Kind RecordKind; ///< Subclass discriminator.
150
151public:
154
155 /// Methods that dispatch to subclass implementations. These need to be
156 /// manually updated when a new subclass is added.
157 ///@{
158 LLVM_ABI void deleteRecord();
159 LLVM_ABI DbgRecord *clone() const;
160 LLVM_ABI void print(raw_ostream &O, bool IsForDebug = false) const;
162 bool IsForDebug) const;
163 LLVM_ABI bool isIdenticalToWhenDefined(const DbgRecord &R) const;
164 /// Convert this DbgRecord back into an appropriate llvm.dbg.* intrinsic.
165 /// \p InsertBefore Optional position to insert this intrinsic.
166 /// \returns A new llvm.dbg.* intrinsic representing this DbgRecord.
168 createDebugIntrinsic(Module *M, Instruction *InsertBefore) const;
169 ///@}
170
171 /// Same as isIdenticalToWhenDefined but checks DebugLoc too.
172 LLVM_ABI bool isEquivalentTo(const DbgRecord &R) const;
173
174 Kind getRecordKind() const { return RecordKind; }
175
176 void setMarker(DbgMarker *M) { Marker = M; }
177
179 const DbgMarker *getMarker() const { return Marker; }
180
181 LLVM_ABI BasicBlock *getBlock();
182 LLVM_ABI const BasicBlock *getBlock() const;
183
185 LLVM_ABI const Function *getFunction() const;
186
187 LLVM_ABI Module *getModule();
188 LLVM_ABI const Module *getModule() const;
189
191 LLVM_ABI const LLVMContext &getContext() const;
192
193 LLVM_ABI Instruction *getInstruction();
194 LLVM_ABI const Instruction *getInstruction() const;
195
197 LLVM_ABI const BasicBlock *getParent() const;
198
199 LLVM_ABI void removeFromParent();
200 LLVM_ABI void eraseFromParent();
201
202 DbgRecord *getNextNode() { return &*std::next(getIterator()); }
203 DbgRecord *getPrevNode() { return &*std::prev(getIterator()); }
204
205 // Some generic lambdas supporting intrinsic-based debug-info mean we need
206 // to support both iterator and instruction position based insertion.
207 LLVM_ABI void insertBefore(DbgRecord *InsertBefore);
208 LLVM_ABI void insertAfter(DbgRecord *InsertAfter);
209 LLVM_ABI void moveBefore(DbgRecord *MoveBefore);
210 LLVM_ABI void moveAfter(DbgRecord *MoveAfter);
211
212 LLVM_ABI void insertBefore(self_iterator InsertBefore);
213 LLVM_ABI void insertAfter(self_iterator InsertAfter);
214 LLVM_ABI void moveBefore(self_iterator MoveBefore);
215 LLVM_ABI void moveAfter(self_iterator MoveAfter);
216
217 DebugLoc getDebugLoc() const { return DbgLoc; }
218 void setDebugLoc(DebugLoc Loc) { DbgLoc = std::move(Loc); }
219
220 LLVM_ABI void dump() const;
221
224
225protected:
226 /// Similarly to Value, we avoid paying the cost of a vtable
227 /// by protecting the dtor and having deleteRecord dispatch
228 /// cleanup.
229 /// Use deleteRecord to delete a generic record.
230 ~DbgRecord() = default;
231};
232
234 R.print(OS);
235 return OS;
236}
237
238/// Records a position in IR for a source label (DILabel). Corresponds to the
239/// llvm.dbg.label intrinsic.
240class DbgLabelRecord : public DbgRecord {
242
243 /// This constructor intentionally left private, so that it is only called via
244 /// "createUnresolvedDbgLabelRecord", which clearly expresses that it is for
245 /// parsing only.
246 DbgLabelRecord(MDNode *Label);
247
248public:
249 LLVM_ABI DbgLabelRecord(DILabel *Label, DebugLoc DL);
250
251 /// For use during parsing; creates a DbgLabelRecord from as-of-yet unresolved
252 /// MDNodes. Trying to access the resulting DbgLabelRecord's fields before
253 /// they are resolved, or if they resolve to the wrong type, will result in a
254 /// crash.
255 LLVM_ABI static DbgLabelRecord *createUnresolvedDbgLabelRecord(MDNode *Label);
256
257 LLVM_ABI DbgLabelRecord *clone() const;
258 LLVM_ABI void print(raw_ostream &O, bool IsForDebug = false) const;
260 bool IsForDebug) const;
262 Instruction *InsertBefore) const;
263
264 void setLabel(DILabel *NewLabel) { Label = NewLabel; }
265 DILabel *getLabel() const { return Label.get(); }
266 MDNode *getRawLabel() const { return Label.getAsMDNode(); };
267
268 /// Support type inquiry through isa, cast, and dyn_cast.
269 static bool classof(const DbgRecord *E) {
270 return E->getRecordKind() == LabelKind;
271 }
272};
273
274/// Record of a variable value-assignment, aka a non instruction representation
275/// of the dbg.value intrinsic.
276///
277/// This class inherits from DebugValueUser to allow LLVM's metadata facilities
278/// to update our references to metadata beneath our feet.
279class DbgVariableRecord : public DbgRecord, protected DebugValueUser {
280 friend class DebugValueUser;
281
282public:
283 enum class LocationType : uint8_t {
288
289 End, ///< Marks the end of the concrete types.
290 Any, ///< To indicate all LocationTypes in searches.
291 };
292 /// Classification of the debug-info record that this DbgVariableRecord
293 /// represents. Essentially, "does this correspond to a dbg.value,
294 /// dbg.declare, or dbg.assign?".
295 /// FIXME: We could use spare padding bits from DbgRecord for this.
297
298 // NB: there is no explicit "Value" field in this class, it's effectively the
299 // DebugValueUser superclass instead. The referred to Value can either be a
300 // ValueAsMetadata or a DIArgList.
301
305
306public:
307 /// Create a new DbgVariableRecord representing the intrinsic \p DVI, for
308 /// example the assignment represented by a dbg.value.
311 /// Directly construct a new DbgVariableRecord representing a dbg.value
312 /// intrinsic assigning \p Location to the DV / Expr / DI variable.
314 DIExpression *Expr, const DILocation *DI,
319 const DILocation *DI);
320
321private:
322 /// Private constructor for creating new instances during parsing only. Only
323 /// called through `createUnresolvedDbgVariableRecord` below, which makes
324 /// clear that this is used for parsing only, and will later return a subclass
325 /// depending on which Type is passed.
329
330public:
331 /// Used to create DbgVariableRecords during parsing, where some metadata
332 /// references may still be unresolved. Although for some fields a generic
333 /// `Metadata*` argument is accepted for forward type-references, the verifier
334 /// and accessors will reject incorrect types later on. The function is used
335 /// for all types of DbgVariableRecords for simplicity while parsing, but
336 /// asserts if any necessary fields are empty or unused fields are not empty,
337 /// i.e. if the #dbg_assign fields are used for a non-dbg-assign type.
341
346 const DILocation *DI);
348 createLinkedDVRAssign(Instruction *LinkedInstr, Value *Val,
351 const DILocation *DI);
352
355 DIExpression *Expr, const DILocation *DI);
358 DIExpression *Expr, const DILocation *DI,
359 DbgVariableRecord &InsertBefore);
361 DILocalVariable *DV,
362 DIExpression *Expr,
363 const DILocation *DI);
366 const DILocation *DI, DbgVariableRecord &InsertBefore);
367
370 const DILocation *DI);
373 const DILocation *DI, DbgVariableRecord &InsertBefore);
374
375 /// Iterator for ValueAsMetadata that internally uses direct pointer iteration
376 /// over either a ValueAsMetadata* or a ValueAsMetadata**, dereferencing to the
377 /// ValueAsMetadata .
380 std::bidirectional_iterator_tag, Value *> {
382
383 public:
384 location_op_iterator(ValueAsMetadata *SingleIter) : I(SingleIter) {}
385 location_op_iterator(ValueAsMetadata **MultiIter) : I(MultiIter) {}
386
389 I = R.I;
390 return *this;
391 }
393 return I == RHS.I;
394 }
395 const Value *operator*() const {
399 return VAM->getValue();
400 };
408 if (auto *VAM = dyn_cast<ValueAsMetadata *>(I))
409 I = VAM + 1;
410 else
411 I = cast<ValueAsMetadata **>(I) + 1;
412 return *this;
413 }
415 if (auto *VAM = dyn_cast<ValueAsMetadata *>(I))
416 I = VAM - 1;
417 else
418 I = cast<ValueAsMetadata **>(I) - 1;
419 return *this;
420 }
421 };
422
423 bool isDbgDeclare() const { return Type == LocationType::Declare; }
424 bool isDbgValue() const { return Type == LocationType::Value; }
426
427 /// Get the locations corresponding to the variable referenced by the debug
428 /// info intrinsic. Depending on the intrinsic, this could be the
429 /// variable's value or its address.
431
432 LLVM_ABI Value *getVariableLocationOp(unsigned OpIdx) const;
433
434 LLVM_ABI void replaceVariableLocationOp(Value *OldValue, Value *NewValue,
435 bool AllowEmpty = false);
436 LLVM_ABI void replaceVariableLocationOp(unsigned OpIdx, Value *NewValue);
437 /// Adding a new location operand will always result in this intrinsic using
438 /// an ArgList, and must always be accompanied by a new expression that uses
439 /// the new operand.
440 LLVM_ABI void addVariableLocationOps(ArrayRef<Value *> NewValues,
442
443 LLVM_ABI unsigned getNumVariableLocationOps() const;
444
445 bool hasArgList() const { return isa<DIArgList>(getRawLocation()); }
446 /// Returns true if this DbgVariableRecord has no empty MDNodes in its
447 /// location list.
448 bool hasValidLocation() const { return getVariableLocationOp(0) != nullptr; }
449
450 /// Does this describe the address of a local variable. True for dbg.addr
451 /// and dbg.declare, but not dbg.value or dbg.declare_value, which describes
452 /// its value.
454
455 /// Determine if this describes the value of a local variable. It is false for
456 /// dbg.declare, but true for dbg.value and dbg.declare_value, which describes
457 /// its value.
461
462 LocationType getType() const { return Type; }
463
464 LLVM_ABI void setKillLocation();
465 LLVM_ABI bool isKillLocation() const;
466
467 void setVariable(DILocalVariable *NewVar) { Variable = NewVar; }
468 DILocalVariable *getVariable() const { return Variable.get(); };
469 MDNode *getRawVariable() const { return Variable.getAsMDNode(); }
470
472 DIExpression *getExpression() const { return Expression.get(); }
473 MDNode *getRawExpression() const { return Expression.getAsMDNode(); }
474
475 /// Returns the metadata operand for the first location description. i.e.,
476 /// dbg intrinsic dbg.value,declare operand and dbg.assign 1st location
477 /// operand (the "value componenet"). Note the operand (singular) may be
478 /// a DIArgList which is a list of values.
479 Metadata *getRawLocation() const { return DebugValues[0]; }
480
481 Value *getValue(unsigned OpIdx = 0) const {
482 return getVariableLocationOp(OpIdx);
483 }
484
485 /// Use of this should generally be avoided; instead,
486 /// replaceVariableLocationOp and addVariableLocationOps should be used where
487 /// possible to avoid creating invalid state.
488 void setRawLocation(Metadata *NewLocation) {
489 assert((isa<ValueAsMetadata>(NewLocation) || isa<DIArgList>(NewLocation) ||
490 isa<MDNode>(NewLocation)) &&
491 "Location for a DbgVariableRecord must be either ValueAsMetadata or "
492 "DIArgList");
493 resetDebugValue(0, NewLocation);
494 }
495
496 LLVM_ABI std::optional<DbgVariableFragmentInfo> getFragment() const;
497 /// Get the FragmentInfo for the variable if it exists, otherwise return a
498 /// FragmentInfo that covers the entire variable if the variable size is
499 /// known, otherwise return a zero-sized fragment.
501 if (auto Frag = getFragment())
502 return *Frag;
503 if (auto Sz = getFragmentSizeInBits())
504 return {*Sz, 0};
505 return {0, 0};
506 }
507 /// Get the size (in bits) of the variable, or fragment of the variable that
508 /// is described.
509 LLVM_ABI std::optional<uint64_t> getFragmentSizeInBits() const;
510
512 return DbgLoc == Other.DbgLoc && isIdenticalToWhenDefined(Other);
513 }
514 // Matches the definition of the Instruction version, equivalent to above but
515 // without checking DbgLoc.
517 return std::tie(Type, DebugValues, Variable, Expression,
519 std::tie(Other.Type, Other.DebugValues, Other.Variable,
520 Other.Expression, Other.AddressExpression);
521 }
522
523 /// @name DbgAssign Methods
524 /// @{
525 bool isDbgAssign() const { return getType() == LocationType::Assign; }
526
527 LLVM_ABI Value *getAddress() const;
529 return isDbgAssign() ? DebugValues[1] : DebugValues[0];
530 }
532 LLVM_ABI DIAssignID *getAssignID() const;
535 return AddressExpression.getAsMDNode();
536 }
540 LLVM_ABI void setAssignId(DIAssignID *New);
542 /// Kill the address component.
543 LLVM_ABI void setKillAddress();
544 /// Check whether this kills the address component. This doesn't take into
545 /// account the position of the intrinsic, therefore a returned value of false
546 /// does not guarantee the address is a valid location for the variable at the
547 /// intrinsic's position in IR.
548 LLVM_ABI bool isKillAddress() const;
549
550 /// @}
551
552 LLVM_ABI DbgVariableRecord *clone() const;
553 /// Convert this DbgVariableRecord back into a dbg.value intrinsic.
554 /// \p InsertBefore Optional position to insert this intrinsic.
555 /// \returns A new dbg.value intrinsic representing this DbgVariableRecord.
557 createDebugIntrinsic(Module *M, Instruction *InsertBefore) const;
558
559 LLVM_ABI void print(raw_ostream &O, bool IsForDebug = false) const;
561 bool IsForDebug) const;
562
563 /// Support type inquiry through isa, cast, and dyn_cast.
564 static bool classof(const DbgRecord *E) {
565 return E->getRecordKind() == ValueKind;
566 }
567};
568
569/// Filter the DbgRecord range to DbgVariableRecord types only and downcast.
570static inline auto
574
575/// Per-instruction record of debug-info. If an Instruction is the position of
576/// some debugging information, it points at a DbgMarker storing that info. Each
577/// marker points back at the instruction that owns it. Various utilities are
578/// provided for manipulating the DbgRecords contained within this marker.
579///
580/// This class has a rough surface area, because it's needed to preserve the
581/// one arefact that we can't yet eliminate from the intrinsic / dbg.value
582/// debug-info design: the order of records is significant, and duplicates can
583/// exist. Thus, if one has a run of debug-info records such as:
584/// dbg.value(...
585/// %foo = barinst
586/// dbg.value(...
587/// and remove barinst, then the dbg.values must be preserved in the correct
588/// order. Hence, the use of iterators to select positions to insert things
589/// into, or the occasional InsertAtHead parameter indicating that new records
590/// should go at the start of the list.
591///
592/// There are only five or six places in LLVM that truly rely on this ordering,
593/// which we can improve in the future. Additionally, many improvements in the
594/// way that debug-info is stored can be achieved in this class, at a future
595/// date.
597public:
598 DbgMarker() = default;
599 /// Link back to the Instruction that owns this marker. Can be null during
600 /// operations that move a marker from one instruction to another.
602
603 /// List of DbgRecords, the non-instruction equivalent of llvm.dbg.*
604 /// intrinsics. There is a one-to-one relationship between each debug
605 /// intrinsic in a block and each DbgRecord once the representation has been
606 /// converted, and the ordering is meaningful in the same way.
608 bool empty() const { return StoredDbgRecords.empty(); }
609
610 LLVM_ABI const BasicBlock *getParent() const;
612
613 /// Handle the removal of a marker: the position of debug-info has gone away,
614 /// but the stored debug records should not. Drop them onto the next
615 /// instruction, or otherwise work out what to do with them.
616 LLVM_ABI void removeMarker();
617 LLVM_ABI void dump() const;
618
621
622 /// Implement operator<< on DbgMarker.
623 LLVM_ABI void print(raw_ostream &O, bool IsForDebug = false) const;
625 bool IsForDebug) const;
626
627 /// Produce a range over all the DbgRecords in this Marker.
631 getDbgRecordRange() const;
632 /// Transfer any DbgRecords from \p Src into this DbgMarker. If \p
633 /// InsertAtHead is true, place them before existing DbgRecords, otherwise
634 /// afterwards.
635 LLVM_ABI void absorbDebugValues(DbgMarker &Src, bool InsertAtHead);
636 /// Transfer the DbgRecords in \p Range from \p Src into this DbgMarker. If
637 /// \p InsertAtHead is true, place them before existing DbgRecords, otherwise
638 // afterwards.
639 LLVM_ABI void
641 DbgMarker &Src, bool InsertAtHead);
642 /// Insert a DbgRecord into this DbgMarker, at the end of the list. If
643 /// \p InsertAtHead is true, at the start.
644 LLVM_ABI void insertDbgRecord(DbgRecord *New, bool InsertAtHead);
645 /// Insert a DbgRecord prior to a DbgRecord contained within this marker.
646 LLVM_ABI void insertDbgRecord(DbgRecord *New, DbgRecord *InsertBefore);
647 /// Insert a DbgRecord after a DbgRecord contained within this marker.
648 LLVM_ABI void insertDbgRecordAfter(DbgRecord *New, DbgRecord *InsertAfter);
649 /// Clone all DbgMarkers from \p From into this marker. There are numerous
650 /// options to customise the source/destination, due to gnarliness, see class
651 /// comment.
652 /// \p FromHere If non-null, copy from FromHere to the end of From's
653 /// DbgRecords
654 /// \p InsertAtHead Place the cloned DbgRecords at the start of
655 /// StoredDbgRecords
656 /// \returns Range over all the newly cloned DbgRecords
659 std::optional<simple_ilist<DbgRecord>::iterator> FromHere,
660 bool InsertAtHead = false);
661 /// Erase all DbgRecords in this DbgMarker.
663 /// Erase a single DbgRecord from this marker. In an ideal future, we would
664 /// never erase an assignment in this way, but it's the equivalent to
665 /// erasing a debug intrinsic from a block.
667
668 /// We generally act like all llvm Instructions have a range of DbgRecords
669 /// attached to them, but in reality sometimes we don't allocate the DbgMarker
670 /// to save time and memory, but still have to return ranges of DbgRecords.
671 /// When we need to describe such an unallocated DbgRecord range, use this
672 /// static markers range instead. This will bite us if someone tries to insert
673 /// a DbgRecord in that range, but they should be using the Official (TM) API
674 /// for that.
678 return make_range(EmptyDbgMarker.StoredDbgRecords.end(),
679 EmptyDbgMarker.StoredDbgRecords.end());
680 }
681};
682
683inline raw_ostream &operator<<(raw_ostream &OS, const DbgMarker &Marker) {
684 Marker.print(OS);
685 return OS;
686}
687
688/// Inline helper to return a range of DbgRecords attached to a marker. It needs
689/// to be inlined as it's frequently called, but also come after the declaration
690/// of DbgMarker. Thus: it's pre-declared by users like Instruction, then an
691/// inlineable body defined here.
692inline iterator_range<simple_ilist<DbgRecord>::iterator>
694 if (!DebugMarker)
696 return DebugMarker->getDbgRecordRange();
697}
698
700
701} // namespace llvm
702
703#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
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
Func getContext().diagnose(DiagnosticInfoUnsupported(Func
bool isKillAddress(const DbgVariableRecord *DVR)
Definition SROA.cpp:5696
This file contains some templates that are useful if you are working with the STL at all.
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...
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
static constexpr size_t AssignIDIdx
Definition Metadata.h:229
std::array< Metadata *, 3 > DebugValues
Definition Metadata.h:227
void resetDebugValue(size_t Idx, Metadata *DebugValue)
Definition Metadata.h:284
This is an important class for using LLVM in a threaded context.
Definition LLVMContext.h:68
Metadata node.
Definition Metadata.h:1081
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition Metadata.h:1578
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:68
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:471
static LLVM_ABI ValueAsMetadata * get(Value *V)
Definition Metadata.cpp:514
Value * getValue() const
Definition Metadata.h:510
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 make_isa_range(RangeT &&Range)
Return a range over Range containing only elements for which isa<T> holds, casting each of them to T.
Definition STLExtras.h:567
iterator_range< simple_ilist< DbgRecord >::iterator > getDbgRecordRange(DbgMarker *DebugMarker)
Inline helper to return a range of DbgRecords attached to a marker.
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 >