Skip to content

Commit 11b76da

Browse files
committed
[OME] Lower move_value to a noop.
1 parent 6caa504 commit 11b76da

File tree

4 files changed

+22
-15
lines changed

4 files changed

+22
-15
lines changed

lib/SILOptimizer/Mandatory/OwnershipModelEliminator.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ struct OwnershipModelEliminatorVisitor
135135
bool visitExplicitCopyValueInst(ExplicitCopyValueInst *cvi);
136136
bool visitDestroyValueInst(DestroyValueInst *dvi);
137137
bool visitLoadBorrowInst(LoadBorrowInst *lbi);
138+
bool visitMoveValueInst(MoveValueInst *mvi) {
139+
eraseInstructionAndRAUW(mvi, mvi->getOperand());
140+
return true;
141+
}
138142
bool visitBeginBorrowInst(BeginBorrowInst *bbi) {
139143
eraseInstructionAndRAUW(bbi, bbi->getOperand());
140144
return true;

test/SILGen/moveonly_deinits.swift

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ var value: Bool { false }
7272
// SILGEN: } // end sil function '$s16moveonly_deinits24testIntPairWithoutDeinityyF'
7373

7474
// SIL-LABEL: sil @$s16moveonly_deinits24testIntPairWithoutDeinityyF : $@convention(thin) () -> () {
75-
// SIL: [[VALUE:%.*]] = move_value [lexical]
75+
// SIL: [[CONSTRUCTOR:%[^,]+]] = function_ref @$s16moveonly_deinits20IntPairWithoutDeinitVACycfC
76+
// SIL: [[VALUE:%.*]] = apply [[CONSTRUCTOR]]
7677
// SIL: cond_br {{%.*}}, bb1, bb2
7778
//
7879
// SIL: bb1:
@@ -113,7 +114,8 @@ public func testIntPairWithoutDeinit() {
113114
// SILGEN: } // end sil function '$s16moveonly_deinits21testIntPairWithDeinityyF'
114115

115116
// SIL-LABEL: sil @$s16moveonly_deinits21testIntPairWithDeinityyF : $@convention(thin) () -> () {
116-
// SIL: [[VALUE:%.*]] = move_value [lexical]
117+
// SIL: [[CONSTRUCTOR:%[^,]+]] = function_ref @$s16moveonly_deinits17IntPairWithDeinitVACycfC
118+
// SIL: [[VALUE:%.*]] = apply [[CONSTRUCTOR]]
117119
// SIL: cond_br {{%.*}}, bb1, bb2
118120
//
119121
// SIL: bb1:
@@ -155,7 +157,8 @@ public func testIntPairWithDeinit() {
155157
// SILGEN: } // end sil function '$s16moveonly_deinits26testKlassPairWithoutDeinityyF'
156158

157159
// SIL-LABEL: sil @$s16moveonly_deinits26testKlassPairWithoutDeinityyF : $@convention(thin) () -> () {
158-
// SIL: [[VALUE:%.*]] = move_value [lexical]
160+
// SIL: [[CONSTRUCTOR:%[^,]+]] = function_ref @$s16moveonly_deinits22KlassPairWithoutDeinitVACycfC
161+
// SIL: [[VALUE:%.*]] = apply [[CONSTRUCTOR]]
159162
// SIL: cond_br {{%.*}}, bb1, bb2
160163
//
161164
// SIL: bb1:
@@ -196,7 +199,8 @@ public func testKlassPairWithoutDeinit() {
196199
// SILGEN: } // end sil function '$s16moveonly_deinits23testKlassPairWithDeinityyF'
197200

198201
// SIL-LABEL: sil @$s16moveonly_deinits23testKlassPairWithDeinityyF : $@convention(thin) () -> () {
199-
// SIL: [[VALUE:%.*]] = move_value [lexical]
202+
// SIL: [[CONSTRUCTOR:%[^,]+]] = function_ref @$s16moveonly_deinits19KlassPairWithDeinitVACycfC
203+
// SIL: [[VALUE:%.*]] = apply [[CONSTRUCTOR]]
200204
// SIL: cond_br {{%.*}}, bb1, bb2
201205
//
202206
// SIL: bb1:
@@ -283,7 +287,7 @@ func consumeKlassEnumPairWithDeinit(_ x: __owned KlassEnumPairWithDeinit) { }
283287
// SILGEN: } // end sil function '$s16moveonly_deinits28testIntEnumPairWithoutDeinityyF'
284288

285289
// SIL-LABEL: sil @$s16moveonly_deinits28testIntEnumPairWithoutDeinityyF : $@convention(thin) () -> () {
286-
// SIL: [[VALUE:%.*]] = move_value [lexical]
290+
// SIL: [[VALUE:%.*]] = enum $IntEnumPairWithoutDeinit
287291
// SIL: cond_br {{%.*}}, bb1, bb2
288292
//
289293
// SIL: bb1:
@@ -324,7 +328,7 @@ public func testIntEnumPairWithoutDeinit() {
324328
// SILGEN: } // end sil function '$s16moveonly_deinits25testIntEnumPairWithDeinityyF'
325329

326330
// SIL-LABEL: sil @$s16moveonly_deinits25testIntEnumPairWithDeinityyF : $@convention(thin) () -> () {
327-
// SIL: [[VALUE:%.*]] = move_value [lexical]
331+
// SIL: [[VALUE:%.*]] = enum $IntEnumPairWithDeinit
328332
// SIL: cond_br {{%.*}}, bb1, bb2
329333
//
330334
// SIL: bb1:
@@ -366,7 +370,7 @@ public func testIntEnumPairWithDeinit() {
366370
// SILGEN: } // end sil function '$s16moveonly_deinits30testKlassEnumPairWithoutDeinityyF'
367371

368372
// SIL-LABEL: sil @$s16moveonly_deinits30testKlassEnumPairWithoutDeinityyF : $@convention(thin) () -> () {
369-
// SIL: [[VALUE:%.*]] = move_value [lexical]
373+
// SIL: [[VALUE:%.*]] = enum $KlassEnumPairWithoutDeinit
370374
// SIL: cond_br {{%.*}}, bb1, bb2
371375
//
372376
// SIL: bb1:
@@ -407,7 +411,7 @@ public func testKlassEnumPairWithoutDeinit() {
407411
// SILGEN: } // end sil function '$s16moveonly_deinits27testKlassEnumPairWithDeinityyF'
408412

409413
// SIL-LABEL: sil @$s16moveonly_deinits27testKlassEnumPairWithDeinityyF : $@convention(thin) () -> () {
410-
// SIL: [[VALUE:%.*]] = move_value [lexical]
414+
// SIL: [[VALUE:%.*]] = enum $KlassEnumPairWithDeinit
411415
// SIL: cond_br {{%.*}}, bb1, bb2
412416
//
413417
// SIL: bb1:

test/SILGen/newtype.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ import Newtype
1010
// CHECK-CANONICAL-LABEL: sil hidden @$s7newtype17createErrorDomain{{[_0-9a-zA-Z]*}}F
1111
// CHECK-CANONICAL: bb0([[STR:%[0-9]+]] : $String)
1212
func createErrorDomain(str: String) -> ErrorDomain {
13-
// CHECK-CANONICAL: [[MOVED_STR:%[^,]+]] = move_value [lexical] [[STR]]
1413
// CHECK-CANONICAL: [[BRIDGE_FN:%[0-9]+]] = function_ref @{{.*}}_bridgeToObjectiveC
15-
// CHECK-CANONICAL-NEXT: [[BRIDGED:%[0-9]+]] = apply [[BRIDGE_FN]]([[MOVED_STR]])
14+
// CHECK-CANONICAL-NEXT: [[BRIDGED:%[0-9]+]] = apply [[BRIDGE_FN]]([[STR]])
1615
// CHECK-CANONICAL: struct $ErrorDomain ([[BRIDGED]] : $NSString)
1716
return ErrorDomain(rawValue: str)
1817
}

test/SILOptimizer/moveonly_lifetime.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-emit-sil -Onone -verify -enable-experimental-move-only -enable-experimental-feature MoveOnlyClasses %s | %FileCheck %s
1+
// RUN: %target-swift-emit-sil -module-name moveonly_lifetime -o /dev/null -Xllvm -sil-print-canonical-module -Onone -verify -enable-experimental-move-only -enable-experimental-feature MoveOnlyClasses %s 2>&1 | %FileCheck %s
22

33
@_moveOnly
44
class C {}
@@ -19,19 +19,19 @@ func something()
1919
// non-consuming scope where it appears but not further (which would require a
2020
// copy).
2121
//
22-
// CHECK-LABEL: sil hidden @test_diamond__consume_r__use_l : $@convention(thin) (Bool) -> () {
22+
// CHECK-LABEL: sil hidden [ossa] @test_diamond__consume_r__use_l : $@convention(thin) (Bool) -> () {
2323
// CHECK: [[INSTANCE:%[^,]+]] = move_value [lexical] {{%[^,]+}}
2424
// CHECK: cond_br {{%[^,]+}}, [[LEFT:bb[0-9]+]], [[RIGHT:bb[0-9]+]]
25+
// CHECK: [[RIGHT]]:
26+
// CHECK: [[TAKE_C:%[^,]+]] = function_ref @takeC
27+
// CHECK: apply [[TAKE_C]]([[INSTANCE]])
2528
// CHECK: [[LEFT]]:
2629
// CHECK: [[BORROW_C:%[^,]+]] = function_ref @borrowC
2730
// CHECK: apply [[BORROW_C]]([[INSTANCE]])
2831
// CHECK: [[SOMETHING:%[^,]+]] = function_ref @something
2932
// CHECK: apply [[SOMETHING]]
3033
// CHECK: [[DESTROY_C:%[^,]+]] = function_ref @$s17moveonly_lifetime1CCfD
3134
// CHECK: apply [[DESTROY_C]]([[INSTANCE]])
32-
// CHECK: [[RIGHT]]:
33-
// CHECK: [[TAKE_C:%[^,]+]] = function_ref @takeC
34-
// CHECK: apply [[TAKE_C]]([[INSTANCE]])
3535
// CHECK-LABEL: } // end sil function 'test_diamond__consume_r__use_l'
3636
@_silgen_name("test_diamond__consume_r__use_l")
3737
func test_diamond(_ condition: Bool) {

0 commit comments

Comments
 (0)