mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
32 lines
1.4 KiB
Plaintext
32 lines
1.4 KiB
Plaintext
// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -emit-ir %s | %FileCheck %s
|
|
|
|
import Swift
|
|
|
|
// CHECK-LABEL: define{{( protected)?}} void @c_native_function_pointer(void ()*)
|
|
sil @c_native_function_pointer : $@convention(c) (@convention(c) () -> ()) -> () {
|
|
entry(%f : $@convention(c) () -> ()):
|
|
return undef : $()
|
|
}
|
|
|
|
// CHECK-LABEL: define{{( protected)?}} swiftcc void @call_with_native_c_function_pointer(i8*)
|
|
sil @call_with_native_c_function_pointer : $@convention(thin) (@convention(c) () -> ()) -> () {
|
|
entry(%f : $@convention(c) () -> ()):
|
|
%c = function_ref @c_native_function_pointer : $@convention(c) (@convention(c) () -> ()) -> ()
|
|
%z = apply %c(%f) : $@convention(c) (@convention(c) () -> ()) -> ()
|
|
return %z : $()
|
|
}
|
|
|
|
// CHECK-LABEL: define{{( protected)?}} swiftcc %swift.type* @c_function_pointer_metadata()
|
|
sil @c_function_pointer_metadata : $@convention(thin) () -> @thick Any.Type {
|
|
entry:
|
|
// CHECK: call %swift.type* @_T0yyXCMa()
|
|
%m = metatype $@thick (@convention(c) () -> ()).Type
|
|
%a = init_existential_metatype %m : $@thick (@convention(c) () -> ()).Type, $@thick Any.Type
|
|
return %a : $@thick Any.Type
|
|
}
|
|
|
|
// CHECK-LABEL: define linkonce_odr hidden %swift.type* @_T0yyXCMa()
|
|
// -- 0x3000001 -- C convention, 1 argument
|
|
// CHECK: call %swift.type* @swift_getFunctionTypeMetadata1([[WORD:i(32|64)]] 50331649
|
|
|