File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed
lib/SILOptimizer/Transforms Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -63,6 +63,11 @@ static bool seemsUseful(SILInstruction *I) {
63
63
if (I->mayHaveSideEffects ())
64
64
return true ;
65
65
66
+ if (llvm::any_of (I->getResults (),
67
+ [](auto result) { return result->isLexical (); })) {
68
+ return true ;
69
+ }
70
+
66
71
if (auto *BI = dyn_cast<BuiltinInst>(I)) {
67
72
// Although the onFastPath builtin has no side-effects we don't want to
68
73
// remove it.
Original file line number Diff line number Diff line change @@ -13,6 +13,9 @@ typealias Int1 = Builtin.Int1
13
13
14
14
class C {}
15
15
16
+ sil @getC : $@convention(thin) () -> @owned C
17
+ sil @barrier : $@convention(thin) () -> ()
18
+
16
19
struct CAndBit {
17
20
var c: C
18
21
var bit: Int1
@@ -468,3 +471,20 @@ bb3:
468
471
%22 = tuple ()
469
472
return %22 : $()
470
473
}
474
+
475
+ // CHECK-LABEL: sil [ossa] @dont_delete_move_value_lexical : {{.*}} {
476
+ // CHECK: [[LEXICAL:%[^,]+]] = move_value [lexical]
477
+ // CHECK: [[DUMMY:%[^,]+]] = function_ref @dummy
478
+ // CHECK: apply [[DUMMY]]()
479
+ // CHECK: destroy_value [[LEXICAL]]
480
+ // CHECK-LABEL: } // end sil function 'dont_delete_move_value_lexical'
481
+ sil [ossa] @dont_delete_move_value_lexical : $@convention(thin) () -> () {
482
+ %getC = function_ref @getC : $@convention(thin) () -> @owned C
483
+ %c = apply %getC() : $@convention(thin) () -> @owned C
484
+ %m = move_value [lexical] %c : $C
485
+ %dummy = function_ref @dummy : $@convention(thin) () -> ()
486
+ apply %dummy() : $@convention(thin) () -> ()
487
+ destroy_value %m : $C
488
+ %retval = tuple ()
489
+ return %retval : $()
490
+ }
You can’t perform that action at this time.
0 commit comments