llvm.org GIT mirror llvm / b56749c
[PM] Add names to passes under the new pass manager, and a debug output mode that can be used to debug the execution of everything. No support for analyses here, that will come later. This already helps show parts of the opt commandline integration that isn't working. Tests of that will start using it as the bugs are fixed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199004 91177308-0d34-0410-b5e6-96231b3b80d8 Chandler Carruth 6 years ago
4 changed file(s) with 51 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
167167 /// desired. Also that the analysis manager may be null if there is no
168168 /// analysis manager in the pass pipeline.
169169 virtual PreservedAnalyses run(IRUnitT IR, AnalysisManagerT *AM) = 0;
170
171 /// \brief Polymorphic method to access the name of a pass.
172 virtual StringRef name() = 0;
170173 };
171174
172175 /// \brief SFINAE metafunction for computing whether \c PassT has a run method
207210 virtual PreservedAnalyses run(IRUnitT IR, AnalysisManagerT *AM) {
208211 return Pass.run(IR, AM);
209212 }
213 virtual StringRef name() { return PassT::name(); }
210214 PassT Pass;
211215 };
212216
220224 virtual PreservedAnalyses run(IRUnitT IR, AnalysisManagerT *AM) {
221225 return Pass.run(IR);
222226 }
227 virtual StringRef name() { return PassT::name(); }
223228 PassT Pass;
224229 };
225230
402407 Passes.push_back(new ModulePassModel(llvm_move(Pass)));
403408 }
404409
410 static StringRef name() { return "ModulePassManager"; }
411
405412 private:
406413 // Pull in the concept type and model template specialized for modules.
407414 typedef detail::PassConcept ModulePassConcept;
426433 }
427434
428435 PreservedAnalyses run(Function *F, FunctionAnalysisManager *AM = 0);
436
437 static StringRef name() { return "FunctionPassManager"; }
429438
430439 private:
431440 // Pull in the concept type and model template specialized for functions.
807816 return PA;
808817 }
809818
819 static StringRef name() { return "ModuleToFunctionPassAdaptor"; }
820
810821 private:
811822 FunctionPassT Pass;
812823 };
66 //
77 //===----------------------------------------------------------------------===//
88
9 #include "llvm/ADT/STLExtras.h"
910 #include "llvm/IR/PassManager.h"
10 #include "llvm/ADT/STLExtras.h"
11 #include "llvm/Support/CommandLine.h"
12 #include "llvm/Support/Debug.h"
1113
1214 using namespace llvm;
1315
16 static cl::opt
17 DebugPM("debug-pass-manager", cl::Hidden,
18 cl::desc("Print pass management debugging information"));
19
1420 PreservedAnalyses ModulePassManager::run(Module *M, ModuleAnalysisManager *AM) {
1521 PreservedAnalyses PA = PreservedAnalyses::all();
22
23 if (DebugPM)
24 dbgs() << "Starting module pass manager run.\n";
25
1626 for (unsigned Idx = 0, Size = Passes.size(); Idx != Size; ++Idx) {
27 if (DebugPM)
28 dbgs() << "Running module pass: " << Passes[Idx]->name() << "\n";
29
1730 PreservedAnalyses PassPA = Passes[Idx]->run(M, AM);
1831 if (AM)
1932 AM->invalidate(M, PassPA);
2033 PA.intersect(llvm_move(PassPA));
2134 }
35
36 if (DebugPM)
37 dbgs() << "Finished module pass manager run.\n";
38
2239 return PA;
2340 }
2441
6077
6178 PreservedAnalyses FunctionPassManager::run(Function *F, FunctionAnalysisManager *AM) {
6279 PreservedAnalyses PA = PreservedAnalyses::all();
80
81 if (DebugPM)
82 dbgs() << "Starting function pass manager run.\n";
83
6384 for (unsigned Idx = 0, Size = Passes.size(); Idx != Size; ++Idx) {
85 if (DebugPM)
86 dbgs() << "Running function pass: " << Passes[Idx]->name() << "\n";
87
6488 PreservedAnalyses PassPA = Passes[Idx]->run(F, AM);
6589 if (AM)
6690 AM->invalidate(F, PassPA);
6791 PA.intersect(llvm_move(PassPA));
6892 }
93
94 if (DebugPM)
95 dbgs() << "Finished function pass manager run.\n";
96
6997 return PA;
7098 }
7199
2323 /// \brief No-op module pass which does nothing.
2424 struct NoOpModulePass {
2525 PreservedAnalyses run(Module *M) { return PreservedAnalyses::all(); }
26 static StringRef name() { return "NoOpModulePass"; }
2627 };
2728
2829 } // End anonymous namespace.
8585 return PreservedAnalyses::none();
8686 }
8787
88 static StringRef name() { return "TestModulePass"; }
89
8890 int &RunCount;
8991 };
9092
9294 PreservedAnalyses run(Module *M) {
9395 return PreservedAnalyses::all();
9496 }
97
98 static StringRef name() { return "TestPreservingModulePass"; }
9599 };
96100
97101 struct TestMinPreservingModulePass {
104108 PA.preserve();
105109 return PA;
106110 }
111
112 static StringRef name() { return "TestMinPreservingModulePass"; }
107113 };
108114
109115 struct TestFunctionPass {
137143 return PreservedAnalyses::all();
138144 }
139145
146 static StringRef name() { return "TestFunctionPass"; }
147
140148 int &RunCount;
141149 int &AnalyzedInstrCount;
142150 int &AnalyzedFunctionCount;
152160 return F->getName() == Name ? PreservedAnalyses::none()
153161 : PreservedAnalyses::all();
154162 }
163
164 static StringRef name() { return "TestInvalidationFunctionPass"; }
155165
156166 StringRef Name;
157167 };