LLVM 20.0.0git
Public Member Functions | Protected Member Functions | Friends | List of all members
llvm::PtrUseVisitor< DerivedT > Class Template Reference

A base class for visitors over the uses of a pointer value. More...

#include "llvm/Analysis/PtrUseVisitor.h"

Inheritance diagram for llvm::PtrUseVisitor< DerivedT >:
Inheritance graph
[legend]

Public Member Functions

 PtrUseVisitor (const DataLayout &DL)
 
PtrInfo visitPtr (Value &I)
 Recursively visit the uses of the given pointer.
 

Protected Member Functions

void visitStoreInst (StoreInst &SI)
 
void visitBitCastInst (BitCastInst &BC)
 
void visitAddrSpaceCastInst (AddrSpaceCastInst &ASC)
 
void visitPtrToIntInst (PtrToIntInst &I)
 
void visitGetElementPtrInst (GetElementPtrInst &GEPI)
 
void visitDbgInfoIntrinsic (DbgInfoIntrinsic &I)
 
void visitMemIntrinsic (MemIntrinsic &I)
 
void visitIntrinsicInst (IntrinsicInst &II)
 
void visitCallBase (CallBase &CB)
 
- Protected Member Functions inherited from llvm::InstVisitor< DerivedT >
void visit (Iterator Start, Iterator End)
 
void visit (Module &M)
 
void visit (Function &F)
 
void visit (BasicBlock &BB)
 
void visit (Module *M)
 
void visit (Function *F)
 
void visit (BasicBlock *BB)
 
void visit (Instruction *I)
 
void visit (Instruction &I)
 
void visitModule (Module &M)
 
void visitFunction (Function &F)
 
void visitBasicBlock (BasicBlock &BB)
 
void visitICmpInst (ICmpInst &I)
 
void visitFCmpInst (FCmpInst &I)
 
void visitAllocaInst (AllocaInst &I)
 
void visitLoadInst (LoadInst &I)
 
void visitStoreInst (StoreInst &I)
 
void visitAtomicCmpXchgInst (AtomicCmpXchgInst &I)
 
void visitAtomicRMWInst (AtomicRMWInst &I)
 
void visitFenceInst (FenceInst &I)
 
void visitGetElementPtrInst (GetElementPtrInst &I)
 
void visitPHINode (PHINode &I)
 
void visitTruncInst (TruncInst &I)
 
void visitZExtInst (ZExtInst &I)
 
void visitSExtInst (SExtInst &I)
 
void visitFPTruncInst (FPTruncInst &I)
 
void visitFPExtInst (FPExtInst &I)
 
void visitFPToUIInst (FPToUIInst &I)
 
void visitFPToSIInst (FPToSIInst &I)
 
void visitUIToFPInst (UIToFPInst &I)
 
void visitSIToFPInst (SIToFPInst &I)
 
void visitPtrToIntInst (PtrToIntInst &I)
 
void visitIntToPtrInst (IntToPtrInst &I)
 
void visitBitCastInst (BitCastInst &I)
 
void visitAddrSpaceCastInst (AddrSpaceCastInst &I)
 
void visitSelectInst (SelectInst &I)
 
void visitVAArgInst (VAArgInst &I)
 
void visitExtractElementInst (ExtractElementInst &I)
 
void visitInsertElementInst (InsertElementInst &I)
 
void visitShuffleVectorInst (ShuffleVectorInst &I)
 
void visitExtractValueInst (ExtractValueInst &I)
 
void visitInsertValueInst (InsertValueInst &I)
 
void visitLandingPadInst (LandingPadInst &I)
 
void visitFuncletPadInst (FuncletPadInst &I)
 
void visitCleanupPadInst (CleanupPadInst &I)
 
void visitCatchPadInst (CatchPadInst &I)
 
void visitFreezeInst (FreezeInst &I)
 
void visitDbgDeclareInst (DbgDeclareInst &I)
 
void visitDbgValueInst (DbgValueInst &I)
 
void visitDbgVariableIntrinsic (DbgVariableIntrinsic &I)
 
void visitDbgLabelInst (DbgLabelInst &I)
 
void visitDbgInfoIntrinsic (DbgInfoIntrinsic &I)
 
void visitMemSetInst (MemSetInst &I)
 
void visitMemSetInlineInst (MemSetInlineInst &I)
 
void visitMemSetPatternInst (MemSetPatternInst &I)
 
void visitMemCpyInst (MemCpyInst &I)
 
void visitMemCpyInlineInst (MemCpyInlineInst &I)
 
void visitMemMoveInst (MemMoveInst &I)
 
void visitMemTransferInst (MemTransferInst &I)
 
void visitMemIntrinsic (MemIntrinsic &I)
 
void visitVAStartInst (VAStartInst &I)
 
void visitVAEndInst (VAEndInst &I)
 
void visitVACopyInst (VACopyInst &I)
 
void visitIntrinsicInst (IntrinsicInst &I)
 
void visitCallInst (CallInst &I)
 
void visitInvokeInst (InvokeInst &I)
 
void visitCallBrInst (CallBrInst &I)
 
void visitReturnInst (ReturnInst &I)
 
void visitBranchInst (BranchInst &I)
 
void visitSwitchInst (SwitchInst &I)
 
void visitIndirectBrInst (IndirectBrInst &I)
 
void visitResumeInst (ResumeInst &I)
 
void visitUnreachableInst (UnreachableInst &I)
 
void visitCleanupReturnInst (CleanupReturnInst &I)
 
void visitCatchReturnInst (CatchReturnInst &I)
 
void visitCatchSwitchInst (CatchSwitchInst &I)
 
void visitTerminator (Instruction &I)
 
void visitCastInst (CastInst &I)
 
void visitUnaryOperator (UnaryOperator &I)
 
void visitBinaryOperator (BinaryOperator &I)
 
void visitCmpInst (CmpInst &I)
 
void visitUnaryInstruction (UnaryInstruction &I)
 
void visitCallBase (CallBase &I)
 
void visitInstruction (Instruction &I)
 
- Protected Member Functions inherited from llvm::detail::PtrUseVisitorBase
 PtrUseVisitorBase (const DataLayout &DL)
 Note that the constructor is protected because this class must be a base class, we can't create instances directly of this class.
 
void enqueueUsers (Value &I)
 Enqueue the users of this instruction in the visit worklist.
 
bool adjustOffsetForGEP (GetElementPtrInst &GEPI)
 Walk the operands of a GEP and adjust the offset as appropriate.
 

Friends

class InstVisitor< DerivedT >
 

Additional Inherited Members

- Protected Attributes inherited from llvm::detail::PtrUseVisitorBase
const DataLayoutDL
 
PtrInfo PI
 The info collected about the pointer being visited thus far.
 
SmallVector< UseToVisit, 8 > Worklist
 The worklist of to-visit uses.
 
SmallPtrSet< Use *, 8 > VisitedUses
 A set of visited uses to break cycles in unreachable code.
 
UseU
 The use currently being visited.
 
bool IsOffsetKnown
 True if we have a known constant offset for the use currently being visited.
 
APInt Offset
 The constant offset of the use if that is known.
 

Detailed Description

template<typename DerivedT>
class llvm::PtrUseVisitor< DerivedT >

A base class for visitors over the uses of a pointer value.

Once constructed, a user can call visit on a pointer value, and this will walk its uses and visit each instruction using an InstVisitor. It also provides visit methods which will recurse through any pointer-to-pointer transformations such as GEPs and bitcasts.

During the visit, the current Use* being visited is available to the subclass, as well as the current offset from the original base pointer if known.

The recursive visit of uses is accomplished with a worklist, so the only ordering guarantee is that an instruction is visited before any uses of it are visited. Note that this does not mean before any of its users are visited! This is because users can be visited multiple times due to multiple, different uses of pointers derived from the same base.

A particular Use will only be visited once, but a User may be visited multiple times, once per Use. This visits may notably have different offsets.

All visit methods on the underlying InstVisitor return a boolean. This return short-circuits the visit, stopping it immediately.

FIXME: Generalize this for all values rather than just instructions.

Definition at line 208 of file PtrUseVisitor.h.

Constructor & Destructor Documentation

◆ PtrUseVisitor()

template<typename DerivedT >
llvm::PtrUseVisitor< DerivedT >::PtrUseVisitor ( const DataLayout DL)
inline

Definition at line 215 of file PtrUseVisitor.h.

Member Function Documentation

◆ visitAddrSpaceCastInst()

template<typename DerivedT >
void llvm::PtrUseVisitor< DerivedT >::visitAddrSpaceCastInst ( AddrSpaceCastInst ASC)
inlineprotected

Definition at line 264 of file PtrUseVisitor.h.

References llvm::detail::PtrUseVisitorBase::enqueueUsers().

◆ visitBitCastInst()

template<typename DerivedT >
void llvm::PtrUseVisitor< DerivedT >::visitBitCastInst ( BitCastInst BC)
inlineprotected

Definition at line 260 of file PtrUseVisitor.h.

References llvm::detail::PtrUseVisitorBase::enqueueUsers().

◆ visitCallBase()

template<typename DerivedT >
void llvm::PtrUseVisitor< DerivedT >::visitCallBase ( CallBase CB)
inlineprotected

◆ visitDbgInfoIntrinsic()

template<typename DerivedT >
void llvm::PtrUseVisitor< DerivedT >::visitDbgInfoIntrinsic ( DbgInfoIntrinsic I)
inlineprotected

Definition at line 288 of file PtrUseVisitor.h.

◆ visitGetElementPtrInst()

template<typename DerivedT >
void llvm::PtrUseVisitor< DerivedT >::visitGetElementPtrInst ( GetElementPtrInst GEPI)
inlineprotected

◆ visitIntrinsicInst()

template<typename DerivedT >
void llvm::PtrUseVisitor< DerivedT >::visitIntrinsicInst ( IntrinsicInst II)
inlineprotected

◆ visitMemIntrinsic()

template<typename DerivedT >
void llvm::PtrUseVisitor< DerivedT >::visitMemIntrinsic ( MemIntrinsic I)
inlineprotected

Definition at line 289 of file PtrUseVisitor.h.

◆ visitPtr()

template<typename DerivedT >
PtrInfo llvm::PtrUseVisitor< DerivedT >::visitPtr ( Value I)
inline

◆ visitPtrToIntInst()

template<typename DerivedT >
void llvm::PtrUseVisitor< DerivedT >::visitPtrToIntInst ( PtrToIntInst I)
inlineprotected

◆ visitStoreInst()

template<typename DerivedT >
void llvm::PtrUseVisitor< DerivedT >::visitStoreInst ( StoreInst SI)
inlineprotected

Friends And Related Function Documentation

◆ InstVisitor< DerivedT >

template<typename DerivedT >
friend class InstVisitor< DerivedT >
friend

Definition at line 136 of file PtrUseVisitor.h.


The documentation for this class was generated from the following file: