LLVM 22.0.0git
llvm::SCCPInstVisitor Class Reference

Helper class for SCCPSolver. More...

Inheritance diagram for llvm::SCCPInstVisitor:
[legend]

Public Member Functions

void addPredicateInfo (Function &F, DominatorTree &DT, AssumptionCache &AC)
void removeSSACopies (Function &F)
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)
const SmallPtrSetImpl< Function * > & getArgumentTrackedFunctions () const
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
const DenseMap< GlobalVariable *, ValueLatticeElement > & getTrackedGlobals () const
const SmallPtrSet< Function *, 16 > & getMRVFunctionsTracked () const
void markOverdefined (Value *V)
ValueLatticeElement getArgAttributeVL (Argument *A)
void trackValueOfArgument (Argument *A)
bool isStructLatticeConstant (Function *F, StructType *STy)
ConstantgetConstant (const ValueLatticeElement &LV, Type *Ty) const
ConstantgetConstantOrNull (Value *V) const
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 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 visitPtrToAddrInst (PtrToAddrInst &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 visitMemSetInst (MemSetInst &I)
void visitMemSetPatternInst (MemSetPatternInst &I)
void visitMemCpyInst (MemCpyInst &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 460 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 804 of file SCCPSolver.cpp.

Referenced by InstVisitor< SCCPInstVisitor >.

Member Function Documentation

◆ addArgumentTrackedFunction()

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

Definition at line 835 of file SCCPSolver.cpp.

References F.

◆ addPredicateInfo()

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

Definition at line 768 of file SCCPSolver.cpp.

References F.

◆ addToMustPreserveReturnsInFunctions()

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

Definition at line 827 of file SCCPSolver.cpp.

References F.

◆ addTrackedFunction()

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

Definition at line 817 of file SCCPSolver.cpp.

References llvm::dyn_cast(), and F.

◆ getArgAttributeVL()

◆ getArgumentTrackedFunctions()

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

Definition at line 843 of file SCCPSolver.cpp.

◆ getConstant()

◆ getConstantOrNull()

◆ getLatticeValueFor()

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

Definition at line 886 of file SCCPSolver.cpp.

References assert(), and I.

Referenced by getConstantOrNull().

◆ getMRVFunctionsTracked()

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

Definition at line 905 of file SCCPSolver.cpp.

◆ getPredicateInfoFor()

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

Definition at line 797 of file SCCPSolver.cpp.

References I.

◆ getStructLatticeValueFor()

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

Definition at line 859 of file SCCPSolver.cpp.

References assert(), llvm::dyn_cast(), and I.

Referenced by getConstantOrNull().

◆ getTrackedGlobals()

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

Definition at line 901 of file SCCPSolver.cpp.

◆ getTrackedRetVals()

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

Definition at line 896 of file SCCPSolver.cpp.

◆ isArgumentTrackedFunction()

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

Definition at line 839 of file SCCPSolver.cpp.

References F.

◆ isBlockExecutable()

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

Definition at line 853 of file SCCPSolver.cpp.

◆ isEdgeFeasible()

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

Definition at line 1302 of file SCCPSolver.cpp.

◆ isStructLatticeConstant()

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

◆ markBlockExecutable()

bool SCCPInstVisitor::markBlockExecutable ( BasicBlock * BB)

Definition at line 983 of file SCCPSolver.cpp.

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

◆ markFunctionUnreachable()

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

Definition at line 943 of file SCCPSolver.cpp.

References F.

◆ markOverdefined()

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

Definition at line 909 of file SCCPSolver.cpp.

References llvm::dyn_cast().

◆ mustPreserveReturn()

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

Definition at line 831 of file SCCPSolver.cpp.

References F.

◆ removeLatticeValueFor()

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

Definition at line 871 of file SCCPSolver.cpp.

◆ removeSSACopies()

void llvm::SCCPInstVisitor::removeSSACopies ( Function & F)
inline

Definition at line 773 of file SCCPSolver.cpp.

References llvm::dyn_cast(), F, and llvm::make_early_inc_range().

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

References assert(), Call, 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 2165 of file SCCPSolver.cpp.

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

Referenced by solveWhileResolvedUndefsIn(), and solveWhileResolvedUndefsIn().

◆ setLatticeValueForSpecializationArguments()

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

◆ solve()

◆ solveWhileResolvedUndefs()

void llvm::SCCPInstVisitor::solveWhileResolvedUndefs ( )
inline

Definition at line 968 of file SCCPSolver.cpp.

References llvm::dyn_cast(), I, resolvedUndef(), and solve().

◆ solveWhileResolvedUndefsIn() [1/2]

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

Definition at line 948 of file SCCPSolver.cpp.

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

◆ solveWhileResolvedUndefsIn() [2/2]

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

Definition at line 958 of file SCCPSolver.cpp.

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

◆ trackValueOfArgument()

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

Definition at line 928 of file SCCPSolver.cpp.

References A(), and getArgAttributeVL().

◆ trackValueOfGlobalVariable()

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

◆ visitCallInst()

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

Definition at line 793 of file SCCPSolver.cpp.

References I.

◆ InstVisitor< SCCPInstVisitor >

friend class InstVisitor< SCCPInstVisitor >
friend

Definition at line 710 of file SCCPSolver.cpp.

References I, and SCCPInstVisitor().


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