Skip to content

Commit 69b5d4a

Browse files
committed
[move-only] Disable move-only devirtualization.
It is not needed for correctness and hides most of the deinit related optimizer bugs.
1 parent e6d697b commit 69b5d4a

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

lib/SILOptimizer/PassManager/PassPipeline.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,6 @@ static void addMandatoryDiagnosticOptPipeline(SILPassPipelinePlan &P) {
156156

157157
// Check noImplicitCopy and move only types for objects and addresses.
158158
P.addMoveOnlyChecker();
159-
// Convert last destroy_value to deinits.
160-
P.addMoveOnlyDeinitDevirtualization();
161159
// Lower move only wrapped trivial types.
162160
P.addTrivialMoveOnlyTypeEliminator();
163161
// Check no uses after consume operator of a value in an address.

lib/SILOptimizer/Transforms/MoveOnlyDeinitDevirtualization.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@
1515
/// This pass runs after move only checking has occurred and transforms last
1616
/// destroy_value of move only types into a call to the move only types deinit.
1717
///
18+
/// TODO: This pass is disabled because it hides bugs in the common case in
19+
/// which optimization passes incorrectly remove the deinit, for example, by
20+
/// destructuring the aggregate rather than destroying it as a whole. Consider
21+
/// reeabling this pass later in the pipeline, after all other OSSA function
22+
/// passes have run. Also consider removing bailouts from this pass. If it's
23+
/// possible to devirtualize, then it should do it.
24+
///
1825
//===----------------------------------------------------------------------===//
1926

2027
#define DEBUG_TYPE "sil-move-only-checker"

test/SILOptimizer/moveonly_lifetime.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ func something()
3838
// CHECK: apply [[BORROW_C]]([[INSTANCE]])
3939
//
4040
// TODO: Once we maximize lifetimes this should be below something.
41-
// CHECK: [[DESTROY_C:%[^,]+]] = function_ref @$s17moveonly_lifetime1CVfD
42-
// CHECK: [[INSTANCE:%.*]] = load [take] [[STACK]]
43-
// CHECK: apply [[DESTROY_C]]([[INSTANCE]])
41+
// CHECK: destroy_addr [[STACK]]
4442
//
4543
// CHECK: [[SOMETHING:%[^,]+]] = function_ref @something
4644
// CHECK: apply [[SOMETHING]]

0 commit comments

Comments
 (0)