LLVM
8.0.1
|
#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 <algorithm>
#include <cassert>
#include <cstdint>
#include <functional>
#include <limits>
#include <map>
#include <memory>
#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 bool | callsiteIsHot (const FunctionSamples *CallsiteFS, ProfileSummaryInfo *PSI) |
Return true if the given callsite is hot wrt to hot cutoff threshold. More... | |
static SmallVector< InstrProfValueData, 2 > | SortCallTargets (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< 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 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 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 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 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. ")) |
sample | profile |
sample Sample Profile | loader |
sample Sample Profile | false |
#define DEBUG_TYPE "sample-profile" |
Definition at line 91 of file SampleProfile.cpp.
Referenced by callsiteIsHot(), and SortCallTargets().
using ProfileCount = Function::ProfileCount |
Definition at line 90 of file SampleProfile.cpp.
|
static |
Return true if the given callsite is hot wrt to hot cutoff threshold.
Functions that were inlined in the original binary will be represented in the inline stack in the sample profile. If the profile shows that the original inline decision was "good" (i.e., the callsite is executed frequently), then we will recreate the inline decision and apply the profile from the inlined callsite.
To decide whether an inlined callsite is hot, we compare the callsite sample count with the hot cutoff computed by ProfileSummaryInfo, it is regarded as hot if the count is above the cutoff value.
Definition at line 377 of file SampleProfile.cpp.
References assert(), llvm::SmallVectorTemplateCommon< T >::begin(), C, Callee, llvm::SmallPtrSetImplBase::clear(), llvm::SmallVectorImpl< T >::clear(), llvm::InlineParams::ComputeFullInlineCost, llvm::detail::DenseSetImpl< ValueT, DenseMap< ValueT, detail::DenseSetEmpty, ValueInfoT, detail::DenseSetPair< ValueT > >, ValueInfoT >::count(), llvm::dbgs(), DEBUG_TYPE, llvm::DominatorTreeBase< NodeT, IsPostDom >::dominates(), E, llvm::empty(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::SmallVectorTemplateCommon< T >::end(), F(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), llvm::sampleprof::FunctionSamples::findCallTargetMapAt(), llvm::sampleprof::FunctionSamples::findFunctionSamplesAt(), llvm::sampleprof::FunctionSamples::findFunctionSamplesMapAt(), llvm::sampleprof::FunctionSamples::findInlinedFunctions(), llvm::sampleprof::FunctionSamples::findSamplesAt(), llvm::ErrorOr< T >::get(), llvm::DILocation::getBaseDiscriminator(), llvm::sampleprof::FunctionSamples::getBodySamples(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, IterTy >::getCalledFunction(), llvm::sampleprof::FunctionSamples::getCallsiteSamples(), llvm::Instruction::getDebugLoc(), llvm::Function::getEntryBlock(), llvm::sampleprof::FunctionSamples::getEntrySamples(), llvm::sampleprof::FunctionSamples::getFuncNameInModule(), llvm::sampleprof::FunctionSamples::getGUID(), llvm::getInlineCost(), llvm::getInlineParams(), llvm::BasicBlock::getInstList(), llvm::DebugLoc::getLine(), getName(), llvm::Value::getName(), llvm::sampleprof::FunctionSamples::getName(), llvm::sampleprof::FunctionSamples::getOffset(), llvm::ProfileSummaryInfo::getOrCompHotCountThreshold(), llvm::Instruction::getParent(), llvm::BasicBlock::getParent(), llvm::Function::getSubprogram(), llvm::sampleprof::FunctionSamples::getTotalSamples(), I, if(), llvm::InlineFunction(), llvm::detail::DenseSetImpl< ValueT, DenseMap< ValueT, detail::DenseSetEmpty, ValueInfoT, detail::DenseSetPair< ValueT > >, ValueInfoT >::insert(), llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::SmallVectorImpl< T >::insert(), llvm::GlobalValue::isDeclaration(), llvm::ProfileSummaryInfo::isHotCount(), llvm::isLegalToPromote(), llvm::InlineCost::isNever(), LLVM_DEBUG, llvm_unreachable, llvm::max(), llvm::None, llvm::pred_begin(), llvm::pred_end(), llvm::pgo::promoteIndirectCall(), llvm::SmallVectorTemplateBase< T >::push_back(), llvm::Remark, SI, llvm::sort(), llvm::succ_begin(), llvm::succ_end(), and llvm::RISCVFenceField::W.
INITIALIZE_PASS_BEGIN | ( | SampleProfileLoaderLegacyPass | , |
"sample-profile" | , | ||
"Sample Profile loader" | , | ||
false | , | ||
false | |||
) |
Referenced by SortCallTargets().
|
static |
Returns the sorted CallTargetMap M
by count in descending order.
Definition at line 1191 of file SampleProfile.cpp.
References llvm::annotateValueSite(), llvm::StringMap< ValueTy, AllocatorTy >::begin(), llvm::MDBuilder::createBranchWeights(), llvm::dbgs(), DEBUG_TYPE, llvm::LLVMContext::diagnose(), llvm::DS_Warning, E, llvm::StringMap< ValueTy, AllocatorTy >::end(), llvm::Instruction::extractProfTotalWeight(), llvm::sampleprof::FunctionSamples::findCallTargetMapAt(), llvm::DILocation::getBaseDiscriminator(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, IterTy >::getCalledFunction(), llvm::Function::getContext(), llvm::Instruction::getDebugLoc(), llvm::DIScope::getFilename(), llvm::BasicBlock::getFirstNonPHIOrDbgOrLifetime(), 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(), llvm::LLVMContext::MD_prof, NoWarnSampleUnused, llvm::Function::PCT_Real, llvm::SmallVectorTemplateBase< T >::push_back(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), SampleProfileMaxPropagateIterations, SampleProfileRecordCoverage, SampleProfileSampleCoverage, llvm::Function::setEntryCount(), llvm::Instruction::setMetadata(), llvm::SmallVectorBase::size(), and llvm::sort().
sample Sample Profile false |
Definition at line 1524 of file SampleProfile.cpp.
sample Sample Profile loader |
Definition at line 1524 of file SampleProfile.cpp.
|
static |
Referenced by SortCallTargets().
sample profile |
Definition at line 1524 of file SampleProfile.cpp.
|
static |
Referenced by llvm::createSampleProfileLoaderPass().
|
static |
Referenced by llvm::SampleProfileLoaderPass::run().
|
static |
Referenced by SortCallTargets().
|
static |
Referenced by SortCallTargets().
|
static |
Referenced by llvm::SampleProfileLoaderPass::run().
|
static |
Referenced by SortCallTargets().