Lines Matching full:pass
1 //===- LegacyPassManagers.h - Legacy Pass Infrastructure --------*- C++ -*-===//
9 // This file declares the LLVM Pass Manager infrastructure.
20 #include "llvm/Pass.h"
25 // The Pass Manager Infrastructure manages passes. It's responsibilities are:
27 // o Manage optimization pass execution order
28 // o Make required Analysis information available before pass P is run
30 // o If Analysis information is dirtied by a pass then regenerate Analysis
31 // information before it is consumed by another pass.
33 // Pass Manager Infrastructure uses multiple pass managers. They are
35 // This class hierarchy uses multiple inheritance but pass managers do not
36 // derive from another pass manager.
38 // PassManager and FunctionPassManager are two top-level pass manager that
39 // represents the external interface of this entire pass manager infrastucture.
52 // used by a pass manager to manage execution order of passes. It also provides
53 // a place to implement common pass manager APIs. All pass managers derive from
70 // [o] class MPPassManager : public Pass, public PMDataManager;
79 // [o] class PassManagerImpl : public Pass, public PMDataManager,
82 // PassManagerImpl is a top level pass manager responsible for managing
97 EXECUTION_MSG, // "Executing Pass '" + PassName
99 FREEING_MSG, // " Freeing Pass '" + PassName
108 /// about what pass is running when/if a stack trace is generated.
110 Pass *P;
115 explicit PassManagerPrettyStackEntry(Pass *p) in PassManagerPrettyStackEntry()
117 PassManagerPrettyStackEntry(Pass *p, Value &v) in PassManagerPrettyStackEntry()
119 PassManagerPrettyStackEntry(Pass *p, Module &m) in PassManagerPrettyStackEntry()
132 /// Top level pass managers (see PassManager.cpp) maintain active Pass Managers
133 /// using PMStack. Each Pass implements assignPassManager() to connect itself
157 /// top level pass managers.
173 /// Schedule pass P for execution. Make sure that passes required by
176 void schedulePass(Pass *P);
178 /// Set pass P as the last user of the given analysis passes.
179 void setLastUser(ArrayRef<Pass*> AnalysisPasses, Pass *P);
182 void collectLastUses(SmallVectorImpl<Pass *> &LastUses, Pass *P);
184 /// Find the pass that implements Analysis AID. Search immutable
185 /// passes and all pass managers. If desired pass is not found
187 Pass *findAnalysisPass(AnalysisID AID);
192 /// Find analysis usage information for the pass P.
193 AnalysisUsage *findAnalysisUsage(Pass *P);
197 /// Add immutable pass and initialize it.
209 // maintained by this top level pass manager
218 // Active Pass Managers
222 /// Collection of pass managers
226 /// Collection of pass managers that are not directly maintained
227 /// by this pass manager
230 // Map to keep track of last user of the analysis pass.
233 DenseMap<Pass *, Pass *> LastUser;
235 // Map to keep track of passes that are last used by a pass.
237 DenseMap<Pass *, SmallPtrSet<Pass *, 8> > InversedLastUser;
271 // when we have multiple instances of the same pass since they'll usually
279 // Maps from a pass to it's associated entry in UniqueAnalysisUsages. Does
281 DenseMap<Pass *, AnalysisUsage*> AnUsageMap;
284 /// level manager. This is used to memoize queries to the pass registry.
285 /// FIXME: This is an egregious hack because querying the pass registry is
294 /// used by pass managers.
301 virtual Pass *getAsPass() = 0;
303 /// Augment AvailableAnalysis by adding analysis made available by pass P.
304 void recordAvailableAnalysis(Pass *P);
306 /// verifyPreservedAnalysis -- Verify analysis presreved by pass P.
307 void verifyPreservedAnalysis(Pass *P);
309 /// Remove Analysis that is not preserved by the pass
310 void removeNotPreservedAnalysis(Pass *P);
313 void removeDeadPasses(Pass *P, StringRef Msg,
317 void freePass(Pass *P, StringRef Msg,
320 /// Add pass P into the PassVector. Update
322 void add(Pass *P, bool ProcessAnalysis = true);
324 /// Add RequiredPass into list of lower level passes required by pass P.
325 /// RequiredPass is run on the fly by Pass Manager when P requests it
327 virtual void addLowerLevelRequiredPass(Pass *P, Pass *RequiredPass);
329 virtual std::tuple<Pass *, bool> getOnTheFlyPass(Pass *P, AnalysisID PI,
341 bool preserveHigherLevelAnalysis(Pass *P);
343 /// Populate UsedPasses with analysis pass that are used or required by pass
344 /// P and are available. Populate ReqPassNotAvailable with analysis pass that
345 /// are required by pass P but are not available.
347 SmallVectorImpl<Pass *> &UsedPasses,
348 SmallVectorImpl<AnalysisID> &ReqPassNotAvailable, Pass *P);
350 /// All Required analyses should be available to the pass as it runs! Here
351 /// we fill in the AnalysisImpls member of the pass so that it can
354 void initializeAnalysisImpl(Pass *P);
356 /// Find the pass that implements Analysis AID. If desired pass is not found
358 Pass *findAnalysisPass(AnalysisID AID, bool Direction);
367 // Print routines used by debug-pass
368 void dumpLastUses(Pass *P, unsigned Offset) const;
370 void dumpPassInfo(Pass *P, enum PassDebuggingString S1,
372 void dumpRequiredSet(const Pass *P) const;
373 void dumpPreservedSet(const Pass *P) const;
374 void dumpUsedSet(const Pass *P) const;
385 DenseMap<AnalysisID, Pass*> *getAvailableAnalysis() { in getAvailableAnalysis()
389 // Collect AvailableAnalysis from all the active Pass Managers.
413 Pass *P, Module &M, int64_t Delta, unsigned CountBefore,
421 // Collection of pass that are managed by this manager
422 SmallVector<Pass *, 16> PassVector;
424 // Collection of Analysis provided by Parent pass manager and
425 // used by current pass manager. At any time there can not be more
426 // then PMT_Last active pass managers.
427 DenseMap<AnalysisID, Pass *> *InheritedAnalysis[PMT_Last];
429 /// isPassDebuggingExecutionsOrMore - Return true if -debug-pass=Executions
434 void dumpAnalysisUsage(StringRef Msg, const Pass *P,
438 // pass. If a pass requires an analysis which is not available then
439 // the required analysis pass is scheduled to run before the pass itself is
441 DenseMap<AnalysisID, Pass*> AvailableAnalysis;
443 // Collection of higher level analysis used by the pass managed by
445 SmallVector<Pass *, 16> HigherLevelAnalysis;
454 /// It batches all function passes and basic block pass managers together and
467 /// cleanup - After running all passes, clean up pass manager cache.
489 Pass *getAsPass() override { return this; } in getAsPass()
491 /// Pass Manager itself does not invalidate any analysis info.
499 StringRef getPassName() const override { return "Function Pass Manager"; } in getPassName()
502 assert ( N < PassVector.size() && "Pass number out of range!"); in getContainedPass()