LLVM 20.0.0git
Namespaces | Macros | Functions | Variables
IndirectCallPromotion.cpp File Reference
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Analysis/IndirectCallPromotionAnalysis.h"
#include "llvm/Analysis/IndirectCallVisitor.h"
#include "llvm/Analysis/OptimizationRemarkEmitter.h"
#include "llvm/Analysis/ProfileSummaryInfo.h"
#include "llvm/Analysis/TypeMetadataUtils.h"
#include "llvm/IR/DiagnosticInfo.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/InstrTypes.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/MDBuilder.h"
#include "llvm/IR/PassManager.h"
#include "llvm/IR/ProfDataUtils.h"
#include "llvm/IR/Value.h"
#include "llvm/ProfileData/InstrProf.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/Instrumentation/PGOInstrumentation.h"
#include "llvm/Transforms/Utils/CallPromotionUtils.h"
#include "llvm/Transforms/Utils/Instrumentation.h"
#include <cassert>
#include <cstdint>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

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 MDNodecreateBranchWeights (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

cl::opt< unsignedMaxNumVTableAnnotations
 
static cl::opt< boolDisableICP ("disable-icp", cl::init(false), cl::Hidden, cl::desc("Disable indirect call promotion"))
 
static cl::opt< unsignedICPCutOff ("icp-cutoff", cl::init(0), cl::Hidden, cl::desc("Max number of promotions for this compilation"))
 
static cl::opt< unsignedICPCSSkip ("icp-csskip", cl::init(0), cl::Hidden, cl::desc("Skip Callsite up to this number for this compilation"))
 
static cl::opt< boolICPLTOMode ("icp-lto", cl::init(false), cl::Hidden, cl::desc("Run indirect-call promotion in LTO " "mode"))
 
static cl::opt< boolICPSamplePGOMode ("icp-samplepgo", cl::init(false), cl::Hidden, cl::desc("Run indirect-call promotion in SamplePGO mode"))
 
static cl::opt< boolICPCallOnly ("icp-call-only", cl::init(false), cl::Hidden, cl::desc("Run indirect-call promotion for call instructions " "only"))
 
static cl::opt< boolICPInvokeOnly ("icp-invoke-only", cl::init(false), cl::Hidden, cl::desc("Run indirect-call promotion for " "invoke instruction only"))
 
static cl::opt< boolICPDUMPAFTER ("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"))
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "pgo-icall-prom"

Definition at line 53 of file IndirectCallPromotion.cpp.

Function Documentation

◆ computeVirtualCallSiteTypeInfoMap()

static void computeVirtualCallSiteTypeInfoMap ( Module M,
ModuleAnalysisManager MAM,
VirtualCallSiteTypeInfoMap &  VirtualCSInfo 
)
static

◆ createBranchWeights()

static MDNode * createBranchWeights ( LLVMContext Context,
uint64_t  TrueWeight,
uint64_t  FalseWeight 
)
static

◆ promoteIndirectCalls()

static bool promoteIndirectCalls ( Module M,
ProfileSummaryInfo PSI,
bool  InLTO,
bool  SamplePGO,
ModuleAnalysisManager MAM 
)
static

◆ STATISTIC() [1/2]

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

◆ STATISTIC() [2/2]

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

Variable Documentation

◆ 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

Referenced by promoteIndirectCalls().

◆ ICPCallOnly

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

◆ 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

cl::opt< unsigned > ICPCutOff("icp-cutoff", cl::init(0), cl::Hidden, cl::desc("Max number of promotions for this compilation")) ( "icp-cutoff"  ,
cl::init(0)  ,
cl::Hidden  ,
cl::desc("Max number of promotions for this compilation")   
)
static

Referenced by promoteIndirectCalls().

◆ 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

Referenced by promoteIndirectCalls().

◆ 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

Referenced by promoteIndirectCalls().

◆ 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

◆ MaxNumVTableAnnotations

cl::opt<unsigned> MaxNumVTableAnnotations
extern