LLVM: include/llvm/IR/DebugProgramInstruction.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47#ifndef LLVM_IR_DEBUGPROGRAMINSTRUCTION_H
48#define LLVM_IR_DEBUGPROGRAMINSTRUCTION_H
49
58
59namespace llvm {
60
61class Instruction;
63class MDNode;
65class DbgVariableIntrinsic;
66class DbgInfoIntrinsic;
67class DbgLabelInst;
68class DIAssignID;
69class DbgMarker;
70class DbgVariableRecord;
71class raw_ostream;
72
73
74
75
78
79public:
80public:
82
83
85
86
87
88
89
90
91
93
94
95
96
97
99 operator T *() const { return get(); }
102
103
104
105
106
107 explicit operator bool() const { return Ref; }
108
109
111
113 return Ref == Other.Ref;
114 }
116 return Ref != Other.Ref;
117 }
118};
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
135public:
136
138
140
141protected:
144
145public:
148
149
150
151
157
158
159
162
163
164
166
168
170
173
176
179
182
185
189
192
199
202
203 void dump() const;
204
207
208protected:
209
210
211
212
214};
215
217 R.print(OS);
218 return OS;
219}
220
221
222
225
226
227
228
230
231public:
233
234
235
236
237
240
246
250
251
253 return E->getRecordKind() == LabelKind;
254 }
255};
256
257
258
259
260
261
264
265public:
270
271 End,
272 Any,
273 };
274
275
276
277
279
280
281
282
283
287
288public:
289
290
293
294
302
303private:
304
305
306
307
311
312public:
313
314
315
316
317
318
319
325
336
352
353
354
355
358 std::bidirectional_iterator_tag, Value *> {
360
361 public:
364
367 I = R.I;
368 return *this;
369 }
372 }
375 ? cast<ValueAsMetadata *>(I)
376 : *cast<ValueAsMetadata **>(I);
378 };
381 ? cast<ValueAsMetadata *>(I)
382 : *cast<ValueAsMetadata **>(I);
384 }
386 if (auto *VAM = dyn_cast<ValueAsMetadata *>(I))
387 I = VAM + 1;
388 else
389 I = cast<ValueAsMetadata **>(I) + 1;
390 return *this;
391 }
393 if (auto *VAM = dyn_cast<ValueAsMetadata *>(I))
394 I = VAM - 1;
395 else
396 I = cast<ValueAsMetadata **>(I) - 1;
397 return *this;
398 }
399 };
400
403
404
405
406
408
410
412 bool AllowEmpty = false);
414
415
416
419
421
423
424
426
427
428
430
431
432
434
436
439
443
447
448
449
450
451
453
456 }
457
458
459
460
462 assert((isa(NewLocation) || isa(NewLocation) ||
463 isa(NewLocation)) &&
464 "Location for a DbgVariableRecord must be either ValueAsMetadata or "
465 "DIArgList");
467 }
468
469 std::optional getFragment() const;
470
471
472
475 return *Frag;
477 return {*Sz, 0};
478 return {0, 0};
479 }
480
481
483
486 }
487
488
493 Other.Expression, Other.AddressExpression);
494 }
495
496
497
499
503 }
509 }
512 }
515
517
518
519
520
522
523
524
526
527
528
531
532
533
535
538
539
541 return E->getRecordKind() == ValueKind;
542 }
543};
544
545
546static inline auto
550 [](DbgRecord &E) { return isa(E); }),
551 [](DbgRecord &E) { return std::ref(cast(E)); });
552}
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
576public:
578
579
581
582
583
584
585
588
591
592
593
594
596 void dump() const;
597
600
601
604
605
609
610
611
613
614
615
617 DbgMarker &Src, bool InsertAtHead);
618
619
621
623
625
626
627
628
629
630
631
632
636 bool InsertAtHead = false);
637
639
640
641
643
644
645
646
647
648
649
650
656 }
657};
658
661 return OS;
662}
663
664
665
666
667
668inline iterator_range<simple_ilist::iterator>
670 if (!DebugMarker)
673}
674
676
677
678
679
681 T &Obj;
682 bool OldState;
683
684public:
686 : Obj(Obj), OldState(Obj.IsNewDbgInfoFormat) {
687 Obj.setIsNewDbgInfoFormat(NewState);
688 }
690};
691
692template
695
696}
697
698#endif
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
BlockVerifier::State From
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define DEFINE_ISA_CONVERSION_FUNCTIONS(ty, ref)
Machine Check Debug Module
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
LLVM Basic Block Representation.
This is the common base class for debug info intrinsics.
This represents the llvm.dbg.label instruction.
Records a position in IR for a source label (DILabel).
MDNode * getRawLabel() const
DbgLabelRecord * clone() const
static bool classof(const DbgRecord *E)
Support type inquiry through isa, cast, and dyn_cast.
void print(raw_ostream &O, bool IsForDebug=false) const
static DbgLabelRecord * createUnresolvedDbgLabelRecord(MDNode *Label, MDNode *DL)
For use during parsing; creates a DbgLabelRecord from as-of-yet unresolved MDNodes.
void setLabel(DILabel *NewLabel)
DILabel * getLabel() const
DbgLabelInst * createDebugIntrinsic(Module *M, Instruction *InsertBefore) const
Per-instruction record of debug-info.
static iterator_range< simple_ilist< DbgRecord >::iterator > getEmptyDbgRecordRange()
Instruction * MarkedInstr
Link back to the Instruction that owns this marker.
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.
void insertDbgRecordAfter(DbgRecord *New, DbgRecord *InsertAfter)
Insert a DbgRecord after a DbgRecord contained within this marker.
void print(raw_ostream &O, bool IsForDebug=false) const
Implement operator<< on DbgMarker.
void removeMarker()
Handle the removal of a marker: the position of debug-info has gone away, but the stored debug record...
void absorbDebugValues(DbgMarker &Src, bool InsertAtHead)
Transfer any DbgRecords from Src into this DbgMarker.
void dropDbgRecords()
Erase all DbgRecords in this DbgMarker.
iterator_range< simple_ilist< DbgRecord >::iterator > getDbgRecordRange()
Produce a range over all the DbgRecords in this Marker.
void dropOneDbgRecord(DbgRecord *DR)
Erase a single DbgRecord from this marker.
const BasicBlock * getParent() const
simple_ilist< DbgRecord > StoredDbgRecords
List of DbgRecords, the non-instruction equivalent of llvm.dbg.
void insertDbgRecord(DbgRecord *New, bool InsertAtHead)
Insert a DbgRecord into this DbgMarker, at the end of the list.
static DbgMarker EmptyDbgMarker
We generally act like all llvm Instructions have a range of DbgRecords attached to them,...
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
DbgRecordParamRef()=default
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.
void insertAfter(DbgRecord *InsertAfter)
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
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...
DbgRecord * getNextNode()
void moveBefore(DbgRecord *MoveBefore)
simple_ilist< DbgRecord >::const_iterator const_self_iterator
Kind
Subclass discriminator.
void setDebugLoc(DebugLoc Loc)
const Instruction * getInstruction() const
void moveAfter(DbgRecord *MoveAfter)
bool isIdenticalToWhenDefined(const DbgRecord &R) const
Kind getRecordKind() const
const DbgMarker * getMarker() const
DbgMarker * Marker
Marker that this DbgRecord is linked into.
void setMarker(DbgMarker *M)
DbgRecord * clone() const
LLVMContext & getContext()
DbgRecord * getPrevNode()
const BasicBlock * getParent() const
This is the common base class for debug info intrinsics for variables.
Iterator for ValueAsMetadata that internally uses direct pointer iteration over either a ValueAsMetad...
location_op_iterator(ValueAsMetadata **MultiIter)
location_op_iterator & operator--()
location_op_iterator(ValueAsMetadata *SingleIter)
bool operator==(const location_op_iterator &RHS) const
location_op_iterator & operator++()
location_op_iterator & operator=(const location_op_iterator &R)
const Value * operator*() const
location_op_iterator(const location_op_iterator &R)
Record of a variable value-assignment, aka a non instruction representation of the dbg....
bool isEquivalentTo(const DbgVariableRecord &Other) const
LocationType getType() const
DbgRecordParamRef< DIExpression > Expression
bool isValueOfVariable() const
Determine if this describes the value of a local variable.
bool isKillAddress() const
Check whether this kills the address component.
void print(raw_ostream &O, bool IsForDebug=false) const
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.
MDNode * getRawExpression() const
DbgRecordParamRef< DILocalVariable > Variable
void setAddressExpression(DIExpression *NewExpr)
bool isKillLocation() const
DIAssignID * getAssignID() const
DbgVariableFragmentInfo getFragmentOrEntireVariable() const
Get the FragmentInfo for the variable if it exists, otherwise return a FragmentInfo that covers the e...
MDNode * getRawAddressExpression() const
bool isAddressOfVariable() const
Does this describe the address of a local variable.
std::optional< uint64_t > getFragmentSizeInBits() const
Get the size (in bits) of the variable, or fragment of the variable that is described.
Value * getValue(unsigned OpIdx=0) const
DbgVariableRecord * clone() const
static DbgVariableRecord * createUnresolvedDbgVariableRecord(LocationType Type, Metadata *Val, MDNode *Variable, MDNode *Expression, MDNode *AssignID, Metadata *Address, MDNode *AddressExpression, MDNode *DI)
Used to create DbgVariableRecords during parsing, where some metadata references may still be unresol...
void setRawLocation(Metadata *NewLocation)
Use of this should generally be avoided; instead, replaceVariableLocationOp and addVariableLocationOp...
static DbgVariableRecord * createDbgVariableRecord(Value *Location, DILocalVariable *DV, DIExpression *Expr, const DILocation *DI)
static DbgVariableRecord * createDVRDeclare(Value *Address, DILocalVariable *DV, DIExpression *Expr, const DILocation *DI)
void setVariable(DILocalVariable *NewVar)
Value * getAddress() const
void setExpression(DIExpression *NewExpr)
DIExpression * getExpression() const
void handleChangedLocation(Metadata *NewLocation)
Handle changes to the location of the Value(s) that we refer to happening "under our feet".
Metadata * getRawAssignID() const
Value * getVariableLocationOp(unsigned OpIdx) const
void setKillAddress()
Kill the address component.
MDNode * getRawVariable() const
DILocalVariable * getVariable() const
static bool classof(const DbgRecord *E)
Support type inquiry through isa, cast, and dyn_cast.
void addVariableLocationOps(ArrayRef< Value * > NewValues, DIExpression *NewExpr)
Adding a new location operand will always result in this intrinsic using an ArgList,...
Metadata * getRawLocation() const
Returns the metadata operand for the first location description.
bool isDbgDeclare() const
void setAssignId(DIAssignID *New)
void setAddress(Value *V)
static DbgVariableRecord * createDVRAssign(Value *Val, DILocalVariable *Variable, DIExpression *Expression, DIAssignID *AssignID, Value *Address, DIExpression *AddressExpression, const DILocation *DI)
unsigned getNumVariableLocationOps() const
DbgVariableIntrinsic * createDebugIntrinsic(Module *M, Instruction *InsertBefore) const
Convert this DbgVariableRecord back into a dbg.value intrinsic.
Metadata * getRawAddress() const
void replaceVariableLocationOp(Value *OldValue, Value *NewValue, bool AllowEmpty=false)
@ End
Marks the end of the concrete types.
@ Any
To indicate all LocationTypes in searches.
std::optional< DbgVariableFragmentInfo > getFragment() const
static DbgVariableRecord * createLinkedDVRAssign(Instruction *LinkedInstr, Value *Val, DILocalVariable *Variable, DIExpression *Expression, Value *Address, DIExpression *AddressExpression, const DILocation *DI)
bool isIdenticalToWhenDefined(const DbgVariableRecord &Other) const
DbgRecordParamRef< DIExpression > AddressExpression
DIExpression * getAddressExpression() const
iterator_range< location_op_iterator > location_ops() const
Get the locations corresponding to the variable referenced by the debug info intrinsic.
Base class for tracking ValueAsMetadata/DIArgLists with user lookups and Owner callbacks outside of V...
std::array< Metadata *, 3 > DebugValues
void resetDebugValue(size_t Idx, Metadata *DebugValue)
Class representing an expression and its matching format.
This is an important class for using LLVM in a threaded context.
Manage lifetime of a slot tracker for printing IR.
A Module instance is used to store all the information related to an LLVM module.
A discriminated union of two or more pointer types, with the discriminator in the low bit of the poin...
Used to temporarily set the debug info format of a function, module, or basic block for the duration ...
ScopedDbgInfoFormatSetter(T &Obj, bool NewState)
~ScopedDbgInfoFormatSetter()
The instances of the Type class are immutable: once they are created, they are never changed.
LLVM Value Representation.
self_iterator getIterator()
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
A range adaptor for a pair of iterators.
This class implements an extremely fast bulk output stream that can only output to a stream.
A simple intrusive list implementation.
typename ilist_select_iterator_type< OptionsT::has_iterator_bits, OptionsT, false, false >::type iterator
typename ilist_select_iterator_type< OptionsT::has_iterator_bits, OptionsT, false, true >::type const_iterator
struct LLVMOpaqueDbgRecord * LLVMDbgRecordRef
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.
This is an optimization pass for GlobalISel generic memory operations.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
auto map_range(ContainerTy &&C, FuncTy F)
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...
iterator_range< simple_ilist< DbgRecord >::iterator > getDbgRecordRange(DbgMarker *DebugMarker)
Inline helper to return a range of DbgRecords attached to a marker.
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
static auto filterDbgVars(iterator_range< simple_ilist< DbgRecord >::iterator > R)
Filter the DbgRecord range to DbgVariableRecord types only and downcast.