mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
This matches how dispatch_once works in C, dramatically cutting the cost of a global accessor by avoiding the runtime call in the hot path and giving the global a unique branch for the CPU to predict away. For now, only do this for Darwin; non-ObjC platforms don't necessarily expose their "done" value as ABI like ours do. While we're here, change "once" to take a thin function pointer. We don't ever emit global initializers with context dependencies, and this simplifies the runtime glue between swift_once and dispatch_once/std::call_once a bit. Swift SVN r28166
1366 lines
52 KiB
Plaintext
1366 lines
52 KiB
Plaintext
// RUN: %target-swift-frontend %s -emit-silgen | FileCheck %s
|
|
|
|
// XFAIL: linux
|
|
|
|
sil_stage raw // CHECK: sil_stage raw
|
|
|
|
import Builtin
|
|
import Swift
|
|
|
|
// CHECK: sil_global private @globalinit_token0 : $Builtin.Word
|
|
sil_global private @globalinit_token0 : $Builtin.Word
|
|
|
|
// Linkage types.
|
|
|
|
// CHECK-LABEL: sil shared @clang_thunk : $@convention(thin) () -> ()
|
|
sil shared @clang_thunk : $() -> () {
|
|
bb0:
|
|
%0 = tuple ()
|
|
return %0 : $()
|
|
}
|
|
|
|
// CHECK-LABEL: sil private @internal_fn : $@convention(thin) () -> ()
|
|
sil private @internal_fn : $() -> () {
|
|
bb0:
|
|
%0 = tuple ()
|
|
return %0 : $()
|
|
}
|
|
|
|
// Type references
|
|
|
|
// Some cyclic type references between SIL function bodies.
|
|
class Class1 {
|
|
var a : Class2
|
|
init()
|
|
}
|
|
class Class2 {
|
|
var b : Class1
|
|
init()
|
|
}
|
|
|
|
sil @type_ref1 : $(Class1, Int) -> () // CHECK-LABEL: sil @type_ref1 : $@convention(thin) (Class1, Int)
|
|
|
|
|
|
// Instructions
|
|
|
|
sil @test1 : $() -> () { // CHECK-LABEL: sil @test1 : $@convention(thin) () -> ()
|
|
bb0: // CHECK: bb0:
|
|
%0 = tuple () // CHECK: %0 = tuple ()
|
|
br bb1 // CHECK: br bb1
|
|
bb1:
|
|
%b = alloc_box $Int // CHECK: %2 = alloc_box $Int
|
|
%c = integer_literal $Builtin.Word, 1
|
|
// CHECK: integer_literal $Builtin.Word, -1
|
|
%e = integer_literal $Builtin.Word, -1
|
|
return %0 : $() // CHECK: return %0 : $()
|
|
}
|
|
|
|
// Forward referenced values.
|
|
sil @test2 : $(Int) -> () { // CHECK-LABEL: sil @test2 : $@convention(thin) (Int) -> ()
|
|
bb0(%0 : $Int):
|
|
br bb2
|
|
bb1:
|
|
// Forward reference MRVs.
|
|
store %0 to %6#1 : $*Int // CHECK: store %0 to %6#1
|
|
strong_release %6#0 : $Builtin.NativeObject // CHECK: strong_release %6#0
|
|
|
|
return %5 : $() // CHECK: return %5 : $()
|
|
bb2:
|
|
%5 = tuple () // CHECK: %5 = tuple ()
|
|
%6 = alloc_box $Int // CHECK: %6 = alloc_box $Int
|
|
br bb1 // CHECK: br bb1
|
|
}
|
|
|
|
sil @named_tuple : $() -> (x: Builtin.Word, Builtin.Word) {
|
|
%0 = integer_literal $Builtin.Word, 42 // CHECK: integer_literal $Builtin.Word, 42
|
|
%9 = tuple $(x: Builtin.Word, Builtin.Word) (%0, %0)
|
|
%10 = return %9 : $(x: Builtin.Word, Builtin.Word)
|
|
}
|
|
|
|
sil @return_int : $@convention(thin) (Int) -> Int { // CHECK: $@convention(thin) (Int) -> Int {
|
|
bb0(%0 : $Int): // CHECK: bb0(%0 : $Int):
|
|
%1 = alloc_stack $Int // CHECK: alloc_stack $Int
|
|
store %0 to %1#1 : $*Int // CHECK: store %0 to %1#1 : $*Int
|
|
%3 = load %1#1 : $*Int // CHECK: load {{.*}} : $*Int
|
|
dealloc_stack %1#0 : $*@local_storage Int // CHECK: dealloc_stack {{.*}} : $*@local_storage Int
|
|
return %3 : $Int // CHECK: return {{.*}} : $Int
|
|
}
|
|
|
|
sil @call_fn_pointer : $@convention(thin) (() -> Int) -> Int {
|
|
bb0(%0 : $() -> Int):
|
|
%1 = alloc_stack $() -> Int // CHECK: alloc_stack $() -> Int
|
|
store %0 to %1#1 : $*() -> Int // CHECK: store %0 to %1#1 : $*() -> Int
|
|
%3 = load %1#1 : $*() -> Int // CHECK: load %1#1 : $*() -> Int
|
|
strong_retain %3 : $() -> Int // CHECK: strong_retain %3 : $() -> Int
|
|
%5 = apply %3() : $() -> Int // CHECK: apply %3() : $() -> Int
|
|
%6 = load %1#1 : $*() -> Int // CHECK: load %1#1 : $*() -> Int
|
|
strong_release %3 : $() -> Int // CHECK: release {{.*}} : $() -> Int
|
|
dealloc_stack %1#0 : $*@local_storage () -> Int // CHECK: dealloc_stack %1#0 : $*@local_storage () -> Int
|
|
return %5 : $Int // CHECK: return %5 : $Int
|
|
}
|
|
|
|
sil @return_constant : $@convention(thin) () -> Int { // CHECK-LABEL: @return_constant
|
|
bb0: // CHECK: bb0:
|
|
// CHECK: function_ref @_TSi25convertFromIntegerLiteralfMSiFT3valBi64__Si : $@convention(thin) (Builtin.Word, @thin Int.Type) -> Int
|
|
%1 = function_ref @_TSi25convertFromIntegerLiteralfMSiFT3valBi64__Si : $@convention(thin) (Builtin.Word, @thin Int.Type) -> Int
|
|
|
|
// CHECK: metatype $@thin Int.Type
|
|
%2 = metatype $@thin Int.Type
|
|
|
|
// CHECK: integer_literal $Builtin.Word, 1
|
|
%3 = integer_literal $Builtin.Word, 1
|
|
|
|
// CHECK: apply
|
|
%4 = apply %1(%3, %2) : $@convention(thin) (Builtin.Word, @thin Int.Type) -> Int
|
|
// CHECK: return
|
|
%5 = return %4 : $Int
|
|
}
|
|
|
|
sil @_TSi25convertFromIntegerLiteralfMSiFT3valBi64__Si : $@convention(thin) (Builtin.Word, @thin Int.Type) -> Int
|
|
|
|
// Parse SIL generated from the following swift program:
|
|
// func x(a : Bool) -> Int { if a { return 4 } else {return 5} }
|
|
sil @_TSb13getLogicValuefRSbFT_Bi1_ : $@convention(method) (@inout Bool) -> Builtin.Int1
|
|
sil @_TSi33_convertFromBuiltinIntegerLiteralfMSiFT3valBi128__Si : $@convention(thin) (Builtin.Int128, @thin Int.Type) -> Int
|
|
|
|
// CHECK-LABEL: @_T4test1xFT1aSb_Si
|
|
sil @_T4test1xFT1aSb_Si : $@convention(thin) (Bool) -> Int {
|
|
// CHECK: bb0(%0 : $Bool):
|
|
bb0(%0 : $Bool):
|
|
// CHECK: alloc_stack $Bool
|
|
%1 = alloc_stack $Bool
|
|
// CHECK: store
|
|
%2 = store %0 to %1#1 : $*Bool
|
|
// CHECK: function_ref @_TSb13getLogicValuefRSbFT_Bi1_ : $@convention(method) (@inout Bool) -> Builtin.Int1
|
|
%3 = function_ref @_TSb13getLogicValuefRSbFT_Bi1_ : $@convention(method) (@inout Bool) -> Builtin.Int1
|
|
// CHECK: apply
|
|
%4 = apply %3(%1#1) : $@convention(method) (@inout Bool) -> Builtin.Int1
|
|
// CHECK: cond_br
|
|
%5 = cond_br %4, bb1, bb2
|
|
|
|
// CHECK: bb1:
|
|
bb1:
|
|
// CHECK: function_ref @_TSi33_convertFromBuiltinIntegerLiteralfMSiFT3valBi128__Si : $@convention(thin) (Builtin.Int128, @thin Int.Type) -> Int
|
|
%6 = function_ref @_TSi33_convertFromBuiltinIntegerLiteralfMSiFT3valBi128__Si : $@convention(thin) (Builtin.Int128, @thin Int.Type) -> Int
|
|
// CHECK: metatype $@thin Int.Type
|
|
%7 = metatype $@thin Int.Type
|
|
// CHECK: integer_literal $Builtin.Int128, 4
|
|
%8 = integer_literal $Builtin.Int128, 4
|
|
// CHECK: apply
|
|
%9 = apply %6(%8, %7) : $@convention(thin) (Builtin.Int128, @thin Int.Type) -> Int
|
|
// CHECK: dealloc_stack
|
|
%10 = dealloc_stack %1#0 : $*@local_storage Bool
|
|
// CHECK: br
|
|
br bb3(%9 : $Int)
|
|
|
|
// CHECK: bb2:
|
|
bb2:
|
|
// CHECK: function_ref @_TSi33_convertFromBuiltinIntegerLiteralfMSiFT3valBi128__Si : $@convention(thin) (Builtin.Int128, @thin Int.Type) -> Int
|
|
%12 = function_ref @_TSi33_convertFromBuiltinIntegerLiteralfMSiFT3valBi128__Si : $@convention(thin) (Builtin.Int128, @thin Int.Type) -> Int
|
|
// CHECK: metatype $@thin Int.Type
|
|
%13 = metatype $@thin Int.Type
|
|
// CHECK: integer_literal $Builtin.Int128, 5
|
|
%14 = integer_literal $Builtin.Int128, 5
|
|
// CHECK: apply
|
|
%15 = apply %12(%14, %13) : $@convention(thin) (Builtin.Int128, @thin Int.Type) -> Int
|
|
// CHECK: dealloc_stack
|
|
%16 = dealloc_stack %1#0 : $*@local_storage Bool
|
|
// CHECK: br
|
|
br bb3(%15 : $Int)
|
|
|
|
bb3(%17 : $Int):
|
|
// CHECK: return
|
|
return %17 : $Int
|
|
}
|
|
|
|
|
|
protocol P {
|
|
func doIt()
|
|
}
|
|
|
|
sil @existentials : $@convention(thin) (@in P) -> () {
|
|
bb0(%0 : $*P):
|
|
// CHECK: open_existential_addr %0
|
|
%1 = open_existential_addr %0 : $*P to $*@opened("01234567-89ab-cdef-0123-000000000000") P
|
|
|
|
// CHECK: witness_method ${{.*}}, #P.doIt!1
|
|
%2 = witness_method $@opened("01234567-89ab-cdef-0123-000000000000") P, #P.doIt!1, %1 : $*@opened("01234567-89ab-cdef-0123-000000000000") P : $@convention(witness_method) <T: P> (@inout T) -> ()
|
|
// Make sure we have the correct scope for generic parameters.
|
|
// CHECK: witness_method $@opened("{{.*}}") P, #P.doIt!1
|
|
%7 = witness_method $@opened("01234567-89ab-cdef-0123-000000000000") P, #P.doIt!1, %1 : $*@opened("01234567-89ab-cdef-0123-000000000000") P : $@convention(witness_method) <T: P> (@inout T) -> ()
|
|
// CHECK: apply
|
|
%3 = apply %2<@opened("01234567-89ab-cdef-0123-000000000000") P>(%1) : $@convention(witness_method) <T: P> (@inout T) -> ()
|
|
%4 = tuple () // CHECK: tuple ()
|
|
%5 = destroy_addr %0 : $*P // CHECK: destroy_addr %0 : $*P
|
|
%6 = return %4 : $() // CHECK: return
|
|
}
|
|
|
|
|
|
class C {
|
|
func doIt() {}
|
|
}
|
|
|
|
class D : C {
|
|
override func doIt() {
|
|
super.doIt()
|
|
}
|
|
}
|
|
|
|
|
|
sil @classes : $@convention(thin) () -> () {
|
|
bb0:
|
|
// CHECK: %0 = alloc_ref $C
|
|
%C = alloc_ref $C
|
|
// CHECK: unchecked_ref_cast %0 : $C to $Builtin.NativeObject
|
|
%1 = unchecked_ref_cast %C : $C to $Builtin.NativeObject
|
|
// CHECK: unchecked_ref_cast %0 : $C to $Builtin.UnknownObject
|
|
%O = unchecked_ref_cast %C : $C to $Builtin.UnknownObject
|
|
|
|
// CHECK: class_method {{.*}} : $C, #C.doIt!1
|
|
%2 = class_method %C : $C, #C.doIt!1 : C -> () -> () , $@convention(method) (@guaranteed C) -> ()
|
|
|
|
// CHECK: alloc_ref $D
|
|
%D = alloc_ref $D
|
|
|
|
// CHECK: upcast {{.*}} : $D to $C
|
|
%a = upcast %D : $D to $C
|
|
|
|
|
|
%5 = unconditional_checked_cast %C : $C to $D // CHECK: unconditional_checked_cast
|
|
%6 = tuple ()
|
|
%7 = return %6 : $()
|
|
}
|
|
|
|
// Generated from:
|
|
// func archetype_member_ref<T:Runcible>(x:T) {
|
|
// x.free_method()
|
|
// var u = x.associated_method()
|
|
// T.static_method()
|
|
// }
|
|
|
|
protocol Runcible {
|
|
var free:Int { get }
|
|
|
|
func free_method() -> Int
|
|
static func static_method()
|
|
}
|
|
|
|
/* SIL parsing of substitutions in apply insts is totally busted.
|
|
// C/HECK: $@convention(thin) <T : Runcible> (@in T) -> ()
|
|
sil @_T4arch20archetype_member_refUS_8Runcible___FT1xQ__T_ : $@convention(thin) <T : Runcible> (@in T) -> () {
|
|
bb0(%0 : $*T):
|
|
// C/HECK: witness_method $*T, #Runcible.free_method!1
|
|
%1 = witness_method $*T, #Runcible.free_method!1 : $@cc(method) (@inout T) -> Int
|
|
%2 = apply %1(%0) : $@cc(method) (@inout T) -> Int
|
|
%3 = alloc_stack $@thick T.U.Type
|
|
// C/HECK: witness_method $*T, #Runcible.associated_method!1
|
|
%4 = witness_method $*T, #Runcible.associated_method!1 : $@cc(method) (@inout T) -> @thick T.U.Type
|
|
%5 = apply %4(%0) : $@cc(method) (@inout T) -> @thick T.U.Type
|
|
%6 = store %5 to %3#1 : $*@thick T.U.Type
|
|
%7 = metatype $@thick T.Type
|
|
// C/HECK: witness_method [volatile] $*T, #Runcible.static_method!1
|
|
%8 = witness_method [volatile] $*T, #Runcible.static_method!1 : $(@thick T.Type) -> ()
|
|
%9 = apply %8(%7) : $(@thick T.Type) -> ()
|
|
%10 = dealloc_stack %3#0 : $*@local_storage @thick T.U.Type
|
|
%11 = tuple ()
|
|
%12 = destroy_addr %0 : $*T
|
|
%13 = return %11 : $()
|
|
}
|
|
*/
|
|
|
|
protocol Bendable { }
|
|
|
|
// CHECK: $@convention(thin) (@out Runcible, @in protocol<Bendable, Runcible>) -> ()
|
|
sil @_T4todo18erasure_from_protoFT1xPS_8RuncibleS_8Bendable__PS0__ : $@convention(thin) (@out Runcible, @in protocol<Bendable, Runcible>) -> () {
|
|
bb0(%0 : $*Runcible, %1 : $*protocol<Bendable, Runcible>):
|
|
// CHECK: alloc_box
|
|
%2 = alloc_box $protocol<Bendable, Runcible>
|
|
// CHECK: copy_addr [take] {{.*}} to [initialization] {{.*}} : $*protocol<Bendable, Runcible>
|
|
%3 = copy_addr [take] %1 to [initialization] %2#1 : $*protocol<Bendable, Runcible>
|
|
// CHECK: alloc_stack
|
|
%4 = alloc_stack $protocol<Bendable, Runcible>
|
|
// CHECK: copy_addr {{.*}} to [initialization] {{.*}} : $*protocol<Bendable, Runcible>
|
|
%5 = copy_addr %2#1 to [initialization] %4#1 : $*protocol<Bendable, Runcible>
|
|
%7 = tuple ()
|
|
// CHECK: destroy_addr
|
|
%8 = destroy_addr %4#1 : $*protocol<Bendable, Runcible>
|
|
// CHECK: dealloc_stack
|
|
%9 = dealloc_stack %4#0 : $*@local_storage protocol<Bendable, Runcible>
|
|
// CHECK: release
|
|
%10 = strong_release %2#0 : $Builtin.NativeObject
|
|
// CHECK: return
|
|
%11 = return %7 : $()
|
|
}
|
|
|
|
protocol ClassBound : class {
|
|
func classBoundMethod()
|
|
}
|
|
|
|
// CHECK: $@convention(thin) (ClassBound) -> ()
|
|
sil @_T4todo18class_bound_methodFT1xPS_10ClassBound__T_ : $@convention(thin) (ClassBound) -> () {
|
|
bb0(%0 : $ClassBound):
|
|
%1 = alloc_box $ClassBound // CHECK: alloc_box
|
|
%2 = store %0 to %1#1 : $*ClassBound // CHECK: store
|
|
%3 = load %1#1 : $*ClassBound // CHECK: load
|
|
%4 = strong_retain %3 : $ClassBound // CHECK: strong_retain
|
|
// CHECK: open_existential_ref {{%.*}} : $ClassBound to $@opened({{.*}}) ClassBound
|
|
%5 = open_existential_ref %3 : $ClassBound to $@opened("01234567-89ab-cdef-0123-111111111111") ClassBound
|
|
// CHECK: witness_method
|
|
%6 = witness_method $@opened("01234567-89ab-cdef-0123-111111111111") ClassBound, #ClassBound.classBoundMethod!1, %5 : $@opened("01234567-89ab-cdef-0123-111111111111") ClassBound : $@convention(witness_method) <T: ClassBound> (T) -> ()
|
|
%7 = apply %6<@opened("01234567-89ab-cdef-0123-111111111111") ClassBound>(%5) : $@convention(witness_method) <T: ClassBound> (T) -> ()
|
|
%8 = tuple ()
|
|
%9 = strong_release %1#0 : $Builtin.NativeObject
|
|
%10 = return %8 : $()
|
|
}
|
|
|
|
struct Val {
|
|
}
|
|
|
|
// CHECK: $@convention(thin) (@thin Val.Type) -> Val
|
|
sil @_TV4todo3ValCfMS0_FT_S0_ : $@convention(thin) (@thin Val.Type) -> Val {
|
|
bb0(%0 : $@thin Val.Type):
|
|
%1 = alloc_stack $Val // CHECK: alloc_stack
|
|
%3 = load %1#1 : $*Val
|
|
dealloc_stack %1#0 : $*@local_storage Val
|
|
%4 = return %3 : $Val
|
|
}
|
|
|
|
class Ref {
|
|
}
|
|
struct Aleph {
|
|
var a:Ref
|
|
var b:Val
|
|
}
|
|
|
|
// CHECK: $@convention(thin) (Ref, Val, @thin Aleph.Type) -> Aleph
|
|
sil @_TV6struct5AlephCfMS0_FT1aCS_3Ref1bVS_3Val_S0_ : $@convention(thin) (Ref, Val, @thin Aleph.Type) -> Aleph {
|
|
bb0(%0 : $Ref, %1 : $Val, %2 : $@thin Aleph.Type):
|
|
// CHECK: struct $Aleph ({{%.*}} : $Ref, {{%.*}} : $Val)
|
|
%3 = struct $Aleph (%0 : $Ref, %1 : $Val)
|
|
%4 = return %3 : $Aleph // CHECK: return
|
|
}
|
|
|
|
// CHECK: $@convention(thin) (@thin Aleph.Type) -> Aleph
|
|
sil @_TV6struct5AlephCfMS0_FT_S0_ : $@convention(thin) (@thin Aleph.Type) -> Aleph {
|
|
bb0(%0 : $@thin Aleph.Type):
|
|
%1 = tuple ()
|
|
%2 = alloc_box $Aleph // CHECK: alloc_box
|
|
// CHECK: struct_element_addr {{.*}} : $*Aleph, #Aleph.a
|
|
%5 = struct_element_addr %2#1 : $*Aleph, #Aleph.a
|
|
%6 = load %5 : $*Ref
|
|
%8 = strong_release %6 : $Ref
|
|
%14 = load %2#1 : $*Aleph
|
|
// CHECK: struct_extract {{%.*}} : $Aleph, #Aleph.a
|
|
%15 = struct_extract %14 : $Aleph, #Aleph.a
|
|
%16 = strong_retain %15 : $Ref
|
|
%17 = strong_release %2#0 : $Builtin.NativeObject
|
|
%18 = return %14 : $Aleph
|
|
}
|
|
|
|
enum Beth {
|
|
case EmptyCase
|
|
case DataCase(Int)
|
|
}
|
|
|
|
// CHECK-LABEL: sil @test_union_empty_case : $@convention(thin) () -> Beth {
|
|
sil @test_union_empty_case : $() -> Beth {
|
|
bb0:
|
|
// CHECK: %0 = enum $Beth, #Beth.EmptyCase!enumelt
|
|
%0 = enum $Beth, #Beth.EmptyCase!enumelt
|
|
return %0 : $Beth
|
|
}
|
|
|
|
// CHECK-LABEL: sil @test_union_data_case : $@convention(thin) (Int) -> Beth {
|
|
sil @test_union_data_case : $Int -> Beth {
|
|
bb0(%0 : $Int):
|
|
// CHECK: %1 = enum $Beth, #Beth.DataCase!enumelt.1, %0 : $Int
|
|
%1 = enum $Beth, #Beth.DataCase!enumelt.1, %0 : $Int
|
|
return %1 : $Beth
|
|
}
|
|
|
|
protocol Q {}
|
|
|
|
enum Gimel {
|
|
case EmptyCase
|
|
case DataCase(Q)
|
|
}
|
|
|
|
sil @test_union_addr_empty_case : $(@out Gimel) -> () {
|
|
bb0(%0 : $*Gimel):
|
|
// CHECK: inject_enum_addr {{%.*}} : $*Gimel, #Gimel.EmptyCase!enumelt
|
|
inject_enum_addr %0 : $*Gimel, #Gimel.EmptyCase!enumelt
|
|
%t = tuple ()
|
|
return %t : $()
|
|
}
|
|
|
|
sil @test_union_addr_data_case : $(@out Gimel, @in Q) -> () {
|
|
bb0(%0 : $*Gimel, %1 : $*Q):
|
|
// CHECK: {{%.*}} = init_enum_data_addr {{%.*}} : $*Gimel, #Gimel.DataCase!enumelt.1
|
|
%p = init_enum_data_addr %0 : $*Gimel, #Gimel.DataCase!enumelt.1
|
|
copy_addr [take] %1 to [initialization] %p : $*Q
|
|
inject_enum_addr %0 : $*Gimel, #Gimel.DataCase!enumelt.1
|
|
%t = tuple ()
|
|
return %t : $()
|
|
}
|
|
|
|
sil @_T5tuple5floatFT1xSf_T_ : $@convention(thin) (Float32) -> ()
|
|
sil @_T5tuple5tupleFT_TSiSf_ : $@convention(thin) () -> (Int, Float32)
|
|
|
|
// CHECK: $@convention(thin) (Int, Float) -> ()
|
|
sil @_T5tuple13tuple_elementFT1xTSiSf__T_ : $@convention(thin) (Int, Float) -> () {
|
|
bb0(%0 : $Int, %1 : $Float):
|
|
%2 = alloc_box $(Int, Float)
|
|
// CHECK: tuple ({{%.*}} : $Int, {{%.*}} : $Float)
|
|
%3 = tuple (%0 : $Int, %1 : $Float)
|
|
%4 = store %3 to %2#1 : $*(Int, Float)
|
|
// CHECK: tuple_element_addr {{%.*}}#{{.*}} : $*(Int, Float), 0
|
|
%6 = tuple_element_addr %2#1 : $*(Int, Float), 0
|
|
// CHECK: load
|
|
%7 = load %6 : $*Int
|
|
// CHECK: tuple_element_addr {{%.*}}#{{.*}} : $*(Int, Float), 1
|
|
%10 = tuple_element_addr %2#1 : $*(Int, Float), 1
|
|
// CHECK: load
|
|
%11 = load %10 : $*Float
|
|
// CHECK: function_ref
|
|
%14 = function_ref @_T5tuple5tupleFT_TSiSf_ : $@convention(thin) () -> (Int, Float)
|
|
// CHECK: apply
|
|
%15 = apply %14() : $@convention(thin) () -> (Int, Float)
|
|
// CHECK: function_ref
|
|
%19 = function_ref @_T5tuple5floatFT1xSf_T_ : $@convention(thin) (Float) -> ()
|
|
// CHECK: tuple_extract {{%.*}} : $(Int, Float), 1
|
|
%17 = tuple_extract %15 : $(Int, Float), 1
|
|
// CHECK: apply
|
|
%24 = apply %19(%17) : $@convention(thin) (Float) -> ()
|
|
%25 = tuple ()
|
|
%26 = strong_release %2#0 : $Builtin.NativeObject
|
|
%27 = return %25 : $()
|
|
}
|
|
|
|
class M {
|
|
var member: Int
|
|
init()
|
|
}
|
|
|
|
// CHECK: $@convention(method) (Int, M) -> ()
|
|
sil @_TC3ref1C3foofS0_FT1xSi_T_ : $@convention(method) (Int, M) -> () {
|
|
bb0(%0 : $Int, %1 : $M):
|
|
%2 = alloc_box $Int // CHECK: alloc_box $Int
|
|
%3 = store %0 to %2#1 : $*Int
|
|
%4 = alloc_box $M // CHECK: alloc_box $M
|
|
%5 = store %1 to %4#1 : $*M
|
|
%6 = load %2#1 : $*Int // CHECK: load {{.*}} : $*Int
|
|
%7 = load %4#1 : $*M // CHECK: load {{.*}} : $*M
|
|
%8 = strong_retain %7 : $M
|
|
// CHECK: ref_element_addr {{%.*}} : $M, #M.member
|
|
%9 = ref_element_addr %7 : $M, #M.member
|
|
%10 = store %6 to %9 : $*Int
|
|
%11 = strong_release %7 : $M
|
|
%12 = tuple ()
|
|
%13 = strong_release %4#0 : $Builtin.NativeObject
|
|
%14 = strong_release %2#0 : $Builtin.NativeObject
|
|
%15 = return %12 : $()
|
|
}
|
|
|
|
class GenericClass<Q> {
|
|
var member: Q
|
|
init()
|
|
}
|
|
|
|
// CHECK: sil @bound_generic_class_ref_element_addr : $@convention(thin) (GenericClass<Int>) -> Int {
|
|
sil @bound_generic_class_ref_element_addr : $@convention(thin) GenericClass<Int> -> Int {
|
|
entry(%0 : $GenericClass<Int>):
|
|
// CHECK: %1 = ref_element_addr %0 : $GenericClass<Int>, #GenericClass.member
|
|
%1 = ref_element_addr %0 : $GenericClass<Int>, #GenericClass.member
|
|
// CHECK: %2 = load %1 : $*Int
|
|
%2 = load %1 : $*Int
|
|
return %2 : $Int
|
|
}
|
|
|
|
class B { }
|
|
class E : B { }
|
|
|
|
// CHECK: $@convention(thin) (B) -> Builtin.Int1
|
|
sil @_T4null3isaFT1bCS_1B_Sb : $@convention(thin) (B) -> Builtin.Int1 {
|
|
bb0(%0 : $B):
|
|
%1 = alloc_box $B // CHECK: alloc_box
|
|
%2 = store %0 to %1#1 : $*B
|
|
%3 = load %1#1 : $*B // CHECK: load
|
|
%4 = strong_retain %3 : $B
|
|
checked_cast_br %3 : $B to $E, yes, no // CHECK: checked_cast_br
|
|
yes(%5 : $E):
|
|
%y = integer_literal $Builtin.Int1, 1
|
|
br isa(%y : $Builtin.Int1)
|
|
no:
|
|
%n = integer_literal $Builtin.Int1, 0
|
|
br isa(%n : $Builtin.Int1)
|
|
isa(%6 : $Builtin.Int1):
|
|
%7 = strong_release %3 : $B
|
|
%8 = strong_release %1#0 : $Builtin.NativeObject
|
|
%9 = return %6 : $Builtin.Int1
|
|
}
|
|
|
|
sil @_TSd31_convertFromBuiltinFloatLiteralfMSdFT5valueBf64__Sd : $@convention(thin) (Builtin.FPIEEE64, @thin Float64.Type) -> Float64
|
|
sil @_TSS32_convertFromBuiltinStringLiteralfMSSFT5valueBp8byteSizeBi64_7isASCIIBi1__SS : $@convention(thin) (Builtin.RawPointer, Builtin.Word, Builtin.Int1, @thin String.Type) -> String
|
|
|
|
|
|
sil @_T5index5gep64FT1pBp1iBi64__Bp : $@convention(thin) (Builtin.RawPointer, Builtin.Word) -> Builtin.RawPointer {
|
|
bb0(%0 : $Builtin.RawPointer, %1 : $Builtin.Word):
|
|
%2 = alloc_box $Builtin.RawPointer // CHECK: alloc_box
|
|
%3 = alloc_box $Builtin.Word // CHECK: alloc_box
|
|
%4 = store %0 to %2#1 : $*Builtin.RawPointer
|
|
%5 = store %1 to %3#1 : $*Builtin.Word
|
|
%7 = load %2#1 : $*Builtin.RawPointer // CHECK: load
|
|
%8 = load %3#1 : $*Builtin.Word // CHECK: load
|
|
// CHECK: index_raw_pointer {{%.*}} : $Builtin.RawPointer, {{%.*}} : $Builtin.Word
|
|
%9 = index_raw_pointer %7 : $Builtin.RawPointer, %8 : $Builtin.Word
|
|
%10 = strong_release %3#0 : $Builtin.NativeObject
|
|
%11 = strong_release %2#0 : $Builtin.NativeObject
|
|
%12 = return %9 : $Builtin.RawPointer
|
|
}
|
|
|
|
sil_global @x : $Int
|
|
sil @global_callee : $@convention(thin) (Builtin.Int128, @thin Int.Type) -> Int
|
|
|
|
// CHECK-LABEL: @global_code : $@convention(thin) () -> ()
|
|
sil private @global_code : $() -> () {
|
|
bb0:
|
|
// CHECK: global_addr @x : $*Int
|
|
%0 = global_addr @x : $*Int
|
|
%1 = function_ref @global_callee : $@convention(thin) (Builtin.Int128, @thin Int.Type) -> Int
|
|
%2 = metatype $@thin Int.Type
|
|
%3 = integer_literal $Builtin.Int128, 0 // CHECK: integer_literal $Builtin.Int128, 0
|
|
%4 = apply %1(%3, %2) : $@convention(thin) (Builtin.Int128, @thin Int.Type) -> Int
|
|
%5 = store %4 to %0 : $*Int
|
|
%6 = tuple ()
|
|
%7 = return %6 : $()
|
|
}
|
|
|
|
protocol SomeProtocol {
|
|
}
|
|
class SomeClass : SomeProtocol {
|
|
}
|
|
class SomeSubclass : SomeClass {}
|
|
|
|
sil @test_class_metatype : $@convention(thin) (SomeClass, SomeSubclass) -> (@thick SomeClass.Type, @thick SomeClass.Type) {
|
|
bb0(%0 : $SomeClass, %1 : $SomeSubclass):
|
|
%2 = alloc_box $SomeClass // CHECK: alloc_box
|
|
%3 = alloc_box $SomeSubclass // CHECK: alloc_box
|
|
%4 = store %0 to %2#1 : $*SomeClass
|
|
%5 = store %1 to %3#1 : $*SomeSubclass
|
|
%7 = load %2#1 : $*SomeClass // CHECK: load
|
|
%8 = strong_retain %7 : $SomeClass
|
|
// CHECK: value_metatype $@thick SomeClass.Type, {{%.*}} : $SomeClass
|
|
%9 = value_metatype $@thick SomeClass.Type, %7 : $SomeClass
|
|
%11 = load %3#1 : $*SomeSubclass // CHECK: load
|
|
%12 = strong_retain %11 : $SomeSubclass
|
|
// CHECK: value_metatype $@thick SomeSubclass.Type, {{%.*}} : $SomeSubclass
|
|
%13 = value_metatype $@thick SomeSubclass.Type, %11 : $SomeSubclass
|
|
%14 = upcast %13 : $@thick SomeSubclass.Type to $@thick SomeClass.Type // CHECK: upcast
|
|
%15 = tuple (%9 : $@thick SomeClass.Type, %14 : $@thick SomeClass.Type) // CHECK: tuple
|
|
%16 = strong_release %11 : $SomeSubclass
|
|
%17 = strong_release %7 : $SomeClass
|
|
%18 = strong_release %3#0 : $Builtin.NativeObject
|
|
%19 = strong_release %2#0 : $Builtin.NativeObject
|
|
%20 = return %15 : $(@thick SomeClass.Type, @thick SomeClass.Type)
|
|
}
|
|
|
|
sil @test_value_metatype : $@convention(thin) <T> (@in T) -> (@thick T.Type, @thick T.Type) {
|
|
bb0(%0 : $*T):
|
|
%1 = alloc_box $T // CHECK: alloc_box
|
|
%2 = copy_addr [take] %0 to [initialization] %1#1 : $*T
|
|
%3 = metatype $@thick T.Type // CHECK: metatype
|
|
%5 = alloc_stack $T // CHECK: alloc_stack
|
|
%6 = copy_addr %1#1 to [initialization] %5#1 : $*T
|
|
// CHECK: value_metatype $@thick T.Type, {{%.*}} : $*T
|
|
%7 = value_metatype $@thick T.Type, %5#1 : $*T
|
|
%8 = tuple (%3 : $@thick T.Type, %7 : $@thick T.Type) // CHECK: tuple
|
|
%9 = destroy_addr %5#1 : $*T
|
|
%10 = dealloc_stack %5#0 : $*@local_storage T
|
|
%11 = strong_release %1#0 : $Builtin.NativeObject
|
|
%12 = return %8 : $(@thick T.Type, @thick T.Type)
|
|
}
|
|
|
|
sil @test_existential_metatype : $@convention(thin) (@in SomeProtocol) -> @thick SomeProtocol.Type {
|
|
bb0(%0 : $*SomeProtocol):
|
|
%1 = alloc_box $SomeProtocol // CHECK: alloc_box
|
|
%2 = copy_addr [take] %0 to [initialization] %1#1 : $*SomeProtocol
|
|
%4 = alloc_stack $SomeProtocol // CHECK: alloc_stack
|
|
%5 = copy_addr %1#1 to [initialization] %4#1 : $*SomeProtocol
|
|
// CHECK: existential_metatype $@thick SomeProtocol.Type, {{%.*}} : $*SomeProtocol
|
|
%6 = existential_metatype $@thick SomeProtocol.Type, %4#1 : $*SomeProtocol
|
|
%7 = destroy_addr %4#1 : $*SomeProtocol
|
|
%8 = dealloc_stack %4#0 : $*@local_storage SomeProtocol
|
|
%9 = strong_release %1#0 : $Builtin.NativeObject
|
|
%10 = return %6 : $@thick SomeProtocol.Type
|
|
}
|
|
|
|
// CHECK-LABEL: sil @test_unreachable
|
|
sil @test_unreachable : $() -> () {
|
|
bb0:
|
|
unreachable
|
|
// CHECK: unreachable
|
|
}
|
|
|
|
sil @test_unowned_retain : $@convention(thin) (SomeClass) -> () {
|
|
bb0(%0 : $SomeClass):
|
|
%1 = ref_to_unowned %0 : $SomeClass to $@sil_unowned SomeClass
|
|
// CHECK: ref_to_unowned %0 : $SomeClass to $@sil_unowned SomeClass
|
|
%2 = unowned_retain %1 : $@sil_unowned SomeClass
|
|
// CHECK: unowned_retain %1 : $@sil_unowned SomeClass
|
|
%3 = unowned_release %1 : $@sil_unowned SomeClass
|
|
// CHECK: unowned_release %1 : $@sil_unowned SomeClass
|
|
%4 = unowned_to_ref %1 : $@sil_unowned SomeClass to $SomeClass
|
|
// CHECK: unowned_to_ref %1 : $@sil_unowned SomeClass to $SomeClass
|
|
%5 = tuple ()
|
|
%6 = return %5 : $()
|
|
}
|
|
|
|
// CHECK-LABEL: sil @test_basic_block_arguments
|
|
sil @test_basic_block_arguments : $@convention(thin) (Builtin.Int1) -> Builtin.Word {
|
|
bb0(%0 : $Builtin.Int1):
|
|
cond_br %0, bb1, bb2
|
|
bb1:
|
|
%2 = integer_literal $Builtin.Word, 5
|
|
br bb3(%2 : $Builtin.Word)
|
|
//CHECK: br bb3(%2 : $Builtin.Word)
|
|
bb2:
|
|
%4 = integer_literal $Builtin.Word, 6
|
|
br bb3(%4 : $Builtin.Word)
|
|
//CHECK: br bb3(%4 : $Builtin.Word)
|
|
bb3(%6 : $Builtin.Word):
|
|
//CHECK: bb3(%6 : $Builtin.Word)
|
|
return %6 : $Builtin.Word
|
|
}
|
|
|
|
// CHECK-LABEL: sil @test_cond_branch_basic_block_args
|
|
sil @test_cond_branch_basic_block_args : $@convention(thin) (Int, Builtin.Int1) -> Int {
|
|
bb0(%0 : $Int, %1 : $Builtin.Int1):
|
|
cond_br %1, bb1(%0 : $Int), bb2(%0 : $Int)
|
|
// CHECK: cond_br %1, bb1(%0 : $Int), bb2(%0 : $Int)
|
|
bb1(%3 : $Int):
|
|
br bb3 (%3 : $Int)
|
|
bb2(%2 : $Int):
|
|
br bb3(%2 : $Int)
|
|
bb3(%4 : $Int):
|
|
return %4 : $Int
|
|
}
|
|
|
|
// CHECK-LABEL: sil @test_builtin
|
|
sil @test_builtin : $@convention(thin) (Builtin.Int1, Builtin.Int1) -> Builtin.Int1 {
|
|
bb0(%0 : $Builtin.Int1, %1 : $Builtin.Int1):
|
|
%2 = alloc_box $Builtin.Int1
|
|
%3 = alloc_box $Builtin.Int1
|
|
store %0 to %2#1 : $*Builtin.Int1
|
|
store %1 to %3#1 : $*Builtin.Int1
|
|
%8 = load %2#1 : $*Builtin.Int1
|
|
%9 = load %3#1 : $*Builtin.Int1
|
|
// CHECK: builtin "cmp_eq_Int1"({{%.*}} : $Builtin.Int1, {{%.*}} : $Builtin.Int1) : $Builtin.Int1
|
|
%10 = builtin "cmp_eq_Int1"(%8 : $Builtin.Int1, %9 : $Builtin.Int1) : $Builtin.Int1
|
|
strong_release %3#0 : $Builtin.NativeObject
|
|
strong_release %2#0 : $Builtin.NativeObject
|
|
return %10 : $Builtin.Int1
|
|
}
|
|
|
|
// CHECK-LABEL: sil @test_dealloc_ref
|
|
sil @test_dealloc_ref : $@convention(thin) () -> () {
|
|
bb0:
|
|
%0 = alloc_ref $Class1
|
|
dealloc_ref %0 : $Class1
|
|
%2 = tuple ()
|
|
return %2 : $()
|
|
}
|
|
|
|
// CHECK-LABEL: sil @test_dealloc_box
|
|
sil @test_dealloc_box : $@convention(thin) () -> () {
|
|
bb0:
|
|
%0 = alloc_box $Class1
|
|
dealloc_box $Class1, %0#0 : $Builtin.NativeObject
|
|
%2 = tuple ()
|
|
return %2 : $()
|
|
}
|
|
|
|
|
|
|
|
// CHECK-LABEL: closure_test
|
|
sil @takes_closure : $@convention(thin) (@callee_owned () -> ()) -> ()
|
|
sil @closure0 : $@convention(thin) (Builtin.NativeObject, @inout Int) -> ()
|
|
|
|
sil @closure_test : $@convention(thin) () -> () {
|
|
bb0:
|
|
%0 = alloc_box $Int // users: %10, %8, %8, %7, %4
|
|
|
|
%5 = function_ref @takes_closure : $@convention(thin) (@callee_owned () -> ()) -> ()
|
|
%6 = function_ref @closure0 : $@convention(thin) (Builtin.NativeObject, @inout Int) -> ()
|
|
strong_retain %0#0 : $Builtin.NativeObject
|
|
%8 = partial_apply %6(%0#0, %0#1) : $@convention(thin) (Builtin.NativeObject, @inout Int) -> ()
|
|
%9 = apply %5(%8) : $@convention(thin) (@callee_owned () -> ()) -> ()
|
|
strong_release %0#0 : $Builtin.NativeObject
|
|
|
|
%11 = tuple ()
|
|
return %11 : $()
|
|
}
|
|
|
|
sil @test_super_to_archetype_ref : $@convention(thin) <T : Class1> (Class1) -> T {
|
|
bb0(%c : $Class1):
|
|
%0 = unconditional_checked_cast %c : $Class1 to $T
|
|
return %0 : $T
|
|
}
|
|
|
|
sil @test_downcast_archetype_ref : $@convention(thin) <T:Class1, U:Class1> (T) -> () {
|
|
bb0(%t : $T):
|
|
%0 = unconditional_checked_cast %t : $T to $U
|
|
%1 = tuple ()
|
|
return %1 : $()
|
|
}
|
|
|
|
protocol ClassP : class {}
|
|
|
|
sil @test_downcast_existential_ref : $@convention(thin) <U : ClassP> (ClassP) -> () {
|
|
bb0(%t : $ClassP):
|
|
%0 = unconditional_checked_cast %t : $ClassP to $U
|
|
%1 = tuple ()
|
|
return %1 : $()
|
|
}
|
|
|
|
enum MaybePair {
|
|
case Neither
|
|
case Left(Int)
|
|
}
|
|
|
|
sil @_T6switch1aFT_T_ : $@convention(thin) () -> ()
|
|
sil @_T6switch1bFT_T_ : $@convention(thin) () -> ()
|
|
sil @_T6switch1cFT_T_ : $@convention(thin) () -> ()
|
|
|
|
// CHECK-LABEL: sil @test_switch_union : $@convention(thin) (MaybePair) -> ()
|
|
sil @test_switch_union : $@convention(thin) (MaybePair) -> () {
|
|
bb0(%0 : $MaybePair):
|
|
%1 = alloc_box $MaybePair
|
|
store %0 to %1#1 : $*MaybePair
|
|
%3 = load %1#1 : $*MaybePair
|
|
%4 = tuple ()
|
|
// CHECK: switch_enum %{{.*}} : $MaybePair, case #MaybePair.Neither!enumelt: bb{{.*}}, case #MaybePair.Left!enumelt.1: bb
|
|
switch_enum %3 : $MaybePair, case #MaybePair.Neither!enumelt: bb1, case #MaybePair.Left!enumelt.1: bb3
|
|
|
|
bb1:
|
|
br bb2
|
|
|
|
bb2:
|
|
%7 = function_ref @_T6switch1aFT_T_ : $@convention(thin) () -> () // CHECK: function_ref
|
|
%8 = apply %7() : $@convention(thin) () -> ()
|
|
br bb5 // CHECK: br
|
|
|
|
bb3(%10 : $Int):
|
|
// CHECK: unchecked_enum_data {{%.*}} : $MaybePair, #MaybePair.Left!enumelt.1
|
|
%x = unchecked_enum_data %3 : $MaybePair, #MaybePair.Left!enumelt.1
|
|
br bb4(%x : $Int)
|
|
|
|
bb4(%y : $Int):
|
|
%12 = function_ref @_T6switch1bFT_T_ : $@convention(thin) () -> () // CHECK: function_ref
|
|
%13 = apply %12() : $@convention(thin) () -> ()
|
|
br bb5 // CHECK: br
|
|
|
|
bb5:
|
|
%15 = function_ref @_T6switch1cFT_T_ : $@convention(thin) () -> () // CHECK: function_ref
|
|
%16 = apply %15() : $@convention(thin) () -> ()
|
|
strong_release %1#0 : $Builtin.NativeObject // CHECK: release
|
|
%18 = tuple ()
|
|
return %18 : $() // CHECK: return
|
|
}
|
|
|
|
enum MaybeAddressOnlyPair {
|
|
case Neither
|
|
case Left(Q)
|
|
}
|
|
|
|
// CHECK-LABEL: sil @test_switch_union_addr : $@convention(thin) (@in MaybeAddressOnlyPair) -> ()
|
|
sil @test_switch_union_addr : $@convention(thin) (@in MaybeAddressOnlyPair) -> () {
|
|
bb0(%0 : $*MaybeAddressOnlyPair):
|
|
// CHECK: switch_enum_addr [[ENUM:%.*]] : $*MaybeAddressOnlyPair, case #MaybeAddressOnlyPair.Neither!enumelt: bb{{.*}}, case #MaybeAddressOnlyPair.Left!enumelt.1: bb
|
|
switch_enum_addr %0 : $*MaybeAddressOnlyPair, case #MaybeAddressOnlyPair.Neither!enumelt: bb1, case #MaybeAddressOnlyPair.Left!enumelt.1: bb2
|
|
|
|
bb1:
|
|
br bb3
|
|
|
|
bb2:
|
|
// CHECK: unchecked_take_enum_data_addr [[ENUM]] : $*MaybeAddressOnlyPair, #MaybeAddressOnlyPair.Left!enumelt.1
|
|
%q = unchecked_take_enum_data_addr %0 : $*MaybeAddressOnlyPair, #MaybeAddressOnlyPair.Left!enumelt.1
|
|
br bb3
|
|
|
|
bb3:
|
|
%t = tuple ()
|
|
return %t : $()
|
|
}
|
|
|
|
// CHECK-LABEL: sil @test_switch_value : $@convention(thin) (Builtin.Word) -> ()
|
|
sil @test_switch_value : $@convention(thin) (Builtin.Word) -> () {
|
|
bb0(%0 : $Builtin.Word):
|
|
// CHECK: switch_value %{{.*}} : $Builtin.Word, case %1: bb1, case %2: bb2
|
|
%1 = integer_literal $Builtin.Word, 1
|
|
%2 = integer_literal $Builtin.Word, 2
|
|
switch_value %0 : $Builtin.Word, case %1: bb1, case %2: bb2
|
|
|
|
bb1:
|
|
%7 = function_ref @_T6switch1aFT_T_ : $@convention(thin) () -> () // CHECK: function_ref
|
|
%8 = apply %7() : $@convention(thin) () -> ()
|
|
br bb3
|
|
|
|
bb2:
|
|
%12 = function_ref @_T6switch1bFT_T_ : $@convention(thin) () -> () // CHECK: function_ref
|
|
%13 = apply %12() : $@convention(thin) () -> ()
|
|
br bb3
|
|
|
|
bb3:
|
|
// CHECK: [[FUNC1:%.*]] = function_ref @_T6switch1aFT_T_
|
|
// CHECK: [[FUNC2:%.*]] = function_ref @_T6switch1bFT_T_
|
|
// CHECK: switch_value %{{.*}} : $@convention(thin) () -> (), case [[FUNC1]]: bb4, case [[FUNC2]]: bb5
|
|
%20 = function_ref @_T6switch1bFT_T_ : $@convention(thin) () -> ()
|
|
%21 = function_ref @_T6switch1aFT_T_ : $@convention(thin) () -> ()
|
|
%22 = function_ref @_T6switch1bFT_T_ : $@convention(thin) () -> ()
|
|
switch_value %20 : $@convention(thin) () -> (), case %21: bb4, case %22: bb5
|
|
|
|
bb4:
|
|
// CHECK: function_ref
|
|
%37 = function_ref @_T6switch1aFT_T_ : $@convention(thin) () -> ()
|
|
%38 = apply %37() : $@convention(thin) () -> ()
|
|
br bb6
|
|
|
|
bb5:
|
|
// CHECK: function_ref
|
|
%42 = function_ref @_T6switch1bFT_T_ : $@convention(thin) () -> ()
|
|
%43 = apply %42() : $@convention(thin) () -> ()
|
|
br bb6
|
|
|
|
bb6:
|
|
%18 = tuple ()
|
|
// CHECK: return
|
|
return %18 : $()
|
|
}
|
|
|
|
// CHECK-LABEL: sil @test_select_value : $@convention(thin) (Builtin.Word) -> Builtin.Word
|
|
sil @test_select_value : $@convention(thin) (Builtin.Word) -> Builtin.Word {
|
|
bb0(%0 : $Builtin.Word):
|
|
|
|
%1 = integer_literal $Builtin.Word, 1
|
|
%2 = integer_literal $Builtin.Word, 2
|
|
%3 = integer_literal $Builtin.Word, 3
|
|
%4 = integer_literal $Builtin.Word, 4
|
|
%5 = integer_literal $Builtin.Word, 5
|
|
%6 = integer_literal $Builtin.Word, 6
|
|
%11 = integer_literal $Builtin.Word, 11
|
|
%22 = integer_literal $Builtin.Word, 22
|
|
%33 = integer_literal $Builtin.Word, 33
|
|
%44 = integer_literal $Builtin.Word, 44
|
|
%55 = integer_literal $Builtin.Word, 55
|
|
%66 = integer_literal $Builtin.Word, 66
|
|
|
|
// CHECK: select_value %{{.*}} : $Builtin.Word, case %{{.*}}: %{{.*}}, case %{{.*}}: %{{.*}}, case %{{.*}}: %{{.*}}, case %{{.*}}: %{{.*}}, case %{{.*}}: %{{.*}}, default %{{.*}} : $Builtin.Word
|
|
%10 = select_value %0: $Builtin.Word, case %1: %11, case %2: %22, case %4: %44, case %5: %55, case %6: %66, default %33 : $Builtin.Word
|
|
|
|
// CHECK: return
|
|
return %10 : $Builtin.Word
|
|
}
|
|
|
|
enum IntEnum : Int {
|
|
case E0
|
|
case E1
|
|
case E2
|
|
}
|
|
|
|
// CHECK-LABEL: sil @test_select_value_with_enum : $@convention(thin) (Builtin.Word) -> Optional<IntEnum>
|
|
sil @test_select_value_with_enum : $@convention(thin) (Builtin.Word) -> Optional<IntEnum> {
|
|
bb0(%0 : $Builtin.Word):
|
|
%1 = integer_literal $Builtin.Word, 0
|
|
%2 = integer_literal $Builtin.Word, 1
|
|
%3 = enum $IntEnum, #IntEnum.E1!enumelt
|
|
%4 = enum $Optional<IntEnum>, #Optional.Some!enumelt.1, %3 : $IntEnum
|
|
%5 = integer_literal $Builtin.Word, 2
|
|
%6 = enum $IntEnum, #IntEnum.E2!enumelt
|
|
%7 = enum $Optional<IntEnum>, #Optional.Some!enumelt.1, %6 : $IntEnum
|
|
%8 = enum $IntEnum, #IntEnum.E0!enumelt
|
|
%9 = enum $Optional<IntEnum>, #Optional.Some!enumelt.1, %8 : $IntEnum
|
|
%10 = enum $Optional<IntEnum>, #Optional.None!enumelt
|
|
|
|
// CHECK: select_value %{{.*}} : $Builtin.Word, case %{{.*}}: %{{.*}}, case %{{.*}}: %{{.*}}, case %{{.*}}: %{{.*}}, default %{{.*}} : $Optional<IntEnum>
|
|
%11 = select_value %0 : $Builtin.Word, case %2: %4, case %5: %7, case %1: %9, default %10 : $Optional<IntEnum>
|
|
|
|
// CHECK: return
|
|
return %11 : $Optional<IntEnum>
|
|
}
|
|
|
|
class ConcreteClass : ClassP {
|
|
}
|
|
struct Spoon : Bendable {
|
|
}
|
|
|
|
// CHECK-LABEL: sil @test_init_existential : $@convention(thin) (@out Bendable, Spoon) -> ()
|
|
sil @test_init_existential : $@convention(thin) (@out Bendable, Spoon) -> () {
|
|
bb0(%0 : $*Bendable, %1 : $Spoon):
|
|
%2 = alloc_box $Spoon
|
|
store %1 to %2#1 : $*Spoon
|
|
// CHECK: init_existential_addr %{{.*}} : $*Bendable, $Spoon
|
|
%4 = init_existential_addr %0 : $*Bendable, $Spoon
|
|
// CHECK: deinit_existential_addr %{{.*}} : $*Bendable
|
|
deinit_existential_addr %0 : $*Bendable
|
|
%5 = load %2#1 : $*Spoon
|
|
store %5 to %4 : $*Spoon
|
|
strong_release %2#0 : $Builtin.NativeObject
|
|
%8 = tuple ()
|
|
return %8 : $()
|
|
}
|
|
|
|
// CHECK-LABEL: sil @test_existential_ref : $@convention(thin) (ConcreteClass) -> ClassP
|
|
sil @test_existential_ref : $@convention(thin) (ConcreteClass) -> ClassP {
|
|
bb0(%0 : $ConcreteClass):
|
|
%1 = alloc_box $ConcreteClass
|
|
store %0 to %1#1 : $*ConcreteClass
|
|
%3 = load %1#1 : $*ConcreteClass
|
|
strong_retain %3 : $ConcreteClass
|
|
// CHECK: init_existential_ref %{{.*}} : $ConcreteClass : $ConcreteClass, $ClassP
|
|
%5 = init_existential_ref %3 : $ConcreteClass : $ConcreteClass, $ClassP
|
|
strong_release %1#0 : $Builtin.NativeObject
|
|
return %5 : $ClassP
|
|
}
|
|
|
|
sil @test_assign : $(Int, @inout Int) -> () { // CHECK-LABEL: sil @test_assign
|
|
bb0(%0 : $Int, %1 : $*Int):
|
|
assign %0 to %1 : $*Int // CHECK: assign %0 to %1
|
|
unreachable
|
|
}
|
|
|
|
// CHECK-LABEL: sil @test_transparent : $@convention(thin) () -> () {
|
|
sil @test_transparent : $@convention(thin) () -> () {
|
|
bb0:
|
|
%0 = function_ref @classes : $@convention(thin) () -> ()
|
|
// CHECK: apply %{{.*}}() : $@convention(thin) () -> ()
|
|
%1 = apply %0() : $@convention(thin) () -> ()
|
|
%2 = tuple ()
|
|
%3 = return %2 : $()
|
|
}
|
|
|
|
// CHECK-LABEL: sil [thunk] @test_thunk : $@convention(thin) () -> () {
|
|
sil [thunk] @test_thunk : $@convention(thin) () -> () {
|
|
bb0:
|
|
%0 = tuple ()
|
|
%1 = return %0 : $()
|
|
}
|
|
|
|
// CHECK-LABEL: sil @takes_unnamed_closure : $@convention(thin) (@callee_owned () -> Int) -> () -> () -> Int
|
|
sil @takes_unnamed_closure : $@convention(thin) (@callee_owned () -> Int) -> () -> () -> Int
|
|
|
|
sil @takes_int64_float32 : $@convention(thin) (Int, Float32) -> ()
|
|
|
|
// CHECK-LABEL: sil @test_partial_apply : $@convention(thin) (Float) -> @callee_owned (Int) -> () {
|
|
sil @test_partial_apply : $@convention(thin) Float -> @callee_owned Int -> () {
|
|
bb0(%0 : $Float):
|
|
%1 = function_ref @takes_int64_float32 : $@convention(thin) (Int, Float) -> ()
|
|
// CHECK: partial_apply %{{.*}}(%{{.*}}) : $@convention(thin) (Int, Float) -> ()
|
|
%2 = partial_apply %1(%0) : $@convention(thin) (Int, Float) -> ()
|
|
%3 = return %2 : $@callee_owned Int -> ()
|
|
}
|
|
|
|
class X {
|
|
@objc func f() { }
|
|
}
|
|
|
|
// CHECK-LABEL: sil @test_dynamic_lookup_br : $@convention(thin) (AnyObject) -> ()
|
|
sil @test_dynamic_lookup_br : $@convention(thin) (AnyObject) -> () {
|
|
bb0(%0 : $AnyObject):
|
|
%1 = alloc_box $AnyObject
|
|
store %0 to %1#1 : $*AnyObject
|
|
%3 = alloc_box $Optional<() -> ()>
|
|
%4 = load %1#1 : $*AnyObject
|
|
strong_retain %4 : $AnyObject
|
|
%6 = open_existential_ref %4 : $AnyObject to $@opened("01234567-89ab-cdef-0123-222222222222") AnyObject
|
|
%7 = unchecked_ref_cast %6 : $@opened("01234567-89ab-cdef-0123-222222222222") AnyObject to $Builtin.UnknownObject
|
|
dynamic_method_br %7 : $Builtin.UnknownObject, #X.f!1.foreign, bb1, bb2
|
|
bb1(%z : $@convention(objc_method) (Builtin.UnknownObject) -> ()):
|
|
br bb3
|
|
|
|
bb2:
|
|
br bb3
|
|
|
|
bb3:
|
|
%28 = tuple ()
|
|
return %28 : $()
|
|
}
|
|
|
|
// CHECK-LABEL: sil @test_mark_fn_escape
|
|
sil @test_mark_fn_escape : $() -> () {
|
|
%b = alloc_box $Int
|
|
%c = alloc_box $Int
|
|
|
|
// CHECK: mark_function_escape {{.*}}#1 : $*Int
|
|
mark_function_escape %b#1 : $*Int
|
|
// CHECK: mark_function_escape {{.*}}#1 : $*Int, {{.*}}#1 : $*Int
|
|
mark_function_escape %b#1 : $*Int, %c#1 : $*Int
|
|
|
|
%28 = tuple ()
|
|
return %28 : $()
|
|
}
|
|
|
|
// CHECK-LABEL: sil @test_copy_release_value
|
|
sil @test_copy_release_value : $(Val) -> (Val) {
|
|
bb0(%0 : $Val):
|
|
retain_value %0 : $Val
|
|
release_value %0 : $Val
|
|
return %0 : $Val
|
|
// CHECK: retain_value [[T0:%.*]] : $Val
|
|
// CHECK-NEXT: release_value [[T0]] : $Val
|
|
}
|
|
|
|
// CHECK-LABEL: sil @test_autorelease_value
|
|
sil @test_autorelease_value : $X -> X {
|
|
bb0(%0 : $X):
|
|
autorelease_value %0 : $X
|
|
return %0 : $X
|
|
// CHECK: autorelease_value [[T0]] : $X
|
|
// CHECK-NEXT: return [[T0]] : $X
|
|
}
|
|
|
|
struct GenericStruct<T> {
|
|
var x : T
|
|
}
|
|
|
|
// CHECK-LABEL: sil @extract_generic_struct
|
|
sil @extract_generic_struct : $GenericStruct<Int> -> Int {
|
|
entry(%0 : $GenericStruct<Int>):
|
|
// CHECK: %1 = struct_extract %0 : $GenericStruct<Int>, #GenericStruct.x
|
|
%1 = struct_extract %0 : $GenericStruct<Int>, #GenericStruct.x
|
|
// CHECK: return %1 : $Int
|
|
return %1 : $Int
|
|
}
|
|
|
|
class Foo {
|
|
subscript (x: Int32, y: Int32) -> Int32 { get set }
|
|
var x: Int32
|
|
var y: Int32
|
|
init()
|
|
}
|
|
|
|
sil @_TFC3tmp3Foog9subscriptFTVSs5Int32S1__S1_ : $@convention(method) (Int32, Int32, Foo) -> Int32 {
|
|
bb0(%0 : $Int32, %1 : $Int32, %2 : $Foo):
|
|
%3 = tuple ()
|
|
%4 = alloc_stack $Int32 // var x // users: %17, %6
|
|
%5 = alloc_stack $Int32 // var y // users: %16, %7
|
|
store %0 to %4#1 : $*Int32
|
|
store %1 to %5#1 : $*Int32
|
|
%8 = alloc_stack $Foo // var self // users: %15, %14, %9
|
|
store %2 to %8#1 : $*Foo
|
|
%10 = metatype $@thin Int32.Type
|
|
%12 = integer_literal $Builtin.Int32, 0 // user: %13
|
|
%13 = struct $Int32 (%12 : $Builtin.Int32) // user: %18
|
|
destroy_addr %8#1 : $*Foo
|
|
dealloc_stack %8#0 : $*@local_storage Foo
|
|
dealloc_stack %5#0 : $*@local_storage Int32
|
|
dealloc_stack %4#0 : $*@local_storage Int32
|
|
return %13 : $Int32
|
|
}
|
|
|
|
sil @_TFC3tmp3Foos9subscriptFTVSs5Int32S1__S1_ : $@convention(method) (Int32, Int32, Int32, Foo) -> () {
|
|
bb0(%0 : $Int32, %1 : $Int32, %2 : $Int32, %3 : $Foo):
|
|
%4 = alloc_stack $Int32 // var value // users: %16, %5
|
|
store %0 to %4#1 : $*Int32
|
|
%6 = alloc_stack $Int32 // var x // users: %15, %8
|
|
%7 = alloc_stack $Int32 // var y // users: %14, %9
|
|
store %1 to %6#1 : $*Int32
|
|
store %2 to %7#1 : $*Int32
|
|
%10 = alloc_stack $Foo // var self // users: %13, %12, %11
|
|
store %3 to %10#1 : $*Foo
|
|
destroy_addr %10#1 : $*Foo
|
|
dealloc_stack %10#0 : $*@local_storage Foo
|
|
dealloc_stack %7#0 : $*@local_storage Int32
|
|
dealloc_stack %6#0 : $*@local_storage Int32
|
|
dealloc_stack %4#0 : $*@local_storage Int32
|
|
%17 = tuple () // user: %18
|
|
return %17 : $()
|
|
}
|
|
|
|
// CHECK-LABEL: sil @cond_fail_test : $@convention(thin) (Builtin.Int1) -> () {
|
|
sil @cond_fail_test : $Builtin.Int1 -> () {
|
|
entry(%0 : $Builtin.Int1):
|
|
// CHECK: cond_fail %0 : $Builtin.Int1
|
|
cond_fail %0 : $Builtin.Int1
|
|
%1 = tuple ()
|
|
return %1 : $()
|
|
}
|
|
|
|
sil_global @staticProp: $Int
|
|
|
|
// CHECK-LABEL: sil private @globalinit_func0 : $@convention(thin) () -> () {
|
|
sil private @globalinit_func0 : $@convention(thin) () -> () {
|
|
bb0:
|
|
%0 = global_addr @staticProp : $*Int
|
|
%1 = mark_uninitialized [var] %0 : $*Int
|
|
%7 = tuple ()
|
|
return %7 : $()
|
|
}
|
|
|
|
// CHECK-LABEL: sil @_TV18lazy_global_access4Type10staticPropSia : $@convention(thin) () -> Builtin.RawPointer {
|
|
sil @_TV18lazy_global_access4Type10staticPropSia : $@convention(thin) () -> Builtin.RawPointer {
|
|
bb0:
|
|
// CHECK: global_addr @globalinit_token0 : $*Builtin.Word
|
|
%1 = global_addr @globalinit_token0 : $*Builtin.Word
|
|
// CHECK: unchecked_addr_cast {{%.*}} : $*Builtin.Word to $*Builtin.RawPointer
|
|
%a = unchecked_addr_cast %1 : $*Builtin.Word to $*Builtin.RawPointer
|
|
%2 = address_to_pointer %a : $*Builtin.RawPointer to $Builtin.RawPointer
|
|
%3 = function_ref @globalinit_func0 : $@convention(thin) () -> ()
|
|
// CHECK: {{%.*}} = builtin "once"({{%.*}} : $Builtin.RawPointer, {{%.*}} : $@convention(thin) () -> ()) : $()
|
|
%5 = builtin "once"(%2 : $Builtin.RawPointer, %3 : $@convention(thin) () -> ()) : $()
|
|
%6 = global_addr @staticProp : $*Int
|
|
%7 = address_to_pointer %6 : $*Int to $Builtin.RawPointer
|
|
return %7 : $Builtin.RawPointer
|
|
}
|
|
|
|
// CHECK-LABEL: sil @thin_metatype : $@convention(thin) (@thin Int.Type) -> @thick Int.Type
|
|
sil @thin_metatype : $@convention(thin) (@thin Int.Type) -> @thick Int.Type
|
|
|
|
sil @undef_value : $() -> () {
|
|
bb0:
|
|
store undef to undef : $*Builtin.Int1
|
|
unreachable
|
|
}
|
|
|
|
// CHECK-LABEL: sil @debug_value
|
|
sil @debug_value : $@convention(thin) (Int, @in P) -> () {
|
|
bb0(%0 : $Int, %1 : $*P):
|
|
debug_value %0 : $Int // CHECK: debug_value %0 : $Int
|
|
debug_value_addr %1 : $*P // CHECK: debug_value_addr %1 : $*P
|
|
unreachable
|
|
}
|
|
|
|
// CHECK-LABEL: sil @block_storage_type
|
|
sil @block_storage_type : $@convention(thin) Int -> @convention(block) () -> () {
|
|
entry(%0 : $Int):
|
|
// CHECK: [[STORAGE:%.*]] = alloc_stack $@block_storage Int
|
|
%s = alloc_stack $@block_storage Int
|
|
// CHECK: [[PROJECT:%.*]] = project_block_storage [[STORAGE]]#1 : $*@block_storage Int
|
|
%c = project_block_storage %s#1 : $*@block_storage Int
|
|
// CHECK: store %0 to [[PROJECT]]
|
|
store %0 to %c : $*Int
|
|
// CHECK: [[FUNC:%.*]] = function_ref
|
|
%f = function_ref @block_invoke : $@convention(c) (@inout @block_storage Int) -> ()
|
|
// CHECK: [[BLOCK:%.*]] = init_block_storage_header [[STORAGE]]#1 : $*@block_storage Int, invoke [[FUNC]] : $@convention(c) (@inout @block_storage Int) -> (), type $@convention(block) () -> ()
|
|
%b = init_block_storage_header %s#1 : $*@block_storage Int, invoke %f : $@convention(c) (@inout @block_storage Int) -> (), type $@convention(block) () -> ()
|
|
// CHECK: dealloc_stack [[STORAGE]]#0 : $*@local_storage @block_storage Int
|
|
dealloc_stack %s#0 : $*@local_storage @block_storage Int
|
|
// CHECK: return [[BLOCK]] : $@convention(block) () -> ()
|
|
return %b : $@convention(block) () -> ()
|
|
}
|
|
|
|
sil @block_invoke : $@convention(c) (@inout @block_storage Int) -> () {
|
|
entry(%0 : $*@block_storage Int):
|
|
return undef : $()
|
|
}
|
|
|
|
// CHECK-LABEL: sil @bitcasts : $@convention(thin) (@owned Class1) -> @owned (Class2, Int) {
|
|
// CHECK-NEXT: bb0(%0 : $Class1):
|
|
// CHECK-NEXT: %1 = unchecked_ref_bit_cast %0 : $Class1 to $Class2
|
|
// CHECK-NEXT: %2 = unchecked_trivial_bit_cast %0 : $Class1 to $Int
|
|
// CHECK-NEXT: %3 = tuple (%1 : $Class2, %2 : $Int)
|
|
// CHECK-NEXT: return %3 : $(Class2, Int)
|
|
sil @bitcasts : $@convention(thin) (@owned Class1) -> @owned (Class2, Int) {
|
|
entry(%0 : $Class1):
|
|
%1 = unchecked_ref_bit_cast %0 : $Class1 to $Class2
|
|
%2 = unchecked_trivial_bit_cast %0 : $Class1 to $Int
|
|
%3 = tuple (%1 : $Class2, %2 : $Int)
|
|
return %3 : $(Class2, Int)
|
|
}
|
|
|
|
// CHECK-LABEL: sil @bridge_object : $@convention(thin) (@owned Class1, Builtin.Word) -> () {
|
|
// CHECK-NEXT: bb0([[X:%.*]] : $Class1, [[W:%.*]] : $Builtin.Word):
|
|
// CHECK-NEXT: [[A:%.*]] = ref_to_bridge_object [[X]] : $Class1, [[W]] : $Builtin.Word
|
|
// CHECK-NEXT: [[B:%.*]] = bridge_object_to_ref [[A]] : $Builtin.BridgeObject to $Class1
|
|
// CHECK-NEXT: [[C:%.*]] = bridge_object_to_word [[A]] : $Builtin.BridgeObject to $Builtin.Word
|
|
// CHECK-NEXT: return undef : $()
|
|
sil @bridge_object : $@convention(thin) (@owned Class1, Builtin.Word) -> () {
|
|
entry(%x : $Class1, %w : $Builtin.Word):
|
|
%a = ref_to_bridge_object %x : $Class1, %w : $Builtin.Word
|
|
%b = bridge_object_to_ref %a : $Builtin.BridgeObject to $Class1
|
|
%c = bridge_object_to_word %a : $Builtin.BridgeObject to $Builtin.Word
|
|
return undef : $()
|
|
}
|
|
|
|
// CHECK-LABEL: sil [_semantics "foo"] @test_semantics : $@convention(thin) () -> () {
|
|
sil [_semantics "foo"] @test_semantics : $@convention(thin) () -> () {
|
|
bb0:
|
|
%0 = tuple ()
|
|
return %0 : $()
|
|
}
|
|
|
|
// CHECK-LABEL: sil shared_external @test_shared_external_definition : $@convention(thin) () -> () {
|
|
sil shared_external @test_shared_external_definition : $@convention(thin) () -> () {
|
|
bb0:
|
|
%0 = tuple ()
|
|
return %0 : $()
|
|
}
|
|
|
|
// CHECK-LABEL: sil @select_enum : $@convention(thin) (@in Beth) -> () {
|
|
sil @select_enum : $@convention(thin) (@in Beth) -> () {
|
|
bb0(%0 : $*Beth):
|
|
%1 = load %0 : $*Beth
|
|
%2 = integer_literal $Builtin.Int32, 2
|
|
%3 = integer_literal $Builtin.Int32, 3
|
|
// CHECK: %4 = select_enum %1 : $Beth, case #Beth.EmptyCase!enumelt: %2, case #Beth.DataCase!enumelt.1: %3 : $Builtin.Int32
|
|
%4 = select_enum %1 : $Beth, case #Beth.EmptyCase!enumelt: %2, case #Beth.DataCase!enumelt.1: %3 : $Builtin.Int32
|
|
// CHECK: %5 = select_enum_addr %0 : $*Beth, case #Beth.EmptyCase!enumelt: %2, case #Beth.DataCase!enumelt.1: %3 : $Builtin.Int32
|
|
%5 = select_enum_addr %0 : $*Beth, case #Beth.EmptyCase!enumelt: %2, case #Beth.DataCase!enumelt.1: %3 : $Builtin.Int32
|
|
// CHECK: %6 = select_enum %1 : $Beth, case #Beth.EmptyCase!enumelt: %2, default %3 : $Builtin.Int32
|
|
%6 = select_enum %1 : $Beth, case #Beth.EmptyCase!enumelt: %2, default %3 : $Builtin.Int32
|
|
// CHECK: %7 = select_enum_addr %0 : $*Beth, case #Beth.EmptyCase!enumelt: %2, default %3 : $Builtin.Int32
|
|
%7 = select_enum_addr %0 : $*Beth, case #Beth.EmptyCase!enumelt: %2, default %3 : $Builtin.Int32
|
|
return undef : $()
|
|
}
|
|
|
|
struct SomeError: _ErrorType {
|
|
var domain: String { get }
|
|
var code: Int { get }
|
|
}
|
|
|
|
// CHECK-LABEL: sil @existential_box : $@convention(thin) (SomeError) -> () {
|
|
sil @existential_box : $@convention(thin) (SomeError) -> () {
|
|
bb0(%0 : $SomeError):
|
|
// CHECK: %1 = alloc_existential_box $_ErrorType, $SomeError
|
|
%1 = alloc_existential_box $_ErrorType, $SomeError
|
|
// CHECK: store %0 to %1#1 : $*SomeError
|
|
store %0 to %1#1 : $*SomeError
|
|
// CHECK: %3 = open_existential_box %1#0 : $_ErrorType to $*@opened("01234567-89AB-CDEF-0123-333333333333") _ErrorType
|
|
%3 = open_existential_box %1#0 : $_ErrorType to $*@opened("01234567-89AB-CDEF-0123-333333333333") _ErrorType
|
|
// CHECK: destroy_addr %3 : $*@opened("01234567-89AB-CDEF-0123-333333333333") _ErrorType
|
|
destroy_addr %3 : $*@opened("01234567-89AB-CDEF-0123-333333333333") _ErrorType
|
|
// CHECK: dealloc_existential_box %1#0 : $_ErrorType, $SomeError
|
|
dealloc_existential_box %1#0 : $_ErrorType, $SomeError
|
|
return undef : $()
|
|
}
|
|
|
|
sil @convert_function : $@convention(thin) (@convention(thin) (AnyObject) -> Optional<AnyObject>) -> (@convention(thin) (Optional<AnyObject>) -> AnyObject) {
|
|
entry(%0 : $@convention(thin) (AnyObject) -> Optional<AnyObject>):
|
|
%1 = convert_function %0 : $@convention(thin) (AnyObject) -> Optional<AnyObject> to $@convention(thin) (Optional<AnyObject>) -> AnyObject
|
|
return %1 : $@convention(thin) (Optional<AnyObject>) -> AnyObject
|
|
}
|
|
|
|
sil @meta_metatype : $@convention(thin) () -> @thick Beth.Type.Type {
|
|
entry:
|
|
%m = metatype $@thick Beth.Type.Type
|
|
return %m : $@thick Beth.Type.Type
|
|
}
|
|
|
|
sil @concrete_meta_existential_metatype : $@convention(thin) () -> @thick P.Type.Protocol {
|
|
entry:
|
|
%m = metatype $@thick P.Type.Protocol
|
|
return %m : $@thick P.Type.Protocol
|
|
}
|
|
|
|
sil @concrete_meta_existential_meta_existential_metatype
|
|
: $@convention(thin) () -> @thick P.Type.Type.Protocol {
|
|
entry:
|
|
%m = metatype $@thick P.Type.Type.Protocol
|
|
return %m : $@thick P.Type.Type.Protocol
|
|
}
|
|
|
|
sil @function_metatype : $@convention(thin) () -> @thick (() -> ()).Type {
|
|
entry:
|
|
%m = metatype $@thick (() -> ()).Type
|
|
return %m : $@thick (() -> ()).Type
|
|
}
|
|
|
|
|
|
// CHECK-LABEL: sil @error_result : $@convention(thin) () -> @error _ErrorType
|
|
sil @error_result : $@convention(thin) () -> @error _ErrorType {
|
|
entry:
|
|
unreachable
|
|
}
|
|
|
|
// CHECK-LABEL: sil @error_result2 : $@convention(thin) () -> (Int, @error _ErrorType)
|
|
sil @error_result2 : $@convention(thin) () -> (Int, @error _ErrorType) {
|
|
entry:
|
|
unreachable
|
|
}
|
|
|
|
// CHECK-LABEL: sil @error_result3 : $@convention(thin) () -> (@owned Class1, @error _ErrorType)
|
|
sil @error_result3 : $@convention(thin) () -> (@owned Class1, @error _ErrorType) {
|
|
entry:
|
|
unreachable
|
|
}
|
|
|
|
// CHECK-LABEL: sil @error_result4 : $@convention(thin) (@owned Class1) -> (@owned Class1, @error _ErrorType)
|
|
sil @error_result4 : $@convention(thin) (@owned Class1) -> (@owned Class1, @error _ErrorType) {
|
|
entry(%0 : $Class1):
|
|
return %0 : $Class1
|
|
}
|
|
|
|
// CHECK-LABEL: sil @try_apply : $@convention(thin) (@owned Class1) -> ()
|
|
sil @try_apply : $@convention(thin) (@owned Class1) -> () {
|
|
entry(%0 : $Class1):
|
|
%1 = function_ref @error_result4 : $@convention(thin) (@owned Class1) -> (@owned Class1, @error _ErrorType)
|
|
// CHECK: try_apply %1(%0) : $@convention(thin) (@owned Class1) -> (@owned Class1, @error _ErrorType), normal bb1, error bb2
|
|
try_apply %1(%0) : $@convention(thin) (@owned Class1) -> (@owned Class1, @error _ErrorType),
|
|
normal bb1, error bb2
|
|
bb1(%2 : $Class1):
|
|
strong_release %2 : $Class1
|
|
br bb3
|
|
bb2(%3 : $_ErrorType):
|
|
release_value %3 : $_ErrorType
|
|
br bb3
|
|
bb3:
|
|
%4 = tuple ()
|
|
return %4 : $()
|
|
}
|
|
|
|
sil @null_class : $@convention(thin) () -> Class1 {
|
|
entry:
|
|
%m = null_class $Class1
|
|
return %m : $Class1
|
|
}
|
|
|
|
|
|
|
|
sil @thin_convention : $@convention(thin) () -> ()
|
|
sil @c_convention : $@convention(c) () -> ()
|
|
sil @method_convention : $@convention(method) (Int) -> ()
|
|
sil @objc_method_convention : $@convention(objc_method) (Int) -> ()
|
|
sil @witness_method_convention : $@convention(witness_method) (Int) -> ()
|
|
|
|
// CHECK-LABEL: sil @conventions : $@convention(thin) (() -> (), @convention(thin) () -> (), @convention(c) () -> (), @convention(block) () -> (), @convention(method) () -> (), @convention(objc_method) () -> (), @convention(witness_method) () -> ()) -> () {
|
|
sil @conventions : $@convention(thin) (@convention(thick) () -> (),
|
|
@convention(thin) () -> (),
|
|
@convention(c) () -> (),
|
|
@convention(block) () -> (),
|
|
@convention(method) () -> (),
|
|
@convention(objc_method) () -> (),
|
|
@convention(witness_method) () -> ()) -> () {
|
|
entry(%0 : $@convention(thick) () -> (),
|
|
%1 : $@convention(thin) () -> (),
|
|
%2 : $@convention(c) () -> (),
|
|
%3 : $@convention(block) () -> (),
|
|
%4 : $@convention(method) () -> (),
|
|
%5 : $@convention(objc_method) () -> (),
|
|
%6 : $@convention(witness_method) () -> ()):
|
|
return undef : $()
|
|
}
|
|
|
|
// CHECK-LABEL: sil @is_unique : $@convention(thin) (@inout Builtin.NativeObject)
|
|
sil @is_unique : $@convention(thin) (@inout Builtin.NativeObject) -> Builtin.Int1 {
|
|
bb0(%0 : $*Builtin.NativeObject):
|
|
// CHECK: %1 = is_unique %0 : $*Builtin.NativeObject
|
|
%1 = is_unique %0 : $*Builtin.NativeObject
|
|
return %1 : $Builtin.Int1
|
|
}
|
|
|
|
// CHECK-LABEL: sil @is_unique_or_pinned : $@convention(thin) (@inout Builtin.NativeObject)
|
|
sil @is_unique_or_pinned : $@convention(thin) (@inout Builtin.NativeObject) -> Builtin.Int1 {
|
|
bb0(%0 : $*Builtin.NativeObject):
|
|
// CHECK: %1 = is_unique_or_pinned %0 : $*Builtin.NativeObject
|
|
%1 = is_unique_or_pinned %0 : $*Builtin.NativeObject
|
|
return %1 : $Builtin.Int1
|
|
}
|
|
|
|
// CHECK-LABEL: sil_vtable Foo {
|
|
// CHECK: #Foo.subscript!getter.1: _TFC3tmp3Foog9subscriptFTVSs5Int32S1__S1_
|
|
// CHECK: #Foo.subscript!setter.1: _TFC3tmp3Foos9subscriptFTVSs5Int32S1__S1_
|
|
// CHECK: }
|
|
sil_vtable Foo {
|
|
#Foo.subscript!getter.1: _TFC3tmp3Foog9subscriptFTVSs5Int32S1__S1_
|
|
#Foo.subscript!setter.1: _TFC3tmp3Foos9subscriptFTVSs5Int32S1__S1_
|
|
}
|
|
|