OSDN Git Service

[PM] Support invalidation of inner analysis managers from a pass over the outer IR...
authorChandler Carruth <chandlerc@gmail.com>
Sat, 10 Dec 2016 06:34:44 +0000 (06:34 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Sat, 10 Dec 2016 06:34:44 +0000 (06:34 +0000)
commit8bf2780092fed6508efe8c97534a41273fe39a19
tree58e941adead34a8507d0dc31fb9b252901c4b4d8
parent2c5ce04e48508496b095106faccff7426518664c
[PM] Support invalidation of inner analysis managers from a pass over the outer IR unit.

Summary:
This never really got implemented, and was very hard to test before
a lot of the refactoring changes to make things more robust. But now we
can test it thoroughly and cleanly, especially at the CGSCC level.

The core idea is that when an inner analysis manager proxy receives the
invalidation event for the outer IR unit, it needs to walk the inner IR
units and propagate it to the inner analysis manager for each of those
units. For example, each function in the SCC needs to get an
invalidation event when the SCC gets one.

The function / module interaction is somewhat boring here. This really
becomes interesting in the face of analysis-backed IR units. This patch
effectively handles all of the CGSCC layer's needs -- both invalidating
SCC analysis and invalidating function analysis when an SCC gets
invalidated.

However, this second aspect doesn't really handle the
LoopAnalysisManager well at this point. That one will need some change
of design in order to fully integrate, because unlike the call graph,
the entire function behind a LoopAnalysis's results can vanish out from
under us, and we won't even have a cached API to access. I'd like to try
to separate solving the loop problems into a subsequent patch though in
order to keep this more focused so I've adapted them to the API and
updated the tests that immediately fail, but I've not added the level of
testing and validation at that layer that I have at the CGSCC layer.

An important aspect of this change is that the proxy for the
FunctionAnalysisManager at the SCC pass layer doesn't work like the
other proxies for an inner IR unit as it doesn't directly manage the
FunctionAnalysisManager and invalidation or clearing of it. This would
create an ever worsening problem of dual ownership of this
responsibility, split between the module-level FAM proxy and this
SCC-level FAM proxy. Instead, this patch changes the SCC-level FAM proxy
to work in terms of the module-level proxy and defer to it to handle
much of the updates. It only does SCC-specific invalidation. This will
become more important in subsequent patches that support more complex
invalidaiton scenarios.

Reviewers: jlebar

Subscribers: mehdi_amini, mcrosier, mzolotukhin, llvm-commits

Differential Revision: https://reviews.llvm.org/D27197

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@289317 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Analysis/CGSCCPassManager.h
include/llvm/Analysis/LoopPassManager.h
include/llvm/IR/PassManager.h
lib/Analysis/CGSCCPassManager.cpp
lib/Analysis/LoopPassManager.cpp
lib/IR/PassManager.cpp
lib/Passes/PassBuilder.cpp
lib/Passes/PassRegistry.def
test/Other/new-pass-manager.ll
unittests/Analysis/CGSCCPassManagerTest.cpp
unittests/IR/PassManagerTest.cpp