Skip to content

Commit 0032b38

Browse files
committed
[move-only] Move move function kills values checking and move only value lifetime checking before diagnostic constant prop.
This is part of a larger piece of work that is going to introduce the ability in SIL for us to wrap trivial values in a move only type wrapper and thus perform ownership based diagnostics upon those trivial values. This is being done now so that we can perform SSA based ownership diagnostics on trivial types. This will allow us to eventually be able to do things like no escape analysis on UnsafePointer. That all sounds great, but also we must consider how this effects the rest of the optimizer. For instance, what if we want to have a no escape integer and have overflow checks used upon it! To ensure that we can do this, the authors realized that we did not need to persist the ownership information so late in that part of the pipeline and we can just do the ownership checking earlier than constant propagation and then lower. This is safe to do since the rest of the optimizer will not introduce escapes of a pointer or extra copies unlike if the underlying non move only type variant was also non-trivial. With that in hand, this PR moves these two move only passes earlier than constant propagation for this purpose. The reason they were put in the current position vs earlier is that I wanted them to run after predictable dead allocation elimination since it cleaned up the SIL I was reading as I designed it. There isn't any reason that they can't run earlier. Once I bring in the new SIL move only type wrapper, after these run, the trivial type lowering will then run.
1 parent b6a4923 commit 0032b38

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

lib/SILOptimizer/PassManager/PassPipeline.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,12 @@ static void addMandatoryDiagnosticOptPipeline(SILPassPipelinePlan &P) {
157157
// SSA based diagnostics.
158158
P.addPredictableMemoryAccessOptimizations();
159159

160+
// Now that we have promoted simple loads for SSA based diagnostics, perform
161+
// SSA based move function checking and no implicit copy checking.
162+
P.addMoveKillsCopyableValuesChecker(); // No uses after _move of copyable
163+
// value.
164+
P.addMoveOnlyChecker(); // Check noImplicitCopy isn't copied.
165+
160166
// This phase performs optimizations necessary for correct interoperation of
161167
// Swift os log APIs with C os_log ABIs.
162168
// Pass dependencies: this pass depends on MandatoryInlining and Mandatory
@@ -173,11 +179,6 @@ static void addMandatoryDiagnosticOptPipeline(SILPassPipelinePlan &P) {
173179
// dead allocations.
174180
P.addPredictableDeadAllocationElimination();
175181

176-
// Now perform move semantic checking.
177-
P.addMoveKillsCopyableValuesChecker(); // No uses after _move of copyable
178-
// value.
179-
P.addMoveOnlyChecker(); // Check noImplicitCopy isn't copied.
180-
181182
// Now that we have finished performing diagnostics that rely on lexical
182183
// scopes, if lexical lifetimes are not enabled, eliminate lexical lfietimes.
183184
if (Options.LexicalLifetimes != LexicalLifetimesOption::On) {

0 commit comments

Comments
 (0)