mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
[NewPM] Add pipeline EP callback after initial frontend cleanup
This matches the legacy PM's EP_ModuleOptimizerEarly. Some backends use this extension point and adding the pass somewhere else like PipelineStartEPCallback doesn't work. Reviewed By: ychen Differential Revision: https://reviews.llvm.org/D91804
This commit is contained in:
parent
08b63023fd
commit
03d1745e44
@ -597,6 +597,15 @@ public:
|
||||
PipelineStartEPCallbacks.push_back(C);
|
||||
}
|
||||
|
||||
/// Register a callback for a default optimizer pipeline extension point.
|
||||
///
|
||||
/// This extension point allows adding optimization right after passes that do
|
||||
/// basic simplification of the input IR.
|
||||
void registerPipelineEarlySimplificationEPCallback(
|
||||
const std::function<void(ModulePassManager &, OptimizationLevel)> &C) {
|
||||
PipelineEarlySimplificationEPCallbacks.push_back(C);
|
||||
}
|
||||
|
||||
/// Register a callback for a default optimizer pipeline extension point
|
||||
///
|
||||
/// This extension point allows adding optimizations at the very end of the
|
||||
@ -729,6 +738,9 @@ private:
|
||||
// Module callbacks
|
||||
SmallVector<std::function<void(ModulePassManager &, OptimizationLevel)>, 2>
|
||||
PipelineStartEPCallbacks;
|
||||
SmallVector<std::function<void(ModulePassManager &, OptimizationLevel)>, 2>
|
||||
PipelineEarlySimplificationEPCallbacks;
|
||||
|
||||
SmallVector<std::function<void(ModuleAnalysisManager &)>, 2>
|
||||
ModuleAnalysisRegistrationCallbacks;
|
||||
SmallVector<std::function<bool(StringRef, ModulePassManager &,
|
||||
|
@ -1032,6 +1032,9 @@ PassBuilder::buildModuleSimplificationPipeline(OptimizationLevel Level,
|
||||
if (Phase == ThinLTOPhase::PostLink)
|
||||
MPM.addPass(LowerTypeTestsPass(nullptr, nullptr, true));
|
||||
|
||||
for (auto &C : PipelineEarlySimplificationEPCallbacks)
|
||||
C(MPM, Level);
|
||||
|
||||
// Interprocedural constant propagation now that basic cleanup has occurred
|
||||
// and prior to optimizing globals.
|
||||
// FIXME: This position in the pipeline hasn't been carefully considered in
|
||||
@ -1703,6 +1706,8 @@ ModulePassManager PassBuilder::buildO0DefaultPipeline(OptimizationLevel Level,
|
||||
|
||||
for (auto &C : PipelineStartEPCallbacks)
|
||||
C(MPM, Level);
|
||||
for (auto &C : PipelineEarlySimplificationEPCallbacks)
|
||||
C(MPM, Level);
|
||||
|
||||
// Build a minimal pipeline based on the semantics required by LLVM,
|
||||
// which is just that always inlining occurs. Further, disable generating
|
||||
|
@ -4,6 +4,7 @@
|
||||
; RUN: opt -disable-output -debug-pass-manager -passes-ep-cgscc-optimizer-late=no-op-cgscc -passes='default<O0>' 2>&1 < %s | FileCheck %s
|
||||
; RUN: opt -disable-output -debug-pass-manager -passes-ep-vectorizer-start=no-op-function -passes='default<O0>' 2>&1 < %s | FileCheck %s
|
||||
; RUN: opt -disable-output -debug-pass-manager -passes-ep-pipeline-start=no-op-module -passes='default<O0>' 2>&1 < %s | FileCheck %s
|
||||
; RUN: opt -disable-output -debug-pass-manager -passes-ep-pipeline-early-simplification=no-op-module -passes='default<O0>' 2>&1 < %s | FileCheck %s
|
||||
; RUN: opt -disable-output -debug-pass-manager -passes-ep-optimizer-last=no-op-function -passes='default<O0>' 2>&1 < %s | FileCheck %s
|
||||
|
||||
; CHECK: Running pass: NoOp
|
||||
|
@ -55,6 +55,10 @@
|
||||
; RUN: -passes='default<O3>' -S %s 2>&1 \
|
||||
; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-DEFAULT,CHECK-O3,%llvmcheckext,CHECK-EP-PIPELINE-START,CHECK-O23SZ
|
||||
; RUN: opt -disable-verify -debug-pass-manager \
|
||||
; RUN: -passes-ep-pipeline-early-simplification='no-op-module' \
|
||||
; RUN: -passes='default<O3>' -S %s 2>&1 \
|
||||
; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-DEFAULT,CHECK-O3,%llvmcheckext,CHECK-EP-PIPELINE-EARLY-SIMPLIFICATION,CHECK-O23SZ
|
||||
; RUN: opt -disable-verify -debug-pass-manager \
|
||||
; RUN: -passes-ep-pipeline-start='no-op-module' \
|
||||
; RUN: -passes='lto-pre-link<O3>' -S %s 2>&1 \
|
||||
; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-LTO,CHECK-O3,%llvmcheckext,CHECK-EP-PIPELINE-START,CHECK-O23SZ
|
||||
@ -84,6 +88,7 @@
|
||||
; CHECK-O-NEXT: Running pass: LowerExpectIntrinsicPass
|
||||
; CHECK-O3-NEXT: Running pass: CallSiteSplittingPass
|
||||
; CHECK-O-NEXT: Finished llvm::Function pass manager run.
|
||||
; CHECK-EP-PIPELINE-EARLY-SIMPLIFICATION-NEXT: Running pass: NoOpModulePass
|
||||
; CHECK-O-NEXT: Running pass: IPSCCPPass
|
||||
; CHECK-O-NEXT: Running pass: CalledValuePropagationPass
|
||||
; CHECK-O-NEXT: Running pass: GlobalOptPass
|
||||
|
@ -276,6 +276,9 @@
|
||||
; RUN: opt -passes-ep-pipeline-start=bad -passes=no-op-function \
|
||||
; RUN: /dev/null -disable-output 2>&1 | FileCheck %s -check-prefix=PASSES-EP-PIPELINESTART-ERR
|
||||
; PASSES-EP-PIPELINESTART-ERR: Could not parse -passes-ep-pipeline-start pipeline: unknown pass name 'bad'
|
||||
; RUN: opt -passes-ep-pipeline-early-simplification=bad -passes=no-op-function \
|
||||
; RUN: /dev/null -disable-output 2>&1 | FileCheck %s -check-prefix=PASSES-EP-PIPELINEEARLYSIMPLIFICATION-ERR
|
||||
; PASSES-EP-PIPELINEEARLYSIMPLIFICATION-ERR: Could not parse -passes-ep-pipeline-early-simplification pipeline: unknown pass name 'bad'
|
||||
|
||||
define void @f() {
|
||||
entry:
|
||||
|
@ -107,6 +107,11 @@ static cl::opt<std::string> PipelineStartEPPipeline(
|
||||
cl::desc("A textual description of the module pass pipeline inserted at "
|
||||
"the PipelineStart extension point into default pipelines"),
|
||||
cl::Hidden);
|
||||
static cl::opt<std::string> PipelineEarlySimplificationEPPipeline(
|
||||
"passes-ep-pipeline-early-simplification",
|
||||
cl::desc("A textual description of the module pass pipeline inserted at "
|
||||
"the EarlySimplification extension point into default pipelines"),
|
||||
cl::Hidden);
|
||||
static cl::opt<std::string> OptimizerLastEPPipeline(
|
||||
"passes-ep-optimizer-last",
|
||||
cl::desc("A textual description of the module pass pipeline inserted at "
|
||||
@ -195,6 +200,13 @@ static void registerEPCallbacks(PassBuilder &PB) {
|
||||
ExitOnError Err("Unable to parse PipelineStartEP pipeline: ");
|
||||
Err(PB.parsePassPipeline(PM, PipelineStartEPPipeline));
|
||||
});
|
||||
if (tryParsePipelineText<ModulePassManager>(
|
||||
PB, PipelineEarlySimplificationEPPipeline))
|
||||
PB.registerPipelineEarlySimplificationEPCallback(
|
||||
[&PB](ModulePassManager &PM, PassBuilder::OptimizationLevel) {
|
||||
ExitOnError Err("Unable to parse EarlySimplification pipeline: ");
|
||||
Err(PB.parsePassPipeline(PM, PipelineEarlySimplificationEPPipeline));
|
||||
});
|
||||
if (tryParsePipelineText<FunctionPassManager>(PB, OptimizerLastEPPipeline))
|
||||
PB.registerOptimizerLastEPCallback(
|
||||
[&PB](ModulePassManager &PM, PassBuilder::OptimizationLevel) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user