#include "llvm/Analysis/CtxProfAnalysis.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/IR/Analysis.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/PassManager.h"
#include "llvm/ProfileData/PGOCtxProfReader.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/JSON.h"
#include "llvm/Support/MemoryBuffer.h"
#define DEBUG_TYPE …
usingnamespacellvm;
cl::opt<std::string>
UseCtxProfile("use-ctx-profile", cl::init(""), cl::Hidden,
cl::desc("Use the specified contextual profile file"));
static cl::opt<CtxProfAnalysisPrinterPass::PrintMode> PrintLevel(
"ctx-profile-printer-level",
cl::init(CtxProfAnalysisPrinterPass::PrintMode::JSON), cl::Hidden,
cl::values(clEnumValN(CtxProfAnalysisPrinterPass::PrintMode::Everything,
"everything", "print everything - most verbose"),
clEnumValN(CtxProfAnalysisPrinterPass::PrintMode::JSON, "json",
"just the json representation of the profile")),
cl::desc("Verbosity level of the contextual profile printer pass."));
namespace llvm {
namespace json {
Value toJSON(const PGOCtxProfContext &P) { … }
Value toJSON(const PGOCtxProfContext::CallTargetMapTy &P) { … }
}
}
const char *AssignGUIDPass::GUIDMetadataName = …;
PreservedAnalyses AssignGUIDPass::run(Module &M, ModuleAnalysisManager &MAM) { … }
GlobalValue::GUID AssignGUIDPass::getGUID(const Function &F) { … }
AnalysisKey CtxProfAnalysis::Key;
CtxProfAnalysis::CtxProfAnalysis(std::optional<StringRef> Profile)
: … { … }
PGOContextualProfile CtxProfAnalysis::run(Module &M,
ModuleAnalysisManager &MAM) { … }
GlobalValue::GUID
PGOContextualProfile::getDefinedFunctionGUID(const Function &F) const { … }
CtxProfAnalysisPrinterPass::CtxProfAnalysisPrinterPass(raw_ostream &OS)
: … { … }
PreservedAnalyses CtxProfAnalysisPrinterPass::run(Module &M,
ModuleAnalysisManager &MAM) { … }
InstrProfCallsite *CtxProfAnalysis::getCallsiteInstrumentation(CallBase &CB) { … }
InstrProfIncrementInst *CtxProfAnalysis::getBBInstrumentation(BasicBlock &BB) { … }
InstrProfIncrementInstStep *
CtxProfAnalysis::getSelectInstrumentation(SelectInst &SI) { … }
template <class ProfilesTy, class ProfTy>
static void preorderVisit(ProfilesTy &Profiles,
function_ref<void(ProfTy &)> Visitor) { … }
void PGOContextualProfile::initIndex() { … }
void PGOContextualProfile::update(Visitor V, const Function &F) { … }
void PGOContextualProfile::visit(ConstVisitor V, const Function *F) const { … }
const CtxProfFlatProfile PGOContextualProfile::flatten() const { … }
void CtxProfAnalysis::collectIndirectCallPromotionList(
CallBase &IC, Result &Profile,
SetVector<std::pair<CallBase *, Function *>> &Candidates) { … }