summaryrefslogtreecommitdiff
path: root/unittests
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
commitedd2b4913433d92fa6b6b89c31a2837d1bba32a5 (patch)
tree14f4cc19077778e00a39e4005ad899cdc90b373c /unittests
parent0bafaacfc96daefa43ac94fc186af71773c877a6 (diff)
downloadllvm-edd2b4913433d92fa6b6b89c31a2837d1bba32a5.tar.gz
llvm-edd2b4913433d92fa6b6b89c31a2837d1bba32a5.tar.bz2
llvm-edd2b4913433d92fa6b6b89c31a2837d1bba32a5.tar.xz
[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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195338 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/IR/PassManagerTest.cpp36
1 files changed, 35 insertions, 1 deletions
diff --git a/unittests/IR/PassManagerTest.cpp b/unittests/IR/PassManagerTest.cpp
index 38ef1a4329..d23d85b882 100644
--- a/unittests/IR/PassManagerTest.cpp
+++ b/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);
}
}