[PM] Add the preservation system to the new pass manager.
authorChandler Carruth <chandlerc@gmail.com>
Wed, 20 Nov 2013 11:31:50 +0000 (11:31 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Wed, 20 Nov 2013 11:31:50 +0000 (11:31 +0000)
commitc49e7e6aeedc8d6fbe6cabb5b61551556fdcbb0b
tree77a71076882f575e643a12300cdc87d35d560a91
parent46198164b398d339e6c9d52354051477aec86dc9
[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
include/llvm/IR/PassManager.h
lib/IR/PassManager.cpp
unittests/IR/PassManagerTest.cpp