#include "llvm/Transforms/Instrumentation/PGOCtxProfLowering.h"
#include "llvm/Analysis/CtxProfAnalysis.h"
#include "llvm/Analysis/OptimizationRemarkEmitter.h"
#include "llvm/IR/Analysis.h"
#include "llvm/IR/DiagnosticInfo.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/PassManager.h"
#include "llvm/ProfileData/InstrProf.h"
#include "llvm/Support/CommandLine.h"
#include <utility>
usingnamespacellvm;
#define DEBUG_TYPE …
static cl::list<std::string> ContextRoots(
"profile-context-root", cl::Hidden,
cl::desc(
"A function name, assumed to be global, which will be treated as the "
"root of an interesting graph, which will be profiled independently "
"from other similar graphs."));
bool PGOCtxProfLoweringPass::isCtxIRPGOInstrEnabled() { … }
namespace CompilerRtAPINames {
static auto StartCtx = …;
static auto ReleaseCtx = …;
static auto GetCtx = …;
static auto ExpectedCalleeTLS = …;
static auto CallsiteTLS = …;
}
namespace {
class CtxInstrumentationLowerer final { … };
std::pair<uint32_t, uint32_t> getNumCountersAndCallsites(const Function &F) { … }
}
CtxInstrumentationLowerer::CtxInstrumentationLowerer(Module &M,
ModuleAnalysisManager &MAM)
: … { … }
PreservedAnalyses PGOCtxProfLoweringPass::run(Module &M,
ModuleAnalysisManager &MAM) { … }
bool CtxInstrumentationLowerer::lowerFunction(Function &F) { … }