|
LLVM
4.0.0
|
#include "llvm/Transforms/PGOInstrumentation.h"#include "CFGMST.h"#include "llvm/ADT/STLExtras.h"#include "llvm/ADT/SmallVector.h"#include "llvm/ADT/Statistic.h"#include "llvm/ADT/Triple.h"#include "llvm/Analysis/BlockFrequencyInfo.h"#include "llvm/Analysis/BranchProbabilityInfo.h"#include "llvm/Analysis/CFG.h"#include "llvm/Analysis/IndirectCallSiteVisitor.h"#include "llvm/IR/CallSite.h"#include "llvm/IR/DiagnosticInfo.h"#include "llvm/IR/GlobalValue.h"#include "llvm/IR/IRBuilder.h"#include "llvm/IR/InstIterator.h"#include "llvm/IR/Instructions.h"#include "llvm/IR/IntrinsicInst.h"#include "llvm/IR/MDBuilder.h"#include "llvm/IR/Module.h"#include "llvm/Pass.h"#include "llvm/ProfileData/InstrProfReader.h"#include "llvm/ProfileData/ProfileCommon.h"#include "llvm/Support/BranchProbability.h"#include "llvm/Support/Debug.h"#include "llvm/Support/JamCRC.h"#include "llvm/Transforms/Instrumentation.h"#include "llvm/Transforms/Utils/BasicBlockUtils.h"#include <algorithm>#include <string>#include <unordered_map>#include <utility>#include <vector>Go to the source code of this file.
Macros | |
| #define | DEBUG_TYPE "pgo-instrumentation" |
Enumerations | |
| enum | VisitMode |
| The select instruction visitor plays three roles specified by the mode. More... | |
Functions | |
| STATISTIC (NumOfPGOInstrument,"Number of edges instrumented.") | |
| STATISTIC (NumOfPGOSelectInsts,"Number of select instruction instrumented.") | |
| STATISTIC (NumOfPGOEdge,"Number of edges.") | |
| STATISTIC (NumOfPGOBB,"Number of basic-blocks.") | |
| STATISTIC (NumOfPGOSplit,"Number of critical edge splits.") | |
| STATISTIC (NumOfPGOFunc,"Number of functions having valid profile counts.") | |
| STATISTIC (NumOfPGOMismatch,"Number of functions having mismatch profile.") | |
| STATISTIC (NumOfPGOMissing,"Number of functions without profile.") | |
| STATISTIC (NumOfPGOICall,"Number of indirect call value instrumentations.") | |
| INITIALIZE_PASS_BEGIN (PGOInstrumentationGenLegacyPass,"pgo-instr-gen","PGO instrumentation.", false, false) INITIALIZE_PASS_END(PGOInstrumentationGenLegacyPass | |
| INITIALIZE_PASS_BEGIN (PGOInstrumentationUseLegacyPass,"pgo-instr-use","Read PGO instrumentation profile.", false, false) INITIALIZE_PASS_END(PGOInstrumentationUseLegacyPass | |
| static void | createIRLevelProfileFlagVariable (Module &M) |
| static void | collectComdatMembers (Module &M, std::unordered_multimap< Comdat *, GlobalValue * > &ComdatMembers) |
| static bool | InstrumentAllFunctions (Module &M, function_ref< BranchProbabilityInfo *(Function &)> LookupBPI, function_ref< BlockFrequencyInfo *(Function &)> LookupBFI) |
| static bool | annotateAllFunctions (Module &M, StringRef ProfileFileName, function_ref< BranchProbabilityInfo *(Function &)> LookupBPI, function_ref< BlockFrequencyInfo *(Function &)> LookupBFI) |
Variables | |
| static cl::opt< std::string > | PGOTestProfileFile ("pgo-test-profile-file", cl::init(""), cl::Hidden, cl::value_desc("filename"), cl::desc("Specify the path of profile data file. This is""mainly for test purpose.")) |
| static cl::opt< bool > | DisableValueProfiling ("disable-vp", cl::init(false), cl::Hidden, cl::desc("Disable Value Profiling")) |
| static cl::opt< unsigned > | MaxNumAnnotations ("icp-max-annotations", cl::init(3), cl::Hidden, cl::ZeroOrMore, cl::desc("Max number of annotations for a single indirect ""call callsite")) |
| static cl::opt< bool > | DoComdatRenaming ("do-comdat-renaming", cl::init(false), cl::Hidden, cl::desc("Append function hash to the name of COMDAT function to avoid ""function hash mismatch due to the preinliner")) |
| static cl::opt< bool > | PGOWarnMissing ("pgo-warn-missing-function", cl::init(false), cl::Hidden) |
| static cl::opt< bool > | NoPGOWarnMismatch ("no-pgo-warn-mismatch", cl::init(false), cl::Hidden) |
| static cl::opt< bool > | NoPGOWarnMismatchComdat ("no-pgo-warn-mismatch-comdat", cl::init(true), cl::Hidden) |
| static cl::opt< bool > | PGOInstrSelect ("pgo-instr-select", cl::init(true), cl::Hidden) |
| pgo instr | gen |
| pgo instr PGO | instrumentation |
| pgo instr PGO | false |
| pgo instr | use |
| pgo instr Read PGO instrumentation | profile |
| #define DEBUG_TYPE "pgo-instrumentation" |
Definition at line 86 of file PGOInstrumentation.cpp.
| enum VisitMode |
The select instruction visitor plays three roles specified by the mode.
In VM_counting mode, it simply counts the number of select instructions. In VM_instrument mode, it inserts code to count the number times TrueValue of select is taken. In VM_annotate mode, it reads the profile data and annotate the select instruction with metadata.
Definition at line 153 of file PGOInstrumentation.cpp.
|
static |
Definition at line 1155 of file PGOInstrumentation.cpp.
References llvm::CallingConv::Cold, collectComdatMembers(), llvm::IndexedInstrProfReader::create(), llvm::StringRef::data(), llvm::dbgs(), DEBUG, llvm::Module::getContext(), llvm::handleAllErrors(), and llvm::ErrorInfoBase::message().
Referenced by llvm::PGOInstrumentationUse::run().
|
static |
Definition at line 1091 of file PGOInstrumentation.cpp.
References DoComdatRenaming.
Referenced by annotateAllFunctions(), and InstrumentAllFunctions().
|
static |
Definition at line 1073 of file PGOInstrumentation.cpp.
References llvm::GlobalValue::DefaultVisibility, llvm::GlobalValue::ExternalLinkage, llvm::Module::getContext(), llvm::Type::getInt64Ty(), llvm::Constant::getIntegerValue(), llvm::Module::getOrInsertComdat(), llvm::Module::getTargetTriple(), and llvm::GlobalValue::WeakAnyLinkage.
Referenced by InstrumentAllFunctions().
| INITIALIZE_PASS_BEGIN | ( | PGOInstrumentationGenLegacyPass | , |
| "pgo-instr-gen" | , | ||
| "PGO instrumentation." | , | ||
| false | , | ||
| false | |||
| ) |
| INITIALIZE_PASS_BEGIN | ( | PGOInstrumentationUseLegacyPass | , |
| "pgo-instr-use" | , | ||
| "Read PGO instrumentation profile." | , | ||
| false | , | ||
| false | |||
| ) |
|
static |
Definition at line 1107 of file PGOInstrumentation.cpp.
References collectComdatMembers(), and createIRLevelProfileFlagVariable().
Referenced by llvm::PGOInstrumentationGen::run().
| STATISTIC | ( | NumOfPGOInstrument | , |
| "Number of edges instrumented." | |||
| ) |
| STATISTIC | ( | NumOfPGOSelectInsts | , |
| "Number of select instruction instrumented." | |||
| ) |
| STATISTIC | ( | NumOfPGOEdge | , |
| "Number of edges." | |||
| ) |
| STATISTIC | ( | NumOfPGOBB | , |
| "Number of basic-blocks." | |||
| ) |
| STATISTIC | ( | NumOfPGOSplit | , |
| "Number of critical edge splits." | |||
| ) |
| STATISTIC | ( | NumOfPGOMismatch | , |
| "Number of functions having mismatch profile." | |||
| ) |
| STATISTIC | ( | NumOfPGOMissing | , |
| "Number of functions without profile." | |||
| ) |
| STATISTIC | ( | NumOfPGOICall | , |
| "Number of indirect call value instrumentations." | |||
| ) |
|
static |
|
static |
Referenced by collectComdatMembers().
| pgo instr Read PGO instrumentation false |
Definition at line 252 of file PGOInstrumentation.cpp.
| pgo instr gen |
Definition at line 252 of file PGOInstrumentation.cpp.
| pgo instr PGO instrumentation |
Definition at line 252 of file PGOInstrumentation.cpp.
|
static |
|
static |
|
static |
Referenced by llvm::PGOInstrumentationUse::PGOInstrumentationUse().
| pgo instr Read PGO instrumentation profile |
Definition at line 264 of file PGOInstrumentation.cpp.
| pgo instr use |
Definition at line 264 of file PGOInstrumentation.cpp.
1.8.6