Skip to content

Commit 7e8f9d6

Browse files
committed
[llvm][Inline] Add FunctionSimplificationPipeline to module inliner pipeline
The FunctionSimplificationPipeline could effectively reduce the size of .text section when module inliner is enabled. Reviewed By: kazu Differential Revision: https://reviews.llvm.org/D114704
1 parent 4380f50 commit 7e8f9d6

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

llvm/include/llvm/Passes/PassBuilder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ class PassBuilder {
199199

200200
/// Construct the module pipeline that performs inlining with
201201
/// module inliner pass.
202-
ModuleInlinerPass buildModuleInlinerPipeline(OptimizationLevel Level,
202+
ModulePassManager buildModuleInlinerPipeline(OptimizationLevel Level,
203203
ThinOrFullLTOPhase Phase);
204204

205205
/// Construct the core LLVM module optimization pipeline.

llvm/lib/Passes/PassBuilderPipelines.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -754,9 +754,11 @@ PassBuilder::buildInlinerPipeline(OptimizationLevel Level,
754754
return MIWP;
755755
}
756756

757-
ModuleInlinerPass
757+
ModulePassManager
758758
PassBuilder::buildModuleInlinerPipeline(OptimizationLevel Level,
759759
ThinOrFullLTOPhase Phase) {
760+
ModulePassManager MPM;
761+
760762
InlineParams IP = getInlineParamsFromOptLevel(Level);
761763
if (Phase == ThinOrFullLTOPhase::ThinLTOPreLink && PGOOpt &&
762764
PGOOpt->Action == PGOOptions::SampleUse)
@@ -773,7 +775,16 @@ PassBuilder::buildModuleInlinerPipeline(OptimizationLevel Level,
773775
// inline deferral logic in module inliner.
774776
IP.EnableDeferral = false;
775777

776-
return ModuleInlinerPass(IP, UseInlineAdvisor);
778+
MPM.addPass(ModuleInlinerPass(IP, UseInlineAdvisor));
779+
780+
MPM.addPass(createModuleToFunctionPassAdaptor(
781+
buildFunctionSimplificationPipeline(Level, Phase),
782+
PTO.EagerlyInvalidateAnalyses));
783+
784+
MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(
785+
CoroSplitPass(Level != OptimizationLevel::O0)));
786+
787+
return MPM;
777788
}
778789

779790
ModulePassManager

0 commit comments

Comments
 (0)