Go to the documentation of this file.
22 #ifndef LLVM_ANALYSIS_PTRUSEVISITOR_H
23 #define LLVM_ANALYSIS_PTRUSEVISITOR_H
33 #include <type_traits>
60 AbortedInfo.setPointer(
nullptr);
61 AbortedInfo.setInt(
false);
62 EscapedInfo.setPointer(
nullptr);
63 EscapedInfo.setInt(
false);
67 bool isAborted()
const {
return AbortedInfo.getInt(); }
70 bool isEscaped()
const {
return EscapedInfo.getInt(); }
85 AbortedInfo.setInt(
true);
86 AbortedInfo.setPointer(
I);
92 EscapedInfo.setInt(
true);
93 EscapedInfo.setPointer(
I);
197 template <
typename DerivedT>
206 static_assert(std::is_base_of<PtrUseVisitor, DerivedT>::value,
207 "Must pass the derived type to this template!");
216 assert(
I.getType()->isPointerTy());
234 static_cast<DerivedT*
>(
this)->
visit(
I);
243 if (
SI.getValueOperand() ==
U->get())
282 case Intrinsic::lifetime_start:
283 case Intrinsic::lifetime_end:
298 #endif // LLVM_ANALYSIS_PTRUSEVISITOR_H
void enqueueUsers(Instruction &I)
Enqueue the users of this instruction in the visit worklist.
This is an optimization pass for GlobalISel generic memory operations.
A parsed version of the target data layout string in and methods for querying it.
Intrinsic::ID getIntrinsicID() const
Return the intrinsic ID of this intrinsic.
void visitDbgInfoIntrinsic(DbgInfoIntrinsic &I)
This class represents a no-op cast from one type to another.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
void visitIntrinsicInst(IntrinsicInst &I)
void visitCallBase(CallBase &I)
Type * getIndexType(Type *PtrTy) const
Returns the type of a GEP index.
A struct of the data needed to visit a particular use.
This is the common base class for memset/memcpy/memmove.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
PtrUseVisitor(const DataLayout &DL)
SmallPtrSet< Use *, 8 > VisitedUses
A set of visited uses to break cycles in unreachable code.
This class represents a conversion between pointers from one address space to another.
void visitGetElementPtrInst(GetElementPtrInst &GEPI)
PtrUseVisitorBase(const DataLayout &DL)
Note that the constructor is protected because this class must be a base class, we can't create insta...
bool IsOffsetKnown
True if we have a known constant offset for the use currently being visited.
void setAborted(Instruction *I=nullptr)
Mark the visit as aborted.
PtrInfo PI
The info collected about the pointer being visited thus far.
Class to represent integer types.
UseAndIsOffsetKnownPair UseAndIsOffsetKnown
This is the common base class for debug info intrinsics.
bool isAborted() const
Did we abort the visit early?
void visitMemIntrinsic(MemIntrinsic &I)
PointerTy getPointer() const
An instruction for storing to memory.
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
bool adjustOffsetForGEP(GetElementPtrInst &GEPI)
Walk the operands of a GEP and adjust the offset as appropriate.
Instruction * getEscapingInst() const
Get the instruction causing the pointer to escape.
This class provides information about the result of a visit.
an instruction for type-safe pointer arithmetic to access elements of arrays and structs
void visit(Iterator Start, Iterator End)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
StandardInstrumentations SI(Debug, VerifyEach)
Class for arbitrary precision integers.
A base class for visitors over the uses of a pointer value.
bool isEscaped() const
Is the pointer escaped at some point?
This class represents a cast from a pointer to an integer.
void visitCallBase(CallBase &CB)
Base class for instruction visitors.
APInt Offset
The constant offset of the use if that is known.
void visitAddrSpaceCastInst(AddrSpaceCastInst &ASC)
Instruction * getAbortingInst() const
Get the instruction causing the visit to abort.
void setEscapedAndAborted(Instruction *I=nullptr)
Mark the pointer as escaped, and the visit as aborted.
A wrapper class for inspecting calls to intrinsic functions.
PointerIntPair - This class implements a pair of a pointer and small integer.
PtrInfo visitPtr(Instruction &I)
Recursively visit the uses of the given pointer.
Use * U
The use currently being visited.
void reset()
Reset the pointer info, clearing all state.
unsigned getBitWidth() const
Get the number of bits in this IntegerType.
void setEscaped(Instruction *I=nullptr)
Mark the pointer as escaped.
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Implementation of non-dependent functionality for PtrUseVisitor.
void visitStoreInst(StoreInst &SI)
void visitIntrinsicInst(IntrinsicInst &II)
void visitPtrToIntInst(PtrToIntInst &I)
SmallVector< UseToVisit, 8 > Worklist
The worklist of to-visit uses.
void visitBitCastInst(BitCastInst &BC)
A Use represents the edge between a Value definition and its users.