summaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2013-11-20 11:31:50 +0000
committerChandler Carruth <chandlerc@gmail.com>2013-11-20 11:31:50 +0000
commitc49e7e6aeedc8d6fbe6cabb5b61551556fdcbb0b (patch)
tree77a71076882f575e643a12300cdc87d35d560a91 /unittests
parent46198164b398d339e6c9d52354051477aec86dc9 (diff)
downloadllvm-c49e7e6aeedc8d6fbe6cabb5b61551556fdcbb0b.tar.gz
llvm-c49e7e6aeedc8d6fbe6cabb5b61551556fdcbb0b.tar.bz2
llvm-c49e7e6aeedc8d6fbe6cabb5b61551556fdcbb0b.tar.xz
[PM] Add the preservation system to the new pass manager.
This adds a new set-like type which represents a set of preserved analysis passes. The set is managed via the opaque PassT::ID() void*s. The expected convenience templates for interacting with specific passes are provided. It also supports a symbolic "all" state which is represented by an invalid pointer in the set. This state is nicely saturating as it comes up often. Finally, it supports intersection which is used when finding the set of preserved passes after N different transforms. The pass API is then changed to return the preserved set rather than a bool. This is much more self-documenting than the previous system. Returning "none" is a conservatively correct solution just like returning "true" from todays passes and not marking any passes as preserved. Passes can also be dynamically preserved or not throughout the run of the pass, and whatever gets returned is the binding state. Finally, preserving "all" the passes is allowed for no-op transforms that simply can't harm such things. Finally, the analysis managers are changed to instead of blindly invalidating all of the analyses, invalidate those which were not preserved. This should rig up all of the basic preservation functionality. This also correctly combines the preservation moving up from one IR-layer to the another and the preservation aggregation across N pass runs. Still to go is incrementally correct invalidation and preservation across IR layers incrementally during N pass runs. That will wait until we have a device for even exposing analyses across IR layers. While the core of this change is obvious, I'm not happy with the current testing, so will improve it to cover at least some of the invalidation that I can test easily in a subsequent commit. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195241 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/IR/PassManagerTest.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/unittests/IR/PassManagerTest.cpp b/unittests/IR/PassManagerTest.cpp
index 1e02d6ba02..f2ce221476 100644
--- a/unittests/IR/PassManagerTest.cpp
+++ b/unittests/IR/PassManagerTest.cpp
@@ -52,9 +52,9 @@ char TestAnalysisPass::PassID;
struct TestModulePass {
TestModulePass(int &RunCount) : RunCount(RunCount) {}
- bool run(Module *M) {
+ PreservedAnalyses run(Module *M) {
++RunCount;
- return true;
+ return PreservedAnalyses::none();
}
int &RunCount;
@@ -65,13 +65,13 @@ struct TestFunctionPass {
int &AnalyzedInstrCount)
: AM(AM), RunCount(RunCount), AnalyzedInstrCount(AnalyzedInstrCount) {}
- bool run(Function *F) {
+ PreservedAnalyses run(Function *F) {
++RunCount;
const TestAnalysisPass::Result &AR = AM.getResult<TestAnalysisPass>(F);
AnalyzedInstrCount += AR.InstructionCount;
- return true;
+ return PreservedAnalyses::none();
}
FunctionAnalysisManager &AM;