mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
1134 lines
42 KiB
Plaintext
1134 lines
42 KiB
Plaintext
sil_stage raw // CHECK: sil_stage raw
|
|
|
|
import Builtin
|
|
import Swift
|
|
import Foundation
|
|
|
|
// Test SIL Global variable.
|
|
// CHECK-NOT: sil_global private @globalinit_token0 : $Builtin.Word
|
|
sil_global private @globalinit_token0 : $Builtin.Word
|
|
|
|
// CHECK-NOT: sil_global public @public_global : $Builtin.Word
|
|
sil_global public @public_global : $Builtin.Word
|
|
|
|
var staticProp: Int = 0
|
|
sil @globalinit_func0 : $@thin () -> ()
|
|
|
|
// We should not serialize this since it references the private variable globalinit_token0.
|
|
// CHECK-NOT: sil public_external @_TFV18lazy_global_access4Type10staticPropSia : $@thin () -> Builtin.RawPointer {
|
|
sil @_TFV18lazy_global_access4Type10staticPropSia : $@thin () -> Builtin.RawPointer {
|
|
bb0:
|
|
%0 = builtin_function_ref "once" : $@thin (Builtin.RawPointer, @owned @callee_owned () -> ()) -> ()
|
|
%1 = sil_global_addr @globalinit_token0 : $*Builtin.Word
|
|
%2 = address_to_pointer %1 : $*Builtin.Word to $Builtin.RawPointer
|
|
%3 = function_ref @globalinit_func0 : $@thin () -> ()
|
|
%4 = thin_to_thick_function %3 : $@thin () -> () to $@callee_owned () -> ()
|
|
%5 = apply %0(%2, %4) : $@thin (Builtin.RawPointer, @owned @callee_owned () -> ()) -> ()
|
|
%6 = global_addr #staticProp : $*Int
|
|
%7 = address_to_pointer %6 : $*Int to $Builtin.RawPointer
|
|
return %7 : $Builtin.RawPointer
|
|
}
|
|
|
|
// This references a public global so we *SHOULD* derserialize this.
|
|
// CHECK-LABEL: sil public_external @_TFV18lazy_global_access4Type10staticPropSia_public : $@thin () -> Builtin.RawPointer {
|
|
sil @_TFV18lazy_global_access4Type10staticPropSia_public : $@thin () -> Builtin.RawPointer {
|
|
bb0:
|
|
%0 = builtin_function_ref "once" : $@thin (Builtin.RawPointer, @owned @callee_owned () -> ()) -> ()
|
|
// CHECK: sil_global_addr @public_global : $*Builtin.Word
|
|
%1 = sil_global_addr @public_global : $*Builtin.Word
|
|
%2 = address_to_pointer %1 : $*Builtin.Word to $Builtin.RawPointer
|
|
%3 = function_ref @globalinit_func0 : $@thin () -> ()
|
|
%4 = thin_to_thick_function %3 : $@thin () -> () to $@callee_owned () -> ()
|
|
%5 = apply %0(%2, %4) : $@thin (Builtin.RawPointer, @owned @callee_owned () -> ()) -> ()
|
|
%6 = global_addr #staticProp : $*Int
|
|
%7 = address_to_pointer %6 : $*Int to $Builtin.RawPointer
|
|
return %7 : $Builtin.RawPointer
|
|
}
|
|
|
|
// Type references
|
|
|
|
// Some cyclic type references between SIL function bodies.
|
|
class Class1 {
|
|
var a : Class2
|
|
init()
|
|
}
|
|
class Class2 {
|
|
var b : Class1
|
|
init()
|
|
}
|
|
|
|
// Instructions
|
|
|
|
// CHECK-LABEL: sil public_external @test1 : $@thin () -> ()
|
|
sil @test1 : $@thin () -> () {
|
|
bb0: // CHECK: bb0:
|
|
%0 = tuple () // CHECK: %0 = tuple ()
|
|
br bb1 // CHECK: br bb1
|
|
bb1:
|
|
%b = alloc_box $Int
|
|
%c = integer_literal $Builtin.Word, 1
|
|
// CHECK: alloc_array $String, %{{.*}} : $Builtin.Word
|
|
%d = alloc_array $String, %c : $Builtin.Word
|
|
return %0 : $() // CHECK: return %0 : $()
|
|
}
|
|
|
|
// Forward referenced values.
|
|
// CHECK-LABEL: sil public_external @test2 : $@thin (Int) -> ()
|
|
sil @test2 : $@thin (Int) -> () {
|
|
// CHECK: bb1:
|
|
// CHECK: %2 = tuple ()
|
|
// CHECK: br bb2
|
|
// CHECK: bb2:
|
|
// FIXME: should be %2
|
|
// CHECK: return %{{.*}} : $()
|
|
bb0(%0 : $Int):
|
|
br bb2
|
|
bb1:
|
|
// Forward reference MRVs.
|
|
store %0 to %6#1 : $*Int
|
|
strong_release %6#0 : $Builtin.ObjectPointer
|
|
|
|
return %5 : $()
|
|
bb2:
|
|
%5 = tuple ()
|
|
%6 = alloc_box $Int
|
|
br bb1
|
|
}
|
|
|
|
// CHECK-LABEL: @named_tuple : $@thin () -> (Builtin.Word, Builtin.Word)
|
|
sil @named_tuple : $@thin () -> (Builtin.Word, Builtin.Word) {
|
|
%0 = integer_literal $Builtin.Word, 42
|
|
// CHECK: integer_literal $Builtin.Word, 42
|
|
%9 = tuple $(Builtin.Word, Builtin.Word) (%0, %0)
|
|
%10 = return %9 : $(Builtin.Word, Builtin.Word)
|
|
}
|
|
|
|
sil @return_int : $@thin (Int) -> Int { // CHECK-LABEL: $@thin (Int) -> Int {
|
|
bb0(%0 : $Int): // CHECK: bb0(%0 : $Int):
|
|
// CHECK: alloc_stack $Int
|
|
// CHECK: store
|
|
%1 = alloc_stack $Int
|
|
store %0 to %1#1 : $*Int
|
|
%3 = load %1#1 : $*Int
|
|
dealloc_stack %1#0 : $*@local_storage Int
|
|
return %3 : $Int // CHECK: return {{.*}} : $Int
|
|
}
|
|
|
|
// CHECK-LABEL: @call_fn_pointer : $@thin (() -> Int) -> Int {
|
|
sil @call_fn_pointer : $@thin (() -> Int) -> Int {
|
|
bb0(%0 : $() -> Int):
|
|
%1 = alloc_stack $() -> Int
|
|
store %0 to %1#1 : $*() -> Int
|
|
%3 = load %1#1 : $*() -> Int
|
|
strong_retain %3 : $() -> Int
|
|
// CHECK: strong_retain %{{.*}} : $() -> Int
|
|
%5 = apply %3() : $() -> Int
|
|
// CHECK: apply %{{.*}}() : $() -> Int
|
|
%6 = load %1#1 : $*() -> Int
|
|
strong_release %3 : $() -> Int
|
|
// CHECK: strong_release {{.*}} : $() -> Int
|
|
dealloc_stack %1#0 : $*@local_storage () -> Int
|
|
return %5 : $Int // CHECK: return %{{.*}} : $Int
|
|
}
|
|
|
|
sil @return_constant : $@thin () -> Int { // CHECK-LABEL: @return_constant
|
|
bb0: // CHECK: bb0:
|
|
// CHECK: function_ref @_TFSi25convertFromIntegerLiteralfMSiFT3valBi64__Si : $@thin (Builtin.Word, @thin Int.Type) -> Int
|
|
%1 = function_ref @_TFSi25convertFromIntegerLiteralfMSiFT3valBi64__Si : $@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) : $@thin (Builtin.Word, @thin Int.Type) -> Int
|
|
// CHECK: return
|
|
%5 = return %4 : $Int
|
|
}
|
|
|
|
sil @_TFSi25convertFromIntegerLiteralfMSiFT3valBi64__Si : $@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 @_TFSb13getLogicValuefRSbFT_Bi1_ : $@cc(method) @thin (@inout Bool) -> Builtin.Int1
|
|
sil @_TFSi33_convertFromBuiltinIntegerLiteralfMSiFT3valBi128__Si : $@thin (Builtin.Int128, @thin Int.Type) -> Int
|
|
|
|
|
|
protocol P {
|
|
func doIt()
|
|
}
|
|
|
|
// CHECK-LABEL: @existentials : $@thin (@in P) -> () {
|
|
sil @existentials : $@thin (@in P) -> () {
|
|
bb0(%0 : $*P):
|
|
%1 = project_existential %0 : $*P to $*@sil_self P // CHECK: project_existential %0
|
|
|
|
// CHECK: protocol_method {{.*}} : $*P, #P.doIt!1
|
|
%2 = protocol_method %0 : $*P, #P.doIt!1 : $@cc(witness_method) (@inout @sil_self P) -> ()
|
|
// CHECK: apply
|
|
%3 = apply %2(%1) : $@cc(witness_method) (@inout @sil_self P) -> ()
|
|
%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()
|
|
}
|
|
}
|
|
|
|
// CHECK-LABEL: @classes : $@thin () -> () {
|
|
sil @classes : $@thin () -> () {
|
|
bb0:
|
|
// CHECK: %0 = alloc_ref $C
|
|
%C = alloc_ref $C
|
|
// CHECK: ref_to_object_pointer %0 : $C to $Builtin.ObjectPointer
|
|
%1 = ref_to_object_pointer %C : $C to $Builtin.ObjectPointer
|
|
// CHECK: ref_to_object_pointer %0 : $C to $Builtin.ObjCPointer
|
|
%O = ref_to_object_pointer %C : $C to $Builtin.ObjCPointer
|
|
|
|
// CHECK: class_method {{.*}} : $C, #C.doIt!1
|
|
%2 = class_method %C : $C, #C.doIt!1 : C -> () -> (), $@cc(method) @thin (@owned C) -> ()
|
|
|
|
// CHECK: alloc_ref $D
|
|
%D = alloc_ref $D
|
|
|
|
// CHECK: upcast {{.*}} : $D to $C
|
|
%a = upcast %D : $D to $C
|
|
|
|
// CHECK: unconditional_checked_cast downcast {{.*}} : $C to $D
|
|
%5 = unconditional_checked_cast downcast %C : $C to $D
|
|
%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 {
|
|
typealias U
|
|
var free:Int { get }
|
|
var associated:U { get }
|
|
|
|
func free_method() -> Int
|
|
func associated_method() -> U.Type
|
|
class func static_method()
|
|
}
|
|
|
|
//sil @_TF4arch20archetype_member_refUS_8Runcible___FT1xQ__T_ : $@thin <T : Runcible> (T) -> () {
|
|
//bb0(%0 : $*T):
|
|
//%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
|
|
//%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
|
|
//%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-LABEL: $@thin (@out Runcible, @in protocol<Bendable, Runcible>) -> ()
|
|
sil @_TF4todo18erasure_from_protoFT1xPS_8RuncibleS_8Bendable__PS0__ : $@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>
|
|
// CHECK: upcast_existential [take] {{.*}} : $*protocol<Bendable, Runcible> to {{.*}} : $*Runcible
|
|
%6 = upcast_existential [take] %4#1 : $*protocol<Bendable, Runcible> to %0 : $*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>
|
|
%10 = strong_release %2#0 : $Builtin.ObjectPointer
|
|
// CHECK: return
|
|
%11 = return %7 : $()
|
|
}
|
|
|
|
@class_protocol protocol ClassBound {
|
|
func classBoundMethod()
|
|
}
|
|
|
|
// CHECK-LABEL: @_TF4todo18class_bound_methodFT1xPS_10ClassBound__T_ : $@thin (@owned ClassBound) -> ()
|
|
sil @_TF4todo18class_bound_methodFT1xPS_10ClassBound__T_ : $@thin (@owned ClassBound) -> () {
|
|
bb0(%0 : $ClassBound):
|
|
%1 = alloc_box $ClassBound
|
|
%2 = store %0 to %1#1 : $*ClassBound
|
|
%3 = load %1#1 : $*ClassBound
|
|
%4 = strong_retain %3 : $ClassBound // CHECK: strong_retain
|
|
// CHECK: project_existential_ref {{%.*}} : $ClassBound to $@sil_self ClassBound
|
|
%5 = project_existential_ref %3 : $ClassBound to $@sil_self ClassBound
|
|
// CHECK: protocol_method
|
|
%6 = protocol_method %3 : $ClassBound, #ClassBound.classBoundMethod!1 : $@cc(witness_method) (@sil_self ClassBound) -> ()
|
|
%7 = apply %6(%5) : $@cc(witness_method) (@sil_self ClassBound) -> ()
|
|
%8 = tuple ()
|
|
%9 = strong_release %1#0 : $Builtin.ObjectPointer
|
|
%10 = return %8 : $()
|
|
}
|
|
|
|
struct Val {
|
|
}
|
|
|
|
//sil @_TFV4todo3ValCfMS0_FT_S0_ : $@thin (@thin Val.Type) -> Val {
|
|
//bb0(%0 : $@thin Val.Type):
|
|
//%1 = alloc_stack $Val
|
|
//%3 = load %1#1 : $*Val
|
|
//%4 = return %3 : $Val
|
|
//}
|
|
|
|
class Ref {
|
|
}
|
|
struct Aleph {
|
|
var a:Ref
|
|
var b:Val
|
|
}
|
|
|
|
// CHECK-LABEL: @_TFV6struct5AlephCfMS0_FT1aCS_3Ref1bVS_3Val_S0_ : $@thin (Ref, Val, @thin Aleph.Type) -> Aleph
|
|
sil @_TFV6struct5AlephCfMS0_FT1aCS_3Ref1bVS_3Val_S0_ : $@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-LABEL: @_TFV6struct5AlephCfMS0_FT_S0_ : $@thin (@thin Aleph.Type) -> Aleph
|
|
sil @_TFV6struct5AlephCfMS0_FT_S0_ : $@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.ObjectPointer
|
|
%18 = return %14 : $Aleph
|
|
}
|
|
|
|
enum Beth {
|
|
case EmptyCase
|
|
case DataCase(Int)
|
|
}
|
|
|
|
// CHECK-LABEL: @test_union_empty_case : $@thin () -> Beth {
|
|
sil @test_union_empty_case : $@thin () -> Beth {
|
|
bb0:
|
|
// CHECK: %0 = enum $Beth, #Beth.EmptyCase!enumelt
|
|
%0 = enum $Beth, #Beth.EmptyCase!enumelt
|
|
return %0 : $Beth
|
|
}
|
|
|
|
// CHECK-LABEL: @test_union_data_case : $@thin (Int) -> Beth {
|
|
sil @test_union_data_case : $@thin 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)
|
|
}
|
|
|
|
// CHECK-LABEL: @test_union_addr_empty_case : $@thin (@out Gimel) -> () {
|
|
sil @test_union_addr_empty_case : $@thin (@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 : $()
|
|
}
|
|
|
|
// CHECK-LABEL: @test_union_addr_data_case : $@thin (@out Gimel, @in Q) -> () {
|
|
sil @test_union_addr_data_case : $@thin (@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 @_TF5tuple5floatFT1xSf_T_ : $@thin (Float32) -> ()
|
|
sil @_TF5tuple5tupleFT_TSiSf_ : $@thin () -> (Int, Float32)
|
|
|
|
// CHECK-LABEL: @_TF5tuple13tuple_elementFT1xTSiSf__T_ : $@thin (Int, Float32) -> ()
|
|
sil @_TF5tuple13tuple_elementFT1xTSiSf__T_ : $@thin (Int, Float32) -> () {
|
|
bb0(%0 : $Int, %1 : $Float32):
|
|
%2 = alloc_box $(Int, Float32)
|
|
%3 = tuple (%0 : $Int, %1 : $Float32)
|
|
%4 = store %3 to %2#1 : $*(Int, Float32)
|
|
// CHECK: tuple_element_addr {{%.*}}#{{.*}} : $*(Int, Float32), 0
|
|
%6 = tuple_element_addr %2#1 : $*(Int, Float32), 0
|
|
%7 = load %6 : $*Int
|
|
// CHECK: tuple_element_addr {{%.*}}#{{.*}} : $*(Int, Float32), 1
|
|
%10 = tuple_element_addr %2#1 : $*(Int, Float32), 1
|
|
%11 = load %10 : $*Float32
|
|
// CHECK: function_ref
|
|
%14 = function_ref @_TF5tuple5tupleFT_TSiSf_ : $@thin () -> (Int, Float32)
|
|
// CHECK: apply
|
|
%15 = apply %14() : $@thin () -> (Int, Float32)
|
|
// CHECK: function_ref
|
|
%19 = function_ref @_TF5tuple5floatFT1xSf_T_ : $@thin (Float32) -> ()
|
|
// CHECK: tuple_extract {{%.*}} : $(Int, Float32), 1
|
|
%17 = tuple_extract %15 : $(Int, Float32), 1
|
|
// CHECK: apply
|
|
%24 = apply %19(%17) : $@thin (Float32) -> ()
|
|
%25 = tuple ()
|
|
%26 = strong_release %2#0 : $Builtin.ObjectPointer
|
|
%27 = return %25 : $()
|
|
}
|
|
|
|
class M {
|
|
var member : Int
|
|
init()
|
|
}
|
|
|
|
// CHECK-LABEL: @_TFC3ref1C3foofS0_FT1xSi_T_ : $@cc(method) @thin (Int, M) -> ()
|
|
sil @_TFC3ref1C3foofS0_FT1xSi_T_ : $@cc(method) @thin (Int, M) -> () {
|
|
bb0(%0 : $Int, %1 : $M):
|
|
%2 = alloc_box $Int
|
|
%3 = store %0 to %2#1 : $*Int
|
|
%4 = alloc_box $M
|
|
%5 = store %1 to %4#1 : $*M
|
|
%6 = load %2#1 : $*Int
|
|
%7 = load %4#1 : $*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.ObjectPointer
|
|
%14 = strong_release %2#0 : $Builtin.ObjectPointer
|
|
%15 = return %12 : $()
|
|
}
|
|
|
|
class B { }
|
|
class E : B { }
|
|
|
|
// CHECK-LABEL: @_TF4null3isaFT1bCS_1B_Sb : $@thin (B) -> Builtin.Int1
|
|
sil @_TF4null3isaFT1bCS_1B_Sb : $@thin (B) -> Builtin.Int1 {
|
|
bb0(%0 : $B):
|
|
%1 = alloc_box $B
|
|
%2 = store %0 to %1#1 : $*B
|
|
%3 = load %1#1 : $*B
|
|
%4 = strong_retain %3 : $B
|
|
checked_cast_br downcast %3 : $B to $E, yes, no // CHECK: checked_cast_br downcast
|
|
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.ObjectPointer
|
|
%9 = return %6 : $Builtin.Int1
|
|
}
|
|
|
|
sil @_TF7literal8literalsFT_T_ : $@thin () -> ()
|
|
|
|
sil @_TFSd31_convertFromBuiltinFloatLiteralfMSdFT5valueBf64__Sd : $@thin (Builtin.FPIEEE64, @thin Float64.Type) -> Float64
|
|
sil @_TFSS32_convertFromBuiltinStringLiteralfMSSFT5valueBp8byteSizeBi64_7isASCIIBi1__SS : $@thin (Builtin.RawPointer, Builtin.Word, Builtin.Int1, @thin String.Type) -> String
|
|
|
|
// CHECK-LABEL: @_TF5index5gep64FT1pBp1iBi64__Bp : $@thin (Builtin.RawPointer, Builtin.Word) -> Builtin.RawPointer {
|
|
sil @_TF5index5gep64FT1pBp1iBi64__Bp : $@thin (Builtin.RawPointer, Builtin.Word) -> Builtin.RawPointer {
|
|
bb0(%0 : $Builtin.RawPointer, %1 : $Builtin.Word):
|
|
%2 = alloc_box $Builtin.RawPointer
|
|
%3 = alloc_box $Builtin.Word
|
|
%4 = store %0 to %2#1 : $*Builtin.RawPointer
|
|
%5 = store %1 to %3#1 : $*Builtin.Word
|
|
%7 = load %2#1 : $*Builtin.RawPointer
|
|
%8 = load %3#1 : $*Builtin.Word
|
|
// CHECK: index_raw_pointer {{%.*}} : $Builtin.RawPointer, {{%.*}} : $Builtin.Word
|
|
%9 = index_raw_pointer %7 : $Builtin.RawPointer, %8 : $Builtin.Word
|
|
%10 = strong_release %3#0 : $Builtin.ObjectPointer
|
|
%11 = strong_release %2#0 : $Builtin.ObjectPointer
|
|
%12 = return %9 : $Builtin.RawPointer
|
|
}
|
|
|
|
var x : Int = 0
|
|
sil @global_callee : $@thin (Builtin.Int128, @thin Int.Type) -> Int
|
|
|
|
// CHECK-LABEL: @global_code : $@thin () -> ()
|
|
sil @global_code : $@thin () -> () {
|
|
bb0:
|
|
// CHECK: global_addr #x : $*Int
|
|
%0 = global_addr #x : $*Int
|
|
%1 = function_ref @global_callee : $@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) : $@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 {}
|
|
|
|
// CHECK-LABEL: @test_class_metatype : $@thin (SomeClass, SomeSubclass) -> (@thick SomeClass.Type, @thick SomeClass.Type) {
|
|
sil @test_class_metatype : $@thin (SomeClass, SomeSubclass) -> (@thick SomeClass.Type, @thick SomeClass.Type) {
|
|
bb0(%0 : $SomeClass, %1 : $SomeSubclass):
|
|
%2 = alloc_box $SomeClass
|
|
%3 = alloc_box $SomeSubclass
|
|
%4 = store %0 to %2#1 : $*SomeClass
|
|
%5 = store %1 to %3#1 : $*SomeSubclass
|
|
%7 = load %2#1 : $*SomeClass
|
|
// CHECK: strong_retain %{{.*}} : $SomeClass
|
|
%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
|
|
%12 = strong_retain %11 : $SomeSubclass
|
|
// CHECK: value_metatype $@thick SomeSubclass.Type, {{%.*}} : $SomeSubclass
|
|
%13 = value_metatype $@thick SomeSubclass.Type, %11 : $SomeSubclass
|
|
// CHECK: upcast %{{.*}} : $@thick SomeSubclass.Type to $@thick SomeClass.Type
|
|
%14 = upcast %13 : $@thick SomeSubclass.Type to $@thick SomeClass.Type
|
|
// CHECK: tuple (%{{.*}} : $@thick SomeClass.Type, %{{.*}} : $@thick SomeClass.Type)
|
|
%15 = tuple (%9 : $@thick SomeClass.Type, %14 : $@thick SomeClass.Type)
|
|
%16 = strong_release %11 : $SomeSubclass
|
|
%17 = strong_release %7 : $SomeClass
|
|
%18 = strong_release %3#0 : $Builtin.ObjectPointer
|
|
%19 = strong_release %2#0 : $Builtin.ObjectPointer
|
|
%20 = return %15 : $(@thick SomeClass.Type, @thick SomeClass.Type)
|
|
}
|
|
|
|
// CHECK-LABEL: @test_existential_metatype : $@thin (@in SomeProtocol) -> @thick SomeProtocol.Type {
|
|
sil @test_existential_metatype : $@thin (@in SomeProtocol) -> @thick SomeProtocol.Type {
|
|
bb0(%0 : $*SomeProtocol):
|
|
%1 = alloc_box $SomeProtocol
|
|
// CHECK: copy_addr [take] %0 to [initialization] %1#1 : $*SomeProtocol
|
|
%2 = copy_addr [take] %0 to [initialization] %1#1 : $*SomeProtocol
|
|
// CHECK: alloc_stack
|
|
%4 = alloc_stack $SomeProtocol
|
|
// CHECK: copy_addr %1#1 to [initialization] %{{.*}}#1 : $*SomeProtocol
|
|
%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.ObjectPointer
|
|
%10 = return %6 : $@thick SomeProtocol.Type
|
|
}
|
|
|
|
// CHECK-LABEL: sil public_external @test_unreachable
|
|
sil @test_unreachable : $@thin () -> () {
|
|
bb0:
|
|
unreachable
|
|
// CHECK: unreachable
|
|
}
|
|
|
|
// CHECK-LABEL: @test_unowned_retain : $@thin (SomeClass) -> () {
|
|
sil @test_unowned_retain : $@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 public_external @test_basic_block_arguments
|
|
sil @test_basic_block_arguments : $@thin (Builtin.Int1) -> Builtin.Word {
|
|
bb0(%0 : $Builtin.Int1):
|
|
// CHECK: cond_br
|
|
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 public_external @test_cond_branch_basic_block_args
|
|
sil @test_cond_branch_basic_block_args : $@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
|
|
}
|
|
|
|
class Bas : NSObject {
|
|
var strRealProp : String
|
|
init()
|
|
}
|
|
sil @test_autorelease_return : $@cc(objc_method) @thin (Bas) -> NSString
|
|
sil @test_super_method : $@cc(method) @thin (Bas) -> Bas
|
|
|
|
sil @swift_StringToNSString : $@thin (@inout String) -> @owned NSString
|
|
sil @_TFSSCfMSSFT_SS : $@thin (@thin String.Type) -> String
|
|
|
|
// CHECK-LABEL: sil public_external @test_builtin_func_ref
|
|
sil @test_builtin_func_ref : $@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
|
|
// CHECK: builtin_function_ref "cmp_eq_Int1" : $@thin (Builtin.Int1, Builtin.Int1) -> Builtin.Int1
|
|
%7 = builtin_function_ref "cmp_eq_Int1" : $@thin (Builtin.Int1, Builtin.Int1) -> Builtin.Int1
|
|
%8 = load %2#1 : $*Builtin.Int1
|
|
%9 = load %3#1 : $*Builtin.Int1
|
|
%10 = apply %7(%8, %9) : $@thin (Builtin.Int1, Builtin.Int1) -> Builtin.Int1
|
|
strong_release %3#0 : $Builtin.ObjectPointer
|
|
strong_release %2#0 : $Builtin.ObjectPointer
|
|
return %10 : $Builtin.Int1
|
|
}
|
|
|
|
// CHECK-LABEL: sil public_external @test_dealloc_ref
|
|
sil @test_dealloc_ref : $@thin () -> () {
|
|
bb0:
|
|
%0 = alloc_ref $Class1
|
|
// CHECK: dealloc_ref %{{.*}} : $Class1
|
|
dealloc_ref %0 : $Class1
|
|
%2 = tuple ()
|
|
return %2 : $()
|
|
}
|
|
|
|
// CHECK-LABEL: sil public_external @test_dealloc_box
|
|
sil @test_dealloc_box : $@thin () -> () {
|
|
bb0:
|
|
%0 = alloc_box $Class1
|
|
dealloc_box $Class1, %0#0 : $Builtin.ObjectPointer
|
|
%2 = tuple ()
|
|
return %2 : $()
|
|
}
|
|
|
|
// CHECK-LABEL: @closure_test
|
|
sil @takes_closure : $@thin (@callee_owned () -> ()) -> ()
|
|
sil @closure0 : $@thin (Builtin.ObjectPointer, @inout Int) -> ()
|
|
|
|
sil @closure_test : $@thin () -> () {
|
|
bb0:
|
|
%0 = alloc_box $Int // users: %10, %8, %8, %7, %4
|
|
|
|
%5 = function_ref @takes_closure : $@thin (@callee_owned () -> ()) -> ()
|
|
%6 = function_ref @closure0 : $@thin (Builtin.ObjectPointer, @inout Int) -> ()
|
|
strong_retain %0#0 : $Builtin.ObjectPointer
|
|
//%8 = partial_apply %6(%0#0, %0#1) : $@thin (Builtin.ObjectPointer, @inout Int) -> ()
|
|
//%9 = apply %5(%8) : $@thin (@callee_owned () -> ()) -> ()
|
|
//strong_release %0#0 : $Builtin.ObjectPointer
|
|
|
|
%11 = tuple ()
|
|
return %11 : $()
|
|
}
|
|
|
|
@class_protocol protocol ClassP {}
|
|
|
|
enum MaybePair {
|
|
case Neither
|
|
case Left(Int)
|
|
}
|
|
|
|
sil @_TF6switch1aFT_T_ : $@thin () -> ()
|
|
sil @_TF6switch1bFT_T_ : $@thin () -> ()
|
|
sil @_TF6switch1cFT_T_ : $@thin () -> ()
|
|
|
|
// CHECK-LABEL: sil public_external @test_switch_union : $@thin (MaybePair) -> ()
|
|
sil @test_switch_union : $@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 @_TF6switch1aFT_T_ : $@thin () -> ()
|
|
%8 = apply %7() : $@thin () -> ()
|
|
br bb5 // CHECK: br
|
|
|
|
bb3(%10 : $Int):
|
|
br bb4
|
|
|
|
bb4:
|
|
%12 = function_ref @_TF6switch1bFT_T_ : $@thin () -> ()
|
|
%13 = apply %12() : $@thin () -> ()
|
|
br bb5 // CHECK: br
|
|
|
|
bb5:
|
|
%15 = function_ref @_TF6switch1cFT_T_ : $@thin () -> ()
|
|
%16 = apply %15() : $@thin () -> ()
|
|
strong_release %1#0 : $Builtin.ObjectPointer
|
|
%18 = tuple ()
|
|
return %18 : $() // CHECK: return
|
|
}
|
|
|
|
enum MaybeAddressOnlyPair {
|
|
case Neither
|
|
case Left(Q)
|
|
}
|
|
|
|
// CHECK-LABEL: sil public_external @test_switch_union_addr : $@thin (@in MaybeAddressOnlyPair) -> ()
|
|
sil @test_switch_union_addr : $@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: take_enum_data_addr [[ENUM]] : $*MaybeAddressOnlyPair, #MaybeAddressOnlyPair.Left!enumelt.1
|
|
%q = take_enum_data_addr %0 : $*MaybeAddressOnlyPair, #MaybeAddressOnlyPair.Left!enumelt.1
|
|
br bb3
|
|
|
|
bb3:
|
|
%t = tuple ()
|
|
return %t : $()
|
|
}
|
|
|
|
// CHECK-LABEL: sil public_external @test_switch_int : $@thin (Builtin.Word) -> ()
|
|
sil @test_switch_int : $@thin (Builtin.Word) -> () {
|
|
bb0(%0 : $Builtin.Word):
|
|
// CHECK: switch_int %{{.*}} : $Builtin.Word, case 1: bb1, case 2: bb2
|
|
switch_int %0 : $Builtin.Word, case 1: bb1, case 2: bb2
|
|
|
|
bb1:
|
|
%7 = function_ref @_TF6switch1aFT_T_ : $@thin () -> () // CHECK: function_ref
|
|
%8 = apply %7() : $@thin () -> ()
|
|
br bb3
|
|
|
|
bb2:
|
|
%12 = function_ref @_TF6switch1bFT_T_ : $@thin () -> () // CHECK: function_ref
|
|
%13 = apply %12() : $@thin () -> ()
|
|
br bb3
|
|
|
|
bb3:
|
|
%18 = tuple ()
|
|
return %18 : $() // CHECK: return
|
|
}
|
|
|
|
class ConcreteClass : ClassP {
|
|
}
|
|
struct Spoon : Bendable {
|
|
}
|
|
|
|
// CHECK-LABEL: sil public_external @test_init_existential : $@thin (@out Bendable, Spoon) -> ()
|
|
sil @test_init_existential : $@thin (@out Bendable, Spoon) -> () {
|
|
bb0(%0 : $*Bendable, %1 : $Spoon):
|
|
%2 = alloc_box $Spoon
|
|
store %1 to %2#1 : $*Spoon
|
|
// CHECK: init_existential %{{.*}} : $*Bendable, $*Spoon
|
|
%4 = init_existential %0 : $*Bendable, $*Spoon
|
|
// CHECK: deinit_existential %{{.*}} : $*Bendable
|
|
deinit_existential %0 : $*Bendable
|
|
%5 = load %2#1 : $*Spoon
|
|
store %5 to %4 : $*Spoon
|
|
strong_release %2#0 : $Builtin.ObjectPointer
|
|
%8 = tuple ()
|
|
return %8 : $()
|
|
}
|
|
|
|
// CHECK-LABEL: sil public_external @test_existential_ref : $@thin (ConcreteClass) -> ClassP
|
|
sil @test_existential_ref : $@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, $ClassP
|
|
%5 = init_existential_ref %3 : $ConcreteClass, $ClassP
|
|
strong_release %1#0 : $Builtin.ObjectPointer
|
|
return %5 : $ClassP
|
|
}
|
|
|
|
sil @test_assign : $@thin (Int, @inout Int) -> () { // CHECK-LABEL: sil public_external @test_assign
|
|
bb0(%0 : $Int, %1 : $*Int):
|
|
assign %0 to %1 : $*Int // CHECK: assign
|
|
unreachable
|
|
}
|
|
|
|
// CHECK-LABEL: sil public_external @test_transparent : $@thin () -> () {
|
|
sil @test_transparent : $@thin () -> () {
|
|
bb0:
|
|
// CHECK: function_ref
|
|
// CHECK: apply [transparent]
|
|
%0 = function_ref @classes : $@thin () -> ()
|
|
%1 = apply [transparent] %0() : $@thin () -> ()
|
|
%2 = tuple ()
|
|
%3 = return %2 : $()
|
|
}
|
|
|
|
sil @takes_unnamed_closure : $@thin (@callee_owned () -> Int) -> @callee_owned () -> @callee_owned () -> Int
|
|
|
|
sil @takes_int64_float32 : $@thin (Int, Float32) -> ()
|
|
|
|
// CHECK-LABEL: sil public_external @test_partial_apply : $@thin (Float32) -> @callee_owned (Int) -> () {
|
|
sil @test_partial_apply : $@thin Float32 -> @callee_owned Int -> () {
|
|
bb0(%0 : $Float32):
|
|
%1 = function_ref @takes_int64_float32 : $@thin (Int, Float32) -> ()
|
|
// CHECK: partial_apply %{{.*}}(%{{.*}}) : $@thin (Int, Float32) -> ()
|
|
%2 = partial_apply %1(%0) : $@thin (Int, Float32) -> ()
|
|
%3 = return %2 : $@callee_owned Int -> ()
|
|
}
|
|
|
|
class X {
|
|
@objc func f() { }
|
|
}
|
|
|
|
// CHECK-LABEL: sil public_external @test_dynamic_lookup_br : $@thin (AnyObject) -> ()
|
|
sil @test_dynamic_lookup_br : $@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
|
|
// CHECK: project_existential_ref %{{.*}} : $AnyObject to $@sil_self AnyObject
|
|
%6 = project_existential_ref %4 : $AnyObject to $@sil_self AnyObject
|
|
%7 = ref_to_object_pointer %6 : $@sil_self AnyObject to $Builtin.ObjCPointer
|
|
// CHECK: dynamic_method_br %{{.*}} : $Builtin.ObjCPointer, #X.f!1, bb{{.*}}, bb{{.*}}
|
|
dynamic_method_br %7 : $Builtin.ObjCPointer, #X.f!1, bb1, bb2
|
|
bb1:
|
|
br bb3
|
|
|
|
bb2:
|
|
br bb3
|
|
|
|
bb3:
|
|
%28 = tuple ()
|
|
return %28 : $()
|
|
}
|
|
|
|
// CHECK-LABEL: sil public_external @test_mark_fn_escape
|
|
sil @test_mark_fn_escape : $@thin () -> () {
|
|
%b = alloc_box $Int
|
|
%c = alloc_box $Int
|
|
|
|
//mark_function_escape %b#1 : $*Int
|
|
//mark_function_escape %b#1 : $*Int, %c#1 : $*Int
|
|
|
|
%28 = tuple ()
|
|
return %28 : $()
|
|
}
|
|
|
|
// CHECK-LABEL: sil public_external @test_copy_release_value
|
|
sil @test_copy_release_value : $@thin (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-NEXT: return [[T0]] : $Val
|
|
}
|
|
|
|
func serialize_all() {
|
|
}
|
|
|
|
// CHECK: sil public_external @cond_fail_test : $@thin (Builtin.Int1) -> () {
|
|
sil @cond_fail_test : $@thin Builtin.Int1 -> () {
|
|
entry(%0 : $Builtin.Int1):
|
|
// CHECK: cond_fail %0 : $Builtin.Int1
|
|
cond_fail %0 : $Builtin.Int1
|
|
%1 = tuple ()
|
|
return %1 : $()
|
|
}
|
|
|
|
// rdar://15351123
|
|
// CHECK-LABEL: @test_forward_ref
|
|
sil @test_forward_ref : $@thin (UInt8, UInt8) -> UInt8
|
|
|
|
// CHECK-LABEL: sil public_external @partial_apply : $@thin (@thin (@out Int, Int) -> (), Int) -> Int {
|
|
// CHECK: [[PA:%.*]] = partial_apply {{%.*}}({{%.*}}) : $@thin (@out Int, Int) -> ()
|
|
// CHECK: apply [[PA]]({{%.*}}) : $@callee_owned (@out Int) -> ()
|
|
sil @partial_apply : $@thin (@thin (@out Int, Int) -> (), Int) -> Int {
|
|
entry(%f : $@thin (@out Int, Int) -> (), %x : $Int):
|
|
%p = partial_apply %f(%x) : $@thin (@out Int, Int) -> ()
|
|
%i = alloc_stack $Int
|
|
%z = apply %p(%i#1) : $@callee_owned (@out Int) -> ()
|
|
%y = load %i#1 : $*Int
|
|
dealloc_stack %i#0 : $*@local_storage Int
|
|
return %y : $Int
|
|
}
|
|
|
|
// Make sure we serialize the body of closure even without -sil-serialize-all.
|
|
// CHECK_DECL-LABEL: @partial_apply_with_closure
|
|
sil [transparent] @partial_apply_with_closure : $@thin (@owned @callee_owned () -> Bool, @owned String, CString, Int64) -> () {
|
|
bb0(%0 : $@callee_owned () -> Bool, %1 : $String, %2 : $CString, %3 : $Int64):
|
|
%17 = function_ref @closure_body : $@thin (CString, CString, Int64) -> ()
|
|
// CHECK_DECL: function_ref @closure_body
|
|
%18 = partial_apply %17(%2, %3) : $@thin (CString, CString, Int64) -> ()
|
|
// CHECK_DECL: partial_apply
|
|
%30 = tuple ()
|
|
return %30 : $()
|
|
}
|
|
|
|
sil shared @closure_body : $@thin (CString, CString, Int64) -> () {
|
|
bb0(%0 : $CString, %1 : $CString, %2 : $Int64):
|
|
%3 = function_ref @assert_fail : $@thin (CString, CString, Int64) -> ()
|
|
%4 = apply %3(%0, %1, %2) : $@thin (CString, CString, Int64) -> ()
|
|
%5 = tuple ()
|
|
return %5 : $()
|
|
}
|
|
|
|
// CHECK_DECL-LABEL: @closure_body : $@thin (CString, CString, Int64) -> () {
|
|
// CHECK_DECL: function_ref @assert_fail
|
|
|
|
sil @assert_fail : $@thin (CString, CString, Int64) -> ()
|
|
|
|
// rdar: 15893086
|
|
struct GenericStruct<T> {
|
|
var x : T
|
|
}
|
|
|
|
// CHECK-LABEL: @extract_generic_struct
|
|
sil @extract_generic_struct : $@thin GenericStruct<Int64> -> Int64 {
|
|
entry(%0 : $GenericStruct<Int64>):
|
|
// CHECK: %1 = struct_extract %0 : $GenericStruct<Int64>, #GenericStruct.x
|
|
%1 = struct_extract %0 : $GenericStruct<Int64>, #GenericStruct.x
|
|
// CHECK: return %1 : $Int64
|
|
return %1 : $Int64
|
|
}
|
|
|
|
class Foo {
|
|
subscript (x: Int, y: Int) -> Int { get set }
|
|
var x: Int
|
|
var y: Int
|
|
init()
|
|
}
|
|
|
|
// CHECK-LABEL: sil @_TFC3tmp3Foog9subscriptFT1xSi1ySi_Si : $@cc(method) @thin (Int, Int, Foo) -> Int
|
|
// CHECK_DECL-LABEL: sil @_TFC3tmp3Foog9subscriptFT1xSi1ySi_Si : $@cc(method) @thin (Int, Int, Foo) -> Int{{$}}
|
|
sil @_TFC3tmp3Foog9subscriptFT1xSi1ySi_Si : $@cc(method) @thin (Int, Int, Foo) -> Int {
|
|
bb0(%0 : $Int, %1 : $Int, %2 : $Foo):
|
|
%3 = tuple ()
|
|
%4 = alloc_stack $Int // var x // users: %17, %6
|
|
%5 = alloc_stack $Int // var y // users: %16, %7
|
|
store %0 to %4#1 : $*Int
|
|
store %1 to %5#1 : $*Int
|
|
%8 = alloc_stack $Foo // var self // users: %15, %14, %9
|
|
store %2 to %8#1 : $*Foo
|
|
%10 = metatype $@thin Int.Type
|
|
%12 = integer_literal $Builtin.Word, 0 // user: %13
|
|
%13 = struct $Int (%12 : $Builtin.Word) // user: %18
|
|
destroy_addr %8#1 : $*Foo
|
|
dealloc_stack %8#0 : $*@local_storage Foo
|
|
dealloc_stack %5#0 : $*@local_storage Int
|
|
dealloc_stack %4#0 : $*@local_storage Int
|
|
return %13 : $Int
|
|
}
|
|
|
|
// CHECK-LABEL: sil @_TFC3tmp3Foos9subscriptFT1xSi1ySi_Si : $@cc(method) @thin (Int, Int, Int, Foo) -> ()
|
|
// CHECK_DECL-LABEL: sil @_TFC3tmp3Foos9subscriptFT1xSi1ySi_Si : $@cc(method) @thin (Int, Int, Int, Foo) -> (){{$}}
|
|
sil @_TFC3tmp3Foos9subscriptFT1xSi1ySi_Si : $@cc(method) @thin (Int, Int, Int, Foo) -> () {
|
|
bb0(%0 : $Int, %1 : $Int, %2 : $Int, %3 : $Foo):
|
|
%4 = alloc_stack $Int // var value // users: %16, %5
|
|
store %0 to %4#1 : $*Int
|
|
%6 = alloc_stack $Int // var x // users: %15, %8
|
|
%7 = alloc_stack $Int // var y // users: %14, %9
|
|
store %1 to %6#1 : $*Int
|
|
store %2 to %7#1 : $*Int
|
|
%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 Int
|
|
dealloc_stack %6#0 : $*@local_storage Int
|
|
dealloc_stack %4#0 : $*@local_storage Int
|
|
%17 = tuple () // user: %18
|
|
return %17 : $()
|
|
}
|
|
|
|
// CHECK-LABEL: sil_vtable Foo {
|
|
// CHECK: #Foo.subscript!getter.1: _TFC3tmp3Foog9subscriptFT1xSi1ySi_Si
|
|
// CHECK: #Foo.subscript!setter.1: _TFC3tmp3Foos9subscriptFT1xSi1ySi_Si
|
|
// CHECK: }
|
|
// CHECK_DECL-LABEL: sil_vtable Foo {
|
|
// CHECK_DECL: #Foo.subscript!getter.1: _TFC3tmp3Foog9subscriptFT1xSi1ySi_Si
|
|
// CHECK_DECL: #Foo.subscript!setter.1: _TFC3tmp3Foos9subscriptFT1xSi1ySi_Si
|
|
// CHECK_DECL: }
|
|
sil_vtable Foo {
|
|
#Foo.subscript!getter.1: _TFC3tmp3Foog9subscriptFT1xSi1ySi_Si
|
|
#Foo.subscript!setter.1: _TFC3tmp3Foos9subscriptFT1xSi1ySi_Si
|
|
}
|
|
|
|
protocol AssocReqt {
|
|
func requiredMethod()
|
|
}
|
|
|
|
struct ConformingAssoc : AssocReqt {
|
|
func requiredMethod()
|
|
}
|
|
|
|
sil @_TFV14witness_tables15ConformingAssoc14requiredMethodfS0_FT_T_ : $@cc(method) @thin (ConformingAssoc) -> () {
|
|
bb0(%0 : $ConformingAssoc):
|
|
debug_value %0 : $ConformingAssoc
|
|
%2 = tuple ()
|
|
return %2 : $()
|
|
}
|
|
|
|
sil @_TTWV14witness_tables15ConformingAssocS_9AssocReqtS_FS1_14requiredMethodU_fRQPS1_FT_T_ : $@cc(witness_method) @thin (@inout ConformingAssoc) -> () {
|
|
bb0(%0 : $*ConformingAssoc):
|
|
%1 = load %0 : $*ConformingAssoc
|
|
%2 = function_ref @_TFV14witness_tables15ConformingAssoc14requiredMethodfS0_FT_T_ : $@cc(method) @thin (ConformingAssoc) -> ()
|
|
%3 = apply %2(%1) : $@cc(method) @thin (ConformingAssoc) -> ()
|
|
return %3 : $()
|
|
}
|
|
|
|
// CHECK-LABEL: sil_witness_table public_external ConformingAssoc: AssocReqt module
|
|
// CHECK: #AssocReqt.requiredMethod!1: @_TTWV14witness_tables15ConformingAssocS_9AssocReqtS_FS1_14requiredMethodU_fRQPS1_FT_T_
|
|
// CHECK: }
|
|
sil_witness_table ConformingAssoc: AssocReqt module def_basic {
|
|
method #AssocReqt.requiredMethod!1: @_TTWV14witness_tables15ConformingAssocS_9AssocReqtS_FS1_14requiredMethodU_fRQPS1_FT_T_
|
|
}
|
|
|
|
protocol AnyProtocol {
|
|
typealias AssocType
|
|
typealias AssocWithReqt : AssocReqt
|
|
func assocTypesMethod(x: AssocType, y: AssocWithReqt)
|
|
class func staticMethod(x: Self)
|
|
}
|
|
class SomeAssoc {
|
|
}
|
|
protocol InheritedProtocol1 : AnyProtocol {
|
|
func inheritedMethod()
|
|
}
|
|
struct InheritedConformance : InheritedProtocol1 {
|
|
typealias AssocType = SomeAssoc
|
|
typealias AssocWithReqt = ConformingAssoc
|
|
func assocTypesMethod(x: SomeAssoc, y: ConformingAssoc)
|
|
static func staticMethod(x: InheritedConformance)
|
|
func inheritedMethod()
|
|
}
|
|
|
|
// CHECK-LABEL: sil_witness_table public_external InheritedConformance: InheritedProtocol1 module
|
|
// CHECK: base_protocol AnyProtocol: InheritedConformance: AnyProtocol module
|
|
// CHECK: }
|
|
sil_witness_table InheritedConformance: InheritedProtocol1 module witness_tables {
|
|
base_protocol AnyProtocol: InheritedConformance: AnyProtocol module witness_tables
|
|
}
|
|
|
|
// CHECK-LABEL: sil_witness_table public_external InheritedConformance: AnyProtocol module
|
|
// CHECK: associated_type AssocType: SomeAssoc
|
|
// CHECK: associated_type_protocol (AssocWithReqt: AssocReqt): ConformingAssoc: AssocReqt module
|
|
// CHECK: }
|
|
sil_witness_table InheritedConformance: AnyProtocol module witness_tables {
|
|
associated_type AssocType: SomeAssoc
|
|
associated_type_protocol (AssocWithReqt: AssocReqt): ConformingAssoc: AssocReqt module witness_tables
|
|
}
|
|
|
|
sil [transparent] @_TF9def_basic13serialize_allFT_T_ : $@thin () -> () {
|
|
bb0:
|
|
%0 = function_ref @_TFV18lazy_global_access4Type10staticPropSia_public : $@thin () -> Builtin.RawPointer
|
|
%1 = function_ref @_TFV18lazy_global_access4Type10staticPropSia : $@thin () -> Builtin.RawPointer
|
|
%2 = function_ref @test1 : $@thin () -> ()
|
|
%4 = function_ref @test2 : $@thin (Int) -> ()
|
|
%6 = function_ref @named_tuple : $@thin () -> (Builtin.Word, Builtin.Word)
|
|
%9 = function_ref @return_int : $@thin (Int) -> Int
|
|
%11 = function_ref @call_fn_pointer : $@thin (() -> Int) -> Int
|
|
%13 = function_ref @return_constant : $@thin () -> Int
|
|
%23 = function_ref @existentials : $@thin (@in P) -> ()
|
|
%25 = function_ref @classes : $@thin () -> ()
|
|
%27 = function_ref @_TF4todo18erasure_from_protoFT1xPS_8RuncibleS_8Bendable__PS0__ : $@thin (@out Runcible, @in protocol<Bendable, Runcible>) -> ()
|
|
%29 = function_ref @_TF4todo18class_bound_methodFT1xPS_10ClassBound__T_ : $@thin (@owned ClassBound) -> ()
|
|
%31 = function_ref @_TFV6struct5AlephCfMS0_FT1aCS_3Ref1bVS_3Val_S0_ : $@thin (Ref, Val, @thin Aleph.Type) -> Aleph
|
|
%33 = function_ref @_TFV6struct5AlephCfMS0_FT_S0_ : $@thin (@thin Aleph.Type) -> Aleph
|
|
%35 = function_ref @test_union_empty_case : $@thin () -> Beth
|
|
%37 = function_ref @test_union_data_case : $@thin Int -> Beth
|
|
%39 = function_ref @test_union_addr_empty_case : $@thin (@out Gimel) -> ()
|
|
%41 = function_ref @test_union_addr_data_case : $@thin (@out Gimel, @in Q) -> ()
|
|
%43 = function_ref @_TF5tuple5floatFT1xSf_T_ : $@thin (Float32) -> ()
|
|
%45 = function_ref @_TF5tuple5tupleFT_TSiSf_ : $@thin () -> (Int, Float32)
|
|
%47 = function_ref @_TF5tuple13tuple_elementFT1xTSiSf__T_ : $@thin (Int, Float32) -> ()
|
|
%49 = function_ref @_TFC3ref1C3foofS0_FT1xSi_T_ : $@cc(method) @thin (Int, M) -> ()
|
|
%51 = function_ref @_TF4null3isaFT1bCS_1B_Sb : $@thin (B) -> Builtin.Int1
|
|
%53 = function_ref @_TFSd31_convertFromBuiltinFloatLiteralfMSdFT5valueBf64__Sd : $@thin (Builtin.FPIEEE64, @thin Float64.Type) -> Float64
|
|
%55 = function_ref @_TFSS32_convertFromBuiltinStringLiteralfMSSFT5valueBp8byteSizeBi64_7isASCIIBi1__SS : $@thin (Builtin.RawPointer, Builtin.Word, Builtin.Int1, @thin String.Type) -> String
|
|
%57 = function_ref @_TF7literal8literalsFT_T_ : $@thin () -> ()
|
|
%59 = function_ref @_TF5index5gep64FT1pBp1iBi64__Bp : $@thin (Builtin.RawPointer, Builtin.Word) -> Builtin.RawPointer
|
|
%60 = function_ref @global_code : $@thin () -> ()
|
|
%63 = function_ref @test_class_metatype : $@thin (SomeClass, SomeSubclass) -> (@thick SomeClass.Type, @thick SomeClass.Type)
|
|
%67 = function_ref @test_existential_metatype : $@thin (@in SomeProtocol) -> @thick SomeProtocol.Type
|
|
%69 = function_ref @test_unreachable : $@thin () -> ()
|
|
%71 = function_ref @test_unowned_retain : $@thin (SomeClass) -> ()
|
|
%73 = function_ref @test_basic_block_arguments : $@thin (Builtin.Int1) -> Builtin.Word
|
|
%75 = function_ref @test_cond_branch_basic_block_args : $@thin (Int, Builtin.Int1) -> Int
|
|
|
|
%77 = function_ref @test_autorelease_return : $@cc(objc_method) @thin (Bas) -> NSString
|
|
%79 = function_ref @test_super_method : $@cc(method) @thin (Bas) -> Bas
|
|
%81 = function_ref @test_builtin_func_ref : $@thin (Builtin.Int1, Builtin.Int1) -> Builtin.Int1
|
|
%83 = function_ref @test_dealloc_ref : $@thin () -> ()
|
|
%85 = function_ref @test_dealloc_box : $@thin () -> ()
|
|
%87 = function_ref @closure_test : $@thin () -> ()
|
|
%97 = function_ref @test_switch_union : $@thin (MaybePair) -> ()
|
|
%99 = function_ref @test_switch_union_addr : $@thin (@in MaybeAddressOnlyPair) -> ()
|
|
%101 = function_ref @test_switch_int : $@thin (Builtin.Word) -> ()
|
|
%103 = function_ref @test_init_existential : $@thin (@out Bendable, Spoon) -> ()
|
|
%105 = function_ref @test_existential_ref : $@thin (ConcreteClass) -> ClassP
|
|
|
|
%107 = function_ref @test_assign : $@thin (Int, @inout Int) -> ()
|
|
%109 = function_ref @test_transparent : $@thin () -> ()
|
|
%111 = function_ref @test_partial_apply : $@thin Float32 -> @callee_owned Int -> ()
|
|
%113 = function_ref @test_dynamic_lookup_br : $@thin (AnyObject) -> ()
|
|
%115 = function_ref @test_mark_fn_escape : $@thin () -> ()
|
|
%117 = function_ref @test_copy_release_value : $@thin (Val) -> (Val)
|
|
%118 = function_ref @cond_fail_test : $@thin Builtin.Int1 -> ()
|
|
|
|
%120 = function_ref @test_forward_ref : $@thin (UInt8, UInt8) -> UInt8
|
|
%121 = function_ref @partial_apply : $@thin (@thin (@out Int, Int) -> (), Int) -> Int
|
|
%122 = function_ref @partial_apply_with_closure : $@thin (@owned @callee_owned () -> Bool, @owned String, CString, Int64) -> ()
|
|
%123 = function_ref @extract_generic_struct : $@thin GenericStruct<Int64> -> Int64
|
|
|
|
%119 = tuple ()
|
|
return %119 : $()
|
|
}
|
|
|