Skip to content

Commit 100d8f5

Browse files
authored
Merge pull request #31270 from eeckstein/pass-manager-reorg
SILOptimizer: reorganize the optimization-prepare passpipeline
2 parents 207958c + 53f6fda commit 100d8f5

File tree

6 files changed

+13
-31
lines changed

6 files changed

+13
-31
lines changed

include/swift/SILOptimizer/PassManager/PassPipeline.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
PASSPIPELINE(Diagnostic, "Guaranteed Passes")
2626
PASSPIPELINE(OwnershipEliminator, "Utility pass to just run the ownership eliminator pass")
27-
PASSPIPELINE(SILOptPrepare, "Passes that prepare SIL for -O")
2827
PASSPIPELINE(Performance, "Passes run at -O")
2928
PASSPIPELINE(Onone, "Passes run at -Onone")
3029
PASSPIPELINE(InstCount, "Utility pipeline to just run the inst count pass")

include/swift/SILOptimizer/PassManager/Passes.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ namespace swift {
3333
/// \returns true if the diagnostic passes produced an error
3434
bool runSILDiagnosticPasses(SILModule &M);
3535

36-
/// Prepare SIL for the -O pipeline.
37-
void runSILOptPreparePasses(SILModule &Module);
38-
3936
/// Run all the SIL performance optimization passes on \p M.
4037
void runSILOptimizationPasses(SILModule &M);
4138

lib/Frontend/Frontend.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,8 +1062,6 @@ static void performSILOptimizations(CompilerInvocation &Invocation,
10621062
runSILPassesForOnone(*SM);
10631063
return;
10641064
}
1065-
runSILOptPreparePasses(*SM);
1066-
10671065
StringRef CustomPipelinePath =
10681066
Invocation.getSILOptions().ExternalPassPipelineFilename;
10691067
if (!CustomPipelinePath.empty()) {

lib/SILOptimizer/PassManager/PassPipeline.cpp

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,15 @@ static void addPerfDebugSerializationPipeline(SILPassPipelinePlan &P) {
396396
P.addPerformanceSILLinker();
397397
}
398398

399+
400+
static void addPrepareOptimizationsPipeline(SILPassPipelinePlan &P) {
401+
P.startPipeline("PrepareOptimizationPasses");
402+
403+
P.addForEachLoopUnroll();
404+
P.addMandatoryCombine();
405+
P.addAccessMarkerElimination();
406+
}
407+
399408
static void addPerfEarlyModulePassPipeline(SILPassPipelinePlan &P) {
400409
P.startPipeline("EarlyModulePasses");
401410

@@ -625,23 +634,6 @@ SILPassPipelinePlan::getIRGenPreparePassPipeline(const SILOptions &Options) {
625634
return P;
626635
}
627636

628-
SILPassPipelinePlan
629-
SILPassPipelinePlan::getSILOptPreparePassPipeline(const SILOptions &Options) {
630-
SILPassPipelinePlan P(Options);
631-
632-
if (Options.DebugSerialization) {
633-
addPerfDebugSerializationPipeline(P);
634-
return P;
635-
}
636-
637-
P.startPipeline("SILOpt Prepare Passes");
638-
P.addForEachLoopUnroll();
639-
P.addMandatoryCombine();
640-
P.addAccessMarkerElimination();
641-
642-
return P;
643-
}
644-
645637
SILPassPipelinePlan
646638
SILPassPipelinePlan::getPerformancePassPipeline(const SILOptions &Options) {
647639
SILPassPipelinePlan P(Options);
@@ -650,6 +642,10 @@ SILPassPipelinePlan::getPerformancePassPipeline(const SILOptions &Options) {
650642
addPerfDebugSerializationPipeline(P);
651643
return P;
652644
}
645+
646+
// Passes which run once before all other optimizations run. Those passes are
647+
// _not_ intended to run later again.
648+
addPrepareOptimizationsPipeline(P);
653649

654650
// Eliminate immediately dead functions and then clone functions from the
655651
// stdlib.

lib/SILOptimizer/PassManager/Passes.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,6 @@ bool swift::runSILOwnershipEliminatorPass(SILModule &Module) {
8484
return Ctx.hadError();
8585
}
8686

87-
// Prepare SIL for the -O pipeline.
88-
void swift::runSILOptPreparePasses(SILModule &Module) {
89-
auto &opts = Module.getOptions();
90-
auto plan = SILPassPipelinePlan::getSILOptPreparePassPipeline(opts);
91-
executePassPipelinePlan(&Module, plan);
92-
}
93-
9487
void swift::runSILOptimizationPasses(SILModule &Module) {
9588
auto &opts = Module.getOptions();
9689

tools/sil-opt/SILOpt.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,6 @@ int main(int argc, char **argv) {
480480
if (OptimizationGroup == OptGroup::Diagnostics) {
481481
runSILDiagnosticPasses(*CI.getSILModule());
482482
} else if (OptimizationGroup == OptGroup::Performance) {
483-
runSILOptPreparePasses(*CI.getSILModule());
484483
runSILOptimizationPasses(*CI.getSILModule());
485484
} else if (OptimizationGroup == OptGroup::Lowering) {
486485
runSILLoweringPasses(*CI.getSILModule());

0 commit comments

Comments
 (0)