LLVM 17.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
Collaboration diagram for llvm::SCCPInstVisitor:
Collaboration graph

Public Member Functions

void addAnalysis (Function &F, AnalysisResultsForFn A)
void visitCallInst (CallInst &I)
bool markBlockExecutable (BasicBlock *BB)
const PredicateBasegetPredicateInfoFor (Instruction *I)
const LoopInfogetLoopInfo (Function &F)
DomTreeUpdater getDTU (Function &F)
 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 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)
const ValueLatticeElementgetLatticeValueFor (Value *V) const
const MapVector< Function *, ValueLatticeElement > & getTrackedRetVals ()
const DenseMap< GlobalVariable *, ValueLatticeElement > & getTrackedGlobals ()
const SmallPtrSet< Function *, 16 > getMRVFunctionsTracked ()
void markOverdefined (Value *V)
bool isStructLatticeConstant (Function *F, StructType *STy)
ConstantgetConstant (const ValueLatticeElement &LV) const
SmallPtrSetImpl< Function * > & getArgumentTrackedFunctions ()
void markArgInFuncSpecialization (Function *F, const SmallVectorImpl< ArgInfo > &Args)
void markFunctionUnreachable (Function *F)
void solveWhileResolvedUndefsIn (Module &M)
void solveWhileResolvedUndefsIn (SmallVectorImpl< Function * > &WorkList)
- 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)


class InstVisitor< SCCPInstVisitor >

Detailed Description

Helper class for SCCPSolver.

This implements the instruction visitor and holds all the state.

Definition at line 349 of file SCCPSolver.cpp.

Constructor & Destructor Documentation

◆ SCCPInstVisitor()

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

Definition at line 639 of file SCCPSolver.cpp.

Member Function Documentation

◆ addAnalysis()

void llvm::SCCPInstVisitor::addAnalysis ( Function F,
AnalysisResultsForFn  A 

◆ addArgumentTrackedFunction()

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

Definition at line 671 of file SCCPSolver.cpp.

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

◆ addToMustPreserveReturnsInFunctions()

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

Definition at line 663 of file SCCPSolver.cpp.

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

◆ addTrackedFunction()

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

◆ getArgumentTrackedFunctions()

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

Definition at line 737 of file SCCPSolver.cpp.

◆ getConstant()

Constant * SCCPInstVisitor::getConstant ( const ValueLatticeElement LV) const

◆ getDTU()

DomTreeUpdater llvm::SCCPInstVisitor::getDTU ( Function F)

◆ getLatticeValueFor()

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

◆ getLoopInfo()

const LoopInfo & llvm::SCCPInstVisitor::getLoopInfo ( Function F)

◆ getMRVFunctionsTracked()

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

Definition at line 721 of file SCCPSolver.cpp.

◆ getPredicateInfoFor()

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

◆ getStructLatticeValueFor()

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

◆ getTrackedGlobals()

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

Definition at line 717 of file SCCPSolver.cpp.

◆ getTrackedRetVals()

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

Definition at line 713 of file SCCPSolver.cpp.

◆ isArgumentTrackedFunction()

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

Definition at line 675 of file SCCPSolver.cpp.

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

◆ isBlockExecutable()

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

Definition at line 683 of file SCCPSolver.cpp.

◆ isEdgeFeasible()

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

◆ isStructLatticeConstant()

bool SCCPInstVisitor::isStructLatticeConstant ( Function F,
StructType STy 

◆ markArgInFuncSpecialization()

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

Definition at line 836 of file SCCPSolver.cpp.

References assert(), llvm::dbgs(), F, llvm::Value::getNameOrAsOperand(), and LLVM_DEBUG.

◆ markBlockExecutable()

bool SCCPInstVisitor::markBlockExecutable ( BasicBlock BB)

Definition at line 772 of file SCCPSolver.cpp.

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

◆ markFunctionUnreachable()

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

Definition at line 744 of file SCCPSolver.cpp.

References F.

◆ markOverdefined()

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

Definition at line 725 of file SCCPSolver.cpp.

◆ mustPreserveReturn()

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

Definition at line 667 of file SCCPSolver.cpp.

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

◆ removeLatticeValueFor()

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

◆ 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 1766 of file SCCPSolver.cpp.

References llvm::dbgs(), F, llvm::CallBase::getCalledFunction(), I, llvm::ValueLatticeElement::isUnknown(), and LLVM_DEBUG.

Referenced by solveWhileResolvedUndefsIn().

◆ solve()

void SCCPInstVisitor::solve ( )

◆ solveWhileResolvedUndefsIn() [1/2]

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

Definition at line 749 of file SCCPSolver.cpp.

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

◆ solveWhileResolvedUndefsIn() [2/2]

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

Definition at line 759 of file SCCPSolver.cpp.

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

◆ trackValueOfGlobalVariable()

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

◆ visitCallInst()

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

Definition at line 615 of file SCCPSolver.cpp.

References I.

Friends And Related Function Documentation

◆ InstVisitor< SCCPInstVisitor >

friend class InstVisitor< SCCPInstVisitor >

Definition at line 555 of file SCCPSolver.cpp.

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