Files
swift-mirror/test/IRGen/objc_casts.sil
Roman Levenstein 4cef619c19 Revert "Verify SIL modules at the beginning and at the end of the SIL optimization pipelines, if -sil-verify-all is provided"
This reverts commit r31863, which was committed by mistake.

Swift SVN r31864
2015-09-10 22:32:36 +00:00

24 lines
1.1 KiB
Plaintext

// RUN: rm -rf %t && mkdir %t
// RUN: %build-irgen-test-overlays
// RUN: %target-swift-frontend(mock-sdk: -sdk %S/Inputs -I %t) -primary-file %s -emit-ir | FileCheck --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize %s
// REQUIRES: objc_interop
import Foundation
// CHECK-LABEL: define hidden %CSo8NSObject* @checkedClassBoundCast(%swift.type*, %CSo8NSObject*, %swift.type* %T) #0 {
// CHECK: [[OPAQUE_OBJ:%.+]] = bitcast %CSo8NSObject* %1 to i8*
// CHECK: [[OPAQUE_CLASS:%.+]] = bitcast %swift.type* %T to i8*
// CHECK: [[OPAQUE_RESULT:%.+]] = call i8* @swift_dynamicCastUnknownClassUnconditional(i8* [[OPAQUE_OBJ]], i8* [[OPAQUE_CLASS]])
// CHECK: [[RESULT:%.+]] = bitcast i8* [[OPAQUE_RESULT]] to %CSo8NSObject*
// CHECK: ret %CSo8NSObject* [[RESULT]]
// CHECK: {{^}$}}
sil hidden @checkedClassBoundCast : $@convention(thin) <T where T : NSObject> (@thick T.Type, @owned NSObject) -> @owned T {
bb0(%unused : $@thick T.Type, %obj : $NSObject):
strong_retain %obj : $NSObject
%result = unconditional_checked_cast %obj : $NSObject to $T
strong_release %obj : $NSObject
return %result : $T
}