LLVM: lib/Transforms/Instrumentation/IndirectCallPromotion.cpp File Reference (original) (raw)

Go to the source code of this file.

Namespaces
namespace llvm
This is an optimization pass for GlobalISel generic memory operations.
Macros
#define DEBUG_TYPE "pgo-icall-prom"
Functions
STATISTIC (NumOfPGOICallPromotion, "Number of indirect call promotions.")
STATISTIC (NumOfPGOICallsites, "Number of indirect call candidate sites.")
static MDNode * createBranchWeights (LLVMContext &Context, uint64_t TrueWeight, uint64_t FalseWeight)
static void computeVirtualCallSiteTypeInfoMap (Module &M, ModuleAnalysisManager &MAM, VirtualCallSiteTypeInfoMap &VirtualCSInfo)
static bool promoteIndirectCalls (Module &M, ProfileSummaryInfo *PSI, bool InLTO, bool SamplePGO, ModuleAnalysisManager &MAM)
Variables
static cl::opt< bool > DisableICP ("disable-icp", cl::init(false), cl::Hidden, cl::desc("Disable indirect call promotion"))
static cl::opt< unsigned > ICPCutOff ("icp-cutoff", cl::init(0), cl::Hidden, cl::desc("Max number of promotions for this compilation"))
static cl::opt< unsigned > ICPCSSkip ("icp-csskip", cl::init(0), cl::Hidden, cl::desc("Skip Callsite up to this number for this compilation"))
static cl::opt< bool > ICPAllowDecls ("icp-allow-decls", cl::init(false), cl::Hidden, cl::desc("Promote the target candidate even when the definition " " is not available"))
static cl::opt< bool > ICPAllowHotOnly ("icp-allow-hot-only", cl::init(true), cl::Hidden, cl::desc("Promote the target candidate only if it is a " "hot function. Otherwise, warm functions can " "also be promoted"))
static cl::opt< bool > ICPAllowCandidateSkip ("icp-allow-candidate-skip", cl::init(false), cl::Hidden, cl::desc("Continue with the remaining targets instead of exiting " "when failing in a candidate"))
static cl::opt< bool > ICPLTOMode ("icp-lto", cl::init(false), cl::Hidden, cl::desc("Run indirect-call promotion in LTO " "mode"))
static cl::opt< bool > ICPSamplePGOMode ("icp-samplepgo", cl::init(false), cl::Hidden, cl::desc("Run indirect-call promotion in SamplePGO mode"))
static cl::opt< bool > ICPCallOnly ("icp-call-only", cl::init(false), cl::Hidden, cl::desc("Run indirect-call promotion for call instructions " "only"))
static cl::opt< bool > ICPInvokeOnly ("icp-invoke-only", cl::init(false), cl::Hidden, cl::desc("Run indirect-call promotion for " "invoke instruction only"))
static cl::opt< bool > ICPDUMPAFTER ("icp-dumpafter", cl::init(false), cl::Hidden, cl::desc("Dump IR after transformation happens"))
static cl::opt< float > ICPVTablePercentageThreshold ("icp-vtable-percentage-threshold", cl::init(0.995), cl::Hidden, cl::desc("The percentage threshold of vtable-count / function-count for " "cost-benefit analysis."))
static cl::opt< int > ICPMaxNumVTableLastCandidate ("icp-max-num-vtable-last-candidate", cl::init(1), cl::Hidden, cl::desc("The maximum number of vtable for the last candidate."))
static cl::list< std::string > ICPIgnoredBaseTypes ("icp-ignored-base-types", cl::Hidden, cl::desc("A list of mangled vtable type info names. Classes specified by the " "type info names and their derived ones will not be vtable-ICP'ed. " "Useful when the profiled types and actual types in the optimized " "binary could be different due to profiling limitations. Type info " "names are those string literals used in LLVM type metadata"))

DEBUG_TYPE

#define DEBUG_TYPE "pgo-icall-prom"

computeVirtualCallSiteTypeInfoMap()

Definition at line 1001 of file IndirectCallPromotion.cpp.

References llvm::cast(), llvm::dyn_cast(), F, FAM, llvm::findDevirtualizableCallsForTypeTest(), llvm::Intrinsic::getDeclarationIfExists(), llvm::make_early_inc_range(), MAM, llvm::PGOIndirectCallVisitor::tryGetVTableInstruction(), llvm::Value::use_empty(), and llvm::Value::uses().

Referenced by promoteIndirectCalls().

createBranchWeights()

promoteIndirectCalls()

Definition at line 1054 of file IndirectCallPromotion.cpp.

References Changed, computeVirtualCallSiteTypeInfoMap(), llvm::InstrProfSymtab::create(), llvm::dbgs(), DisableICP, E(), llvm::EnableVTableProfileUse, F, FAM, ICPCutOff, ICPDUMPAFTER, ICPIgnoredBaseTypes, llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::insert_range(), LLVM_DEBUG, MAM, and llvm::toString().

Referenced by llvm::PGOIndirectCallPromotion::run().

STATISTIC() [1/2]

STATISTIC ( NumOfPGOICallPromotion ,
"Number of indirect call promotions." )

STATISTIC() [2/2]

STATISTIC ( NumOfPGOICallsites ,
"Number of indirect call candidate sites." )

DisableICP

cl::opt< bool > DisableICP("disable-icp", cl::init(false), cl::Hidden, cl::desc("Disable indirect call promotion")) ( "disable-icp" , cl::init(false) , cl::Hidden , cl::desc("Disable indirect call promotion") ) static

ICPAllowCandidateSkip

cl::opt< bool > ICPAllowCandidateSkip("icp-allow-candidate-skip", cl::init(false), cl::Hidden, cl::desc("Continue with the remaining targets instead of exiting " "when failing in a candidate")) ( "icp-allow-candidate-skip" , cl::init(false) , cl::Hidden , cl::desc("Continue with the remaining targets instead of exiting " "when failing in a candidate") ) static

ICPAllowDecls

cl::opt< bool > ICPAllowDecls("icp-allow-decls", cl::init(false), cl::Hidden, cl::desc("Promote the target candidate even when the definition " " is not available")) ( "icp-allow-decls" , cl::init(false) , cl::Hidden , cl::desc("Promote the target candidate even when the definition " " is not available") ) static

ICPAllowHotOnly

cl::opt< bool > ICPAllowHotOnly("icp-allow-hot-only", cl::init(true), cl::Hidden, cl::desc("Promote the target candidate only if it is a " "hot function. Otherwise, warm functions can " "also be promoted")) ( "icp-allow-hot-only" , cl::init(true) , cl::Hidden , cl::desc("Promote the target candidate only if it is a " "hot function. Otherwise, warm functions can " "also be promoted") ) static

ICPCallOnly

ICPCSSkip

cl::opt< unsigned > ICPCSSkip("icp-csskip", cl::init(0), cl::Hidden, cl::desc("Skip Callsite up to this number for this compilation")) ( "icp-csskip" , cl::init(0) , cl::Hidden , cl::desc("Skip Callsite up to this number for this compilation") ) static

ICPCutOff

ICPDUMPAFTER

cl::opt< bool > ICPDUMPAFTER("icp-dumpafter", cl::init(false), cl::Hidden, cl::desc("Dump IR after transformation happens")) ( "icp-dumpafter" , cl::init(false) , cl::Hidden , cl::desc("Dump IR after transformation happens") ) static

ICPIgnoredBaseTypes

cl::list< std::string > ICPIgnoredBaseTypes("icp-ignored-base-types", cl::Hidden, cl::desc( "A list of mangled vtable type info names. Classes specified by the " "type info names and their derived ones will not be vtable-ICP'ed. " "Useful when the profiled types and actual types in the optimized " "binary could be different due to profiling limitations. Type info " "names are those string literals used in LLVM type metadata")) ( "icp-ignored-base-types" , cl::Hidden , cl::desc( "A list of mangled vtable type info names. Classes specified by the " "type info names and their derived ones will not be vtable-ICP'ed. " "Useful when the profiled types and actual types in the optimized " "binary could be different due to profiling limitations. Type info " "names are those string literals used in LLVM type metadata") ) static

ICPInvokeOnly

cl::opt< bool > ICPInvokeOnly("icp-invoke-only", cl::init(false), cl::Hidden, cl::desc("Run indirect-call promotion for " "invoke instruction only")) ( "icp-invoke-only" , cl::init(false) , cl::Hidden , cl::desc("Run indirect-call promotion for " "invoke instruction only") ) static

ICPLTOMode

cl::opt< bool > ICPLTOMode("icp-lto", cl::init(false), cl::Hidden, cl::desc("Run indirect-call promotion in LTO " "mode")) ( "icp-lto" , cl::init(false) , cl::Hidden , cl::desc("Run indirect-call promotion in LTO " "mode") ) static

ICPMaxNumVTableLastCandidate

cl::opt< int > ICPMaxNumVTableLastCandidate("icp-max-num-vtable-last-candidate", cl::init(1), cl::Hidden, cl::desc("The maximum number of vtable for the last candidate.")) ( "icp-max-num-vtable-last-candidate" , cl::init(1) , cl::Hidden , cl::desc("The maximum number of vtable for the last candidate.") ) static

ICPSamplePGOMode

cl::opt< bool > ICPSamplePGOMode("icp-samplepgo", cl::init(false), cl::Hidden, cl::desc("Run indirect-call promotion in SamplePGO mode")) ( "icp-samplepgo" , cl::init(false) , cl::Hidden , cl::desc("Run indirect-call promotion in SamplePGO mode") ) static

ICPVTablePercentageThreshold

cl::opt< float > ICPVTablePercentageThreshold("icp-vtable-percentage-threshold", cl::init(0.995), cl::Hidden, cl::desc("The percentage threshold of vtable-count / function-count for " "cost-benefit analysis.")) ( "icp-vtable-percentage-threshold" , cl::init(0.995) , cl::Hidden , cl::desc("The percentage threshold of vtable-count / function-count for " "cost-benefit analysis.") ) static