llvm.org GIT mirror llvm / 19c51a9
whitespace git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149479 91177308-0d34-0410-b5e6-96231b3b80d8 Andrew Trick 7 years ago
2 changed file(s) with 41 addition(s) and 41 deletion(s). Raw diff Collapse all Expand all
5252 /// will be destroyed as well, so there is no need to delete the pass. This
5353 /// implies that all passes MUST be allocated with 'new'.
5454 void add(Pass *P);
55
55
5656 /// run - Execute all of the passes scheduled for execution. Keep track of
5757 /// whether any of the passes modifies the module, and if so, return true.
5858 bool run(Module &M);
6262 /// checking whether to add a printer pass.
6363 void addImpl(Pass *P);
6464
65 /// PassManagerImpl_New is the actual class. PassManager is just the
65 /// PassManagerImpl_New is the actual class. PassManager is just the
6666 /// wraper to publish simple pass manager interface
6767 PassManagerImpl *PM;
6868 };
7474 /// but does not take ownership of, the specified Module.
7575 explicit FunctionPassManager(Module *M);
7676 ~FunctionPassManager();
77
77
7878 /// add - Add a pass to the queue of passes to run. This passes
7979 /// ownership of the Pass to the PassManager. When the
8080 /// PassManager_X is destroyed, the pass will be destroyed as well, so
8787 /// so, return true.
8888 ///
8989 bool run(Function &F);
90
90
9191 /// doInitialization - Run all of the initializers for the function passes.
9292 ///
9393 bool doInitialization();
94
94
9595 /// doFinalization - Run all of the finalizers for the function passes.
9696 ///
9797 bool doFinalization();
98
98
9999 private:
100100 /// addImpl - Add a pass to the queue of passes to run, without
101101 /// checking whether to add a printer pass.
66 //
77 //===----------------------------------------------------------------------===//
88 //
9 // This file declares the LLVM Pass Manager infrastructure.
9 // This file declares the LLVM Pass Manager infrastructure.
1010 //
1111 //===----------------------------------------------------------------------===//
1212
2323 //===----------------------------------------------------------------------===//
2424 // Overview:
2525 // The Pass Manager Infrastructure manages passes. It's responsibilities are:
26 //
26 //
2727 // o Manage optimization pass execution order
2828 // o Make required Analysis information available before pass P is run
2929 // o Release memory occupied by dead passes
30 // o If Analysis information is dirtied by a pass then regenerate Analysis
30 // o If Analysis information is dirtied by a pass then regenerate Analysis
3131 // information before it is consumed by another pass.
3232 //
3333 // Pass Manager Infrastructure uses multiple pass managers. They are
4242 //
4343 // [o] class PMTopLevelManager;
4444 //
45 // Two top level managers, PassManager and FunctionPassManager, derive from
46 // PMTopLevelManager. PMTopLevelManager manages information used by top level
45 // Two top level managers, PassManager and FunctionPassManager, derive from
46 // PMTopLevelManager. PMTopLevelManager manages information used by top level
4747 // managers such as last user info.
4848 //
4949 // [o] class PMDataManager;
5050 //
51 // PMDataManager manages information, e.g. list of available analysis info,
51 // PMDataManager manages information, e.g. list of available analysis info,
5252 // used by a pass manager to manage execution order of passes. It also provides
5353 // a place to implement common pass manager APIs. All pass managers derive from
5454 // PMDataManager.
108108 ON_REGION_MSG, // " 'on Region ...\n'"
109109 ON_LOOP_MSG, // " 'on Loop ...\n'"
110110 ON_CG_MSG // "' on Call Graph ...\n'"
111 };
111 };
112112
113113 /// PassManagerPrettyStackEntry - This is used to print informative information
114114 /// about what pass is running when/if a stack trace is generated.
123123 : P(p), V(&v), M(0) {} // When P is run on V
124124 PassManagerPrettyStackEntry(Pass *p, Module &m)
125125 : P(p), V(0), M(&m) {} // When P is run on M
126
126
127127 /// print - Emit information about this stack frame to OS.
128128 virtual void print(raw_ostream &OS) const;
129129 };
130
131
130
131
132132 //===----------------------------------------------------------------------===//
133133 // PMStack
134134 //
135135 /// PMStack - This class implements a stack data structure of PMDataManager
136136 /// pointers.
137137 ///
138 /// Top level pass managers (see PassManager.cpp) maintain active Pass Managers
138 /// Top level pass managers (see PassManager.cpp) maintain active Pass Managers
139139 /// using PMStack. Each Pass implements assignPassManager() to connect itself
140140 /// with appropriate manager. assignPassManager() walks PMStack to find
141141 /// suitable manager.
173173 void initializeAllAnalysisInfo();
174174
175175 private:
176 /// This is implemented by top level pass manager and used by
176 /// This is implemented by top level pass manager and used by
177177 /// schedulePass() to add analysis info passes that are not available.
178178 virtual void addTopLevelPass(Pass *P) = 0;
179179
197197 /// Find analysis usage information for the pass P.
198198 AnalysisUsage *findAnalysisUsage(Pass *P);
199199
200 virtual ~PMTopLevelManager();
200 virtual ~PMTopLevelManager();
201201
202202 /// Add immutable pass and initialize it.
203203 inline void addImmutablePass(ImmutablePass *P) {
227227 PMStack activeStack;
228228
229229 protected:
230
230
231231 /// Collection of pass managers
232232 SmallVector PassManagers;
233233
253253 };
254254
255255
256
256
257257 //===----------------------------------------------------------------------===//
258258 // PMDataManager
259259
267267 }
268268
269269 virtual ~PMDataManager();
270
270
271271 virtual Pass *getAsPass() = 0;
272272
273273 /// Augment AvailableAnalysis by adding analysis made available by pass P.
278278
279279 /// Remove Analysis that is not preserved by the pass
280280 void removeNotPreservedAnalysis(Pass *P);
281
281
282282 /// Remove dead passes used by P.
283 void removeDeadPasses(Pass *P, StringRef Msg,
283 void removeDeadPasses(Pass *P, StringRef Msg,
284284 enum PassDebuggingString);
285285
286286 /// Remove P.
287 void freePass(Pass *P, StringRef Msg,
287 void freePass(Pass *P, StringRef Msg,
288288 enum PassDebuggingString);
289289
290 /// Add pass P into the PassVector. Update
290 /// Add pass P into the PassVector. Update
291291 /// AvailableAnalysis appropriately if ProcessAnalysis is true.
292292 void add(Pass *P, bool ProcessAnalysis = true);
293293
299299 virtual Pass *getOnTheFlyPass(Pass *P, AnalysisID PI, Function &F);
300300
301301 /// Initialize available analysis information.
302 void initializeAnalysisInfo() {
302 void initializeAnalysisInfo() {
303303 AvailableAnalysis.clear();
304304 for (unsigned i = 0; i < PMT_Last; ++i)
305305 InheritedAnalysis[i] = NULL;
346346 return (unsigned)PassVector.size();
347347 }
348348
349 virtual PassManagerType getPassManagerType() const {
349 virtual PassManagerType getPassManagerType() const {
350350 assert ( 0 && "Invalid use of getPassManagerType");
351 return PMT_Unknown;
351 return PMT_Unknown;
352352 }
353353
354354 std::map *getAvailableAnalysis() {
376376 // then PMT_Last active pass mangers.
377377 std::map *InheritedAnalysis[PMT_Last];
378378
379
379
380380 /// isPassDebuggingExecutionsOrMore - Return true if -debug-pass=Executions
381381 /// or higher is specified.
382382 bool isPassDebuggingExecutionsOrMore() const;
383
383
384384 private:
385385 void dumpAnalysisUsage(StringRef Msg, const Pass *P,
386386 const AnalysisUsage::VectorType &Set) const;
387387
388 // Set of available Analysis. This information is used while scheduling
389 // pass. If a pass requires an analysis which is not available then
388 // Set of available Analysis. This information is used while scheduling
389 // pass. If a pass requires an analysis which is not available then
390390 // the required analysis pass is scheduled to run before the pass itself is
391391 // scheduled to run.
392392 std::map AvailableAnalysis;
402402 // FPPassManager
403403 //
404404 /// FPPassManager manages BBPassManagers and FunctionPasses.
405 /// It batches all function passes and basic block pass managers together and
406 /// sequence them to process one function at a time before processing next
405 /// It batches all function passes and basic block pass managers together and
406 /// sequence them to process one function at a time before processing next
407407 /// function.
408408 class FPPassManager : public ModulePass, public PMDataManager {
409409 public:
410410 static char ID;
411 explicit FPPassManager()
411 explicit FPPassManager()
412412 : ModulePass(ID), PMDataManager() { }
413
413
414414 /// run - Execute all of the passes scheduled for execution. Keep track of
415415 /// whether any of the passes modifies the module, and if so, return true.
416416 bool runOnFunction(Function &F);
417417 bool runOnModule(Module &M);
418
418
419419 /// cleanup - After running all passes, clean up pass manager cache.
420420 void cleanup();
421421
422422 /// doInitialization - Run all of the initializers for the function passes.
423423 ///
424424 bool doInitialization(Module &M);
425
425
426426 /// doFinalization - Run all of the finalizers for the function passes.
427427 ///
428428 bool doFinalization(Module &M);
448448 return FP;
449449 }
450450
451 virtual PassManagerType getPassManagerType() const {
452 return PMT_FunctionPassManager;
451 virtual PassManagerType getPassManagerType() const {
452 return PMT_FunctionPassManager;
453453 }
454454 };
455455