File tree 3 files changed +23
-1
lines changed
lib/SILOptimizer/Mandatory
3 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -8265,6 +8265,7 @@ class MoveValueInst
8265
8265
void setAllowsDiagnostics (bool newValue) { allowDiagnostics = newValue; }
8266
8266
8267
8267
bool isLexical () const { return lexical; };
8268
+ void removeIsLexical () { lexical = false ; }
8268
8269
};
8269
8270
8270
8271
// / Equivalent to a copy_addr to [init] except that it is used for diagnostics
Original file line number Diff line number Diff line change @@ -46,7 +46,13 @@ class LexicalLifetimeEliminatorPass : public SILFunctionTransform {
46
46
}
47
47
continue ;
48
48
}
49
-
49
+ if (auto *mvi = dyn_cast<MoveValueInst>(&inst)) {
50
+ if (mvi->isLexical ()) {
51
+ mvi->removeIsLexical ();
52
+ madeChange = true ;
53
+ }
54
+ continue ;
55
+ }
50
56
if (auto *asi = dyn_cast<AllocStackInst>(&inst)) {
51
57
if (asi->isLexical ()) {
52
58
asi->removeIsLexical ();
Original file line number Diff line number Diff line change @@ -6,6 +6,8 @@ import Builtin
6
6
7
7
class Klass {}
8
8
9
+ sil @getKlass : $() -> (@owned Klass)
10
+
9
11
// CHECK-LABEL: sil [ossa] @lexical_lifetime_object : $@convention(thin) (@owned Klass) -> () {
10
12
// CHECK: bb0(%0 : @owned $Klass):
11
13
// CHECK-NEXT: %1 = begin_borrow %0 : $Klass
@@ -23,6 +25,19 @@ bb0(%0 : @owned $Klass):
23
25
return %9999 : $()
24
26
}
25
27
28
+ // CHECK-LABEL: sil [ossa] @lexical_lifetime_move : {{.*}} {
29
+ // CHECK-NOT: move_value [lexical]
30
+ // CHECK: move_value
31
+ // CHECK-LABEL: } // end sil function 'lexical_lifetime_move'
32
+ sil [ossa] @lexical_lifetime_move : $@convention(thin) () -> () {
33
+ %getKlass = function_ref @getKlass : $@convention(thin) () -> (@owned Klass)
34
+ %instance = apply %getKlass() : $@convention(thin) () -> (@owned Klass)
35
+ %lifetime = move_value [lexical] %instance : $Klass
36
+ destroy_value %lifetime : $Klass
37
+ %retval = tuple ()
38
+ return %retval : $()
39
+ }
40
+
26
41
// CHECK-LABEL: sil [ossa] @lexical_lifetime_address : $@convention(thin) (@in Klass) -> () {
27
42
// CHECK: bb0(%0 : $*Klass):
28
43
// CHECK-NEXT: %1 = alloc_stack $Klass
You can’t perform that action at this time.
0 commit comments