mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
46 lines
1.3 KiB
Plaintext
46 lines
1.3 KiB
Plaintext
// RUN: %target-sil-opt -performance-constant-propagation %s | %FileCheck %s
|
|
|
|
// REQUIRES: objc_interop
|
|
|
|
sil_stage canonical
|
|
|
|
import Builtin
|
|
import Swift
|
|
import Foundation
|
|
|
|
class TestObjCKeyTy : NSObject {
|
|
override init()
|
|
}
|
|
struct TestBridgedKeyTy : _ObjectiveCBridgeable {
|
|
func _bridgeToObjectiveC() -> TestObjCKeyTy
|
|
static func _forceBridgeFromObjectiveC(_ x: TestObjCKeyTy, result: inout TestBridgedKeyTy?)
|
|
static func _conditionallyBridgeFromObjectiveC(_ x: TestObjCKeyTy, result: inout TestBridgedKeyTy?) -> Bool
|
|
static func _unconditionallyBridgeFromObjectiveC(_ source: TestObjCKeyTy?) -> TestBridgedKeyTy
|
|
}
|
|
|
|
// Test that we don't crash in the verifier because of a critical edge
|
|
|
|
// CHECK-LABEL: testit
|
|
// CHECK: checked_cast_br
|
|
sil @testit : $@convention(thin) (@owned NSObject) -> () {
|
|
bb0(%0 : $NSObject):
|
|
%73 = alloc_stack $NSObject
|
|
store %0 to %73 : $*NSObject
|
|
%75 = alloc_stack $Optional<TestBridgedKeyTy>
|
|
%76 = init_enum_data_addr %75 : $*Optional<TestBridgedKeyTy>, #Optional.some!enumelt
|
|
%77 = load %73 : $*NSObject
|
|
checked_cast_addr_br take_always NSObject in %73 : $*NSObject to TestBridgedKeyTy in %76 : $*TestBridgedKeyTy, bb1, bb2
|
|
|
|
bb1:
|
|
br bb3
|
|
|
|
bb2:
|
|
br bb3
|
|
|
|
bb3:
|
|
dealloc_stack %75 : $*Optional<TestBridgedKeyTy>
|
|
dealloc_stack %73 : $*NSObject
|
|
%r = tuple ()
|
|
return %r : $()
|
|
}
|