22#ifndef LLVM_ANALYSIS_PTRUSEVISITOR_H
23#define LLVM_ANALYSIS_PTRUSEVISITOR_H
57 AbortedInfo =
nullptr;
58 EscapedInfo =
nullptr;
62 bool isAborted()
const {
return AbortedInfo !=
nullptr; }
65 bool isEscaped()
const {
return EscapedInfo !=
nullptr; }
87 assert(
I &&
"Expected a valid pointer in setAborted");
94 assert(
I &&
"Expected a valid pointer in setEscaped");
100 assert(
I &&
"Expected a valid pointer in setEscapedReadOnly");
207template <
typename DerivedT>
216 static_assert(std::is_base_of<PtrUseVisitor, DerivedT>::value,
217 "Must pass the derived type to this template!");
228 assert(
I.getType()->isPointerTy());
229 assert(isa<Instruction>(
I) || isa<Argument>(
I));
247 static_cast<DerivedT*
>(
this)->
visit(
I);
256 if (
SI.getValueOperand() ==
U->get())
291 switch (
II.getIntrinsicID()) {
297 case Intrinsic::fake_use:
301 case Intrinsic::lifetime_start:
302 case Intrinsic::lifetime_end:
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