LLVM: include/llvm/Analysis/PtrUseVisitor.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#ifndef LLVM_ANALYSIS_PTRUSEVISITOR_H
23#define LLVM_ANALYSIS_PTRUSEVISITOR_H
24
32#include
33#include <type_traits>
34
35namespace llvm {
36class DataLayout;
37
39
40
41
42
43
44
45
47public:
48
49
50
51
52
54 public:
55
57 AbortedInfo = nullptr;
58 EscapedInfo = nullptr;
59 }
60
61
62 bool isAborted() const { return AbortedInfo != nullptr; }
63
64
65 bool isEscaped() const { return EscapedInfo != nullptr; }
66
67
69
70
71
72
74
75
76
77
79
80
81
83
84
85
87 assert(I && "Expected a valid pointer in setAborted");
88 AbortedInfo = I;
89 }
90
91
92
94 assert(I && "Expected a valid pointer in setEscaped");
95 EscapedInfo = I;
96 }
97
98
100 assert(I && "Expected a valid pointer in setEscapedReadOnly");
101 EscapedReadOnly = I;
102 }
103
104
105
106
107
111 }
112
113 private:
117 };
118
119protected:
121
122
123
124
125
127
128
129
130
131
134
137 };
138
139
141
142
144
145
146
147
148
149
150
151
153
154
155
157
158
160
161
162
163
164
166
167
168
169
170
172
173
174
175
176
178};
179
180}
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207template
211
213
214public:
216 static_assert(std::is_base_of<PtrUseVisitor, DerivedT>::value,
217 "Must pass the derived type to this template!");
218 }
219
220
221
222
223
225
226
227
228 assert(I.getType()->isPointerTy());
234
235
237
238
245
246 Instruction *I = cast(U->getUser());
247 static_cast<DerivedT*>(this)->visit(I);
249 break;
250 }
251 return PI;
252 }
253
254protected:
256 if (SI.getValueOperand() == U->get())
258 }
259
262 }
263
266 }
267
270 }
271
274 return;
275
276
280 }
281
282
284 }
285
286
287
291 switch (II.getIntrinsicID()) {
292 default:
294
295
296
297 case Intrinsic::fake_use:
299 return;
300
301 case Intrinsic::lifetime_start:
302 case Intrinsic::lifetime_end:
303 return;
304 }
305 }
306
307
308
312 }
313};
314
315}
316
317#endif
This file implements a class to represent arbitrary precision integral constant values and operations...
uint64_t IntrinsicInst * II
StandardInstrumentations SI(Mod->getContext(), Debug, VerifyEach)
This file defines the PointerIntPair class.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallPtrSet class.
This file defines the SmallVector class.
Class for arbitrary precision integers.
This class represents a conversion between pointers from one address space to another.
This class represents a no-op cast from one type to another.
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
A parsed version of the target data layout string in and methods for querying it.
IntegerType * getIndexType(LLVMContext &C, unsigned AddressSpace) const
Returns the type of a GEP index in AddressSpace.
This is the common base class for debug info intrinsics.
an instruction for type-safe pointer arithmetic to access elements of arrays and structs
Base class for instruction visitors.
void visitCallBase(CallBase &I)
void visitIntrinsicInst(IntrinsicInst &I)
void visit(Iterator Start, Iterator End)
Class to represent integer types.
unsigned getBitWidth() const
Get the number of bits in this IntegerType.
A wrapper class for inspecting calls to intrinsic functions.
This is the common base class for memset/memcpy/memmove.
PointerTy getPointer() const
This class represents a cast from a pointer to an integer.
A base class for visitors over the uses of a pointer value.
void visitCallBase(CallBase &CB)
void visitDbgInfoIntrinsic(DbgInfoIntrinsic &I)
PtrUseVisitor(const DataLayout &DL)
PtrInfo visitPtr(Value &I)
Recursively visit the uses of the given pointer.
void visitGetElementPtrInst(GetElementPtrInst &GEPI)
void visitAddrSpaceCastInst(AddrSpaceCastInst &ASC)
void visitBitCastInst(BitCastInst &BC)
void visitStoreInst(StoreInst &SI)
void visitIntrinsicInst(IntrinsicInst &II)
void visitPtrToIntInst(PtrToIntInst &I)
void visitMemIntrinsic(MemIntrinsic &I)
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
An instruction for storing to memory.
A Use represents the edge between a Value definition and its users.
LLVM Value Representation.
This class provides information about the result of a visit.
Instruction * getEscapedReadOnlyInst() const
Get the instruction causing the pointer to escape which is a read-only nocapture call.
Instruction * getAbortingInst() const
Get the instruction causing the visit to abort.
Instruction * getEscapingInst() const
Get the instruction causing the pointer to escape.
bool isEscaped() const
Is the pointer escaped at some point?
void setEscaped(Instruction *I)
Mark the pointer as escaped.
void setAborted(Instruction *I)
Mark the visit as aborted.
bool isEscapedReadOnly() const
Is the pointer escaped into a read-only nocapture call at some point?
void reset()
Reset the pointer info, clearing all state.
bool isAborted() const
Did we abort the visit early?
void setEscapedAndAborted(Instruction *I)
Mark the pointer as escaped, and the visit as aborted.
void setEscapedReadOnly(Instruction *I)
Mark the pointer as escaped into a readonly-nocapture call.
Implementation of non-dependent functionality for PtrUseVisitor.
APInt Offset
The constant offset of the use if that is known.
void enqueueUsers(Value &I)
Enqueue the users of this instruction in the visit worklist.
PtrUseVisitorBase(const DataLayout &DL)
Note that the constructor is protected because this class must be a base class, we can't create insta...
SmallVector< UseToVisit, 8 > Worklist
The worklist of to-visit uses.
bool IsOffsetKnown
True if we have a known constant offset for the use currently being visited.
bool adjustOffsetForGEP(GetElementPtrInst &GEPI)
Walk the operands of a GEP and adjust the offset as appropriate.
PtrInfo PI
The info collected about the pointer being visited thus far.
Use * U
The use currently being visited.
SmallPtrSet< Use *, 8 > VisitedUses
A set of visited uses to break cycles in unreachable code.
This is an optimization pass for GlobalISel generic memory operations.
A struct of the data needed to visit a particular use.
UseAndIsOffsetKnownPair UseAndIsOffsetKnown