File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed
lib/SILOptimizer/SemanticARC Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -805,7 +805,9 @@ bool SemanticARCOptVisitor::tryPerformOwnedCopyValueOptimization(
805
805
// Ok, we have an owned value. If we do not have any non-destroying consuming
806
806
// uses, see if all of our uses (ignoring destroying uses) are within our
807
807
// parent owned value's lifetime.
808
- LinearLifetimeChecker checker (&ctx.getDeadEndBlocks ());
808
+ // Note: we cannot optimistically ignore DeadEndBlocks - unlike for ownership
809
+ // verification.
810
+ LinearLifetimeChecker checker (nullptr );
809
811
if (!checker.validateLifetime (originalValue, parentLifetimeEndingUses,
810
812
allCopyUses))
811
813
return false ;
Original file line number Diff line number Diff line change 1
1
// RUN: %target-sil-opt -module-name Swift -enable-sil-verify-all -semantic-arc-opts -sil-semantic-arc-peepholes-redundant-copyvalue-elim %s | %FileCheck %s
2
- // REQUIRES: swift_stdlib_asserts
3
2
4
3
// NOTE: Some of our tests here depend on borrow elimination /not/ running!
5
4
// Please do not add it to clean up the IR like we did in
@@ -59,6 +58,11 @@ extension Klass : MyFakeAnyObject {
59
58
sil [ossa] @guaranteed_klass_user : $@convention(thin) (@guaranteed Klass) -> ()
60
59
sil [ossa] @guaranteed_fakeoptional_klass_user : $@convention(thin) (@guaranteed FakeOptional<Klass>) -> ()
61
60
sil [ossa] @guaranteed_fakeoptional_classlet_user : $@convention(thin) (@guaranteed FakeOptional<ClassLet>) -> ()
61
+ sil [ossa] @create_klass : $@convention(thin) () -> @owned Klass
62
+
63
+ struct ContainsKlass {
64
+ var x: Klass
65
+ }
62
66
63
67
struct MyInt {
64
68
var value: Builtin.Int32
@@ -186,3 +190,17 @@ bb3:
186
190
return %9999 : $()
187
191
}
188
192
193
+ // CHECK-LABEL: sil [ossa] @copy_in_deadend_block :
194
+ // CHECK: copy_value
195
+ // CHECK: } // end sil function 'copy_in_deadend_block'
196
+ sil [ossa] @copy_in_deadend_block : $@convention(thin) (@inout ContainsKlass) -> () {
197
+ bb0(%1 : $*ContainsKlass):
198
+ %129 = function_ref @create_klass : $@convention(thin) () -> @owned Klass
199
+ %130 = apply %129() : $@convention(thin) () -> @owned Klass
200
+ %131 = copy_value %130
201
+ %133 = struct $ContainsKlass (%130)
202
+ store %133 to [assign] %1
203
+ fix_lifetime %131
204
+ destroy_value %131
205
+ unreachable
206
+ }
You can’t perform that action at this time.
0 commit comments