mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
We didn't serialize the ownership kind, which resulted in a miscompile causing an over-release. The unchecked_ref_cast is the only instruction for which we change the ownership in the optimizer, so that it doesn't match the operand's ownership. Therefore this fix is sufficient for now - we don't need to serialize the ownership of other instructions. But this is really a design flaw of the `OwnershipForwardingMixin`. It should not allow to set the ownership to arbitrary values. rdar://92696202
22 lines
670 B
Plaintext
22 lines
670 B
Plaintext
// RUN: %empty-directory(%t)
|
|
// RUN: %target-build-swift -emit-module -module-name ossa -o %t/ossa.swiftmodule %s
|
|
// RUN: %target-sil-opt %t/ossa.swiftmodule | %FileCheck %s
|
|
|
|
sil_stage canonical
|
|
|
|
import Builtin
|
|
import Swift
|
|
import SwiftShims
|
|
|
|
class X {}
|
|
|
|
// CHECK-LABEL: sil [serialized] [canonical] [ossa] @test_unchecked_ref_cast
|
|
sil [serialized] [ossa] @test_unchecked_ref_cast : $@convention(thin) (@guaranteed AnyObject) -> @owned X {
|
|
bb0(%0 : @guaranteed $AnyObject):
|
|
// CHECK: %1 = unchecked_ref_cast %0 : $AnyObject to $X, forwarding: @unowned
|
|
%1 = unchecked_ref_cast %0 : $AnyObject to $X, forwarding: @unowned
|
|
%2 = copy_value %1 : $X
|
|
return %2 : $X
|
|
}
|
|
|