diff --git a/include/swift/SIL/SILNodes.def b/include/swift/SIL/SILNodes.def index 041737d4d86fa..5362378146532 100644 --- a/include/swift/SIL/SILNodes.def +++ b/include/swift/SIL/SILNodes.def @@ -574,8 +574,10 @@ ABSTRACT_VALUE_AND_INST(SingleValueInstruction, ValueBase, SILInstruction) SingleValueInstruction, MayHaveSideEffects, DoesNotRelease) SINGLE_VALUE_INST(CopyBlockWithoutEscapingInst, copy_block_without_escaping, SingleValueInstruction, MayHaveSideEffects, DoesNotRelease) + // A copy_value's retain semantics are fully encapsulated in OSSA + // invariants. It has no side effects relative to other OSSA values. BRIDGED_SINGLE_VALUE_INST(CopyValueInst, copy_value, - SingleValueInstruction, MayHaveSideEffects, DoesNotRelease) + SingleValueInstruction, None, DoesNotRelease) #define UNCHECKED_REF_STORAGE(Name, name, ...) \ SINGLE_VALUE_INST(StrongCopy##Name##ValueInst, strong_copy_##name##_value, \ SingleValueInstruction, MayHaveSideEffects, DoesNotRelease) diff --git a/test/SILOptimizer/cse_apply_ossa.sil b/test/SILOptimizer/cse_apply_ossa.sil index 3713a24328181..eac5f22c51e3c 100644 --- a/test/SILOptimizer/cse_apply_ossa.sil +++ b/test/SILOptimizer/cse_apply_ossa.sil @@ -122,11 +122,11 @@ bb0(%0 : $Int64): return %14 : $Int64 } -// CHECK-LABEL: sil [ossa] @dont_cse_retain_only_apply : -// CHECK: %{{[0-9]+}} = apply -// CHECK: %{{[0-9]+}} = apply -// CHECK-LABEL:} // end sil function 'dont_cse_retain_only_apply' -sil [ossa] @dont_cse_retain_only_apply : $@convention(thin) () -> () { +// CHECK-LABEL: sil [ossa] @cse_retain_only_apply : +// CHECK: apply +// CHECK-NOT: apply +// CHECK-LABEL:} // end sil function 'cse_retain_only_apply' +sil [ossa] @cse_retain_only_apply : $@convention(thin) () -> () { bb0: %f = function_ref @retain_only : $@convention(thin) () -> @owned XX %a1 = apply %f() : $@convention(thin) () -> @owned XX @@ -169,7 +169,7 @@ bb0(%0 : @guaranteed $Klass): // CHECK-LABEL: sil [ossa] @apply_nontrivial_test2 : // CHECK: apply -// CHECK: apply +// CHECK-NOT: apply // CHECK-LABEL:} // end sil function 'apply_nontrivial_test2' sil [ossa] @apply_nontrivial_test2 : $@convention(thin) (@guaranteed Klass) -> () { bb0(%0 : @guaranteed $Klass): diff --git a/test/SILOptimizer/sil_combine_ossa.sil b/test/SILOptimizer/sil_combine_ossa.sil index dfef85df1f402..08405102d04f5 100644 --- a/test/SILOptimizer/sil_combine_ossa.sil +++ b/test/SILOptimizer/sil_combine_ossa.sil @@ -772,14 +772,18 @@ sil [ossa] @unbalanced_closure : $@convention(thin) (@guaranteed B) -> () // CHECK-NOT: partial_apply // Check that the arguments of the closure are released after its last use // CHECK-NEXT: destroy_value %0 : $B -// CHECK-NEXT: unreachable +// CHECK-NEXT: tuple +// CHECK-NEXT: return // CHECK: } // end sil function 'partial_apply_unbalanced_retain_release' sil [ossa] @partial_apply_unbalanced_retain_release : $@convention(thin) (@owned B) -> () { bb0(%0 : @owned $B): %1 = function_ref @unbalanced_closure : $@convention(thin) (@guaranteed B) -> () %2 = partial_apply %1(%0) : $@convention(thin) (@guaranteed B) -> () %2a = copy_value %2 : $@callee_owned () -> () - unreachable + destroy_value %2 : $@callee_owned () -> () + destroy_value %2a : $@callee_owned () -> () + %99 = tuple () + return %99 : $() } class C1 {}