LLVM  10.0.0svn
Macros | Typedefs | Functions | Variables
SampleProfile.cpp File Reference
#include "llvm/Transforms/IPO/SampleProfile.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/None.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Analysis/AssumptionCache.h"
#include "llvm/Analysis/InlineCost.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/OptimizationRemarkEmitter.h"
#include "llvm/Analysis/PostDominators.h"
#include "llvm/Analysis/ProfileSummaryInfo.h"
#include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/CFG.h"
#include "llvm/IR/CallSite.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/DebugLoc.h"
#include "llvm/IR/DiagnosticInfo.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GlobalValue.h"
#include "llvm/IR/InstrTypes.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/MDBuilder.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/PassManager.h"
#include "llvm/IR/ValueSymbolTable.h"
#include "llvm/Pass.h"
#include "llvm/ProfileData/InstrProf.h"
#include "llvm/ProfileData/SampleProf.h"
#include "llvm/ProfileData/SampleProfReader.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/ErrorOr.h"
#include "llvm/Support/GenericDomTree.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/IPO.h"
#include "llvm/Transforms/Instrumentation.h"
#include "llvm/Transforms/Utils/CallPromotionUtils.h"
#include "llvm/Transforms/Utils/Cloning.h"
#include "llvm/Transforms/Utils/MisExpect.h"
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <functional>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <string>
#include <system_error>
#include <utility>
#include <vector>

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "sample-profile"
 

Typedefs

using ProfileCount = Function::ProfileCount
 

Functions

static SmallVector< InstrProfValueData, 2 > GetSortedValueDataFromCallTargets (const SampleRecord::CallTargetMap &M)
 Returns the sorted CallTargetMap M by count in descending order. More...
 
 INITIALIZE_PASS_BEGIN (SampleProfileLoaderLegacyPass, "sample-profile", "Sample Profile loader", false, false) INITIALIZE_PASS_END(SampleProfileLoaderLegacyPass
 

Variables

static cl::opt< std::string > SampleProfileFile ("sample-profile-file", cl::init(""), cl::value_desc("filename"), cl::desc("Profile file loaded by -sample-profile"), cl::Hidden)
 
static cl::opt< std::string > SampleProfileRemappingFile ("sample-profile-remapping-file", cl::init(""), cl::value_desc("filename"), cl::desc("Profile remapping file loaded by -sample-profile"), cl::Hidden)
 
static cl::opt< unsignedSampleProfileMaxPropagateIterations ("sample-profile-max-propagate-iterations", cl::init(100), cl::desc("Maximum number of iterations to go through when propagating " "sample block/edge weights through the CFG."))
 
static cl::opt< unsignedSampleProfileRecordCoverage ("sample-profile-check-record-coverage", cl::init(0), cl::value_desc("N"), cl::desc("Emit a warning if less than N% of records in the input profile " "are matched to the IR."))
 
static cl::opt< unsignedSampleProfileSampleCoverage ("sample-profile-check-sample-coverage", cl::init(0), cl::value_desc("N"), cl::desc("Emit a warning if less than N% of samples in the input profile " "are matched to the IR."))
 
static cl::opt< boolNoWarnSampleUnused ("no-warn-sample-unused", cl::init(false), cl::Hidden, cl::desc("Use this option to turn off/on warnings about function with " "samples but without debug information to use those samples. "))
 
static cl::opt< boolProfileSampleAccurate ("profile-sample-accurate", cl::Hidden, cl::init(false), cl::desc("If the sample profile is accurate, we will mark all un-sampled " "callsite and function as having 0 samples. Otherwise, treat " "un-sampled callsites and functions conservatively as unknown. "))
 
static cl::opt< boolProfileAccurateForSymsInList ("profile-accurate-for-symsinlist", cl::Hidden, cl::ZeroOrMore, cl::init(true), cl::desc("For symbols in profile symbol list, regard their profiles to " "be accurate. It may be overriden by profile-sample-accurate. "))
 
sample profile
 
sample Sample Profile loader
 
sample Sample Profile false
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "sample-profile"

Definition at line 92 of file SampleProfile.cpp.

Referenced by GetSortedValueDataFromCallTargets().

Typedef Documentation

◆ ProfileCount

Definition at line 91 of file SampleProfile.cpp.

Function Documentation

◆ GetSortedValueDataFromCallTargets()

static SmallVector<InstrProfValueData, 2> GetSortedValueDataFromCallTargets ( const SampleRecord::CallTargetMap M)
static

Returns the sorted CallTargetMap M by count in descending order.

Definition at line 1343 of file SampleProfile.cpp.

References llvm::annotateValueSite(), llvm::MDBuilder::createBranchWeights(), llvm::dbgs(), DEBUG_TYPE, llvm::LLVMContext::diagnose(), llvm::DS_Warning, E, llvm::SmallVectorImpl< T >::emplace_back(), llvm::Instruction::extractProfTotalWeight(), llvm::sampleprof::FunctionSamples::findCallTargetMapAt(), llvm::DILocation::getBaseDiscriminator(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, CallBrTy, IterTy >::getCalledFunction(), llvm::Function::getContext(), llvm::Value::getContext(), llvm::Instruction::getDebugLoc(), llvm::DIScope::getFilename(), llvm::BasicBlock::getFirstNonPHIOrDbgOrLifetime(), llvm::sampleprof::FunctionSamples::getGUID(), llvm::LoopBase< BlockT, LoopT >::getHeader(), llvm::DebugLoc::getLine(), llvm::Value::getName(), llvm::Instruction::getNumSuccessors(), llvm::sampleprof::FunctionSamples::getOffset(), llvm::Function::getSubprogram(), llvm::Instruction::getSuccessor(), I, INITIALIZE_PASS_BEGIN(), INITIALIZE_PASS_DEPENDENCY, LLVM_DEBUG, llvm::max(), NoWarnSampleUnused, llvm::Function::PCT_Real, llvm::SmallVectorTemplateBase< T, bool >::push_back(), SampleProfileMaxPropagateIterations, SampleProfileRecordCoverage, SampleProfileSampleCoverage, llvm::Function::setEntryCount(), llvm::Instruction::setMetadata(), llvm::SmallVectorBase::size(), llvm::sampleprof::SampleRecord::SortCallTargets(), and llvm::misexpect::verifyMisExpect().

◆ INITIALIZE_PASS_BEGIN()

INITIALIZE_PASS_BEGIN ( SampleProfileLoaderLegacyPass  ,
"sample-profile ,
"Sample Profile loader ,
false  ,
false   
)

Variable Documentation

◆ false

sample Sample Profile false

Definition at line 1673 of file SampleProfile.cpp.

◆ loader

sample Sample Profile loader

Definition at line 1673 of file SampleProfile.cpp.

◆ NoWarnSampleUnused

cl::opt<bool> NoWarnSampleUnused("no-warn-sample-unused", cl::init(false), cl::Hidden, cl::desc("Use this option to turn off/on warnings about function with " "samples but without debug information to use those samples. "))
static

◆ profile

sample profile

Definition at line 1673 of file SampleProfile.cpp.

◆ ProfileAccurateForSymsInList

cl::opt<bool> ProfileAccurateForSymsInList("profile-accurate-for-symsinlist", cl::Hidden, cl::ZeroOrMore, cl::init(true), cl::desc("For symbols in profile symbol list, regard their profiles to " "be accurate. It may be overriden by profile-sample-accurate. "))
static

◆ ProfileSampleAccurate

cl::opt<bool> ProfileSampleAccurate("profile-sample-accurate", cl::Hidden, cl::init(false), cl::desc("If the sample profile is accurate, we will mark all un-sampled " "callsite and function as having 0 samples. Otherwise, treat " "un-sampled callsites and functions conservatively as unknown. "))
static

◆ SampleProfileFile

cl::opt<std::string> SampleProfileFile("sample-profile-file", cl::init(""), cl::value_desc("filename"), cl::desc("Profile file loaded by -sample-profile"), cl::Hidden)
static

◆ SampleProfileMaxPropagateIterations

cl::opt<unsigned> SampleProfileMaxPropagateIterations("sample-profile-max-propagate-iterations", cl::init(100), cl::desc("Maximum number of iterations to go through when propagating " "sample block/edge weights through the CFG."))
static

◆ SampleProfileRecordCoverage

cl::opt<unsigned> SampleProfileRecordCoverage("sample-profile-check-record-coverage", cl::init(0), cl::value_desc("N"), cl::desc("Emit a warning if less than N% of records in the input profile " "are matched to the IR."))
static

◆ SampleProfileRemappingFile

cl::opt<std::string> SampleProfileRemappingFile("sample-profile-remapping-file", cl::init(""), cl::value_desc("filename"), cl::desc("Profile remapping file loaded by -sample-profile"), cl::Hidden)
static

◆ SampleProfileSampleCoverage

cl::opt<unsigned> SampleProfileSampleCoverage("sample-profile-check-sample-coverage", cl::init(0), cl::value_desc("N"), cl::desc("Emit a warning if less than N% of samples in the input profile " "are matched to the IR."))
static