49#ifndef LLVM_IR_PASSINSTRUMENTATION_H
50#define LLVM_IR_PASSINSTRUMENTATION_H
62class PreservedAnalyses;
96 template <
typename CallableT>
101 template <
typename CallableT>
106 template <
typename CallableT>
111 template <
typename CallableT>
114 AfterPassCallbacks.
insert(AfterPassCallbacks.
begin(), std::move(
C));
119 template <
typename CallableT>
122 AfterPassInvalidatedCallbacks.
insert(
123 AfterPassInvalidatedCallbacks.
begin(), std::move(
C));
128 template <
typename CallableT>
133 template <
typename CallableT>
136 AfterAnalysisCallbacks.
insert(AfterAnalysisCallbacks.
begin(),
142 template <
typename CallableT>
147 template <
typename CallableT>
152 template <
typename CallableT>
168 ShouldRunOptionalPassCallbacks;
171 BeforeSkippedPassCallbacks;
174 BeforeNonSkippedPassCallbacks;
179 AfterPassInvalidatedCallbacks;
182 BeforeAnalysisCallbacks;
185 AfterAnalysisCallbacks;
188 AnalysisInvalidatedCallbacks;
191 AnalysesClearedCallbacks;
208 template <
typename PassT>
209 using has_required_t =
decltype(std::declval<PassT &>().isRequired());
211 template <
typename PassT>
212 static std::enable_if_t<is_detected<has_required_t, PassT>::value,
bool>
213 isRequired(
const PassT &
Pass) {
214 return Pass.isRequired();
216 template <
typename PassT>
217 static std::enable_if_t<!is_detected<has_required_t, PassT>::value,
bool>
218 isRequired(
const PassT &
Pass) {
235 template <
typename IRUnitT,
typename PassT>
240 bool ShouldRun =
true;
241 if (!isRequired(
Pass)) {
242 for (
auto &
C : Callbacks->ShouldRunOptionalPassCallbacks)
247 for (
auto &
C : Callbacks->BeforeNonSkippedPassCallbacks)
250 for (
auto &
C : Callbacks->BeforeSkippedPassCallbacks)
260 template <
typename IRUnitT,
typename PassT>
264 for (
auto &
C : Callbacks->AfterPassCallbacks)
271 template <
typename IRUnitT,
typename PassT>
275 for (
auto &
C : Callbacks->AfterPassInvalidatedCallbacks)
281 template <
typename IRUnitT,
typename PassT>
284 for (
auto &
C : Callbacks->BeforeAnalysisCallbacks)
290 template <
typename IRUnitT,
typename PassT>
293 for (
auto &
C : Callbacks->AfterAnalysisCallbacks)
300 template <
typename IRUnitT,
typename PassT>
303 for (
auto &
C : Callbacks->AnalysisInvalidatedCallbacks)
311 for (
auto &
C : Callbacks->AnalysesClearedCallbacks)
320 template <
typename IRUnitT,
typename... ExtraArgsT>
326 template <
typename CallableT>
329 Callbacks->BeforeNonSkippedPassCallbacks.
emplace_back(std::move(
C));
333 Callbacks->BeforeNonSkippedPassCallbacks.
pop_back();
344bool isSpecialPass(StringRef PassID,
const std::vector<StringRef> &Specials);
359 : Callbacks(Callbacks) {}
363 template <
typename IRUnitT,
typename AnalysisManagerT,
typename... ExtraArgTs>
364 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.
Legalize the Machine IR a function s Machine IR
This header defines various interfaces for pass management in LLVM.
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 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)
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 addClassToPassName(StringRef ClassName, StringRef PassName)
Add a class name to pass name mapping for use by pass instrumentation.
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)
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)
iterator insert(iterator I, T &&Elt)
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...