llvm.org GIT mirror llvm / 5b12a2f
[PM] Add a collection of no-op analysis passes and switch the new pass manager tests to use them and be significantly more comprehensive. This, naturally, uncovered a bug where the CGSCC pass manager wasn't printing analyses when they were run. The only remaining core manipulator is I think an invalidate pass similar to the require pass. That'll be next. =] git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225240 91177308-0d34-0410-b5e6-96231b3b80d8 Chandler Carruth 4 years ago
4 changed file(s) with 57 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
6161 // If we don't have a cached result for this function, look up the pass and
6262 // run it to produce a result, which we then add to the cache.
6363 if (Inserted) {
64 auto &P = lookupPass(PassID);
65 if (DebugPM)
66 dbgs() << "Running CGSCC analysis: " << P.name() << "\n";
6467 CGSCCAnalysisResultListT &ResultList = CGSCCAnalysisResultLists[&C];
65 ResultList.emplace_back(PassID, lookupPass(PassID).run(C, this));
68 ResultList.emplace_back(PassID, P.run(C, this));
6669 RI->second = std::prev(ResultList.end());
6770 }
6871
8585 ; CHECK-NO-VERIFY-NOT: VerifierPass
8686 ; CHECK-NO-VERIFY: Finished module pass manager
8787
88 ; RUN: opt -disable-output -debug-pass-manager -passes='require' %s 2>&1 \
89 ; RUN: | FileCheck %s --check-prefix=CHECK-LCG-ANALYSIS
90 ; CHECK-LCG-ANALYSIS: Starting module pass manager
91 ; CHECK-LCG-ANALYSIS: Running module pass: No-op Analysis Requirement Pass
92 ; CHECK-LCG-ANALYSIS: Running module analysis: Lazy CallGraph Analysis
88 ; RUN: opt -disable-output -debug-pass-manager -debug-cgscc-pass-manager \
89 ; RUN: -passes='require,cgscc(require,function(require))' %s 2>&1 \
90 ; RUN: | FileCheck %s --check-prefix=CHECK-ANALYSES
91 ; CHECK-ANALYSES: Starting module pass manager
92 ; CHECK-ANALYSES: Running module pass: No-op Analysis Requirement Pass
93 ; CHECK-ANALYSES: Running module analysis: NoOpModuleAnalysis
94 ; CHECK-ANALYSES: Starting CGSCC pass manager
95 ; CHECK-ANALYSES: Running CGSCC pass: No-op Analysis Requirement Pass
96 ; CHECK-ANALYSES: Running CGSCC analysis: NoOpCGSCCAnalysis
97 ; CHECK-ANALYSES: Starting function pass manager
98 ; CHECK-ANALYSES: Running function pass: No-op Analysis Requirement Pass
99 ; CHECK-ANALYSES: Running function analysis: NoOpFunctionAnalysis
93100
94101 ; Make sure no-op passes that preserve all analyses don't even try to do any
95102 ; analysis invalidation.
96 ; RUN: opt -disable-output -debug-pass-manager -debug-cgscc-pass-manager -passes='cgscc(function(no-op-function))' %s 2>&1 \
103 ; RUN: opt -disable-output -debug-pass-manager -debug-cgscc-pass-manager \
104 ; RUN: -passes='require,cgscc(require,function(require))' %s 2>&1 \
97105 ; RUN: | FileCheck %s --check-prefix=CHECK-NO-OP-INVALIDATION
98106 ; CHECK-NO-OP-INVALIDATION: Starting module pass manager
99107 ; CHECK-NO-OP-INVALIDATION-NOT: Invalidating all non-preserved analyses
1919 #define MODULE_ANALYSIS(NAME, CREATE_PASS)
2020 #endif
2121 MODULE_ANALYSIS("lcg", LazyCallGraphAnalysis())
22 MODULE_ANALYSIS("no-op-module", NoOpModuleAnalysis())
2223 #undef MODULE_ANALYSIS
2324
2425 #ifndef MODULE_PASS
3334 #ifndef CGSCC_ANALYSIS
3435 #define CGSCC_ANALYSIS(NAME, CREATE_PASS)
3536 #endif
37 CGSCC_ANALYSIS("no-op-cgscc", NoOpCGSCCAnalysis())
3638 #undef CGSCC_ANALYSIS
3739
3840 #ifndef CGSCC_PASS
4446 #ifndef FUNCTION_ANALYSIS
4547 #define FUNCTION_ANALYSIS(NAME, CREATE_PASS)
4648 #endif
49 FUNCTION_ANALYSIS("no-op-function", NoOpFunctionAnalysis())
4750 #undef FUNCTION_ANALYSIS
4851
4952 #ifndef FUNCTION_PASS
3131 static StringRef name() { return "NoOpModulePass"; }
3232 };
3333
34 /// \brief No-op module analysis.
35 struct NoOpModuleAnalysis {
36 struct Result {};
37 Result run(Module &) { return Result(); }
38 static StringRef name() { return "NoOpModuleAnalysis"; }
39 static void *ID() { return (void *)&PassID; }
40 private:
41 static char PassID;
42 };
43
44 char NoOpModuleAnalysis::PassID;
45
3446 /// \brief No-op CGSCC pass which does nothing.
3547 struct NoOpCGSCCPass {
3648 PreservedAnalyses run(LazyCallGraph::SCC &C) {
3951 static StringRef name() { return "NoOpCGSCCPass"; }
4052 };
4153
54 /// \brief No-op CGSCC analysis.
55 struct NoOpCGSCCAnalysis {
56 struct Result {};
57 Result run(LazyCallGraph::SCC &) { return Result(); }
58 static StringRef name() { return "NoOpCGSCCAnalysis"; }
59 static void *ID() { return (void *)&PassID; }
60 private:
61 static char PassID;
62 };
63
64 char NoOpCGSCCAnalysis::PassID;
65
4266 /// \brief No-op function pass which does nothing.
4367 struct NoOpFunctionPass {
4468 PreservedAnalyses run(Function &F) { return PreservedAnalyses::all(); }
4569 static StringRef name() { return "NoOpFunctionPass"; }
4670 };
71
72 /// \brief No-op function analysis.
73 struct NoOpFunctionAnalysis {
74 struct Result {};
75 Result run(Function &) { return Result(); }
76 static StringRef name() { return "NoOpFunctionAnalysis"; }
77 static void *ID() { return (void *)&PassID; }
78 private:
79 static char PassID;
80 };
81
82 char NoOpFunctionAnalysis::PassID;
4783
4884 } // End anonymous namespace.
4985