62 virtual bool run(
T Arg) = 0;
73 virtual bool run(
T Arg) {
return Pass.run(Arg); }
85 template <
typename ModulePassT>
void addPass(ModulePassT
Pass) {
86 Passes.push_back(
new ModulePassModel<ModulePassT>(
llvm_move(Pass)));
94 template <
typename PassT>
96 ModulePassModel(PassT
Pass) : detail::PassModel<
Module *, PassT>(Pass) {}
101 std::vector<polymorphic_ptr<ModulePassConcept> > Passes;
108 template <
typename FunctionPassT>
void addPass(FunctionPassT
Pass) {
109 Passes.push_back(
new FunctionPassModel<FunctionPassT>(
llvm_move(Pass)));
117 template <
typename PassT>
119 FunctionPassModel(PassT
Pass)
120 : detail::PassModel<
Function *, PassT>(Pass) {}
124 std::vector<polymorphic_ptr<FunctionPassConcept> > Passes;
152 template <
typename PassT>
155 "This analysis pass was not registered prior to being queried");
157 const AnalysisResultConcept<Module> &ResultConcept =
159 typedef AnalysisResultModel<Module, typename PassT::Result> ResultModelT;
160 return static_cast<const ResultModelT &
>(ResultConcept).Result;
167 template <
typename PassT>
170 "This analysis pass was not registered prior to being queried");
172 const AnalysisResultConcept<Function> &ResultConcept =
174 typedef AnalysisResultModel<Function, typename PassT::Result> ResultModelT;
175 return static_cast<const ResultModelT &
>(ResultConcept).Result;
186 registerAnalysisPassImpl<PassT>(
llvm_move(Pass));
223 template <
typename IRUnitT>
struct AnalysisResultConcept {
224 virtual ~AnalysisResultConcept() {}
225 virtual AnalysisResultConcept *clone() = 0;
240 template <
typename IRUnitT,
typename ResultT>
241 struct AnalysisResultModel : AnalysisResultConcept<IRUnitT> {
242 AnalysisResultModel(ResultT Result) : Result(
llvm_move(Result)) {}
243 virtual AnalysisResultModel *clone() {
244 return new AnalysisResultModel(Result);
248 virtual bool invalidate(IRUnitT *
IR) {
return Result.invalidate(IR); }
257 template <
typename IRUnitT>
struct AnalysisPassConcept {
258 virtual ~AnalysisPassConcept() {}
259 virtual AnalysisPassConcept *clone() = 0;
264 virtual AnalysisResultConcept<IRUnitT> *run(IRUnitT *
IR) = 0;
272 template <
typename PassT>
273 struct AnalysisPassModel : AnalysisPassConcept<typename PassT::IRUnitT> {
274 AnalysisPassModel(PassT Pass) : Pass(
llvm_move(Pass)) {}
275 virtual AnalysisPassModel *clone() {
return new AnalysisPassModel(Pass); }
278 typedef typename PassT::IRUnitT IRUnitT;
281 typedef AnalysisResultModel<IRUnitT, typename PassT::Result> ResultModelT;
286 virtual ResultModelT *run(IRUnitT *
IR) {
287 return new ResultModelT(Pass.run(IR));
295 const AnalysisResultConcept<Module> &getResultImpl(
void *PassID, Module *M);
298 const AnalysisResultConcept<Function> &getResultImpl(
void *PassID,
302 void invalidateImpl(
void *PassID, Module *M);
305 void invalidateImpl(
void *PassID, Function *
F);
309 template <
typename PassT>
310 typename enable_if<is_same<typename PassT::IRUnitT, Module> >::type
311 registerAnalysisPassImpl(PassT Pass) {
313 "Registered the same analysis pass twice!");
315 new AnalysisPassModel<PassT>(
llvm_move(Pass));
319 template <
typename PassT>
320 typename enable_if<is_same<typename PassT::IRUnitT, Function> >::type
321 registerAnalysisPassImpl(PassT Pass) {
323 "Registered the same analysis pass twice!");
325 new AnalysisPassModel<PassT>(
llvm_move(Pass));
330 typedef DenseMap<void *, polymorphic_ptr<AnalysisPassConcept<Module> > >
331 ModuleAnalysisPassMapT;
334 ModuleAnalysisPassMapT ModuleAnalysisPasses;
337 typedef DenseMap<void *, polymorphic_ptr<AnalysisResultConcept<Module> > >
338 ModuleAnalysisResultMapT;
341 ModuleAnalysisResultMapT ModuleAnalysisResults;
345 typedef DenseMap<void *, polymorphic_ptr<AnalysisPassConcept<Function> > >
346 FunctionAnalysisPassMapT;
349 FunctionAnalysisPassMapT FunctionAnalysisPasses;
357 std::pair<void *, polymorphic_ptr<AnalysisResultConcept<Function> > > >
358 FunctionAnalysisResultListT;
361 typedef DenseMap<Function *, FunctionAnalysisResultListT> FunctionAnalysisResultListMapT;
367 FunctionAnalysisResultListMapT FunctionAnalysisResultLists;
371 typedef DenseMap<std::pair<void *, Function *>,
372 FunctionAnalysisResultListT::iterator>
373 FunctionAnalysisResultMapT;
377 FunctionAnalysisResultMapT FunctionAnalysisResults;
void addPass(ModulePassT Pass)
The main container class for the LLVM Intermediate Representation.
const PassT::Result & getResult(Module *M)
Get the result of an analysis pass for this module.
Template for the abstract base class used to dispatch polymorphically over pass objects.
virtual bool run(T Arg)
The polymorphic API which runs the pass over a given IR entity.
void registerAnalysisPass(PassT Pass)
Register an analysis pass with the manager.
ID
LLVM Calling Convention Representation.
AnalysisManager(Module *M)
virtual PassModel * clone()
bool count(const KeyT &Val) const
count - Return true if the specified key is in the map.
ModulePassManager(Module *M, AnalysisManager *AM=0)
void invalidateAll(Module *M)
Invalidate analyses cached for an IR Module.
void invalidate(Module *M)
Invalidate a specific analysis pass for an IR module.
A template wrapper used to implement the polymorphic API.
FunctionPassManager(AnalysisManager *AM=0)
virtual PassConcept * clone()=0
void addPass(FunctionPassT Pass)
const PassT::Result & getResult(Function *F)
Get the result of an analysis pass for a function.
void invalidate(Function *F)
Invalidate a specific analysis pass for an IR function.
An analysis manager to coordinate and cache analyses run over a module.
Statically lint checks LLVM IR
virtual bool run(T Arg)=0
The polymorphic API which runs the pass over a given IR entity.