@@ -129,9 +129,30 @@ static void addMandatoryDiagnosticOptPipeline(SILPassPipelinePlan &P) {
129129 P.addNoReturnFolding ();
130130 addDefiniteInitialization (P);
131131
132+ P.addAddressLowering ();
133+
134+ P.addFlowIsolation ();
135+
136+ // Automatic differentiation: canonicalize all differentiability witnesses
137+ // and `differentiable_function` instructions.
138+ P.addDifferentiation ();
139+
140+ // Only run semantic arc opts if we are optimizing and if mandatory semantic
141+ // arc opts is explicitly enabled.
142+ //
143+ // NOTE: Eventually this pass will be split into a mandatory/more aggressive
144+ // pass. This will happen when OSSA is no longer eliminated before the
145+ // optimizer pipeline is run implying we can put a pass that requires OSSA
146+ // there.
147+ const auto &Options = P.getOptions ();
148+ P.addClosureLifetimeFixup ();
149+
132150 // ===---
133151 // Begin Ownership Optimizations
134152 //
153+ // These happen after ClosureLifetimeFixup because they depend on the
154+ // resolution of nonescaping closure lifetimes to correctly check the use
155+ // of move-only values as captures in nonescaping closures as borrows.
135156
136157 // Check noImplicitCopy and move only types for addresses.
137158 P.addMoveOnlyAddressChecker ();
@@ -150,24 +171,6 @@ static void addMandatoryDiagnosticOptPipeline(SILPassPipelinePlan &P) {
150171 // End Ownership Optimizations
151172 // ===---
152173
153- P.addAddressLowering ();
154-
155- P.addFlowIsolation ();
156-
157- // Automatic differentiation: canonicalize all differentiability witnesses
158- // and `differentiable_function` instructions.
159- P.addDifferentiation ();
160-
161- // Only run semantic arc opts if we are optimizing and if mandatory semantic
162- // arc opts is explicitly enabled.
163- //
164- // NOTE: Eventually this pass will be split into a mandatory/more aggressive
165- // pass. This will happen when OSSA is no longer eliminated before the
166- // optimizer pipeline is run implying we can put a pass that requires OSSA
167- // there.
168- const auto &Options = P.getOptions ();
169- P.addClosureLifetimeFixup ();
170-
171174#ifndef NDEBUG
172175 // Add a verification pass to check our work when skipping
173176 // function bodies.
0 commit comments