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) {
6363 if (I->mayHaveSideEffects ())
6464 return true ;
6565
66+ if (llvm::any_of (I->getResults (),
67+ [](auto result) { return result->isLexical (); })) {
68+ return true ;
69+ }
70+
6671 if (auto *BI = dyn_cast<BuiltinInst>(I)) {
6772 // Although the onFastPath builtin has no side-effects we don't want to
6873 // remove it.
Original file line number Diff line number Diff line change @@ -13,6 +13,9 @@ typealias Int1 = Builtin.Int1
1313
1414class C {}
1515
16+ sil @getC : $@convention(thin) () -> @owned C
17+ sil @barrier : $@convention(thin) () -> ()
18+
1619struct CAndBit {
1720 var c: C
1821 var bit: Int1
@@ -468,3 +471,20 @@ bb3:
468471 %22 = tuple ()
469472 return %22 : $()
470473}
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