File tree Expand file tree Collapse file tree 5 files changed +38
-11
lines changed
include/swift/SILOptimizer/Utils Expand file tree Collapse file tree 5 files changed +38
-11
lines changed Original file line number Diff line number Diff line change @@ -368,9 +368,7 @@ class CanonicalizeOSSALifetime final {
368
368
currentDef = def;
369
369
currentLexicalLifetimeEnds = lexicalLifetimeEnds;
370
370
371
- if (maximizeLifetime || respectsDeinitBarriers ()) {
372
- liveness->initializeDiscoveredBlocks (&discoveredBlocks);
373
- }
371
+ liveness->initializeDiscoveredBlocks (&discoveredBlocks);
374
372
liveness->initializeDef (getCurrentDef ());
375
373
}
376
374
Original file line number Diff line number Diff line change @@ -1356,8 +1356,8 @@ bool CanonicalizeOSSALifetime::computeLiveness() {
1356
1356
clear ();
1357
1357
return false ;
1358
1358
}
1359
+ extendLivenessToDeadEnds ();
1359
1360
if (respectsDeinitBarriers ()) {
1360
- extendLivenessToDeadEnds ();
1361
1361
extendLivenessToDeinitBarriers ();
1362
1362
}
1363
1363
if (accessBlockAnalysis) {
Original file line number Diff line number Diff line change @@ -28,8 +28,8 @@ func checkResult(_ plaintext: [UInt8]) {
28
28
29
29
@_semantics ( " optremark.sil-assembly-vision-remark-gen " )
30
30
public func run_ChaCha( _ N: Int ) {
31
- let key = Array ( repeating: UInt8 ( 1 ) , count: 32 ) // expected-remark {{release of type ' }}
32
- let nonce = Array ( repeating: UInt8 ( 2 ) , count: 12 ) // expected-remark {{release of type ' }}
31
+ let key = Array ( repeating: UInt8 ( 1 ) , count: 32 ) // expected-note {{of 'key }}
32
+ let nonce = Array ( repeating: UInt8 ( 2 ) , count: 12 ) // expected-note {{of 'nonce }}
33
33
34
34
var checkedtext = Array ( repeating: UInt8 ( 0 ) , count: 1024 ) // expected-note {{of 'checkedtext}}
35
35
ChaCha20 . encrypt ( bytes: & checkedtext, key: key, nonce: nonce)
@@ -44,3 +44,5 @@ public func run_ChaCha(_ N: Int) {
44
44
}
45
45
} // expected-remark {{release of type '}}
46
46
// expected-remark @-1 {{release of type '}}
47
+ // expected-remark @-2 {{release of type '}}
48
+ // expected-remark @-3 {{release of type '}}
Original file line number Diff line number Diff line change @@ -885,6 +885,33 @@ die:
885
885
unreachable
886
886
}
887
887
888
+ // CHECK-LABEL: begin running test {{.*}} on consume_copy_before_use_in_dead_end_2
889
+ // CHECK-LABEL: sil [ossa] @consume_copy_before_use_in_dead_end_2 : {{.*}} {
890
+ // CHECK-NOT: destroy_value [dead_end]
891
+ // CHECK-LABEL: } // end sil function 'consume_copy_before_use_in_dead_end_2'
892
+ // CHECK-LABEL: end running test {{.*}} on consume_copy_before_use_in_dead_end_2
893
+ sil [ossa] @consume_copy_before_use_in_dead_end_2 : $@convention(thin) (@owned C) -> () {
894
+ entry(%c : @owned $C):
895
+ cond_br undef, exit, die
896
+
897
+ exit:
898
+ destroy_value %c
899
+ %retval = tuple ()
900
+ return %retval
901
+
902
+ die:
903
+ %move = move_value %c
904
+ %copy = copy_value %move
905
+ specify_test "canonicalize_ossa_lifetime true false true %move"
906
+ apply undef(%move) : $@convention(thin) (@owned C) -> ()
907
+ %addr = alloc_stack $C
908
+ %token = store_borrow %copy to %addr
909
+ apply undef() : $@convention(thin) () -> ()
910
+ %reload = load_borrow %token
911
+ apply undef(%reload) : $@convention(thin) (@guaranteed C) -> ()
912
+ unreachable
913
+ }
914
+
888
915
// The destroy of a value must not be hoisted over a destroy of a copy of a
889
916
// partial_apply [on_stack] which captures the value.
890
917
// CHECK-LABEL: begin running test {{.*}} on destroy_after_pa_copy_destroy
Original file line number Diff line number Diff line change @@ -838,13 +838,13 @@ bb4:
838
838
839
839
// Test a dead begin_borrow (with no scope ending uses). Make sure
840
840
// copy-propagation doesn't end the lifetime before the dead borrow.
841
+ // (Indeed, it doesn't end the lifetime at all.)
841
842
//
842
843
// CHECK-LABEL: sil hidden [ossa] @testDeadBorrow : {{.*}} {
843
- // CHECK: bb0:
844
- // CHECK-NOT: copy_value
845
- // CHECK: begin_borrow
846
- // CHECK: destroy_value
847
- // CHECK: unreachable
844
+ // CHECK: bb0:
845
+ // CHECK-NOT: copy_value
846
+ // CHECK: begin_borrow
847
+ // CHECK-NEXT: unreachable
848
848
// CHECK-LABEL: } // end sil function 'testDeadBorrow'
849
849
sil hidden [ossa] @testDeadBorrow : $@convention(thin) () -> () {
850
850
bb0:
You can’t perform that action at this time.
0 commit comments