49#ifndef LLVM_IR_PASSINSTRUMENTATION_H
50#define LLVM_IR_PASSINSTRUMENTATION_H
63class PreservedAnalyses;
69extern template struct LLVM_TEMPLATE_ABI Any::TypeId<const Module *>;
70extern template struct LLVM_TEMPLATE_ABI Any::TypeId<const Function *>;
71extern template struct LLVM_TEMPLATE_ABI Any::TypeId<const Loop *>;
104 template <
typename CallableT>
106 ShouldRunOptionalPassCallbacks.emplace_back(std::move(
C));
109 template <
typename CallableT>
111 BeforeSkippedPassCallbacks.emplace_back(std::move(
C));
114 template <
typename CallableT>
116 BeforeNonSkippedPassCallbacks.emplace_back(std::move(
C));
119 template <
typename CallableT>
122 AfterPassCallbacks.insert(AfterPassCallbacks.begin(), std::move(
C));
124 AfterPassCallbacks.emplace_back(std::move(
C));
127 template <
typename CallableT>
130 AfterPassInvalidatedCallbacks.insert(
131 AfterPassInvalidatedCallbacks.begin(), std::move(
C));
133 AfterPassInvalidatedCallbacks.emplace_back(std::move(
C));
136 template <
typename CallableT>
138 BeforeAnalysisCallbacks.emplace_back(std::move(
C));
141 template <
typename CallableT>
144 AfterAnalysisCallbacks.insert(AfterAnalysisCallbacks.begin(),
147 AfterAnalysisCallbacks.emplace_back(std::move(
C));
150 template <
typename CallableT>
152 AnalysisInvalidatedCallbacks.emplace_back(std::move(
C));
155 template <
typename CallableT>
157 AnalysesClearedCallbacks.emplace_back(std::move(
C));
160 template <
typename CallableT>
162 ClassToPassNameCallbacks.emplace_back(std::move(
C));
176 ShouldRunOptionalPassCallbacks;
179 BeforeSkippedPassCallbacks;
182 BeforeNonSkippedPassCallbacks;
187 AfterPassInvalidatedCallbacks;
190 BeforeAnalysisCallbacks;
193 AfterAnalysisCallbacks;
196 AnalysisInvalidatedCallbacks;
199 AnalysesClearedCallbacks;
216 template <
typename PassT>
217 using has_required_t =
decltype(std::declval<PassT &>().isRequired());
219 template <
typename PassT>
220 static std::enable_if_t<is_detected<has_required_t, PassT>::value,
bool>
221 isRequired(
const PassT &
Pass) {
222 return Pass.isRequired();
224 template <
typename PassT>
225 static std::enable_if_t<!is_detected<has_required_t, PassT>::value,
bool>
226 isRequired(
const PassT &
Pass) {
243 template <
typename IRUnitT,
typename PassT>
248 bool ShouldRun =
true;
249 if (!isRequired(
Pass)) {
250 for (
auto &
C : Callbacks->ShouldRunOptionalPassCallbacks)
255 for (
auto &
C : Callbacks->BeforeNonSkippedPassCallbacks)
258 for (
auto &
C : Callbacks->BeforeSkippedPassCallbacks)
268 template <
typename IRUnitT,
typename PassT>
272 for (
auto &
C : Callbacks->AfterPassCallbacks)
279 template <
typename IRUnitT,
typename PassT>
283 for (
auto &
C : Callbacks->AfterPassInvalidatedCallbacks)
289 template <
typename IRUnitT,
typename PassT>
292 for (
auto &
C : Callbacks->BeforeAnalysisCallbacks)
298 template <
typename IRUnitT,
typename PassT>
301 for (
auto &
C : Callbacks->AfterAnalysisCallbacks)
308 template <
typename IRUnitT,
typename PassT>
311 for (
auto &
C : Callbacks->AnalysisInvalidatedCallbacks)
319 for (
auto &
C : Callbacks->AnalysesClearedCallbacks)
328 template <
typename IRUnitT,
typename... ExtraArgsT>
334 template <
typename CallableT>
337 Callbacks->BeforeNonSkippedPassCallbacks.
emplace_back(std::move(
C));
341 Callbacks->BeforeNonSkippedPassCallbacks.
pop_back();
352bool isSpecialPass(StringRef PassID,
const std::vector<StringRef> &Specials);
367 : Callbacks(Callbacks) {}
371 template <
typename IRUnitT,
typename AnalysisManagerT,
typename... ExtraArgTs>
372 Result run(IRUnitT &, AnalysisManagerT &, ExtraArgTs &&...) {
This file provides Any, a non-template class modeled in the spirit of std::any.
block Block Frequency Analysis
This file defines the DenseMap class.
This header defines various interfaces for pass management in LLVM.
Legalize the Machine IR a function s Machine IR
Machine Check Debug Module
This file defines the SmallVector class.
static const char PassName[]
Pseudo-analysis pass that exposes the PassInstrumentation to pass managers.
Result run(IRUnitT &, AnalysisManagerT &, ExtraArgTs &&...)
PassInstrumentationAnalysis(PassInstrumentationCallbacks *Callbacks=nullptr)
PassInstrumentationCallbacks object is shared, owned by something else, not this analysis.
This class provides instrumentation entry points for the Pass Manager, doing calls to callbacks regis...
void runAfterPassInvalidated(const PassT &Pass, const PreservedAnalyses &PA) const
AfterPassInvalidated instrumentation point - takes Pass instance that has just been executed.
void pushBeforeNonSkippedPassCallback(CallableT C)
PassInstrumentation(PassInstrumentationCallbacks *CB=nullptr)
Callbacks object is not owned by PassInstrumentation, its life-time should at least match the life-ti...
bool invalidate(IRUnitT &, const class llvm::PreservedAnalyses &, ExtraArgsT...)
Handle invalidation from the pass manager when PassInstrumentation is used as the result of PassInstr...
void runBeforeAnalysis(const PassT &Analysis, const IRUnitT &IR) const
BeforeAnalysis instrumentation point - takes Analysis instance to be executed and constant reference ...
void runAnalysisInvalidated(const PassT &Analysis, const IRUnitT &IR) const
AnalysisInvalidated instrumentation point - takes Analysis instance that has just been invalidated an...
void runAnalysesCleared(StringRef Name) const
AnalysesCleared instrumentation point - takes name of IR that analyses operated on.
StringRef getPassNameForClassName(StringRef ClassName) const
Get the pass name for a given pass class name.
void popBeforeNonSkippedPassCallback()
void runAfterPass(const PassT &Pass, const IRUnitT &IR, const PreservedAnalyses &PA) const
AfterPass instrumentation point - takes Pass instance that has just been executed and constant refere...
void runAfterAnalysis(const PassT &Analysis, const IRUnitT &IR) const
AfterAnalysis instrumentation point - takes Analysis instance that has just been executed and constan...
bool runBeforePass(const PassT &Pass, const IRUnitT &IR) const
BeforePass instrumentation point - takes Pass instance to be executed and constant reference to IR it...
Pass interface - Implemented by all 'passes'.
A set of analyses that are preserved following a run of a transformation pass.
reference emplace_back(ArgTypes &&... Args)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
unique_function is a type-erasing functor similar to std::function.
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.
bool isSpecialPass(StringRef PassID, const std::vector< StringRef > &Specials)
A CRTP mix-in that provides informational APIs needed for analysis passes.
A special type used by analysis passes to provide an address that identifies that particular analysis...
This class manages callbacks registration, as well as provides a way for PassInstrumentation to pass ...
void registerAnalysesClearedCallback(CallableT C)
void registerBeforeAnalysisCallback(CallableT C)
void registerAfterPassInvalidatedCallback(CallableT C, bool ToFront=false)
void registerAnalysisInvalidatedCallback(CallableT C)
StringRef getPassNameForClassName(StringRef ClassName)
Get the pass name for a given pass class name.
void registerAfterAnalysisCallback(CallableT C, bool ToFront=false)
friend class PassInstrumentation
void(StringRef, const PreservedAnalyses &) AfterPassInvalidatedFunc
void(StringRef, Any) BeforeNonSkippedPassFunc
void registerBeforeNonSkippedPassCallback(CallableT C)
void registerClassToPassNameCallback(CallableT C)
void registerBeforeSkippedPassCallback(CallableT C)
PassInstrumentationCallbacks(const PassInstrumentationCallbacks &)=delete
Copying PassInstrumentationCallbacks is not intended.
PassInstrumentationCallbacks()=default
bool(StringRef, Any) BeforePassFunc
void(StringRef) AnalysesClearedFunc
void registerShouldRunOptionalPassCallback(CallableT C)
void(StringRef, Any) BeforeSkippedPassFunc
void operator=(const PassInstrumentationCallbacks &)=delete
void(StringRef, Any) AfterAnalysisFunc
void(StringRef, Any) BeforeAnalysisFunc
void(StringRef, Any) AnalysisInvalidatedFunc
void(StringRef, Any, const PreservedAnalyses &) AfterPassFunc
void registerAfterPassCallback(CallableT C, bool ToFront=false)