LLVM: include/llvm/IR/DebugLoc.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14#ifndef LLVM_IR_DEBUGLOC_H
15#define LLVM_IR_DEBUGLOC_H
16
17#include "llvm/Config/llvm-config.h"
21
22namespace llvm {
23
28
29#if LLVM_ENABLE_DEBUGLOC_TRACKING_COVERAGE
30#if LLVM_ENABLE_DEBUGLOC_TRACKING_ORIGIN
31struct DbgLocOrigin {
32 static constexpr unsigned long MaxDepth = 16;
33 using StackTracesTy =
34 SmallVector<std::pair<int, std::array<void *, MaxDepth>>, 0>;
35 StackTracesTy StackTraces;
36 DbgLocOrigin(bool ShouldCollectTrace);
37 void addTrace();
38 const StackTracesTy &getOriginStackTraces() const { return StackTraces; };
39};
40#else
41struct DbgLocOrigin {
42 DbgLocOrigin(bool) {}
43};
44#endif
45
46
47
48
49enum class DebugLocKind : uint8_t {
50
52
53
55
56
57
58
59 Dropped,
60
61
62
63
65
66
67
68
69
70 Temporary
71};
72
73
74
75
76
77
78
79class DILocAndCoverageTracking : public TrackingMDNodeRef, public DbgLocOrigin {
80public:
81 DebugLocKind Kind;
82
83 DILocAndCoverageTracking()
86
87 DILocAndCoverageTracking(const MDNode *Loc)
88 : TrackingMDNodeRef(const_cast<MDNode *>(Loc)), DbgLocOrigin(!Loc),
90 LLVM_ABI DILocAndCoverageTracking(const DILocation *Loc);
91
92 DILocAndCoverageTracking(DebugLocKind Kind)
95};
96template <> struct simplify_type {
98
100 return MD.get();
101 }
102};
105
106 static MDNode *getSimplifiedValue(const DILocAndCoverageTracking &MD) {
107 return MD.get();
108 }
109};
110
112#else
114#endif
115
116
117
118
119
120
121
122
124
126
127public:
129
130
132
133
134
135
136
137
138
140
141#if LLVM_ENABLE_DEBUGLOC_TRACKING_COVERAGE
142 DebugLoc(DebugLocKind Kind) : Loc(Kind) {}
143 DebugLocKind getKind() const { return Loc.Kind; }
144#endif
145
146#if LLVM_ENABLE_DEBUGLOC_TRACKING_COVERAGE
148 return DebugLoc(DebugLocKind::Temporary);
149 }
151 return DebugLoc(DebugLocKind::Unknown);
152 }
154 return DebugLoc(DebugLocKind::CompilerGenerated);
155 }
157 return DebugLoc(DebugLocKind::Dropped);
158 }
159#else
164#endif
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
182
183
184
185
186
188
189
190
191
192
193
194
196 if (*this)
197 return *this;
198#if LLVM_ENABLE_DEBUGLOC_TRACKING_COVERAGE
201 if (getKind() != DebugLocKind::Normal)
202 return *this;
203 if (Other.getKind() != DebugLocKind::Normal)
205 return *this;
206#else
208#endif
209 }
210
211#if LLVM_ENABLE_DEBUGLOC_TRACKING_ORIGIN
212 const DbgLocOrigin::StackTracesTy &getOriginStackTraces() const {
213 return Loc.getOriginStackTraces();
214 }
217 NewDL.Loc.addTrace();
218 return NewDL;
219 }
220#else
222#endif
223
224
225
226
227
232
233
234
235
236
237
238
239
240 explicit operator bool() const { return Loc; }
241
242
244
246
247
248
252
253
254
257 return true;
258 return ((bool)*this == (bool)Other) && getLine() == Other.getLine() &&
261 }
262
267
268
269
270
272
273
274
279
280
281
282
283
284
285
286
288
289
291
292
295
298
300
301
303};
304
305}
306
307#endif
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Subprogram description. Uses SubclassData1.
A debug info location.
Definition DebugLoc.h:123
LLVM_ABI void setImplicitCode(bool ImplicitCode)
DILocation & operator*() const
Definition DebugLoc.h:231
bool isSameSourceLocation(const DebugLoc &Other) const
Return true if the source locations match, ignoring isImplicitCode and source atom info.
Definition DebugLoc.h:255
static DebugLoc getCompilerGenerated()
Definition DebugLoc.h:162
bool operator==(const DebugLoc &DL) const
Definition DebugLoc.h:296
LLVM_ABI unsigned getLine() const
DebugLoc orElse(DebugLoc Other) const
If this DebugLoc is non-empty, returns this DebugLoc; otherwise, selects Other.
Definition DebugLoc.h:195
LLVM_ABI DebugLoc getFnDebugLoc() const
Find the debug info location for the start of the function.
LLVM_ABI DILocation * get() const
Get the underlying DILocation.
LLVM_ABI MDNode * getScope() const
DebugLoc getCopied() const
Definition DebugLoc.h:221
static LLVM_ABI DebugLoc appendInlinedAt(const DebugLoc &DL, DILocation *InlinedAt, LLVMContext &Ctx, DenseMap< const MDNode *, MDNode * > &Cache)
Rebuild the entire inlined-at chain for this instruction so that the top of the chain now is inlined-...
DILocation * operator->() const
Definition DebugLoc.h:230
bool hasTrivialDestructor() const
Check whether this has a trivial destructor.
Definition DebugLoc.h:243
static DebugLoc getTemporary()
Definition DebugLoc.h:160
@ ReplaceLastInlinedAt
Definition DebugLoc.h:245
static LLVM_ABI DebugLoc getMergedLocation(DebugLoc LocA, DebugLoc LocB)
When two instructions are combined into a single instruction we also need to combine the original loc...
LLVM_ABI void print(raw_ostream &OS) const
prints source location /path/to/file.exe:line:col @[inlined at]
static LLVM_ABI DebugLoc getMergedLocations(ArrayRef< DebugLoc > Locs)
Try to combine the vector of locations passed as input in a single one.
MDNode * getAsMDNode() const
Return this as a bar MDNode.
Definition DebugLoc.h:290
LLVM_ABI unsigned getCol() const
static LLVM_ABI DebugLoc replaceInlinedAtSubprogram(const DebugLoc &DL, DISubprogram &NewSP, LLVMContext &Ctx, DenseMap< const MDNode *, MDNode * > &Cache)
Rebuild the entire inline-at chain by replacing the subprogram at the end of the chain with NewSP.
LLVM_ABI bool isImplicitCode() const
Check if the DebugLoc corresponds to an implicit code.
LLVM_ABI void dump() const
static DebugLoc getUnknown()
Definition DebugLoc.h:161
LLVM_ABI DILocation * getInlinedAt() const
static DebugLoc getDropped()
Definition DebugLoc.h:163
bool operator!=(const DebugLoc &DL) const
Definition DebugLoc.h:297
LLVM_ABI MDNode * getInlinedAtScope() const
Get the fully inlined-at scope for a DebugLoc.
This is an important class for using LLVM in a threaded context.
This class implements an extremely fast bulk output stream that can only output to a stream.
This is an optimization pass for GlobalISel generic memory operations.
TypedTrackingMDRef< MDNode > TrackingMDNodeRef
TrackingMDNodeRef DebugLocTrackingRef
Definition DebugLoc.h:113
Define a template that can be specialized by smart pointers to reflect the fact that they are automat...
static SimpleType & getSimplifiedValue(From &Val)