Skip to content

Commit a624fec

Browse files
committed
[move-only] Move MoveOnlyObjectChecker /before/ MoveOnlyAddressChecker in the pass pipeline and move post checker verification into the MoveOnlyAddressChecker.
The reason why I am doing this is that: 1. There are sometimes copy_value on move only values loaded from memory that the MoveOnlyAddressChecker needs to eliminate. 2. Previously, the move only address checker did not rewrite copy_value -> explicit_copy_value if it failed in diagnostics (it did handle load [copy] and copy_addr though). This could then cause the copy_value elimination verification in the MoveOnlyObjectChecker to then fail. So this suggested that I needed to move the verification from the object checkt to the address checker. 3. If we run the verification in the address checker, then the object checker (which previously ran before the address checker) naturally needed to run /before/ the address checker.
1 parent e70a722 commit a624fec

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

lib/SILOptimizer/Mandatory/MoveOnlyObjectChecker.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,9 @@ class MoveOnlyCheckerPass : public SILFunctionTransform {
806806
if (checker.changed) {
807807
invalidateAnalysis(SILAnalysis::InvalidationKind::Instructions);
808808
}
809+
810+
// NOTE: We validate in the MoveOnlyAddressChecker (which runs after this)
811+
// that we eliminated all copy_value and emit errors otherwise.
809812
}
810813
};
811814

lib/SILOptimizer/PassManager/PassPipeline.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,14 @@ static void addMandatoryDiagnosticOptPipeline(SILPassPipelinePlan &P) {
154154
// resolution of nonescaping closure lifetimes to correctly check the use
155155
// of move-only values as captures in nonescaping closures as borrows.
156156

157-
// Check noImplicitCopy and move only types for addresses.
158-
P.addMoveOnlyAddressChecker();
159157
// Check noImplicitCopy and move only types for objects
158+
//
159+
// NOTE: It is important that this is run /before/ move only address checker
160+
// since if the address checker emits an error, it will cleanup copy_value of
161+
// move only objects meaning that we could lose object level diagnostics.
160162
P.addMoveOnlyObjectChecker();
163+
// Check noImplicitCopy and move only types for addresses.
164+
P.addMoveOnlyAddressChecker();
161165
// Convert last destroy_value to deinits.
162166
P.addMoveOnlyDeinitInsertion();
163167
// Lower move only wrapped trivial types.

0 commit comments

Comments
 (0)