summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/IR/PassManagerTest.cpp
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2013-11-21 10:53:05 +0000
committerChandler Carruth <chandlerc@gmail.com>2013-11-21 10:53:05 +0000
commit2846e9ef1529debcffcb7b10a5c289f00cd35c9f (patch)
treea71896f7692509cab54403e35887775cbb484f7b /llvm/unittests/IR/PassManagerTest.cpp
parent05c091455edf41709a7eeb9b3b7cdc2a644d884a (diff)
downloadbcm5719-llvm-2846e9ef1529debcffcb7b10a5c289f00cd35c9f.tar.gz
bcm5719-llvm-2846e9ef1529debcffcb7b10a5c289f00cd35c9f.zip
[PM] Widen the interface for invalidate on an analysis result now that
it is completely optional, and sink the logic for handling the preserved analysis set into it. This allows us to implement the delegation logic desired in the proxy module analysis for the function analysis manager where if the proxy itself is preserved we assume the set of functions hasn't changed and we do a fine grained invalidation by walking the functions in the module and running the invalidate for them all at the manager level and letting it try to invalidate any passes. This in turn makes it blindingly obvious why we should hoist the invalidate trait and have two collections of results. That allows handling invalidation for almost all analyses without indirect calls and it allows short circuiting when the preserved set is all. llvm-svn: 195338
Diffstat (limited to 'llvm/unittests/IR/PassManagerTest.cpp')
-rw-r--r--llvm/unittests/IR/PassManagerTest.cpp36
1 files changed, 35 insertions, 1 deletions
diff --git a/llvm/unittests/IR/PassManagerTest.cpp b/llvm/unittests/IR/PassManagerTest.cpp
index 38ef1a43290..d23d85b8828 100644
--- a/llvm/unittests/IR/PassManagerTest.cpp
+++ b/llvm/unittests/IR/PassManagerTest.cpp
@@ -64,6 +64,20 @@ struct TestModulePass {
int &RunCount;
};
+struct TestPreservingModulePass {
+ PreservedAnalyses run(Module *M) {
+ return PreservedAnalyses::all();
+ }
+};
+
+struct TestMinPreservingModulePass {
+ PreservedAnalyses run(Module *M) {
+ PreservedAnalyses PA;
+ PA.preserve<FunctionAnalysisModuleProxy>();
+ return PA;
+ }
+};
+
struct TestFunctionPass {
TestFunctionPass(FunctionAnalysisManager &AM, int &RunCount,
int &AnalyzedInstrCount)
@@ -137,6 +151,22 @@ TEST_F(PassManagerTest, Basic) {
FPM2.addPass(TestFunctionPass(FAM, FunctionPassRunCount2, AnalyzedInstrCount2));
MPM.addPass(createModuleToFunctionPassAdaptor(FPM2, &MAM));
+ // A third function pass manager but with only preserving intervening passes.
+ MPM.addPass(TestPreservingModulePass());
+ FunctionPassManager FPM3(&FAM);
+ int FunctionPassRunCount3 = 0;
+ int AnalyzedInstrCount3 = 0;
+ FPM3.addPass(TestFunctionPass(FAM, FunctionPassRunCount3, AnalyzedInstrCount3));
+ MPM.addPass(createModuleToFunctionPassAdaptor(FPM3, &MAM));
+
+ // A fourth function pass manager but with a minimal intervening passes.
+ MPM.addPass(TestMinPreservingModulePass());
+ FunctionPassManager FPM4(&FAM);
+ int FunctionPassRunCount4 = 0;
+ int AnalyzedInstrCount4 = 0;
+ FPM4.addPass(TestFunctionPass(FAM, FunctionPassRunCount4, AnalyzedInstrCount4));
+ MPM.addPass(createModuleToFunctionPassAdaptor(FPM4, &MAM));
+
MPM.run(M.get());
// Validate module pass counters.
@@ -147,8 +177,12 @@ TEST_F(PassManagerTest, Basic) {
EXPECT_EQ(5, AnalyzedInstrCount1);
EXPECT_EQ(3, FunctionPassRunCount2);
EXPECT_EQ(5, AnalyzedInstrCount2);
+ EXPECT_EQ(3, FunctionPassRunCount3);
+ EXPECT_EQ(5, AnalyzedInstrCount3);
+ EXPECT_EQ(3, FunctionPassRunCount4);
+ EXPECT_EQ(5, AnalyzedInstrCount4);
// Validate the analysis counters.
- EXPECT_EQ(6, AnalysisRuns);
+ EXPECT_EQ(9, AnalysisRuns);
}
}
OpenPOWER on IntegriCloud