diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2013-11-23 01:25:07 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2013-11-23 01:25:07 +0000 |
commit | e510665548d7291b7e935a17514f9380b770e26c (patch) | |
tree | fe82037c15e660725f6d73e99b1fd18c2d333619 /include | |
parent | 2ea1151162206f6bbc744fa008150ba6266da4d9 (diff) | |
download | llvm-e510665548d7291b7e935a17514f9380b770e26c.tar.gz llvm-e510665548d7291b7e935a17514f9380b770e26c.tar.bz2 llvm-e510665548d7291b7e935a17514f9380b770e26c.tar.xz |
[PM] Complete the cross-layer interfaces with a Module-to-Function
proxy. This lets a function pass query a module analysis manager.
However, the interface is const to indicate that only cached results can
be safely queried.
With this, I think the new pass manager is largely functionally complete
for modules and analyses. Still lots to test, and need to generalize to
SCCs and Loops, and need to build an adaptor layer to support the use of
existing Pass objects in the new managers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195538 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/IR/PassManager.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/include/llvm/IR/PassManager.h b/include/llvm/IR/PassManager.h index d6e97419de..3c9414986e 100644 --- a/include/llvm/IR/PassManager.h +++ b/include/llvm/IR/PassManager.h @@ -733,6 +733,50 @@ private: FunctionAnalysisManager &FAM; }; +/// \brief A function analysis which acts as a proxy for a module analysis +/// manager. +/// +/// This primarily provides an accessor to a parent module analysis manager to +/// function passes. Only the const interface of the module analysis manager is +/// provided to indicate that once inside of a function analysis pass you +/// cannot request a module analysis to actually run. Instead, the user must +/// rely on the \c getCachedResult API. +/// +/// This proxy *doesn't* manage the invalidation in any way. That is handled by +/// the recursive return path of each layer of the pass manager and the +/// returned PreservedAnalysis set. +class ModuleAnalysisManagerFunctionProxy { +public: + /// \brief Result proxy object for \c ModuleAnalysisManagerFunctionProxy. + class Result { + public: + Result(const ModuleAnalysisManager &MAM) : MAM(MAM) {} + + const ModuleAnalysisManager &getManager() const { return MAM; } + + /// \brief Handle invalidation by ignoring it, this pass is immutable. + bool invalidate(Function *) { return false; } + + private: + const ModuleAnalysisManager &MAM; + }; + + static void *ID() { return (void *)&PassID; } + + ModuleAnalysisManagerFunctionProxy(const ModuleAnalysisManager &MAM) + : MAM(MAM) {} + + /// \brief Run the analysis pass and create our proxy result object. + /// Nothing to see here, it just forwards the \c MAM reference into the + /// result. + Result run(Function *) { return Result(MAM); } + +private: + static char PassID; + + const ModuleAnalysisManager &MAM; +}; + /// \brief Trivial adaptor that maps from a module to its functions. /// /// Designed to allow composition of a FunctionPass(Manager) and |