Skip to content

Commit d1b41e9

Browse files
committed
[ownership] Add an extra run of TempRValueOpt before Semantic ARC Opts.
There is a natural synergy in between the two passes since TempRValueOpt often times eliminates temporaries that prevent Semantic ARC Opts from removing ARC traffic. NOTE: The reason why I am adding an extra run rather than moving the TempRValueOpt that runs slightly after SemanticARCOpts on non-ownership SIL is that the run afterwards is able to run on non-ossa code from the stdlib/etc and eliminate copies that way. With time once we transition to always serializing in OSSA form, we will be able to get rid of that second run.
1 parent c3c5fbc commit d1b41e9

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/SILOptimizer/PassManager/PassPipeline.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,16 +395,21 @@ static void addPerfEarlyModulePassPipeline(SILPassPipelinePlan &P) {
395395
// we do not spend time optimizing them.
396396
P.addDeadFunctionElimination();
397397

398+
// Cleanup after SILGen: remove trivial copies to temporaries.
399+
P.addTempRValueOpt();
400+
// Cleanup after SILGen: remove unneeded borrows/copies.
398401
P.addSemanticARCOpts();
399402

400403
// Strip ownership from non-transparent functions.
401404
if (P.getOptions().StripOwnershipAfterSerialization)
402405
P.addNonTransparentFunctionOwnershipModelEliminator();
403406

404-
// Start by cloning functions from stdlib.
407+
// Start by linking in referenced functions from other modules.
405408
P.addPerformanceSILLinker();
406409

407-
// Cleanup after SILGen: remove trivial copies to temporaries.
410+
// Cleanup after SILGen: remove trivial copies to temporaries. This version of
411+
// temp-rvalue opt is here so that we can hit copies from non-ossa code that
412+
// is linked in from the stdlib.
408413
P.addTempRValueOpt();
409414

410415
// Add the outliner pass (Osize).

0 commit comments

Comments
 (0)