Skip to content

Commit 75cdaa3

Browse files
committed
Run more function passes in a single run of the pass manager.
This commit moves the SILLinker pass out of AddSSAPasses, so that we run more function passes on each function before moving up to it's callers. Now the only remaining module passes in AddSSAPasses are GlobalOpt and LetPropertiesOpt, which run only when we call AddSSAPasses for the MidLevel optimizations. This commit also adds the high level loop opt passes onto the same pass run. As a result of this and moving SILLinker out of AddSSAPasses, we now run far more passes together on a given function before moving up the call graph to the callers. The net result is that I am now seeing approximately a 2% reduction in stdlib compile times, with only a single significant performance regression (there are some other minor improvements and regressions, and some major improvements with -Ounchecked). The 2% reduction appears to come largely from the mechanism in the pass manager that skips running passes if we've not made any changes to a function since the last time the pass was run.
1 parent e6d1344 commit 75cdaa3

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

lib/SILOptimizer/PassManager/Passes.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,6 @@ void AddSSAPasses(SILPassManager &PM, OptimizationLevelKind OpLevel) {
239239
PM.addEarlyCodeMotion();
240240
PM.addARCSequenceOpts();
241241

242-
PM.addSILLinker();
243-
244242
PM.addSimplifyCFG();
245243
// Only hoist releases very late.
246244
if (OpLevel == OptimizationLevelKind::LowLevel)
@@ -264,7 +262,7 @@ void swift::runSILOptimizationPasses(SILModule &Module) {
264262
return;
265263
}
266264

267-
SILPassManager PM(&Module, "PreSpecialize");
265+
SILPassManager PM(&Module, "EarlyModulePasses");
268266

269267
// Get rid of apparently dead functions as soon as possible so that
270268
// we do not spend time optimizing them.
@@ -275,15 +273,15 @@ void swift::runSILOptimizationPasses(SILModule &Module) {
275273
PM.resetAndRemoveTransformations();
276274

277275
// Run an iteration of the high-level SSA passes.
278-
PM.setStageName("HighLevel");
276+
PM.setStageName("HighLevel+EarlyLoopOpt");
279277
AddSSAPasses(PM, OptimizationLevelKind::HighLevel);
278+
AddHighLevelLoopOptPasses(PM);
280279
PM.runOneIteration();
281280
PM.resetAndRemoveTransformations();
282281

283-
PM.setStageName("EarlyLoopOpt");
284-
AddHighLevelLoopOptPasses(PM);
285-
282+
PM.setStageName("MidModulePasses+StackPromote");
286283
PM.addDeadFunctionElimination();
284+
PM.addSILLinker();
287285
PM.addDeadObjectElimination();
288286
PM.addGlobalPropertyOpt();
289287

0 commit comments

Comments
 (0)