24#define DEBUG_TYPE "ctx_prof"
29 cl::desc(
"Use the specified contextual profile file"));
35 Ret[
"Guid"] =
P.guid();
36 Ret[
"Counters"] =
Array(
P.counters());
37 if (
P.callsites().empty())
42 assert(MaxIt != AllCS.end() &&
"We should have a max value because the "
43 "callsites collection is not empty.");
46 for (
auto I = 0U, Max = *MaxIt;
I <= Max; ++
I) {
50 for (
const auto &[
_, Ctx] :
P.callsite(
I))
53 Ret[
"Callsites"] = std::move(CSites);
60 for (
const auto &[
_, Ctx] :
P)
61 Ret.push_back(
toJSON(Ctx));
73 M.getContext().emitError(
"could not open contextual profile file: " +
80 M.getContext().emitError(
"contextual profile file is invalid: " +
84 return Result(std::move(*MaybeCtx));
91 M.getContext().emitError(
"Invalid CtxProfAnalysis");
cl::opt< std::string > UseCtxProfile("use-ctx-profile", cl::init(""), cl::Hidden, cl::desc("Use the specified contextual profile file"))
This file supports working with JSON data.
Module.h This file contains the declarations for the Module class.
Reader for contextual iFDO profile, which comes in bitstream format.
ModuleAnalysisManager MAM
This header defines various interfaces for pass management in LLVM.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
A container for analyses that lazily runs them and caches their results.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM)
PGOContextualProfile run(Module &M, ModuleAnalysisManager &MAM)
PGOContextualProfile Result
Represents either an error or a value T.
std::error_code getError() const
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFile(const Twine &Filename, bool IsText=false, bool RequiresNullTerminator=true, bool IsVolatile=false, std::optional< Align > Alignment=std::nullopt)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful,...
A Module instance is used to store all the information related to an LLVM module.
The instrumented contextual profile, produced by the CtxProfAnalysis.
A node (context) in the loaded contextual profile, suitable for mutation during IPO passes.
std::map< GlobalValue::GUID, PGOCtxProfContext > CallTargetMapTy
Expected< std::map< GlobalValue::GUID, PGOCtxProfContext > > loadContexts()
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
An Array is a JSON array, which contains heterogeneous JSON values.
void push_back(const Value &E)
An Object is a JSON object, which maps strings to heterogenous JSON values.
A Value is an JSON value of unknown type.
const json::Array * getAsArray() const
Pass manager infrastructure for declaring and invalidating analyses.
@ C
The default llvm calling convention, compatible with C.
initializer< Ty > init(const Ty &Val)
std::optional< const char * > toString(const std::optional< DWARFFormValue > &V)
Take an optional DWARFFormValue and try to extract a string value from it.
Value toJSON(const std::optional< T > &Opt)
This is an optimization pass for GlobalISel generic memory operations.
auto formatv(const char *Fmt, Ts &&...Vals) -> formatv_object< decltype(std::make_tuple(support::detail::build_format_adapter(std::forward< Ts >(Vals))...))>
auto map_range(ContainerTy &&C, FuncTy F)
auto max_element(R &&Range)
A special type used by analysis passes to provide an address that identifies that particular analysis...