LLVM 20.0.0git
CtxProfAnalysis.h
Go to the documentation of this file.
1//===- CtxProfAnalysis.h - maintain contextual profile info -*- C++ ---*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9#ifndef LLVM_ANALYSIS_CTXPROFANALYSIS_H
10#define LLVM_ANALYSIS_CTXPROFANALYSIS_H
11
12#include "llvm/IR/GlobalValue.h"
13#include "llvm/IR/PassManager.h"
15#include <map>
16
17namespace llvm {
18
19class CtxProfAnalysis;
20
21/// The instrumented contextual profile, produced by the CtxProfAnalysis.
23 std::optional<PGOCtxProfContext::CallTargetMapTy> Profiles;
24
25public:
27 : Profiles(std::move(Profiles)) {}
31
32 operator bool() const { return Profiles.has_value(); }
33
35 return *Profiles;
36 }
37
40 // Check whether the analysis has been explicitly invalidated. Otherwise,
41 // it's stateless and remains preserved.
42 auto PAC = PA.getChecker<CtxProfAnalysis>();
43 return !PAC.preservedWhenStateless();
44 }
45};
46
47class CtxProfAnalysis : public AnalysisInfoMixin<CtxProfAnalysis> {
48 StringRef Profile;
49
50public:
52 explicit CtxProfAnalysis(StringRef Profile) : Profile(Profile) {};
53
55
57};
58
60 : public PassInfoMixin<CtxProfAnalysisPrinterPass> {
61 raw_ostream &OS;
62
63public:
65
67 static bool isRequired() { return true; }
68};
69} // namespace llvm
70#endif // LLVM_ANALYSIS_CTXPROFANALYSIS_H
Load MIR Sample Profile
Reader for contextual iFDO profile, which comes in bitstream format.
ModuleAnalysisManager MAM
This header defines various interfaces for pass management in LLVM.
raw_pwrite_stream & OS
API to communicate dependencies between analyses during invalidation.
Definition: PassManager.h:292
A container for analyses that lazily runs them and caches their results.
Definition: PassManager.h:253
PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM)
CtxProfAnalysisPrinterPass(raw_ostream &OS)
PGOContextualProfile run(Module &M, ModuleAnalysisManager &MAM)
CtxProfAnalysis(StringRef Profile)
static AnalysisKey Key
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
The instrumented contextual profile, produced by the CtxProfAnalysis.
PGOContextualProfile(PGOContextualProfile &&)=default
const PGOCtxProfContext::CallTargetMapTy & profiles() const
bool invalidate(Module &, const PreservedAnalyses &PA, ModuleAnalysisManager::Invalidator &)
PGOContextualProfile(const PGOContextualProfile &)=delete
PGOContextualProfile(PGOCtxProfContext::CallTargetMapTy &&Profiles)
std::map< GlobalValue::GUID, PGOCtxProfContext > CallTargetMapTy
A set of analyses that are preserved following a run of a transformation pass.
Definition: Analysis.h:111
PreservedAnalysisChecker getChecker() const
Build a checker for this PreservedAnalyses and the specified analysis type.
Definition: Analysis.h:264
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1849
Implement std::hash so that hash_code can be used in STL containers.
Definition: BitVector.h:858
A CRTP mix-in that provides informational APIs needed for analysis passes.
Definition: PassManager.h:92
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition: Analysis.h:28
A CRTP mix-in to automatically provide informational APIs needed for passes.
Definition: PassManager.h:69