Lines Matching full:pass
1 //===- LegacyPassManagers.h - Legacy Pass Infrastructure --------*- C++ -*-===//
10 // This file declares the LLVM Pass Manager infrastructure.
21 #include "llvm/Pass.h"
27 // The Pass Manager Infrastructure manages passes. It's responsibilities are:
29 // o Manage optimization pass execution order
30 // o Make required Analysis information available before pass P is run
32 // o If Analysis information is dirtied by a pass then regenerate Analysis
33 // information before it is consumed by another pass.
35 // Pass Manager Infrastructure uses multiple pass managers. They are
37 // This class hierarchy uses multiple inheritance but pass managers do not
38 // derive from another pass manager.
40 // PassManager and FunctionPassManager are two top-level pass manager that
41 // represents the external interface of this entire pass manager infrastucture.
54 // used by a pass manager to manage execution order of passes. It also provides
55 // a place to implement common pass manager APIs. All pass managers derive from
76 // [o] class MPPassManager : public Pass, public PMDataManager;
85 // [o] class PassManagerImpl : public Pass, public PMDataManager,
88 // PassManagerImpl is a top level pass manager responsible for managing
96 class Pass;
104 EXECUTION_MSG, // "Executing Pass '" + PassName
106 FREEING_MSG, // " Freeing Pass '" + PassName
116 /// about what pass is running when/if a stack trace is generated.
118 Pass *P;
122 explicit PassManagerPrettyStackEntry(Pass *p)
124 PassManagerPrettyStackEntry(Pass *p, Value &v)
126 PassManagerPrettyStackEntry(Pass *p, Module &m)
140 /// Top level pass managers (see PassManager.cpp) maintain active Pass Managers
141 /// using PMStack. Each Pass implements assignPassManager() to connect itself
166 /// top level pass managers.
182 /// Schedule pass P for execution. Make sure that passes required by
185 void schedulePass(Pass *P);
187 /// Set pass P as the last user of the given analysis passes.
188 void setLastUser(ArrayRef<Pass*> AnalysisPasses, Pass *P);
191 void collectLastUses(SmallVectorImpl<Pass *> &LastUses, Pass *P);
193 /// Find the pass that implements Analysis AID. Search immutable
194 /// passes and all pass managers. If desired pass is not found
196 Pass *findAnalysisPass(AnalysisID AID);
201 /// Find analysis usage information for the pass P.
202 AnalysisUsage *findAnalysisUsage(Pass *P);
206 /// Add immutable pass and initialize it.
221 // maintained by this top level pass manager
230 // Active Pass Managers
235 /// Collection of pass managers
240 /// Collection of pass managers that are not directly maintained
241 /// by this pass manager
244 // Map to keep track of last user of the analysis pass.
246 DenseMap<Pass *, Pass *> LastUser;
248 // Map to keep track of passes that are last used by a pass.
251 DenseMap<Pass *, SmallPtrSet<Pass *, 8> > InversedLastUser;
256 DenseMap<Pass *, AnalysisUsage *> AnUsageMap;
259 /// level manager. This is used to memoize queries to the pass registry.
260 /// FIXME: This is an egregious hack because querying the pass registry is
271 /// used by pass managers.
281 virtual Pass *getAsPass() = 0;
283 /// Augment AvailableAnalysis by adding analysis made available by pass P.
284 void recordAvailableAnalysis(Pass *P);
286 /// verifyPreservedAnalysis -- Verify analysis presreved by pass P.
287 void verifyPreservedAnalysis(Pass *P);
289 /// Remove Analysis that is not preserved by the pass
290 void removeNotPreservedAnalysis(Pass *P);
293 void removeDeadPasses(Pass *P, StringRef Msg,
297 void freePass(Pass *P, StringRef Msg,
300 /// Add pass P into the PassVector. Update
302 void add(Pass *P, bool ProcessAnalysis = true);
304 /// Add RequiredPass into list of lower level passes required by pass P.
305 /// RequiredPass is run on the fly by Pass Manager when P requests it
307 virtual void addLowerLevelRequiredPass(Pass *P, Pass *RequiredPass);
309 virtual Pass *getOnTheFlyPass(Pass *P, AnalysisID PI, Function &F);
320 bool preserveHigherLevelAnalysis(Pass *P);
323 /// Populate RequiredPasses with analysis pass that are required by
324 /// pass P and are available. Populate ReqPassNotAvailable with analysis
325 /// pass that are required by pass P but are not available.
326 void collectRequiredAnalysis(SmallVectorImpl<Pass *> &RequiredPasses,
328 Pass *P);
330 /// All Required analyses should be available to the pass as it runs! Here
331 /// we fill in the AnalysisImpls member of the pass so that it can
334 void initializeAnalysisImpl(Pass *P);
336 /// Find the pass that implements Analysis AID. If desired pass is not found
338 Pass *findAnalysisPass(AnalysisID AID, bool Direction);
347 // Print routines used by debug-pass
348 void dumpLastUses(Pass *P, unsigned Offset) const;
350 void dumpPassInfo(Pass *P, enum PassDebuggingString S1,
352 void dumpRequiredSet(const Pass *P) const;
353 void dumpPreservedSet(const Pass *P) const;
364 DenseMap<AnalysisID, Pass*> *getAvailableAnalysis() {
368 // Collect AvailableAnalysis from all the active Pass Managers.
381 // Collection of pass that are managed by this manager
382 SmallVector<Pass *, 16> PassVector;
384 // Collection of Analysis provided by Parent pass manager and
385 // used by current pass manager. At at time there can not be more
386 // then PMT_Last active pass mangers.
387 DenseMap<AnalysisID, Pass *> *InheritedAnalysis[PMT_Last];
389 /// isPassDebuggingExecutionsOrMore - Return true if -debug-pass=Executions
394 void dumpAnalysisUsage(StringRef Msg, const Pass *P,
398 // pass. If a pass requires an analysis which is not available then
399 // the required analysis pass is scheduled to run before the pass itself is
401 DenseMap<AnalysisID, Pass*> AvailableAnalysis;
403 // Collection of higher level analysis used by the pass managed by
405 SmallVector<Pass *, 16> HigherLevelAnalysis;
414 /// It batches all function passes and basic block pass managers together and
428 /// cleanup - After running all passes, clean up pass manager cache.
450 Pass *getAsPass() override { return this; }
452 /// Pass Manager itself does not invalidate any analysis info.
461 return "Function Pass Manager";
465 assert ( N < PassVector.size() && "Pass number out of range!");
475 Timer *getPassTimer(Pass *);