LLVM 19.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 hierachy defined
18// elsewhere in LLVM. In the "DPValue" design, each instruction /may/ have a
19// connection with a DPMarker, which identifies a position immediately before the
20// instruction, and each DPMarker /may/ then have connections to DPValues which
21// record the variable assignment information. To illustrate:
22//
23// %foo = add i32 1, %0
24// ; foo->DbgMarker == nullptr
25// ;; There are no variable assignments / debug records "in front" of
26// ;; the instruction for %foo, therefore it has no DbgMarker.
27// %bar = void call @ext(%foo)
28// ; bar->DbgMarker = {
29// ; StoredDPValues = {
30// ; DPValue(metadata i32 %foo, ...)
31// ; }
32// ; }
33// ;; There is a debug-info record in front of the %bar instruction,
34// ;; thus it points at a DPMarker object. That DPMarker contains a
35// ;; DPValue in it's ilist, storing the equivalent information to the
36// ;; 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 hierachy 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"
53#include "llvm/IR/DebugLoc.h"
54#include "llvm/IR/Instruction.h"
57
58namespace llvm {
59
60class Instruction;
61class BasicBlock;
62class MDNode;
63class Module;
64class DbgVariableIntrinsic;
65class DbgInfoIntrinsic;
66class DbgLabelInst;
67class DIAssignID;
68class DPMarker;
69class DPValue;
70class raw_ostream;
71
72/// Base class for non-instruction debug metadata records that have positions
73/// within IR. Features various methods copied across from the Instruction
74/// class to aid ease-of-use. DbgRecords should always be linked into a
75/// DPMarker's StoredDPValues list. The marker connects a DbgRecord back to
76/// it's position in the BasicBlock.
77///
78/// We need a discriminator for dyn/isa casts. In order to avoid paying for a
79/// vtable for "virtual" functions too, subclasses must add a new discriminator
80/// value (RecordKind) and cases to a few functions in the base class:
81/// deleteRecord
82/// clone
83/// isIdenticalToWhenDefined
84/// both print methods
85/// createDebugIntrinsic
86class DbgRecord : public ilist_node<DbgRecord> {
87public:
88 /// Marker that this DbgRecord is linked into.
89 DPMarker *Marker = nullptr;
90 /// Subclass discriminator.
91 enum Kind : uint8_t { ValueKind, LabelKind };
92
93protected:
95 Kind RecordKind; ///< Subclass discriminator.
96
97public:
100
101 /// Methods that dispatch to subclass implementations. These need to be
102 /// manually updated when a new subclass is added.
103 ///@{
104 void deleteRecord();
105 DbgRecord *clone() const;
106 void print(raw_ostream &O, bool IsForDebug = false) const;
107 void print(raw_ostream &O, ModuleSlotTracker &MST, bool IsForDebug) const;
108 bool isIdenticalToWhenDefined(const DbgRecord &R) const;
109 /// Convert this DbgRecord back into an appropriate llvm.dbg.* intrinsic.
110 /// \p InsertBefore Optional position to insert this intrinsic.
111 /// \returns A new llvm.dbg.* intrinsic representiung this DbgRecord.
113 Instruction *InsertBefore) const;
114 ///@}
115
116 /// Same as isIdenticalToWhenDefined but checks DebugLoc too.
117 bool isEquivalentTo(const DbgRecord &R) const;
118
119 Kind getRecordKind() const { return RecordKind; }
120
121 void setMarker(DPMarker *M) { Marker = M; }
122
123 DPMarker *getMarker() { return Marker; }
124 const DPMarker *getMarker() const { return Marker; }
125
127 const BasicBlock *getBlock() const;
128
130 const Function *getFunction() const;
131
132 Module *getModule();
133 const Module *getModule() const;
134
136 const LLVMContext &getContext() const;
137
138 const Instruction *getInstruction() const;
139 const BasicBlock *getParent() const;
141
142 void removeFromParent();
143 void eraseFromParent();
144
145 DbgRecord *getNextNode() { return &*std::next(getIterator()); }
146 DbgRecord *getPrevNode() { return &*std::prev(getIterator()); }
147 void insertBefore(DbgRecord *InsertBefore);
148 void insertAfter(DbgRecord *InsertAfter);
149 void moveBefore(DbgRecord *MoveBefore);
150 void moveAfter(DbgRecord *MoveAfter);
151
152 DebugLoc getDebugLoc() const { return DbgLoc; }
153 void setDebugLoc(DebugLoc Loc) { DbgLoc = std::move(Loc); }
154
155 void dump() const;
156
159
160protected:
161 /// Similarly to Value, we avoid paying the cost of a vtable
162 /// by protecting the dtor and having deleteRecord dispatch
163 /// cleanup.
164 /// Use deleteRecord to delete a generic record.
165 ~DbgRecord() = default;
166};
167
169 R.print(OS);
170 return OS;
171}
172
173/// Records a position in IR for a source label (DILabel). Corresponds to the
174/// llvm.dbg.label intrinsic.
175/// FIXME: Rename DbgLabelRecord when DPValue is renamed to DbgVariableRecord.
176class DPLabel : public DbgRecord {
177 DILabel *Label;
178
179public:
181 : DbgRecord(LabelKind, DL), Label(Label) {
182 assert(Label && "Unexpected nullptr");
183 }
184
185 DPLabel *clone() const;
186 void print(raw_ostream &O, bool IsForDebug = false) const;
187 void print(raw_ostream &ROS, ModuleSlotTracker &MST, bool IsForDebug) const;
189 Instruction *InsertBefore) const;
190
191 void setLabel(DILabel *NewLabel) { Label = NewLabel; }
192 DILabel *getLabel() const { return Label; }
193
194 /// Support type inquiry through isa, cast, and dyn_cast.
195 static bool classof(const DbgRecord *E) {
196 return E->getRecordKind() == LabelKind;
197 }
198};
199
200/// Record of a variable value-assignment, aka a non instruction representation
201/// of the dbg.value intrinsic.
202///
203/// This class inherits from DebugValueUser to allow LLVM's metadata facilities
204/// to update our references to metadata beneath our feet.
205class DPValue : public DbgRecord, protected DebugValueUser {
206 friend class DebugValueUser;
207
208public:
209 enum class LocationType : uint8_t {
210 Declare,
211 Value,
212 Assign,
213
214 End, ///< Marks the end of the concrete types.
215 Any, ///< To indicate all LocationTypes in searches.
216 };
217 /// Classification of the debug-info record that this DPValue represents.
218 /// Essentially, "is this a dbg.value or dbg.declare?". dbg.declares are not
219 /// currently supported, but it would be trivial to do so.
220 /// FIXME: We could use spare padding bits from DbgRecord for this.
222
223 // NB: there is no explicit "Value" field in this class, it's effectively the
224 // DebugValueUser superclass instead. The referred to Value can either be a
225 // ValueAsMetadata or a DIArgList.
226
230
231public:
232 /// Create a new DPValue representing the intrinsic \p DVI, for example the
233 /// assignment represented by a dbg.value.
234 DPValue(const DbgVariableIntrinsic *DVI);
235 DPValue(const DPValue &DPV);
236 /// Directly construct a new DPValue representing a dbg.value intrinsic
237 /// assigning \p Location to the DV / Expr / DI variable.
238 DPValue(Metadata *Location, DILocalVariable *DV, DIExpression *Expr,
241 DIAssignID *AssignID, Metadata *Address,
243
246 DIAssignID *AssignID, Value *Address,
248 const DILocation *DI);
249 static DPValue *createLinkedDPVAssign(Instruction *LinkedInstr, Value *Val,
252 Value *Address,
254 const DILocation *DI);
255
256 static DPValue *createDPValue(Value *Location, DILocalVariable *DV,
257 DIExpression *Expr, const DILocation *DI);
258 static DPValue *createDPValue(Value *Location, DILocalVariable *DV,
259 DIExpression *Expr, const DILocation *DI,
260 DPValue &InsertBefore);
262 DIExpression *Expr, const DILocation *DI);
264 DIExpression *Expr, const DILocation *DI,
265 DPValue &InsertBefore);
266
267 /// Iterator for ValueAsMetadata that internally uses direct pointer iteration
268 /// over either a ValueAsMetadata* or a ValueAsMetadata**, dereferencing to the
269 /// ValueAsMetadata .
271 : public iterator_facade_base<location_op_iterator,
272 std::bidirectional_iterator_tag, Value *> {
274
275 public:
276 location_op_iterator(ValueAsMetadata *SingleIter) : I(SingleIter) {}
277 location_op_iterator(ValueAsMetadata **MultiIter) : I(MultiIter) {}
278
281 I = R.I;
282 return *this;
283 }
285 return I == RHS.I;
286 }
287 const Value *operator*() const {
288 ValueAsMetadata *VAM = I.is<ValueAsMetadata *>()
289 ? I.get<ValueAsMetadata *>()
290 : *I.get<ValueAsMetadata **>();
291 return VAM->getValue();
292 };
294 ValueAsMetadata *VAM = I.is<ValueAsMetadata *>()
295 ? I.get<ValueAsMetadata *>()
296 : *I.get<ValueAsMetadata **>();
297 return VAM->getValue();
298 }
300 if (I.is<ValueAsMetadata *>())
301 I = I.get<ValueAsMetadata *>() + 1;
302 else
303 I = I.get<ValueAsMetadata **>() + 1;
304 return *this;
305 }
307 if (I.is<ValueAsMetadata *>())
308 I = I.get<ValueAsMetadata *>() - 1;
309 else
310 I = I.get<ValueAsMetadata **>() - 1;
311 return *this;
312 }
313 };
314
316 bool isDbgValue() { return Type == LocationType::Value; }
317
318 /// Get the locations corresponding to the variable referenced by the debug
319 /// info intrinsic. Depending on the intrinsic, this could be the
320 /// variable's value or its address.
322
323 Value *getVariableLocationOp(unsigned OpIdx) const;
324
325 void replaceVariableLocationOp(Value *OldValue, Value *NewValue,
326 bool AllowEmpty = false);
327 void replaceVariableLocationOp(unsigned OpIdx, Value *NewValue);
328 /// Adding a new location operand will always result in this intrinsic using
329 /// an ArgList, and must always be accompanied by a new expression that uses
330 /// the new operand.
333
334 void setVariable(DILocalVariable *NewVar);
335
337
338 unsigned getNumVariableLocationOps() const;
339
340 bool hasArgList() const { return isa<DIArgList>(getRawLocation()); }
341 /// Returns true if this DPValue has no empty MDNodes in its location list.
342 bool hasValidLocation() const { return getVariableLocationOp(0) != nullptr; }
343
344 /// Does this describe the address of a local variable. True for dbg.addr
345 /// and dbg.declare, but not dbg.value, which describes its value.
347 LocationType getType() const { return Type; }
348
349 void setKillLocation();
350 bool isKillLocation() const;
351
353 MDNode *getRawVariable() const { return Variable; }
354
356
357 /// Returns the metadata operand for the first location description. i.e.,
358 /// dbg intrinsic dbg.value,declare operand and dbg.assign 1st location
359 /// operand (the "value componenet"). Note the operand (singular) may be
360 /// a DIArgList which is a list of values.
361 Metadata *getRawLocation() const { return DebugValues[0]; }
362
363 Value *getValue(unsigned OpIdx = 0) const {
364 return getVariableLocationOp(OpIdx);
365 }
366
367 /// Use of this should generally be avoided; instead,
368 /// replaceVariableLocationOp and addVariableLocationOps should be used where
369 /// possible to avoid creating invalid state.
370 void setRawLocation(Metadata *NewLocation) {
371 assert(
372 (isa<ValueAsMetadata>(NewLocation) || isa<DIArgList>(NewLocation) ||
373 isa<MDNode>(NewLocation)) &&
374 "Location for a DPValue must be either ValueAsMetadata or DIArgList");
375 resetDebugValue(0, NewLocation);
376 }
377
378 /// Get the size (in bits) of the variable, or fragment of the variable that
379 /// is described.
380 std::optional<uint64_t> getFragmentSizeInBits() const;
381
382 bool isEquivalentTo(const DPValue &Other) const {
383 return DbgLoc == Other.DbgLoc && isIdenticalToWhenDefined(Other);
384 }
385 // Matches the definition of the Instruction version, equivalent to above but
386 // without checking DbgLoc.
388 return std::tie(Type, DebugValues, Variable, Expression,
390 std::tie(Other.Type, Other.DebugValues, Other.Variable,
391 Other.Expression, Other.AddressExpression);
392 }
393
394 /// @name DbgAssign Methods
395 /// @{
396 bool isDbgAssign() const { return getType() == LocationType::Assign; }
397
398 Value *getAddress() const;
400 return isDbgAssign() ? DebugValues[1] : DebugValues[0];
401 }
402 Metadata *getRawAssignID() const { return DebugValues[2]; }
403 DIAssignID *getAssignID() const;
407 }
408 void setAssignId(DIAssignID *New);
410 /// Kill the address component.
411 void setKillAddress();
412 /// Check whether this kills the address component. This doesn't take into
413 /// account the position of the intrinsic, therefore a returned value of false
414 /// does not guarentee the address is a valid location for the variable at the
415 /// intrinsic's position in IR.
416 bool isKillAddress() const;
417
418 /// @}
419
420 DPValue *clone() const;
421 /// Convert this DPValue back into a dbg.value intrinsic.
422 /// \p InsertBefore Optional position to insert this intrinsic.
423 /// \returns A new dbg.value intrinsic representiung this DPValue.
425 Instruction *InsertBefore) const;
426
427 /// Handle changes to the location of the Value(s) that we refer to happening
428 /// "under our feet".
429 void handleChangedLocation(Metadata *NewLocation);
430
431 void print(raw_ostream &O, bool IsForDebug = false) const;
432 void print(raw_ostream &ROS, ModuleSlotTracker &MST, bool IsForDebug) const;
433
434 /// Filter the DbgRecord range to DPValue types only and downcast.
435 static inline auto
437 return map_range(
438 make_filter_range(R, [](DbgRecord &E) { return isa<DPValue>(E); }),
439 [](DbgRecord &E) { return std::ref(cast<DPValue>(E)); });
440 }
441
442 /// Support type inquiry through isa, cast, and dyn_cast.
443 static bool classof(const DbgRecord *E) {
444 return E->getRecordKind() == ValueKind;
445 }
446};
447
448/// Per-instruction record of debug-info. If an Instruction is the position of
449/// some debugging information, it points at a DPMarker storing that info. Each
450/// marker points back at the instruction that owns it. Various utilities are
451/// provided for manipulating the DbgRecords contained within this marker.
452///
453/// This class has a rough surface area, because it's needed to preserve the
454/// one arefact that we can't yet eliminate from the intrinsic / dbg.value
455/// debug-info design: the order of records is significant, and duplicates can
456/// exist. Thus, if one has a run of debug-info records such as:
457/// dbg.value(...
458/// %foo = barinst
459/// dbg.value(...
460/// and remove barinst, then the dbg.values must be preserved in the correct
461/// order. Hence, the use of iterators to select positions to insert things
462/// into, or the occasional InsertAtHead parameter indicating that new records
463/// should go at the start of the list.
464///
465/// There are only five or six places in LLVM that truly rely on this ordering,
466/// which we can improve in the future. Additionally, many improvements in the
467/// way that debug-info is stored can be achieved in this class, at a future
468/// date.
469class DPMarker {
470public:
472 /// Link back to the Instruction that owns this marker. Can be null during
473 /// operations that move a marker from one instruction to another.
475
476 /// List of DbgRecords, the non-instruction equivalent of llvm.dbg.*
477 /// intrinsics. There is a one-to-one relationship between each debug
478 /// intrinsic in a block and each DbgRecord once the representation has been
479 /// converted, and the ordering is meaningful in the same way.
481 bool empty() const { return StoredDPValues.empty(); }
482
483 const BasicBlock *getParent() const;
485
486 /// Handle the removal of a marker: the position of debug-info has gone away,
487 /// but the stored debug records should not. Drop them onto the next
488 /// instruction, or otherwise work out what to do with them.
489 void removeMarker();
490 void dump() const;
491
492 void removeFromParent();
493 void eraseFromParent();
494
495 /// Implement operator<< on DPMarker.
496 void print(raw_ostream &O, bool IsForDebug = false) const;
497 void print(raw_ostream &ROS, ModuleSlotTracker &MST, bool IsForDebug) const;
498
499 /// Produce a range over all the DPValues in this Marker.
502 getDbgValueRange() const;
503 /// Transfer any DPValues from \p Src into this DPMarker. If \p InsertAtHead
504 /// is true, place them before existing DPValues, otherwise afterwards.
505 void absorbDebugValues(DPMarker &Src, bool InsertAtHead);
506 /// Transfer the DPValues in \p Range from \p Src into this DPMarker. If
507 /// \p InsertAtHead is true, place them before existing DPValues, otherwise
508 // afterwards.
510 DPMarker &Src, bool InsertAtHead);
511 /// Insert a DPValue into this DPMarker, at the end of the list. If
512 /// \p InsertAtHead is true, at the start.
513 void insertDPValue(DbgRecord *New, bool InsertAtHead);
514 /// Insert a DPValue prior to a DPValue contained within this marker.
515 void insertDPValue(DbgRecord *New, DbgRecord *InsertBefore);
516 /// Insert a DPValue after a DPValue contained within this marker.
517 void insertDPValueAfter(DbgRecord *New, DbgRecord *InsertAfter);
518 /// Clone all DPMarkers from \p From into this marker. There are numerous
519 /// options to customise the source/destination, due to gnarliness, see class
520 /// comment.
521 /// \p FromHere If non-null, copy from FromHere to the end of From's DPValues
522 /// \p InsertAtHead Place the cloned DPValues at the start of StoredDPValues
523 /// \returns Range over all the newly cloned DPValues
526 std::optional<simple_ilist<DbgRecord>::iterator> FromHere,
527 bool InsertAtHead = false);
528 /// Erase all DPValues in this DPMarker.
529 void dropDbgValues();
530 /// Erase a single DbgRecord from this marker. In an ideal future, we would
531 /// never erase an assignment in this way, but it's the equivalent to
532 /// erasing a debug intrinsic from a block.
533 void dropOneDbgValue(DbgRecord *DR);
534
535 /// We generally act like all llvm Instructions have a range of DPValues
536 /// attached to them, but in reality sometimes we don't allocate the DPMarker
537 /// to save time and memory, but still have to return ranges of DPValues. When
538 /// we need to describe such an unallocated DPValue range, use this static
539 /// markers range instead. This will bite us if someone tries to insert a
540 /// DPValue in that range, but they should be using the Official (TM) API for
541 /// that.
547 }
548};
549
550inline raw_ostream &operator<<(raw_ostream &OS, const DPMarker &Marker) {
551 Marker.print(OS);
552 return OS;
553}
554
555/// Inline helper to return a range of DPValues attached to a marker. It needs
556/// to be inlined as it's frequently called, but also come after the declaration
557/// of DPMarker. Thus: it's pre-declared by users like Instruction, then an
558/// inlineable body defined here.
559inline iterator_range<simple_ilist<DbgRecord>::iterator>
561 if (!DbgMarker)
563 return DbgMarker->getDbgValueRange();
564}
565
566} // namespace llvm
567
568#endif // LLVM_IR_DEBUGPROGRAMINSTRUCTION_H
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
BlockVerifier::State From
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define I(x, y, z)
Definition: MD5.cpp:58
Machine Check Debug Module
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
raw_pwrite_stream & OS
Value * RHS
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
LLVM Basic Block Representation.
Definition: BasicBlock.h:60
Assignment ID.
DWARF expression.
Debug location.
Records a position in IR for a source label (DILabel).
void print(raw_ostream &O, bool IsForDebug=false) const
Definition: AsmWriter.cpp:4930
DbgLabelInst * createDebugIntrinsic(Module *M, Instruction *InsertBefore) const
DPLabel * clone() const
DILabel * getLabel() const
void setLabel(DILabel *NewLabel)
static bool classof(const DbgRecord *E)
Support type inquiry through isa, cast, and dyn_cast.
DPLabel(DILabel *Label, DebugLoc DL)
Per-instruction record of debug-info.
static iterator_range< simple_ilist< DbgRecord >::iterator > getEmptyDPValueRange()
void dropOneDbgValue(DbgRecord *DR)
Erase a single DbgRecord from this marker.
const BasicBlock * getParent() const
void dropDbgValues()
Erase all DPValues in this DPMarker.
void insertDPValue(DbgRecord *New, bool InsertAtHead)
Insert a DPValue into this DPMarker, at the end of the list.
void insertDPValueAfter(DbgRecord *New, DbgRecord *InsertAfter)
Insert a DPValue after a DPValue contained within this marker.
Instruction * MarkedInstr
Link back to the Instruction that owns this marker.
void print(raw_ostream &O, bool IsForDebug=false) const
Implement operator<< on DPMarker.
Definition: AsmWriter.cpp:4903
void absorbDebugValues(DPMarker &Src, bool InsertAtHead)
Transfer any DPValues from Src into this DPMarker.
simple_ilist< DbgRecord > StoredDPValues
List of DbgRecords, the non-instruction equivalent of llvm.dbg.
void dump() const
Definition: AsmWriter.cpp:5216
static DPMarker EmptyDPMarker
We generally act like all llvm Instructions have a range of DPValues attached to them,...
iterator_range< simple_ilist< DbgRecord >::iterator > getDbgValueRange()
Produce a range over all the DPValues in this Marker.
iterator_range< simple_ilist< DbgRecord >::iterator > cloneDebugInfoFrom(DPMarker *From, std::optional< simple_ilist< DbgRecord >::iterator > FromHere, bool InsertAtHead=false)
Clone all DPMarkers from From into this marker.
void removeMarker()
Handle the removal of a marker: the position of debug-info has gone away, but the stored debug record...
Iterator for ValueAsMetadata that internally uses direct pointer iteration over either a ValueAsMetad...
location_op_iterator(ValueAsMetadata *SingleIter)
location_op_iterator & operator=(const location_op_iterator &R)
bool operator==(const location_op_iterator &RHS) const
location_op_iterator(ValueAsMetadata **MultiIter)
location_op_iterator(const location_op_iterator &R)
Record of a variable value-assignment, aka a non instruction representation of the dbg....
LocationType Type
Classification of the debug-info record that this DPValue represents.
bool isIdenticalToWhenDefined(const DPValue &Other) const
Value * getValue(unsigned OpIdx=0) const
bool hasValidLocation() const
Returns true if this DPValue has no empty MDNodes in its location list.
void setAddressExpression(DIExpression *NewExpr)
Value * getAddress() const
DIExpression * AddressExpression
DIExpression * getExpression() const
void addVariableLocationOps(ArrayRef< Value * > NewValues, DIExpression *NewExpr)
Adding a new location operand will always result in this intrinsic using an ArgList,...
static bool classof(const DbgRecord *E)
Support type inquiry through isa, cast, and dyn_cast.
void setAssignId(DIAssignID *New)
MDNode * getRawVariable() const
void print(raw_ostream &O, bool IsForDebug=false) const
Definition: AsmWriter.cpp:4909
void setVariable(DILocalVariable *NewVar)
void setAddress(Value *V)
bool isEquivalentTo(const DPValue &Other) const
static DPValue * createDPValue(Value *Location, DILocalVariable *DV, DIExpression *Expr, const DILocation *DI)
iterator_range< location_op_iterator > location_ops() const
Get the locations corresponding to the variable referenced by the debug info intrinsic.
static DPValue * createDPVAssign(Value *Val, DILocalVariable *Variable, DIExpression *Expression, DIAssignID *AssignID, Value *Address, DIExpression *AddressExpression, const DILocation *DI)
TrackingMDNodeRef Variable
static DPValue * createDPVDeclare(Value *Address, DILocalVariable *DV, DIExpression *Expr, const DILocation *DI)
void setRawLocation(Metadata *NewLocation)
Use of this should generally be avoided; instead, replaceVariableLocationOp and addVariableLocationOp...
void handleChangedLocation(Metadata *NewLocation)
Handle changes to the location of the Value(s) that we refer to happening "under our feet".
static DPValue * createLinkedDPVAssign(Instruction *LinkedInstr, Value *Val, DILocalVariable *Variable, DIExpression *Expression, Value *Address, DIExpression *AddressExpression, const DILocation *DI)
DIExpression * getAddressExpression() const
unsigned getNumVariableLocationOps() const
LocationType getType() const
void setExpression(DIExpression *NewExpr)
std::optional< uint64_t > getFragmentSizeInBits() const
Get the size (in bits) of the variable, or fragment of the variable that is described.
Metadata * getRawLocation() const
Returns the metadata operand for the first location description.
DPValue * clone() const
void setKillAddress()
Kill the address component.
bool isKillAddress() const
Check whether this kills the address component.
Metadata * getRawAssignID() const
Value * getVariableLocationOp(unsigned OpIdx) const
Metadata * getRawAddress() const
@ End
Marks the end of the concrete types.
@ Any
To indicate all LocationTypes in searches.
DIAssignID * getAssignID() const
DILocalVariable * getVariable() const
DbgVariableIntrinsic * createDebugIntrinsic(Module *M, Instruction *InsertBefore) const
Convert this DPValue back into a dbg.value intrinsic.
static auto filter(iterator_range< simple_ilist< DbgRecord >::iterator > R)
Filter the DbgRecord range to DPValue types only and downcast.
void replaceVariableLocationOp(Value *OldValue, Value *NewValue, bool AllowEmpty=false)
DIExpression * Expression
bool isAddressOfVariable() const
Does this describe the address of a local variable.
This is the common base class for debug info intrinsics.
This represents the llvm.dbg.label instruction.
Base class for non-instruction debug metadata records that have positions within IR.
void insertAfter(DbgRecord *InsertAfter)
void setMarker(DPMarker *M)
void print(raw_ostream &O, bool IsForDebug=false) const
bool isEquivalentTo(const DbgRecord &R) const
Same as isIdenticalToWhenDefined but checks DebugLoc too.
DbgRecord(Kind RecordKind, DebugLoc DL)
simple_ilist< DbgRecord >::iterator self_iterator
DebugLoc getDebugLoc() const
void dump() const
Definition: AsmWriter.cpp:5220
DbgInfoIntrinsic * createDebugIntrinsic(Module *M, Instruction *InsertBefore) const
Convert this DbgRecord back into an appropriate llvm.dbg.
Kind RecordKind
Subclass discriminator.
void deleteRecord()
Methods that dispatch to subclass implementations.
void insertBefore(DbgRecord *InsertBefore)
~DbgRecord()=default
Similarly to Value, we avoid paying the cost of a vtable by protecting the dtor and having deleteReco...
void moveBefore(DbgRecord *MoveBefore)
simple_ilist< DbgRecord >::const_iterator const_self_iterator
Kind
Subclass discriminator.
void setDebugLoc(DebugLoc Loc)
const Instruction * getInstruction() const
DPMarker * Marker
Marker that this DbgRecord is linked into.
void moveAfter(DbgRecord *MoveAfter)
bool isIdenticalToWhenDefined(const DbgRecord &R) const
DbgRecord * clone() const
const DPMarker * getMarker() const
const BasicBlock * getParent() const
This is the common base class for debug info intrinsics for variables.
A debug info location.
Definition: DebugLoc.h:33
Base class for tracking ValueAsMetadata/DIArgLists with user lookups and Owner callbacks outside of V...
Definition: Metadata.h:212
std::array< Metadata *, 3 > DebugValues
Definition: Metadata.h:218
void resetDebugValue(size_t Idx, Metadata *DebugValue)
Definition: Metadata.h:273
Class representing an expression and its matching format.
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:67
Metadata node.
Definition: Metadata.h:1067
Root of the metadata hierarchy.
Definition: Metadata.h:62
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:65
A discriminated union of two or more pointer types, with the discriminator in the low bit of the poin...
Definition: PointerUnion.h:118
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
Value wrapper in the Metadata hierarchy.
Definition: Metadata.h:450
static ValueAsMetadata * get(Value *V)
Definition: Metadata.cpp:492
Value * getValue() const
Definition: Metadata.h:490
LLVM Value Representation.
Definition: Value.h:74
self_iterator getIterator()
Definition: ilist_node.h:109
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:52
A simple intrusive list implementation.
Definition: simple_ilist.h:81
typename ilist_select_iterator_type< OptionsT::has_iterator_bits, OptionsT, false, false >::type iterator
Definition: simple_ilist.h:97
typename ilist_select_iterator_type< OptionsT::has_iterator_bits, OptionsT, false, true >::type const_iterator
Definition: simple_ilist.h:100
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...
@ BasicBlock
Various leaf nodes.
Definition: ISDOpcodes.h:71
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
iterator_range< simple_ilist< DbgRecord >::iterator > getDbgValueRange(DPMarker *DbgMarker)
Inline helper to return a range of DPValues attached to a marker.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
auto map_range(ContainerTy &&C, FuncTy F)
Definition: STLExtras.h:377
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:581
@ Other
Any other memory.
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
Definition: APFixedPoint.h:293