LLVM 22.0.0git
llvm::InstCostVisitor Class Reference

#include "llvm/Transforms/IPO/FunctionSpecialization.h"

Inheritance diagram for llvm::InstCostVisitor:
[legend]

Public Member Functions

 InstCostVisitor (std::function< BlockFrequencyInfo &(Function &)> GetBFI, Function *F, const DataLayout &DL, TargetTransformInfo &TTI, SCCPSolver &Solver)
bool isBlockExecutable (BasicBlock *BB) const
LLVM_ABI Cost getCodeSizeSavingsForArg (Argument *A, Constant *C)
 Compute the codesize savings for replacing argument A with constant C.
LLVM_ABI Cost getCodeSizeSavingsFromPendingPHIs ()
LLVM_ABI Cost getLatencySavingsForKnownConstants ()
 Compute the latency savings from replacing all arguments with constants for a specialization candidate.
Public Member Functions inherited from llvm::InstVisitor< InstCostVisitor, Constant * >
void visit (Iterator Start, Iterator End)
void visitModule (Module &M)
void visitFunction (Function &F)
void visitBasicBlock (BasicBlock &BB)
ConstantvisitICmpInst (ICmpInst &I)
ConstantvisitFCmpInst (FCmpInst &I)
ConstantvisitAllocaInst (AllocaInst &I)
ConstantvisitLoadInst (LoadInst &I)
ConstantvisitStoreInst (StoreInst &I)
ConstantvisitAtomicCmpXchgInst (AtomicCmpXchgInst &I)
ConstantvisitAtomicRMWInst (AtomicRMWInst &I)
ConstantvisitFenceInst (FenceInst &I)
ConstantvisitGetElementPtrInst (GetElementPtrInst &I)
ConstantvisitPHINode (PHINode &I)
ConstantvisitTruncInst (TruncInst &I)
ConstantvisitZExtInst (ZExtInst &I)
ConstantvisitSExtInst (SExtInst &I)
ConstantvisitFPTruncInst (FPTruncInst &I)
ConstantvisitFPExtInst (FPExtInst &I)
ConstantvisitFPToUIInst (FPToUIInst &I)
ConstantvisitFPToSIInst (FPToSIInst &I)
ConstantvisitUIToFPInst (UIToFPInst &I)
ConstantvisitSIToFPInst (SIToFPInst &I)
ConstantvisitPtrToIntInst (PtrToIntInst &I)
ConstantvisitPtrToAddrInst (PtrToAddrInst &I)
ConstantvisitIntToPtrInst (IntToPtrInst &I)
ConstantvisitBitCastInst (BitCastInst &I)
ConstantvisitAddrSpaceCastInst (AddrSpaceCastInst &I)
ConstantvisitSelectInst (SelectInst &I)
ConstantvisitVAArgInst (VAArgInst &I)
ConstantvisitExtractElementInst (ExtractElementInst &I)
ConstantvisitInsertElementInst (InsertElementInst &I)
ConstantvisitShuffleVectorInst (ShuffleVectorInst &I)
ConstantvisitExtractValueInst (ExtractValueInst &I)
ConstantvisitInsertValueInst (InsertValueInst &I)
ConstantvisitLandingPadInst (LandingPadInst &I)
ConstantvisitFuncletPadInst (FuncletPadInst &I)
ConstantvisitCleanupPadInst (CleanupPadInst &I)
ConstantvisitCatchPadInst (CatchPadInst &I)
ConstantvisitFreezeInst (FreezeInst &I)
ConstantvisitMemSetInst (MemSetInst &I)
ConstantvisitMemSetPatternInst (MemSetPatternInst &I)
ConstantvisitMemCpyInst (MemCpyInst &I)
ConstantvisitMemMoveInst (MemMoveInst &I)
ConstantvisitMemTransferInst (MemTransferInst &I)
ConstantvisitMemIntrinsic (MemIntrinsic &I)
ConstantvisitVAStartInst (VAStartInst &I)
ConstantvisitVAEndInst (VAEndInst &I)
ConstantvisitVACopyInst (VACopyInst &I)
ConstantvisitIntrinsicInst (IntrinsicInst &I)
ConstantvisitCallInst (CallInst &I)
ConstantvisitInvokeInst (InvokeInst &I)
ConstantvisitCallBrInst (CallBrInst &I)
ConstantvisitReturnInst (ReturnInst &I)
ConstantvisitBranchInst (BranchInst &I)
ConstantvisitSwitchInst (SwitchInst &I)
ConstantvisitIndirectBrInst (IndirectBrInst &I)
ConstantvisitResumeInst (ResumeInst &I)
ConstantvisitUnreachableInst (UnreachableInst &I)
ConstantvisitCleanupReturnInst (CleanupReturnInst &I)
ConstantvisitCatchReturnInst (CatchReturnInst &I)
ConstantvisitCatchSwitchInst (CatchSwitchInst &I)
ConstantvisitTerminator (Instruction &I)
ConstantvisitCastInst (CastInst &I)
ConstantvisitUnaryOperator (UnaryOperator &I)
ConstantvisitBinaryOperator (BinaryOperator &I)
ConstantvisitCmpInst (CmpInst &I)
ConstantvisitUnaryInstruction (UnaryInstruction &I)
ConstantvisitCallBase (CallBase &I)
void visitInstruction (Instruction &I)

Friends

class InstVisitor< InstCostVisitor, Constant * >

Detailed Description

Definition at line 153 of file FunctionSpecialization.h.

Constructor & Destructor Documentation

◆ InstCostVisitor()

llvm::InstCostVisitor::InstCostVisitor ( std::function< BlockFrequencyInfo &(Function &)> GetBFI,
Function * F,
const DataLayout & DL,
TargetTransformInfo & TTI,
SCCPSolver & Solver )
inline

Definition at line 174 of file FunctionSpecialization.h.

Referenced by InstVisitor< InstCostVisitor, Constant * >.

Member Function Documentation

◆ getCodeSizeSavingsForArg()

Cost InstCostVisitor::getCodeSizeSavingsForArg ( Argument * A,
Constant * C )

Compute the codesize savings for replacing argument A with constant C.

Definition at line 164 of file FunctionSpecialization.cpp.

References A(), llvm::CallingConv::C, CodeSize, llvm::dbgs(), llvm::dyn_cast(), isBlockExecutable(), and LLVM_DEBUG.

◆ getCodeSizeSavingsFromPendingPHIs()

Cost InstCostVisitor::getCodeSizeSavingsFromPendingPHIs ( )

Definition at line 152 of file FunctionSpecialization.cpp.

References CodeSize, and isBlockExecutable().

◆ getLatencySavingsForKnownConstants()

Cost InstCostVisitor::getLatencySavingsForKnownConstants ( )

Compute the latency savings from replacing all arguments with constants for a specialization candidate.

As this function computes the latency savings for all Instructions in KnownConstants at once, it should be called only after every instruction has been visited, i.e. after:

  • getCodeSizeSavingsForArg has been run for every constant argument of a specialization candidate
  • getCodeSizeSavingsFromPendingPHIs has been run

to ensure that the latency savings are calculated for all Instructions we have visited and found to be constant.

Definition at line 190 of file FunctionSpecialization.cpp.

References llvm::dbgs(), llvm::dyn_cast(), I, llvm::Latency, LLVM_DEBUG, and llvm::TargetTransformInfo::TCK_Latency.

◆ isBlockExecutable()

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

◆ InstVisitor< InstCostVisitor, Constant * >

friend class InstVisitor< InstCostVisitor, Constant * >
friend

Definition at line 187 of file FunctionSpecialization.h.

References llvm::CallingConv::C, I, InstCostVisitor(), and LLVM_ABI.


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