[PATCH] D65805: [PassManager] add setupAnalysis() to customize analyses registered in AnalysisManager
Fedor Sergeev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 6 07:10:18 PDT 2019
fedor.sergeev created this revision.
fedor.sergeev added reviewers: chandlerc, philip.pfaffe.
Herald added a subscriber: mehdi_amini.
Herald added a project: LLVM.
fedor.sergeev added a parent revision: D65806: [MemDep] allow customization of block-scan-limit of MemoryDependenceAnalysis instance.
One of the problems we have in customization of compilation pipeline is inability to construct
a customized analysis. Currently the only way to customize is to use a global option.
This does not work when per-compilation-context or per-module customization is required
(say, in JIT scenario).
Our current downstream need is to customize MemoryDependenceAnalysis with a different
block scan limit (to make compile-time/run-time tradeoff choice per individual JIT compilation).
Plan is to register analysis normally (through e.g. PassBuilder) and then run:
FAM.setupAnalysis([](MemoryDependenceAnalysis& MDep) {
MDep.setDefaultBlockScanLimit(NonDefaultBlockScanLimit);
}
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D65805
Files:
llvm/include/llvm/IR/PassManager.h
Index: llvm/include/llvm/IR/PassManager.h
===================================================================
--- llvm/include/llvm/IR/PassManager.h
+++ llvm/include/llvm/IR/PassManager.h
@@ -841,6 +841,19 @@
return true;
}
+ /// Setup an analysis pass previously registered with the manager.
+ ///
+ /// The parameter is a callable taking a pointer to \p PassT and returning bool.
+ /// This allows passing in a lambda to modify the analysis behavior after
+ /// it has been registered.
+ template <typename PassT, typename CallableT>
+ bool setupAnalysis(CallableT Setup) {
+ auto &PassPtr = AnalysisPasses[PassT::ID()];
+ if (PassPtr)
+ return Setup(PassPtr.get());
+ return false;
+ }
+
/// Invalidate a specific analysis pass for an IR module.
///
/// Note that the analysis result can disregard invalidation, if it determines
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65805.213601.patch
Type: text/x-patch
Size: 873 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190806/321e2bd3/attachment.bin>
More information about the llvm-commits
mailing list