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(
805805 // Ok, we have an owned value. If we do not have any non-destroying consuming
806806 // uses, see if all of our uses (ignoring destroying uses) are within our
807807 // 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 );
809811 if (!checker.validateLifetime (originalValue, parentLifetimeEndingUses,
810812 allCopyUses))
811813 return false ;
Original file line number Diff line number Diff line change 11// 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
32
43// NOTE: Some of our tests here depend on borrow elimination /not/ running!
54// Please do not add it to clean up the IR like we did in
@@ -59,6 +58,11 @@ extension Klass : MyFakeAnyObject {
5958sil [ossa] @guaranteed_klass_user : $@convention(thin) (@guaranteed Klass) -> ()
6059sil [ossa] @guaranteed_fakeoptional_klass_user : $@convention(thin) (@guaranteed FakeOptional<Klass>) -> ()
6160sil [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+ }
6266
6367struct MyInt {
6468 var value: Builtin.Int32
@@ -186,3 +190,17 @@ bb3:
186190 return %9999 : $()
187191}
188192
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