[PATCH] D151053: [PassManager] Add extension point to LTO pipeline to enable module optimization passes to run shortly before loop optimizations
William Moses via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun May 21 18:06:51 PDT 2023
wsmoses created this revision.
wsmoses added a reviewer: jdoerfert.
Herald added subscribers: hiraditya, inglorion.
Herald added a project: All.
wsmoses requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
This pass introduces an extension point to the LTO new pass manager pipeline to run module passes shortly before loop optimiaztion. This is necessary for transformation passes like Enzyme.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D151053
Files:
llvm/include/llvm/Passes/PassBuilder.h
llvm/lib/Passes/PassBuilderPipelines.cpp
Index: llvm/lib/Passes/PassBuilderPipelines.cpp
===================================================================
--- llvm/lib/Passes/PassBuilderPipelines.cpp
+++ llvm/lib/Passes/PassBuilderPipelines.cpp
@@ -340,6 +340,11 @@
for (auto &C : FullLinkTimeOptimizationEarlyEPCallbacks)
C(MPM, Level);
}
+void PassBuilder::invokeFullLinkTimeOptimizationBeforeLoopEPCallbacks(
+ ModulePassManager &MPM, OptimizationLevel Level) {
+ for (auto &C : FullLinkTimeOptimizationBeforeLoopEPCallbacks)
+ C(MPM, Level);
+}
void PassBuilder::invokeFullLinkTimeOptimizationLastEPCallbacks(
ModulePassManager &MPM, OptimizationLevel Level) {
for (auto &C : FullLinkTimeOptimizationLastEPCallbacks)
@@ -1794,6 +1799,9 @@
// Require the GlobalsAA analysis for the module so we can query it within
// MainFPM.
MPM.addPass(RequireAnalysisPass<GlobalsAA, Module>());
+
+ invokeFullLinkTimeOptimizationBeforeLoopEPCallbacks(MPM, Level);
+
// Invalidate AAManager so it can be recreated and pick up the newly available
// GlobalsAA.
MPM.addPass(
Index: llvm/include/llvm/Passes/PassBuilder.h
===================================================================
--- llvm/include/llvm/Passes/PassBuilder.h
+++ llvm/include/llvm/Passes/PassBuilder.h
@@ -470,6 +470,15 @@
const std::function<void(ModulePassManager &, OptimizationLevel)> &C) {
FullLinkTimeOptimizationEarlyEPCallbacks.push_back(C);
}
+
+ /// Register a callback for a default optimizer pipeline extension point
+ ///
+ /// This extension point allows adding optimizations at the module level before
+ /// any loop optimizations are run.
+ void registerFullLinkTimeOptimizatioBeforeLoopEPCallback(
+ const std::function<void(ModulePassManager &, OptimizationLevel)> &C) {
+ FullLinkTimeOptimizationBeforeLoopEPCallbacks.push_back(C);
+ }
/// Register a callback for a default optimizer pipeline extension point
///
@@ -576,6 +585,8 @@
OptimizationLevel Level);
void invokeFullLinkTimeOptimizationEarlyEPCallbacks(ModulePassManager &MPM,
OptimizationLevel Level);
+ void invokeFullLinkTimeOptimizationBeforeLoopEPCallbacks(ModulePassManager &MPM,
+ OptimizationLevel Level);
void invokeFullLinkTimeOptimizationLastEPCallbacks(ModulePassManager &MPM,
OptimizationLevel Level);
void invokePipelineStartEPCallbacks(ModulePassManager &MPM,
@@ -638,6 +649,8 @@
OptimizerLastEPCallbacks;
SmallVector<std::function<void(ModulePassManager &, OptimizationLevel)>, 2>
FullLinkTimeOptimizationEarlyEPCallbacks;
+ SmallVector<std::function<void(ModulePassManager &, OptimizationLevel)>, 2>
+ FullLinkTimeOptimizationBeforeLoopEPCallbacks;
SmallVector<std::function<void(ModulePassManager &, OptimizationLevel)>, 2>
FullLinkTimeOptimizationLastEPCallbacks;
SmallVector<std::function<void(ModulePassManager &, OptimizationLevel)>, 2>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151053.524142.patch
Type: text/x-patch
Size: 3087 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230522/a1566d0c/attachment.bin>
More information about the llvm-commits
mailing list