LLVM 20.0.0git
Public Member Functions | Friends | List of all members
llvm::SCCPInstVisitor Class Reference

Helper class for SCCPSolver. More...

Inheritance diagram for llvm::SCCPInstVisitor:
Inheritance graph
[legend]

Public Member Functions

void addPredicateInfo (Function &F, DominatorTree &DT, AssumptionCache &AC)
 
void visitCallInst (CallInst &I)
 
bool markBlockExecutable (BasicBlock *BB)
 
const PredicateBasegetPredicateInfoFor (Instruction *I)
 
 SCCPInstVisitor (const DataLayout &DL, std::function< const TargetLibraryInfo &(Function &)> GetTLI, LLVMContext &Ctx)
 
void trackValueOfGlobalVariable (GlobalVariable *GV)
 
void addTrackedFunction (Function *F)
 
void addToMustPreserveReturnsInFunctions (Function *F)
 
bool mustPreserveReturn (Function *F)
 
void addArgumentTrackedFunction (Function *F)
 
bool isArgumentTrackedFunction (Function *F)
 
void solve ()
 
bool resolvedUndef (Instruction &I)
 
bool resolvedUndefsIn (Function &F)
 While solving the dataflow for a function, we don't compute a result for operations with an undef operand, to allow undef to be lowered to a constant later.
 
bool isBlockExecutable (BasicBlock *BB) const
 
bool isEdgeFeasible (BasicBlock *From, BasicBlock *To) const
 
std::vector< ValueLatticeElementgetStructLatticeValueFor (Value *V) const
 
void removeLatticeValueFor (Value *V)
 
void resetLatticeValueFor (CallBase *Call)
 Invalidate the Lattice Value of Call and its users after specializing the call.
 
const ValueLatticeElementgetLatticeValueFor (Value *V) const
 
const MapVector< Function *, ValueLatticeElement > & getTrackedRetVals ()
 
const DenseMap< GlobalVariable *, ValueLatticeElement > & getTrackedGlobals ()
 
const SmallPtrSet< Function *, 16 > getMRVFunctionsTracked ()
 
void markOverdefined (Value *V)
 
void trackValueOfArgument (Argument *A)
 
bool isStructLatticeConstant (Function *F, StructType *STy)
 
ConstantgetConstant (const ValueLatticeElement &LV, Type *Ty) const
 
ConstantgetConstantOrNull (Value *V) const
 
SmallPtrSetImpl< Function * > & getArgumentTrackedFunctions ()
 
void setLatticeValueForSpecializationArguments (Function *F, const SmallVectorImpl< ArgInfo > &Args)
 
void markFunctionUnreachable (Function *F)
 
void solveWhileResolvedUndefsIn (Module &M)
 
void solveWhileResolvedUndefsIn (SmallVectorImpl< Function * > &WorkList)
 
void solveWhileResolvedUndefs ()
 
- Public Member Functions inherited from llvm::InstVisitor< SCCPInstVisitor >
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 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)
 

Friends

class InstVisitor< SCCPInstVisitor >
 

Detailed Description

Helper class for SCCPSolver.

This implements the instruction visitor and holds all the state.

Definition at line 358 of file SCCPSolver.cpp.

Constructor & Destructor Documentation

◆ SCCPInstVisitor()

llvm::SCCPInstVisitor::SCCPInstVisitor ( const DataLayout DL,
std::function< const TargetLibraryInfo &(Function &)>  GetTLI,
LLVMContext Ctx 
)
inline

Definition at line 706 of file SCCPSolver.cpp.

Member Function Documentation

◆ addArgumentTrackedFunction()

void llvm::SCCPInstVisitor::addArgumentTrackedFunction ( Function F)
inline

Definition at line 738 of file SCCPSolver.cpp.

References F, and llvm::SmallPtrSetImpl< PtrType >::insert().

◆ addPredicateInfo()

void llvm::SCCPInstVisitor::addPredicateInfo ( Function F,
DominatorTree DT,
AssumptionCache AC 
)
inline

◆ addToMustPreserveReturnsInFunctions()

void llvm::SCCPInstVisitor::addToMustPreserveReturnsInFunctions ( Function F)
inline

Definition at line 730 of file SCCPSolver.cpp.

References F, and llvm::SmallPtrSetImpl< PtrType >::insert().

◆ addTrackedFunction()

void llvm::SCCPInstVisitor::addTrackedFunction ( Function F)
inline

◆ getArgumentTrackedFunctions()

SmallPtrSetImpl< Function * > & llvm::SCCPInstVisitor::getArgumentTrackedFunctions ( )
inline

Definition at line 832 of file SCCPSolver.cpp.

◆ getConstant()

Constant * SCCPInstVisitor::getConstant ( const ValueLatticeElement LV,
Type Ty 
) const

◆ getConstantOrNull()

Constant * SCCPInstVisitor::getConstantOrNull ( Value V) const

◆ getLatticeValueFor()

const ValueLatticeElement & llvm::SCCPInstVisitor::getLatticeValueFor ( Value V) const
inline

◆ getMRVFunctionsTracked()

const SmallPtrSet< Function *, 16 > llvm::SCCPInstVisitor::getMRVFunctionsTracked ( )
inline

Definition at line 803 of file SCCPSolver.cpp.

◆ getPredicateInfoFor()

const PredicateBase * llvm::SCCPInstVisitor::getPredicateInfoFor ( Instruction I)
inline

◆ getStructLatticeValueFor()

std::vector< ValueLatticeElement > llvm::SCCPInstVisitor::getStructLatticeValueFor ( Value V) const
inline

◆ getTrackedGlobals()

const DenseMap< GlobalVariable *, ValueLatticeElement > & llvm::SCCPInstVisitor::getTrackedGlobals ( )
inline

Definition at line 799 of file SCCPSolver.cpp.

◆ getTrackedRetVals()

const MapVector< Function *, ValueLatticeElement > & llvm::SCCPInstVisitor::getTrackedRetVals ( )
inline

Definition at line 795 of file SCCPSolver.cpp.

◆ isArgumentTrackedFunction()

bool llvm::SCCPInstVisitor::isArgumentTrackedFunction ( Function F)
inline

Definition at line 742 of file SCCPSolver.cpp.

References llvm::SmallPtrSetImpl< PtrType >::count(), and F.

◆ isBlockExecutable()

bool llvm::SCCPInstVisitor::isBlockExecutable ( BasicBlock BB) const
inline

Definition at line 752 of file SCCPSolver.cpp.

◆ isEdgeFeasible()

bool SCCPInstVisitor::isEdgeFeasible ( BasicBlock From,
BasicBlock To 
) const

◆ isStructLatticeConstant()

bool SCCPInstVisitor::isStructLatticeConstant ( Function F,
StructType STy 
)

◆ markBlockExecutable()

bool SCCPInstVisitor::markBlockExecutable ( BasicBlock BB)

Definition at line 879 of file SCCPSolver.cpp.

References llvm::dbgs(), llvm::Value::getName(), and LLVM_DEBUG.

◆ markFunctionUnreachable()

void llvm::SCCPInstVisitor::markFunctionUnreachable ( Function F)
inline

Definition at line 839 of file SCCPSolver.cpp.

References F.

◆ markOverdefined()

void llvm::SCCPInstVisitor::markOverdefined ( Value V)
inline

Definition at line 807 of file SCCPSolver.cpp.

◆ mustPreserveReturn()

bool llvm::SCCPInstVisitor::mustPreserveReturn ( Function F)
inline

Definition at line 734 of file SCCPSolver.cpp.

References llvm::SmallPtrSetImpl< PtrType >::count(), and F.

◆ removeLatticeValueFor()

void llvm::SCCPInstVisitor::removeLatticeValueFor ( Value V)
inline

◆ resetLatticeValueFor()

void llvm::SCCPInstVisitor::resetLatticeValueFor ( CallBase Call)
inline

Invalidate the Lattice Value of Call and its users after specializing the call.

Then recompute it.

Definition at line 774 of file SCCPSolver.cpp.

References assert(), llvm::MapVector< KeyT, ValueT, MapType, VectorType >::count(), llvm::SmallPtrSetImpl< PtrType >::count(), and F.

◆ resolvedUndef()

bool SCCPInstVisitor::resolvedUndef ( Instruction I)

◆ resolvedUndefsIn()

bool SCCPInstVisitor::resolvedUndefsIn ( Function F)

While solving the dataflow for a function, we don't compute a result for operations with an undef operand, to allow undef to be lowered to a constant later.

For example, constant folding of "zext i8 undef to i16" would result in "i16 0", and if undef is later lowered to "i8 1", then the zext result would become "i16 1" and would result into an overdefined lattice value once merged with the previous result. Not computing the result of the zext (treating undef the same as unknown) allows us to handle a later undef->constant lowering more optimally.

However, if the operand remains undef when the solver returns, we do need to assign some result to the instruction (otherwise we would treat it as unreachable). For simplicity, we mark any instructions that are still unknown as overdefined.

Definition at line 2018 of file SCCPSolver.cpp.

References llvm::dbgs(), F, I, LLVM_DEBUG, and resolvedUndef().

Referenced by solveWhileResolvedUndefsIn().

◆ setLatticeValueForSpecializationArguments()

void SCCPInstVisitor::setLatticeValueForSpecializationArguments ( Function F,
const SmallVectorImpl< ArgInfo > &  Args 
)

◆ solve()

void SCCPInstVisitor::solve ( )

◆ solveWhileResolvedUndefs()

void llvm::SCCPInstVisitor::solveWhileResolvedUndefs ( )
inline

Definition at line 864 of file SCCPSolver.cpp.

References I, Invalidated, resolvedUndef(), and solve().

◆ solveWhileResolvedUndefsIn() [1/2]

void llvm::SCCPInstVisitor::solveWhileResolvedUndefsIn ( Module M)
inline

Definition at line 844 of file SCCPSolver.cpp.

References F, resolvedUndefsIn(), and solve().

◆ solveWhileResolvedUndefsIn() [2/2]

void llvm::SCCPInstVisitor::solveWhileResolvedUndefsIn ( SmallVectorImpl< Function * > &  WorkList)
inline

Definition at line 854 of file SCCPSolver.cpp.

References F, resolvedUndefsIn(), and solve().

◆ trackValueOfArgument()

void llvm::SCCPInstVisitor::trackValueOfArgument ( Argument A)
inline

Definition at line 815 of file SCCPSolver.cpp.

References A, and Range.

◆ trackValueOfGlobalVariable()

void llvm::SCCPInstVisitor::trackValueOfGlobalVariable ( GlobalVariable GV)
inline

◆ visitCallInst()

void llvm::SCCPInstVisitor::visitCallInst ( CallInst I)
inline

Definition at line 695 of file SCCPSolver.cpp.

References I.

Friends And Related Function Documentation

◆ InstVisitor< SCCPInstVisitor >

friend class InstVisitor< SCCPInstVisitor >
friend

Definition at line 634 of file SCCPSolver.cpp.


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