sil_stage raw // CHECK: sil_stage canonical import Builtin import Swift // Test SIL Global variable. sil_global private @globalinit_token0 : $Builtin.Word sil_global public @public_global : $Builtin.Word sil_global @staticProp : $Int sil [transparent] [serialized] @globalinit_func0 : $@convention(thin) () -> () // CHECK-LABEL: sil_global {{.*}}@static_global_vector : $Int32 = { // CHECK: %initval = vector (%1 : $Int32, %3 : $Int32) // CHECK-NEXT: } sil_global [serialized] @static_global_vector : $Int32 = { %0 = integer_literal $Builtin.Int32, 0 %1 = struct $Int32 (%0 : $Builtin.Int32) %2 = integer_literal $Builtin.Int32, 1 %3 = struct $Int32 (%2 : $Builtin.Int32) %initval = vector (%1 : $Int32, %3 : $Int32) } // We should not serialize this. // CHECK-NOT: sil public_external @_TV18lazy_global_access4Type10staticPropySia : $@convention(thin) () -> Builtin.RawPointer { sil @_TV18lazy_global_access4Type10staticPropySia : $@convention(thin) () -> Builtin.RawPointer { bb0: %1 = global_addr @globalinit_token0 : $*Builtin.Word %2 = address_to_pointer %1 : $*Builtin.Word to $Builtin.RawPointer %3 = function_ref @globalinit_func0 : $@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 } // This references a public global so we *SHOULD* deserialize this. // CHECK-LABEL: sil public_external [transparent] @_TV18lazy_global_access4Type10staticPropySia_public : $@convention(thin) () -> Builtin.RawPointer { sil [transparent] [serialized] @_TV18lazy_global_access4Type10staticPropySia_public : $@convention(thin) () -> Builtin.RawPointer { bb0: // CHECK: alloc_global @public_global alloc_global @public_global // CHECK: global_addr @public_global : $*Builtin.Word %1 = global_addr @public_global : $*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: [[O:%.*]] = builtin "once"({{%.*}} : $Builtin.RawPointer, {{%.*}} : $@convention(thin) () -> ()) : $Builtin.SILToken %5 = builtin "once"(%2 : $Builtin.RawPointer, %3 : $@convention(thin) () -> ()) : $Builtin.SILToken // CHECK: global_addr @staticProp : $*Int depends_on [[O]] %6 = global_addr @staticProp : $*Int depends_on %5 %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 [transparent] @test1 : $@convention(thin) () -> () sil [transparent] [serialized] @test1 : $@convention(thin) () -> () { bb0: // CHECK: bb0: %0 = tuple () // CHECK: %0 = tuple () br bb1 // CHECK: br bb1 bb1: %b = alloc_box $<τ_0_0> { var τ_0_0 } %c = integer_literal $Builtin.Word, 1 return %0 : $() // CHECK: return %0 : $() } // Forward referenced values. // CHECK-LABEL: sil public_external [transparent] @test2 : $@convention(thin) (Int) -> () sil [transparent] [serialized] @test2 : $@convention(thin) (Int) -> () { // CHECK: bb1: // CHECK: %[[VAL:[0-9]+]] = tuple () // CHECK: br bb2 // CHECK: bb2: // CHECK: return %[[VAL]] : $() bb0(%0 : $Int): br bb2 bb1: // Forward reference MRVs. store %0 to %7 : $*Int strong_release %6 : $<τ_0_0> { var τ_0_0 } return %5 : $() bb2: %5 = tuple () %6 = alloc_box $<τ_0_0> { var τ_0_0 } %7 = project_box %6 : $<τ_0_0> { var τ_0_0 } , 0 br bb1 } // CHECK-LABEL: @named_tuple : $@convention(thin) () -> (Builtin.Word, Builtin.Word) sil [transparent] [serialized] @named_tuple : $@convention(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) return %9 : $(Builtin.Word, Builtin.Word) } sil [transparent] [serialized] @return_int : $@convention(thin) (Int) -> Int { // CHECK-LABEL: $@convention(thin) (Int) -> Int { bb0(%0 : $Int): // CHECK: bb0(%0 : $Int): %1 = alloc_stack $Int store %0 to %1 : $*Int %3 = load %1 : $*Int dealloc_stack %1 : $*Int return %3 : $Int // CHECK: return {{.*}} : $Int } // CHECK-LABEL: sil public_external @vector_base_addr : // CHECK: %1 = vector_base_addr %0 : $*Builtin.FixedArray<10, Int> // CHECK-LABEL: } // end sil function 'vector_base_addr' sil [serialized] @vector_base_addr : $@convention(thin) (@inout Builtin.FixedArray<10, Int>) -> Int { bb0(%0 : $*Builtin.FixedArray<10, Int>): %1 = vector_base_addr %0 %2 = load %1 return %2 } // CHECK-LABEL: @call_fn_pointer : $@convention(thin) (() -> Int) -> Int { sil [transparent] [serialized] @call_fn_pointer : $@convention(thin) (() -> Int) -> Int { bb0(%0 : $() -> Int): %1 = alloc_stack $() -> Int store %0 to %1 : $*() -> Int %3 = load %1 : $*() -> Int strong_retain %3 : $() -> Int // CHECK: strong_retain %{{.*}} : $() -> Int %5 = apply %3() : $() -> Int // CHECK: apply %{{.*}}() : $() -> Int %6 = load %1 : $*() -> Int strong_release %3 : $() -> Int // CHECK: strong_release {{.*}} : $() -> Int dealloc_stack %1 : $*() -> Int return %5 : $Int // CHECK: return %{{.*}} : $Int } sil [transparent] [serialized] @return_constant : $@convention(thin) () -> Int { // CHECK-LABEL: @return_constant bb0: // CHECK: bb0: // CHECK: function_ref @$sSi25convertFromIntegerLiteralySiBi64_3val_tcSimF : $@convention(thin) (Builtin.Word, @thin Int.Type) -> Int %1 = function_ref @$sSi25convertFromIntegerLiteralySiBi64_3val_tcSimF : $@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 return %4 : $Int } sil [serialized] @$sSi25convertFromIntegerLiteralySiBi64_3val_tcSimF : $@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 [transparent] [serialized] @$sSb13getLogicValueyBi1_ycSbzF : $@convention(method) (@inout Bool) -> Builtin.Int1 sil [transparent] [serialized] @$sSi33_convertFromBuiltinIntegerLiteralySiBi128_3val_tcSimF : $@convention(thin) (Builtin.Int128, @thin Int.Type) -> Int protocol P { func doIt() } // CHECK-LABEL: @existentials : $@convention(thin) (@in any P) -> () { sil [transparent] [serialized] @existentials : $@convention(thin) (@in P) -> () { bb0(%0 : $*P): %1 = open_existential_addr mutable_access %0 : $*P to $*@opened("01234567-89ab-cdef-0123-000000000000", P) Self // CHECK: open_existential_addr mutable_access %0 %imm = open_existential_addr immutable_access %0 : $*P to $*@opened("01234567-89ab-cdef-0123-100000000000", P) Self // CHECK: open_existential_addr immutable_access %0 %meth = witness_method $@opened("01234567-89ab-cdef-0123-100000000000", P) Self, #P.doIt, %imm : $*@opened("01234567-89ab-cdef-0123-100000000000", P) Self : $@convention(witness_method: P) (@in_guaranteed T) -> () %call = apply %meth<@opened("01234567-89ab-cdef-0123-100000000000", P) Self>(%imm) : $@convention(witness_method: P) (@in_guaranteed T) -> () // CHECK: witness_method ${{.*}}, #P.doIt %2 = witness_method $@opened("01234567-89ab-cdef-0123-000000000000", P) Self, #P.doIt, %1 : $*@opened("01234567-89ab-cdef-0123-000000000000", P) Self : $@convention(witness_method: P) (@inout T) -> () // Make sure we have the correct scope for generic parameters. // CHECK: witness_method $@opened("{{.*}}", any P) Self, #P.doIt %7 = witness_method $@opened("01234567-89ab-cdef-0123-000000000000", P) Self, #P.doIt, %1 : $*@opened("01234567-89ab-cdef-0123-000000000000", P) Self : $@convention(witness_method: P) (@inout T) -> () // CHECK: apply %3 = apply %2<@opened("01234567-89ab-cdef-0123-000000000000", P) Self>(%1) : $@convention(witness_method: P) (@inout T) -> () %4 = tuple () // CHECK: tuple () destroy_addr %0 : $*P // CHECK: destroy_addr %0 : $*any P return %4 : $() // CHECK: return } class C { func doIt() {} } class D : C { override func doIt() { super.doIt() } } // CHECK-LABEL: @classes : $@convention(thin) () -> () { sil [transparent] [serialized] @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 $AnyObject %O = unchecked_ref_cast %C : $C to $Builtin.AnyObject // CHECK: class_method {{.*}} : $C, #C.doIt %2 = class_method %C : $C, #C.doIt : (C) -> () -> (), $@convention(method) (@guaranteed C) -> () // CHECK: alloc_ref $D %D = alloc_ref $D // CHECK: upcast {{.*}} : $D to $C %a = upcast %D : $D to $C // CHECK: unconditional_checked_cast {{.*}} : $C to D %5 = unconditional_checked_cast %C : $C to D %6 = tuple () return %6 : $() } // Generated from: // func archetype_member_ref(_ 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 [transparent] @_TF4arch20archetype_member_refUS_8Runcible___FT1xQ__T_ : $@convention(thin) (T) -> () { //bb0(%0 : $*T): //%1 = witness_method $*T, #Runcible.free_method : $@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 : $@cc(method) (@inout T) -> @thick T.U.Type //%5 = apply %4(%0) : $@cc(method) ((), @inout T) -> @thick T.U.Type //store %5 to %3#1 : $*@thick T.U.Type //%7 = metatype $@thick T.Type //%8 = objc_method %7 : $*T, #Runcible.static_method : $(@thick T.Type) -> () //%9 = apply %8(%7) : $((), @thick T.Type) -> () //dealloc_stack %3#0 : $*@thick T.U.Type //%11 = tuple () //destroy_addr %0 : $*T //return %11 : $() //} protocol Bendable { } // CHECK-LABEL: $@convention(thin) (@in any Bendable & Runcible) -> @out any Runcible sil [transparent] [serialized] @$s4todo18erasure_from_proto1xAA8Runcible_pAaD_AA8Bendablep_tF : $@convention(thin) (@in Bendable & Runcible) -> (@out Runcible) { bb0(%0 : $*Runcible, %1 : $*Bendable & Runcible): // CHECK: alloc_box %2 = alloc_box $<τ_0_0> { var τ_0_0 } <(Bendable & Runcible)> %2a = project_box %2 : $<τ_0_0> { var τ_0_0 } , 0 // CHECK: copy_addr [take] {{.*}} to [init] {{.*}} : $*any Bendable & Runcible copy_addr [take] %1 to [init] %2a : $*Bendable & Runcible // CHECK: alloc_stack %4 = alloc_stack $Bendable & Runcible // CHECK: copy_addr {{.*}} to [init] {{.*}} : $*any Bendable & Runcible copy_addr %2a to [init] %4 : $*Bendable & Runcible %7 = tuple () // CHECK: destroy_addr destroy_addr %4 : $*Bendable & Runcible // CHECK: dealloc_stack dealloc_stack %4 : $*Bendable & Runcible strong_release %2 : $<τ_0_0> { var τ_0_0 } // CHECK: return return %7 : $() } protocol ClassBound : class { func classBoundMethod() } // CHECK-LABEL: @$s4todo18class_bound_method1xyAA10ClassBound_p_tF : $@convention(thin) (@owned any ClassBound) -> () sil [transparent] [serialized] @$s4todo18class_bound_method1xyAA10ClassBound_p_tF : $@convention(thin) (@owned ClassBound) -> () { bb0(%0 : $ClassBound): %1 = alloc_box $<τ_0_0> { var τ_0_0 } %1a = project_box %1 : $<τ_0_0> { var τ_0_0 } , 0 store %0 to %1a : $*ClassBound %3 = load %1a : $*ClassBound strong_retain %3 : $ClassBound // CHECK: strong_retain // CHECK: open_existential_ref {{%.*}} : $any ClassBound to $@opened({{.*}}, any ClassBound) Self %5 = open_existential_ref %3 : $ClassBound to $@opened("01234567-89ab-cdef-0123-111111111111", ClassBound) Self // CHECK: witness_method %6 = witness_method $@opened("01234567-89ab-cdef-0123-111111111111", ClassBound) Self, #ClassBound.classBoundMethod, %5 : $@opened("01234567-89ab-cdef-0123-111111111111", ClassBound) Self : $@convention(witness_method: ClassBound) (T) -> () %7 = apply %6<@opened("01234567-89ab-cdef-0123-111111111111", ClassBound) Self>(%5) : $@convention(witness_method: ClassBound) (T) -> () %8 = tuple () strong_release %1 : $<τ_0_0> { var τ_0_0 } return %8 : $() } struct Val { } //sil @$s4todo3ValVyACycACmcfC : $@convention(thin) (@thin Val.Type) -> Val { //bb0(%0 : $@thin Val.Type): //%1 = alloc_stack $Val //%3 = load %1#1 : $*Val //return %3 : $Val //} class Ref { } struct Aleph { var a:Ref var b:Val } // CHECK-LABEL: @$s6struct5AlephVyAcA3RefC1a_AA3ValV1btcACmcfC : $@convention(thin) (Ref, Val, @thin Aleph.Type) -> Aleph sil [transparent] [serialized] @$s6struct5AlephVyAcA3RefC1a_AA3ValV1btcACmcfC : $@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) return %3 : $Aleph // CHECK: return } // CHECK-LABEL: @$s6struct5AlephVyACycACmcfC : $@convention(thin) (@thin Aleph.Type) -> Aleph sil [transparent] [serialized] @$s6struct5AlephVyACycACmcfC : $@convention(thin) (@thin Aleph.Type) -> Aleph { bb0(%0 : $@thin Aleph.Type): %1 = tuple () %2 = alloc_box $<τ_0_0> { var τ_0_0 } // CHECK: alloc_box %2a = project_box %2 : $<τ_0_0> { var τ_0_0 } , 0 // CHECK: struct_element_addr {{.*}} : $*Aleph, #Aleph.a %5 = struct_element_addr %2a : $*Aleph, #Aleph.a %6 = load %5 : $*Ref strong_release %6 : $Ref %14 = load %2a : $*Aleph // CHECK: struct_extract {{%.*}} : $Aleph, #Aleph.a %15 = struct_extract %14 : $Aleph, #Aleph.a strong_retain %15 : $Ref strong_release %2 : $<τ_0_0> { var τ_0_0 } return %14 : $Aleph } enum Beth { case EmptyCase case DataCase(Int) } // CHECK-LABEL: @test_union_empty_case : $@convention(thin) () -> Beth { sil [transparent] [serialized] @test_union_empty_case : $@convention(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 : $@convention(thin) (Int) -> Beth { sil [transparent] [serialized] @test_union_data_case : $@convention(thin) (Int) -> Beth { bb0(%0 : $Int): // CHECK: %1 = enum $Beth, #Beth.DataCase!enumelt, %0 : $Int %1 = enum $Beth, #Beth.DataCase!enumelt, %0 : $Int return %1 : $Beth } protocol Q {} enum Gimel { case EmptyCase case DataCase(Q) } // CHECK-LABEL: @test_union_addr_empty_case : $@convention(thin) () -> @out Gimel { sil [transparent] [serialized] @test_union_addr_empty_case : $@convention(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 : $@convention(thin) (@in any Q) -> @out Gimel { sil [transparent] [serialized] @test_union_addr_data_case : $@convention(thin) (@in Q) -> @out Gimel { bb0(%0 : $*Gimel, %1 : $*Q): // CHECK: {{%.*}} = init_enum_data_addr {{%.*}} : $*Gimel, #Gimel.DataCase!enumelt %p = init_enum_data_addr %0 : $*Gimel, #Gimel.DataCase!enumelt copy_addr [take] %1 to [init] %p : $*Q inject_enum_addr %0 : $*Gimel, #Gimel.DataCase!enumelt %t = tuple () return %t : $() } sil [transparent] [serialized] @$s5tuple5float1xySf_tF : $@convention(thin) (Float32) -> () sil [transparent] [serialized] @$s5tupleAASi_SftyF : $@convention(thin) () -> (Int, Float32) // CHECK-LABEL: @$s5tuple0A8_element1xySi_Sft_tF : $@convention(thin) (Int, Float) -> () sil [transparent] [serialized] @$s5tuple0A8_element1xySi_Sft_tF : $@convention(thin) (Int, Float) -> () { bb0(%0 : $Int, %1 : $Float32): %2 = alloc_box $<τ_0_0> { var τ_0_0 } <(Int, Float32)> %2a = project_box %2 : $<τ_0_0> { var τ_0_0 } <(Int, Float32)>, 0 %3 = tuple (%0 : $Int, %1 : $Float32) store %3 to %2a : $*(Int, Float32) %6 = tuple_element_addr %2a : $*(Int, Float), 0 %7 = load %6 : $*Int %10 = tuple_element_addr %2a : $*(Int, Float), 1 %11 = load %10 : $*Float32 // CHECK: function_ref %14 = function_ref @$s5tupleAASi_SftyF : $@convention(thin) () -> (Int, Float32) // CHECK: apply %15 = apply %14() : $@convention(thin) () -> (Int, Float32) // CHECK: function_ref %19 = function_ref @$s5tuple5float1xySf_tF : $@convention(thin) (Float32) -> () // CHECK: tuple_extract {{%.*}} : $(Int, Float), 1 %17 = tuple_extract %15 : $(Int, Float), 1 // CHECK: apply %24 = apply %19(%17) : $@convention(thin) (Float32) -> () %25 = tuple () strong_release %2 : $<τ_0_0> { var τ_0_0 } <(Int, Float32)> return %25 : $() } class M { var member : Int init() } // CHECK-LABEL: @$s3ref1CC3fooyySi1x_tcACF : $@convention(method) (Int, @guaranteed M) -> () sil [transparent] [serialized] @$s3ref1CC3fooyySi1x_tcACF : $@convention(method) (Int, @guaranteed M) -> () { bb0(%0 : $Int, %1 : $M): %2 = alloc_box $<τ_0_0> { var τ_0_0 } %2a = project_box %2 : $<τ_0_0> { var τ_0_0 } , 0 store %0 to %2a : $*Int %4 = alloc_box $<τ_0_0> { var τ_0_0 } %4a = project_box %4 : $<τ_0_0> { var τ_0_0 } , 0 store %1 to %4a : $*M %6 = load %2a : $*Int %7 = load %4a : $*M strong_retain %7 : $M // CHECK: ref_element_addr {{%.*}} : $M, #M.member %9 = ref_element_addr %7 : $M, #M.member store %6 to %9 : $*Int strong_release %7 : $M %12 = tuple () strong_release %4 : $<τ_0_0> { var τ_0_0 } strong_release %2 : $<τ_0_0> { var τ_0_0 } return %12 : $() } class B { } class E : B { } // CHECK-LABEL: @$s4null3isa1bSbAA1BC_tF : $@convention(thin) (B) -> Builtin.Int1 sil [transparent] [serialized] @$s4null3isa1bSbAA1BC_tF : $@convention(thin) (B) -> Builtin.Int1 { bb0(%0 : $B): %1 = alloc_box $<τ_0_0> { var τ_0_0 } %1a = project_box %1 : $<τ_0_0> { var τ_0_0 } , 0 store %0 to %1a : $*B %3 = load %1a : $*B strong_retain %3 : $B checked_cast_br B in %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): strong_release %3 : $B strong_release %1 : $<τ_0_0> { var τ_0_0 } return %6 : $Builtin.Int1 } sil [transparent] [serialized] @$s7literal8literalsyyF : $@convention(thin) () -> () sil [transparent] [serialized] @$sSd31_convertFromBuiltinFloatLiteralySdBf64_5value_tcSdmF : $@convention(thin) (Builtin.FPIEEE64, @thin Float64.Type) -> Float64 sil [transparent] [serialized] @$sSS32_convertFromBuiltinStringLiteralySSBp5value_Bi64_17utf8CodeUnitCountBi1_7isASCIItcSSmF : $@convention(thin) (Builtin.RawPointer, Builtin.Word, Builtin.Int1, @thin String.Type) -> String // CHECK-LABEL: @$s5index5gep641p1iBpBp_Bi64_tF : $@convention(thin) (Builtin.RawPointer, Builtin.Word) -> Builtin.RawPointer { sil [transparent] [serialized] @$s5index5gep641p1iBpBp_Bi64_tF : $@convention(thin) (Builtin.RawPointer, Builtin.Word) -> Builtin.RawPointer { bb0(%0 : $Builtin.RawPointer, %1 : $Builtin.Word): %2 = alloc_box $<τ_0_0> { var τ_0_0 } %2a = project_box %2 : $<τ_0_0> { var τ_0_0 } , 0 %3 = alloc_box $<τ_0_0> { var τ_0_0 } %3a = project_box %3 : $<τ_0_0> { var τ_0_0 } , 0 store %0 to %2a : $*Builtin.RawPointer store %1 to %3a : $*Builtin.Word %7 = load %2a : $*Builtin.RawPointer %8 = load %3a : $*Builtin.Word // CHECK: index_raw_pointer {{%.*}} : $Builtin.RawPointer, {{%.*}} : $Builtin.Word %9 = index_raw_pointer %7 : $Builtin.RawPointer, %8 : $Builtin.Word strong_release %3 : $<τ_0_0> { var τ_0_0 } strong_release %2 : $<τ_0_0> { var τ_0_0 } return %9 : $Builtin.RawPointer } sil_global @x : $Int sil [transparent] [serialized] @global_callee : $@convention(thin) (Builtin.Int128, @thin Int.Type) -> Int // CHECK-LABEL: @global_code : $@convention(thin) () -> () sil [transparent] [serialized] @global_code : $@convention(thin) () -> () { 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 store %4 to %0 : $*Int %6 = tuple () return %6 : $() } // CHECK-LABEL: @base_addr : $@convention(thin) () -> () sil [transparent] [serialized] @base_addr : $@convention(thin) () -> () { bb0: // CHECK: base_addr_for_offset $*Int %0 = base_addr_for_offset $*Int %1 = tuple () return %1 : $() } class GlobalObject { } sil_global @static_global_object : $GlobalObject = { %initval = object $GlobalObject () } // CHECK-LABEL: @global_object : $@convention(thin) () -> GlobalObject { sil [transparent] [serialized] @global_object : $@convention(thin) () -> GlobalObject { bb0: // CHECK: %0 = global_value @static_global_object : $GlobalObject %0 = global_value @static_global_object : $GlobalObject return %0 : $GlobalObject } protocol SomeProtocol { } class SomeClass : SomeProtocol { } class SomeSubclass : SomeClass {} // CHECK-LABEL: @test_class_metatype : $@convention(thin) (SomeClass, SomeSubclass) -> (@thick SomeClass.Type, @thick SomeClass.Type) { sil [transparent] [serialized] @test_class_metatype : $@convention(thin) (SomeClass, SomeSubclass) -> (@thick SomeClass.Type, @thick SomeClass.Type) { bb0(%0 : $SomeClass, %1 : $SomeSubclass): %2 = alloc_box $<τ_0_0> { var τ_0_0 } %2a = project_box %2 : $<τ_0_0> { var τ_0_0 } , 0 %3 = alloc_box $<τ_0_0> { var τ_0_0 } %3a = project_box %3 : $<τ_0_0> { var τ_0_0 } , 0 store %0 to %2a : $*SomeClass store %1 to %3a : $*SomeSubclass %7 = load %2a : $*SomeClass strong_retain %7 : $SomeClass // CHECK: value_metatype $@thick SomeClass.Type, {{%.*}} : $SomeClass %9 = value_metatype $@thick SomeClass.Type, %7 : $SomeClass %11 = load %3a : $*SomeSubclass 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) strong_release %11 : $SomeSubclass strong_release %7 : $SomeClass strong_release %3 : $<τ_0_0> { var τ_0_0 } strong_release %2 : $<τ_0_0> { var τ_0_0 } return %15 : $(@thick SomeClass.Type, @thick SomeClass.Type) } // CHECK-LABEL: @test_existential_metatype : $@convention(thin) (@in any SomeProtocol) -> @thick any SomeProtocol.Type { sil [transparent] [serialized] @test_existential_metatype : $@convention(thin) (@in SomeProtocol) -> @thick SomeProtocol.Type { bb0(%0 : $*SomeProtocol): %1 = alloc_box $<τ_0_0> { var τ_0_0 } %1a = project_box %1 : $<τ_0_0> { var τ_0_0 } , 0 // CHECK: copy_addr [take] %0 to [init] %{{.*}} : $*any SomeProtocol copy_addr [take] %0 to [init] %1a : $*SomeProtocol // CHECK: alloc_stack %4 = alloc_stack $SomeProtocol // CHECK: copy_addr %{{.*}} to [init] %{{.*}} : $*any SomeProtocol copy_addr %1a to [init] %4 : $*SomeProtocol // CHECK: existential_metatype $@thick any SomeProtocol.Type, {{%.*}} : $*any SomeProtocol %6 = existential_metatype $@thick SomeProtocol.Type, %4 : $*SomeProtocol destroy_addr %4 : $*SomeProtocol dealloc_stack %4 : $*SomeProtocol strong_release %1 : $<τ_0_0> { var τ_0_0 } return %6 : $@thick SomeProtocol.Type } // CHECK-LABEL: sil public_external [transparent] @test_unreachable sil [transparent] [serialized] @test_unreachable : $@convention(thin) () -> () { bb0: unreachable // CHECK: unreachable } // CHECK-LABEL: @test_unowned_retain : $@convention(thin) (SomeClass) -> () { sil [transparent] [serialized] @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 unowned_retain %1 : $@sil_unowned SomeClass // CHECK: unowned_retain %1 : $@sil_unowned SomeClass 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 () return %5 : $() } // CHECK-LABEL: sil public_external [transparent] @test_basic_block_arguments sil [transparent] [serialized] @test_basic_block_arguments : $@convention(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 [transparent] @test_cond_branch_basic_block_args sil [transparent] [serialized] @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, bb2(%0 : $Int), bb1(%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 public_external [transparent] @test_builtin_func_ref sil [transparent] [serialized] @test_builtin_func_ref : $@convention(thin) (Builtin.Int1, Builtin.Int1) -> Builtin.Int1 { bb0(%0 : $Builtin.Int1, %1 : $Builtin.Int1): %2 = alloc_box $<τ_0_0> { var τ_0_0 } %2a = project_box %2 : $<τ_0_0> { var τ_0_0 } , 0 %3 = alloc_box $<τ_0_0> { var τ_0_0 } %3a = project_box %3 : $<τ_0_0> { var τ_0_0 } , 0 store %0 to %2a : $*Builtin.Int1 store %1 to %3a : $*Builtin.Int1 %8 = load %2a : $*Builtin.Int1 %9 = load %3a : $*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_0> { var τ_0_0 } strong_release %2 : $<τ_0_0> { var τ_0_0 } return %10 : $Builtin.Int1 } // CHECK-LABEL: sil public_external [transparent] @test_dealloc_ref sil [transparent] [serialized] @test_dealloc_ref : $@convention(thin) () -> () { bb0: %0 = alloc_ref $Class1 dealloc_ref %0 : $Class1 %2 = tuple () return %2 : $() } // CHECK-LABEL: sil public_external [transparent] @test_dealloc_partial_ref sil [transparent] [serialized] @test_dealloc_partial_ref : $@convention(thin) () -> () { bb0: %0 = alloc_ref $Class1 %1 = metatype $@thick Class1.Type dealloc_partial_ref %0 : $Class1, %1 : $@thick Class1.Type %2 = tuple () return %2 : $() } // CHECK-LABEL: sil public_external [transparent] @test_dealloc_box sil [transparent] [serialized] @test_dealloc_box : $@convention(thin) () -> () { bb0: %0 = alloc_box $<τ_0_0> { var τ_0_0 } dealloc_box %0 : $<τ_0_0> { var τ_0_0 } %2 = tuple () return %2 : $() } // CHECK-LABEL: sil public_external [transparent] @test_stack_flag sil [transparent] [serialized] @test_stack_flag : $@convention(thin) () -> () { bb0: // CHECK: alloc_ref [stack] $Class1 %0 = alloc_ref [stack] $Class1 // CHECK: dealloc_stack_ref %0 : $Class1 dealloc_stack_ref %0 : $Class1 %2 = tuple () return %2 : $() } // CHECK-LABEL: sil public_external [transparent] @test_bare_flags sil [transparent] [serialized] @test_bare_flags : $@convention(thin) () -> () { bb0: // CHECK: alloc_ref [bare] $Class1 %0 = alloc_ref [bare] $Class1 // CHECK: global_value [bare] @static_global_object : $GlobalObject %1 = global_value [bare] @static_global_object : $GlobalObject %2 = tuple () return %2 : $() } // CHECK-LABEL: sil public_external [transparent] @test_stack_protection_flags sil [transparent] [serialized] @test_stack_protection_flags : $@convention(thin) (@inout Builtin.Word) -> () { bb0(%0 : $*Builtin.Word): // CHECK: address_to_pointer [stack_protection] %0 %1 = address_to_pointer [stack_protection] %0 : $*Builtin.Word to $Builtin.RawPointer // CHECK: address_to_pointer %0 %2 = address_to_pointer %0 : $*Builtin.Word to $Builtin.RawPointer %3 = integer_literal $Builtin.Word, 0 // CHECK: index_addr [stack_protection] %0 %4 = index_addr [stack_protection] %0 : $*Builtin.Word, %3 : $Builtin.Word // CHECK: index_addr %0 %5 = index_addr %0 : $*Builtin.Word, %3 : $Builtin.Word %6 = tuple () return %6 : $() } // CHECK-LABEL: sil public_external [transparent] @test_tail_elems sil [transparent] [serialized] @test_tail_elems : $@convention(thin) (Builtin.Word, Builtin.Word) -> () { bb0(%0 : $Builtin.Word, %1 : $Builtin.Word): // CHECK: alloc_ref [tail_elems $Val * %0 : $Builtin.Word] [tail_elems $Aleph * %1 : $Builtin.Word] $Class1 %2 = alloc_ref [tail_elems $Val * %0 : $Builtin.Word] [tail_elems $Aleph * %1 : $Builtin.Word] $Class1 // CHECK: dealloc_ref %2 : $Class1 dealloc_ref %2 : $Class1 %3 = tuple () return %3 : $() } // CHECK-LABEL: sil public_external [transparent] @test_tail_elems_dynamic sil [transparent] [serialized] @test_tail_elems_dynamic : $@convention(thin) (Builtin.Word, Builtin.Word, @thick Class1.Type) -> () { bb0(%0 : $Builtin.Word, %1 : $Builtin.Word, %2 : $@thick Class1.Type): // CHECK: alloc_ref_dynamic [tail_elems $Val * %0 : $Builtin.Word] [tail_elems $Aleph * %1 : $Builtin.Word] %2 : $@thick Class1 %3 = alloc_ref_dynamic [tail_elems $Val * %0 : $Builtin.Word] [tail_elems $Aleph * %1 : $Builtin.Word] %2 : $@thick Class1.Type, $Class1 // CHECK: dealloc_ref %3 : $Class1 dealloc_ref %3 : $Class1 %4 = tuple () return %4 : $() } // CHECK-LABEL: sil public_external [transparent] @test_tail_addr sil [transparent] [serialized] @test_tail_addr : $@convention(thin) (@owned Class1, Builtin.Word) -> @owned Class1 { bb0(%0 : $Class1, %1 : $Builtin.Word): // CHECK: [[T:%[0-9]+]] = ref_tail_addr %0 : $Class1, $Val %2 = ref_tail_addr %0 : $Class1, $Val // CHECK: tail_addr [[T]] : $*Val, %1 : $Builtin.Word, $Aleph %3 = tail_addr %2 : $*Val, %1 : $Builtin.Word, $Aleph return %0 : $Class1 } // CHECK-LABEL: sil public_external [transparent] @test_cow_mutation sil [transparent] [serialized] @test_cow_mutation : $@convention(thin) (@owned Class1) -> @owned Class1 { bb0(%0 : $Class1): // CHECK: (%1, %2) = begin_cow_mutation %0 : $Class1 (%1, %2) = begin_cow_mutation %0 : $Class1 // CHECK: %3 = end_cow_mutation [keep_unique] %2 : $Class1 %3 = end_cow_mutation [keep_unique] %2 : $Class1 // CHECK: (%4, %5) = begin_cow_mutation [native] %0 : $Class1 (%4, %5) = begin_cow_mutation [native] %0 : $Class1 // CHECK: %6 = end_cow_mutation %5 : $Class1 %6 = end_cow_mutation %5 : $Class1 // CHECK: [[T:%[0-9]+]] = ref_tail_addr [immutable] %3 : $Class1, $Val %7 = ref_tail_addr [immutable] %3 : $Class1, $Val // CHECK: ref_element_addr [immutable] %3 : $Class1, #Class1.a %8 = ref_element_addr [immutable] %3 : $Class1, #Class1.a return %0 : $Class1 } // CHECK-LABEL: @closure_test sil [transparent] [serialized] @takes_closure : $@convention(thin) (@callee_owned () -> ()) -> () sil [transparent] [serialized] @closure0 : $@convention(thin) (<τ_0_0> { var τ_0_0 } , @inout Int) -> () sil [transparent] [serialized] @closure_test : $@convention(thin) () -> () { bb0: %0 = alloc_box $<τ_0_0> { var τ_0_0 } // users: %10, %8, %8, %7, %4 %0a = project_box %0 : $<τ_0_0> { var τ_0_0 } , 0 %5 = function_ref @takes_closure : $@convention(thin) (@callee_owned () -> ()) -> () %6 = function_ref @closure0 : $@convention(thin) (<τ_0_0> { var τ_0_0 } , @inout Int) -> () strong_retain %0 : $<τ_0_0> { var τ_0_0 } //%8 = partial_apply %6(%0, %0a) : $@convention(thin) (<τ_0_0> { var τ_0_0 } , @inout Int) -> () //%9 = apply %5(%8) : $@convention(thin) (@callee_owned () -> ()) -> () //strong_release %0 : $<τ_0_0> { var τ_0_0 } %11 = tuple () return %11 : $() } protocol ClassP : class {} enum MaybePair { case Neither case Left(Int) } sil [transparent] [serialized] @$s6switch1ayyF : $@convention(thin) () -> () sil [transparent] [serialized] @$s6switch1byyF : $@convention(thin) () -> () sil [transparent] [serialized] @$s6switch1cyyF : $@convention(thin) () -> () // CHECK-LABEL: sil public_external [transparent] @test_switch_union : $@convention(thin) (MaybePair) -> () sil [transparent] [serialized] @test_switch_union : $@convention(thin) (MaybePair) -> () { bb0(%0 : $MaybePair): %1 = alloc_box $<τ_0_0> { var τ_0_0 } %1a = project_box %1 : $<τ_0_0> { var τ_0_0 } , 0 store %0 to %1a : $*MaybePair %3 = load %1a : $*MaybePair %4 = tuple () // CHECK: switch_enum %{{.*}} : $MaybePair, case #MaybePair.Neither!enumelt: bb{{.*}}, case #MaybePair.Left!enumelt: bb switch_enum %3 : $MaybePair, case #MaybePair.Neither!enumelt: bb1, case #MaybePair.Left!enumelt: bb3 bb1: br bb2 bb2: %7 = function_ref @$s6switch1ayyF : $@convention(thin) () -> () %8 = apply %7() : $@convention(thin) () -> () br bb5 bb3(%10 : $Int): %x = unchecked_enum_data %3 : $MaybePair, #MaybePair.Left!enumelt br bb4(%x : $Int) // CHECK: br bb4(%y : $Int): %12 = function_ref @$s6switch1byyF : $@convention(thin) () -> () %13 = apply %12() : $@convention(thin) () -> () br bb5 // CHECK: br bb5: %15 = function_ref @$s6switch1cyyF : $@convention(thin) () -> () %16 = apply %15() : $@convention(thin) () -> () strong_release %1 : $<τ_0_0> { var τ_0_0 } %18 = tuple () return %18 : $() // CHECK: return } enum MaybeAddressOnlyPair { case Neither case Left(Q) } // CHECK-LABEL: sil public_external [transparent] @test_switch_union_addr : $@convention(thin) (@in MaybeAddressOnlyPair) -> () sil [transparent] [serialized] @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: bb switch_enum_addr %0 : $*MaybeAddressOnlyPair, case #MaybeAddressOnlyPair.Neither!enumelt: bb1, case #MaybeAddressOnlyPair.Left!enumelt: bb2 bb1: br bb3 bb2: // CHECK: unchecked_take_enum_data_addr [[ENUM]] : $*MaybeAddressOnlyPair, #MaybeAddressOnlyPair.Left!enumelt %q = unchecked_take_enum_data_addr %0 : $*MaybeAddressOnlyPair, #MaybeAddressOnlyPair.Left!enumelt br bb3 bb3: %t = tuple () return %t : $() } // CHECK-LABEL: sil public_external [transparent] @test_switch_value : $@convention(thin) (Builtin.Word) -> () sil [transparent] [serialized] @test_switch_value : $@convention(thin) (Builtin.Word) -> () { bb0(%0 : $Builtin.Word): // CHECK: switch_value %{{.*}} : $Builtin.Word, case %1: bb2, case %2: bb1 %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 @$s6switch1ayyF : $@convention(thin) () -> () // CHECK: function_ref %8 = apply %7() : $@convention(thin) () -> () br bb3 bb2: %12 = function_ref @$s6switch1byyF : $@convention(thin) () -> () // CHECK: function_ref %13 = apply %12() : $@convention(thin) () -> () br bb3 bb3: %18 = tuple () return %18 : $() // CHECK: return } class ConcreteClass : ClassP { } struct Spoon : Bendable { } // CHECK-LABEL: sil public_external [transparent] @test_init_existential : $@convention(thin) (Spoon) -> @out any Bendable sil [transparent] [serialized] @test_init_existential : $@convention(thin) (Spoon) -> @out Bendable { bb0(%0 : $*Bendable, %1 : $Spoon): %2 = alloc_box $<τ_0_0> { var τ_0_0 } %2a = project_box %2 : $<τ_0_0> { var τ_0_0 } , 0 store %1 to %2a : $*Spoon // CHECK: init_existential_addr %{{.*}} : $*any Bendable, $Spoon %4 = init_existential_addr %0 : $*Bendable, $Spoon // CHECK: deinit_existential_addr %{{.*}} : $*any Bendable deinit_existential_addr %0 : $*Bendable %5 = load %2a : $*Spoon store %5 to %4 : $*Spoon strong_release %2 : $<τ_0_0> { var τ_0_0 } %8 = tuple () return %8 : $() } // CHECK-LABEL: sil public_external [transparent] @test_existential_ref : $@convention(thin) (ConcreteClass) -> any ClassP sil [transparent] [serialized] @test_existential_ref : $@convention(thin) (ConcreteClass) -> ClassP { bb0(%0 : $ConcreteClass): %1 = alloc_box $<τ_0_0> { var τ_0_0 } %1a = project_box %1 : $<τ_0_0> { var τ_0_0 } , 0 store %0 to %1a : $*ConcreteClass %3 = load %1a : $*ConcreteClass strong_retain %3 : $ConcreteClass // CHECK: init_existential_ref %{{.*}} : $ConcreteClass : $ConcreteClass, $any ClassP %5 = init_existential_ref %3 : $ConcreteClass : $ConcreteClass, $ClassP strong_release %1 : $<τ_0_0> { var τ_0_0 } return %5 : $ClassP } // CHECK-LABEL: sil public_external [transparent] @test_store sil [transparent] [serialized] @test_store : $@convention(thin) (Int, @inout Int) -> () { bb0(%0 : $Int, %1 : $*Int): store %0 to %1 : $*Int // CHECK: store unreachable } // CHECK-LABEL: sil public_external [transparent] @test_transparent : $@convention(thin) () -> () { sil [transparent] [serialized] @test_transparent : $@convention(thin) () -> () { bb0: // CHECK: function_ref // CHECK: apply %0 = function_ref @classes : $@convention(thin) () -> () %1 = apply %0() : $@convention(thin) () -> () %2 = tuple () return %2 : $() } // CHECK-LABEL: sil public_external [transparent] [thunk] @test_thunk : $@convention(thin) () -> () { sil [transparent] [serialized] [thunk] @test_thunk : $@convention(thin) () -> () { bb0: %0 = tuple () return %0 : $() } // CHECK-LABEL: [noinline] @noinline_callee sil [transparent] [serialized] [noinline] @noinline_callee : $@convention(thin) () -> Int { bb0: %0 = function_ref @$sSi33_convertFromBuiltinIntegerLiteralySiBI_cSimF : $@convention(thin) (Builtin.IntLiteral, @thin Int.Type) -> Int %1 = metatype $@thin Int.Type %2 = integer_literal $Builtin.IntLiteral, 0 %3 = apply %0(%2, %1) : $@convention(thin) (Builtin.IntLiteral, @thin Int.Type) -> Int return %3 : $Int } // CHECK-LABEL: [heuristic_always_inline] @always_inline_callee sil [transparent] [serialized] [heuristic_always_inline] @always_inline_callee : $@convention(thin) () -> Int { bb0: %0 = function_ref @$sSi33_convertFromBuiltinIntegerLiteralySiBI_cSimF : $@convention(thin) (Builtin.IntLiteral, @thin Int.Type) -> Int %1 = metatype $@thin Int.Type %2 = integer_literal $Builtin.IntLiteral, 0 %3 = apply %0(%2, %1) : $@convention(thin) (Builtin.IntLiteral, @thin Int.Type) -> Int return %3 : $Int } // CHECK-LABEL: [always_inline] @always_inline_callee2 sil [transparent] [serialized] [always_inline] @always_inline_callee2 : $@convention(thin) () -> Int { bb0: %0 = function_ref @$sSi33_convertFromBuiltinIntegerLiteralySiBI_cSimF : $@convention(thin) (Builtin.IntLiteral, @thin Int.Type) -> Int %1 = metatype $@thin Int.Type %2 = integer_literal $Builtin.IntLiteral, 0 %3 = apply %0(%2, %1) : $@convention(thin) (Builtin.IntLiteral, @thin Int.Type) -> Int return %3 : $Int } sil [transparent] [serialized] [transparent] @$sSi33_convertFromBuiltinIntegerLiteralySiBI_cSimF : $@convention(thin) (Builtin.IntLiteral, @thin Int.Type) -> Int // CHECK-LABEL: [_semantics "foo"] @test_semantics : $@convention(thin) () -> () sil [transparent] [serialized] [_semantics "foo"] @test_semantics : $@convention(thin) () -> () { bb0: %2 = tuple () return %2 : $() } // CHECK-LABEL: [Onone] @test_onone : $@convention(thin) () -> () sil [transparent] [serialized] [Onone] @test_onone : $@convention(thin) () -> () { bb0: %2 = tuple () return %2 : $() } // CHECK-LABEL: [Ospeed] @test_ospeed : $@convention(thin) () -> () sil [transparent] [serialized] [Ospeed] @test_ospeed : $@convention(thin) () -> () { bb0: %2 = tuple () return %2 : $() } // CHECK-LABEL: [Osize] @test_osize : $@convention(thin) () -> () sil [transparent] [serialized] [Osize] @test_osize : $@convention(thin) () -> () { bb0: %2 = tuple () return %2 : $() } sil [transparent] [serialized] @takes_unnamed_closure : $@convention(thin) (@callee_owned () -> Int) -> @callee_owned () -> @callee_owned () -> Int sil [transparent] [serialized] @takes_int64_float32 : $@convention(thin) (Int, Float32) -> () // CHECK-LABEL: sil public_external [transparent] @test_partial_apply : $@convention(thin) (Float) -> @callee_owned (Int) -> () { sil [transparent] [serialized] @test_partial_apply : $@convention(thin) (Float32) -> @callee_owned (Int) -> () { bb0(%0 : $Float32): %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) -> () return %2 : $@callee_owned (Int) -> () } class X { @objc func f() { } } // CHECK-LABEL: sil public_external [transparent] @test_dynamic_lookup_br : $@convention(thin) (AnyObject) -> () sil [transparent] [serialized] @test_dynamic_lookup_br : $@convention(thin) (AnyObject) -> () { bb0(%0 : $AnyObject): %1 = alloc_box $<τ_0_0> { var τ_0_0 } %1a = project_box %1 : $<τ_0_0> { var τ_0_0 } , 0 store %0 to %1a : $*AnyObject %3 = alloc_box $<τ_0_0> { var τ_0_0 } ()>> %4 = load %1a : $*AnyObject strong_retain %4 : $AnyObject // CHECK: open_existential_ref %{{.*}} : $AnyObject to $@opened([[EXISTENTIAL_UUID:.*]], AnyObject) Self %6 = open_existential_ref %4 : $AnyObject to $@opened("01234567-89ab-cdef-0123-222222222222", AnyObject) Self // CHECK: dynamic_method_br %{{.*}} : $@opened([[EXISTENTIAL_UUID]], AnyObject) Self, #X.f!foreign, bb{{.*}}, bb{{.*}} dynamic_method_br %6 : $@opened("01234567-89ab-cdef-0123-222222222222", AnyObject) Self, #X.f!foreign, bb1, bb2 bb1(%z : $@convention(objc_method) (@opened("01234567-89ab-cdef-0123-222222222222", AnyObject) Self) -> ()): br bb3 bb2: br bb3 bb3: %28 = tuple () return %28 : $() } // CHECK-LABEL: sil public_external [transparent] @test_mark_fn_escape sil [transparent] [serialized] @test_mark_fn_escape : $@convention(thin) () -> () { %b = alloc_box $<τ_0_0> { var τ_0_0 } %ba = project_box %b : $<τ_0_0> { var τ_0_0 } , 0 %c = alloc_box $<τ_0_0> { var τ_0_0 } %ca = project_box %c : $<τ_0_0> { var τ_0_0 } , 0 // mark_function_escape %ba : $*Int // mark_function_escape %ba : $*Int, %ca : $*Int %28 = tuple () return %28 : $() } // CHECK-LABEL: sil public_external [transparent] @test_copy_release_value sil [transparent] [serialized] @test_copy_release_value : $@convention(thin) (X) -> (X) { bb0(%0 : $X): retain_value %0 : $X release_value %0 : $X autorelease_value %0 : $X return %0 : $X // CHECK: autorelease_value [[T0:%.+]] : $X // CHECK-NEXT: return [[T0]] : $X } // CHECK-LABEL: sil public_external [transparent] @test_begin_end_ref sil [transparent] [serialized] @test_begin_end_ref : $@convention(thin) () -> (X) { bb0: %0 = alloc_ref $X %1 = end_init_let_ref %0 : $X %2 = begin_dealloc_ref %1 : $X of %0 : $X return %2 : $X // CHECK: %0 = alloc_ref // CHECK-NEXT: %1 = end_init_let_ref %0 : $X // CHECK-NEXT: %2 = begin_dealloc_ref %1 : $X of %0 : $X // CHECK-NEXT: return %2 : $X } // CHECK-LABEL: sil public_external [transparent] @test_pointer_to_address sil [transparent] [serialized] @test_pointer_to_address : $@convention(thin) (Builtin.RawPointer, X) -> () { bb0(%0 : $Builtin.RawPointer, %1 : $X): %2 = pointer_to_address %0 : $Builtin.RawPointer to $*X store %1 to %2 : $*X // CHECK: [[T2:%.*]] = pointer_to_address {{%.*}} : $Builtin.RawPointer to $*X // CHECK-NEXT: store %1 to [[T2]] : $*X %3 = pointer_to_address %0 : $Builtin.RawPointer to [strict] $*X store %1 to %3 : $*X // CHECK: [[T3:%.*]] = pointer_to_address {{%.*}} : $Builtin.RawPointer to [strict] $*X // CHECK-NEXT: store %1 to [[T3]] : $*X %28 = tuple () return %28 : $() } // CHECK-LABEL: sil public_external [transparent] @test_bind_memory sil [transparent] [serialized] @test_bind_memory : $@convention(thin) (Builtin.RawPointer, Builtin.Word) -> () { bb0(%0 : $Builtin.RawPointer, %1 : $Builtin.Word): %2 = bind_memory %0 : $Builtin.RawPointer, %1 : $Builtin.Word to $*X // CHECK: [[BIND:%.*]] = bind_memory %0 : $Builtin.RawPointer, %1 : $Builtin.Word to $*X %3 = rebind_memory %0 : $Builtin.RawPointer to %2 : $Builtin.Word // CHECK: [[REBIND:%.*]] = rebind_memory %0 : $Builtin.RawPointer to [[BIND]] : $Builtin.Word %4 = rebind_memory %0 : $Builtin.RawPointer to %3 : $Builtin.Word // CHECK: %{{.*}} = rebind_memory %0 : $Builtin.RawPointer to [[REBIND]] : $Builtin.Word %28 = tuple () return %28 : $() } @_transparent public func serialize_all() { } // CHECK: sil public_external [transparent] @cond_fail_test : $@convention(thin) (Builtin.Int1) -> () { sil [transparent] [serialized] @cond_fail_test : $@convention(thin) (Builtin.Int1) -> () { entry(%0 : $Builtin.Int1): // CHECK: cond_fail %0 : $Builtin.Int1, "message" cond_fail %0 : $Builtin.Int1, "message" %1 = tuple () return %1 : $() } // CHECK-LABEL: sil public_external [transparent] @test_dynamic_lifetime_flag : $@convention(thin) () -> () sil [transparent] [serialized] @test_dynamic_lifetime_flag : $@convention(thin) () -> () { bb0: // CHECK: alloc_box [dynamic_lifetime] $<τ_0_0> { var τ_0_0 } %0 = alloc_box [dynamic_lifetime] $<τ_0_0> { var τ_0_0 } // CHECK: alloc_stack [dynamic_lifetime] $AnyObject %1 = alloc_stack [dynamic_lifetime] $AnyObject dealloc_stack %1 : $*AnyObject %2 = tuple () return %2 : $() } // CHECK-LABEL: sil public_external [transparent] @block_storage_type sil [transparent] [serialized] @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]] : $*@block_storage Int %c = project_block_storage %s : $*@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_aliasable @block_storage Int) -> () // CHECK: [[BLOCK:%.*]] = init_block_storage_header [[STORAGE]] : $*@block_storage Int, invoke [[FUNC]] : $@convention(c) (@inout_aliasable @block_storage Int) -> (), type $@convention(block) () -> () %b = init_block_storage_header %s : $*@block_storage Int, invoke %f : $@convention(c) (@inout_aliasable @block_storage Int) -> (), type $@convention(block) () -> () // CHECK: dealloc_stack [[STORAGE]] : $*@block_storage Int dealloc_stack %s : $*@block_storage Int // CHECK: return [[BLOCK]] : $@convention(block) () -> () return %b : $@convention(block) () -> () } // CHECK-LABEL: sil public_external [transparent] @bitcasts : $@convention(thin) (@owned Class1) -> @owned (Class2, Int) { // CHECK: bb0(%0 : $Class1): // CHECK-NEXT: %1 = unchecked_ref_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 [transparent] [serialized] @bitcasts : $@convention(thin) (@owned Class1) -> @owned (Class2, Int) { entry(%0 : $Class1): %1 = unchecked_ref_cast %0 : $Class1 to $Class2 %2 = unchecked_trivial_bit_cast %0 : $Class1 to $Int %3 = tuple (%1 : $Class2, %2 : $Int) return %3 : $(Class2, Int) } sil [transparent] [serialized] @block_invoke : $@convention(c) (@inout_aliasable @block_storage Int) -> () // Test try_apply and throws // rdar://20925014 // CHECK-LABEL: sil public_external [transparent] @test_try_apply : $@convention(thin) (@convention(thin) () -> @error any Error) -> @error any Error { sil [transparent] [serialized] @test_try_apply : $@convention(thin) (@convention(thin) () -> @error Error) -> @error Error { bb0(%0 : $@convention(thin) () -> @error Error): // CHECK: try_apply %0() : $@convention(thin) () -> @error any Error, normal bb2, error bb1 try_apply %0() : $@convention(thin) () -> @error Error, normal bb1, error bb2 bb1(%1 : $()): %2 = tuple () return %2 : $() bb2(%3 : $Error): throw %3 : $Error } // Test apply with the nothrow attribute // CHECK-LABEL: sil public_external [transparent] @test_try_nothrow : $@convention(thin) (@convention(thin) () -> @error any Error) -> () { sil [transparent] [serialized] @test_try_nothrow : $@convention(thin) (@convention(thin) () -> @error Error) -> () { bb0(%0 : $@convention(thin) () -> @error Error): // CHECK: apply [nothrow] %0() : $@convention(thin) () -> @error any Error apply [nothrow] %0() : $@convention(thin) () -> @error Error %2 = tuple () return %2 : $() } // CHECK-LABEL: sil public_external [transparent] @box_type : $@convention(thin) (<τ_0_0> { var τ_0_0 } , Int) -> () { sil [transparent] [serialized] @box_type : $@convention(thin) (<τ_0_0> { var τ_0_0 } , Int) -> () { // CHECK: bb0(%0 : $<τ_0_0> { var τ_0_0 } , %1 : $Int): bb0(%0 : $<τ_0_0> { var τ_0_0 } , %1 : $Int): strong_retain %0 : $<τ_0_0> { var τ_0_0 } %3 = project_box %0 : $<τ_0_0> { var τ_0_0 } , 0 store %1 to %3 : $*Int strong_release %0 : $<τ_0_0> { var τ_0_0 } return undef : $() } // rdar://15351123 // CHECK-LABEL: @test_forward_ref sil [transparent] [serialized] @test_forward_ref : $@convention(thin) (UInt8, UInt8) -> UInt8 // CHECK-LABEL: sil public_external [transparent] @partial_apply : $@convention(thin) (@convention(thin) (Int) -> @out Int, Int) -> Int { // CHECK: [[PA:%.*]] = partial_apply {{%.*}}({{%.*}}) : $@convention(thin) (Int) -> @out Int // CHECK: apply [[PA]]({{%.*}}) : $@callee_owned () -> @out Int sil [transparent] [serialized] @partial_apply : $@convention(thin) (@convention(thin) (Int) -> @out Int, Int) -> Int { entry(%f : $@convention(thin) (Int) -> @out Int, %x : $Int): %p = partial_apply %f(%x) : $@convention(thin) (Int) -> @out Int %i = alloc_stack $Int %z = apply %p(%i) : $@callee_owned () -> @out Int %y = load %i : $*Int dealloc_stack %i : $*Int return %y : $Int } // CHECK-LABEL: @partial_apply_with_closure sil [transparent] [serialized] @partial_apply_with_closure : $@convention(thin) (@owned @callee_owned () -> Bool, @owned String, UnsafePointer, Int64) -> () { bb0(%0 : $@callee_owned () -> Bool, %1 : $String, %2 : $UnsafePointer, %3 : $Int64): %17 = function_ref @closure_body : $@convention(thin) (UnsafePointer, UnsafePointer, Int64) -> () // CHECK: function_ref @closure_body %18 = partial_apply %17(%2, %3) : $@convention(thin) (UnsafePointer, UnsafePointer, Int64) -> () // CHECK: partial_apply %30 = tuple () return %30 : $() } // rdar: 15893086 struct GenericStruct { var x : T } // CHECK-LABEL: sil public_external [transparent] @extract_generic_struct sil [transparent] [serialized] @extract_generic_struct : $@convention(thin) (GenericStruct) -> Int64 { entry(%0 : $GenericStruct): // CHECK: %1 = struct_extract %0 : $GenericStruct, #GenericStruct.x %1 = struct_extract %0 : $GenericStruct, #GenericStruct.x // CHECK: return %1 : $Int64 return %1 : $Int64 } // CHECK-LABEL: sil public_external [transparent] @select_enum : $@convention(thin) (@in Beth) -> () { sil [transparent] [serialized] @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: %3 : $Builtin.Int32 %4 = select_enum %1 : $Beth, case #Beth.EmptyCase!enumelt: %2, case #Beth.DataCase!enumelt: %3 : $Builtin.Int32 // CHECK: %5 = select_enum_addr %0 : $*Beth, case #Beth.EmptyCase!enumelt: %2, case #Beth.DataCase!enumelt: %3 : $Builtin.Int32 %5 = select_enum_addr %0 : $*Beth, case #Beth.EmptyCase!enumelt: %2, case #Beth.DataCase!enumelt: %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: Error { var _domain: String { get } var _code: Int { get } } // CHECK-LABEL: sil public_external [transparent] @existential_box : $@convention(thin) (SomeError) -> () { sil [transparent] [serialized] @existential_box : $@convention(thin) (SomeError) -> () { bb0(%0 : $SomeError): // CHECK: %1 = alloc_existential_box $any Error, $SomeError %1 = alloc_existential_box $Error, $SomeError // CHECK: %2 = project_existential_box $SomeError in %1 : $any Error %2 = project_existential_box $SomeError in %1 : $Error // CHECK: store %0 to %2 : $*SomeError store %0 to %2 : $*SomeError // CHECK: %4 = open_existential_box %1 : $any Error to $*[[OPENED:@opened\(".*", any Error\) Self]] %4 = open_existential_box %1 : $Error to $*@opened("01234567-89AB-CDEF-0123-333333333333", any Error) Self // CHECK: destroy_addr %4 : $*[[OPENED]] destroy_addr %4 : $*@opened("01234567-89AB-CDEF-0123-333333333333", any Error) Self // CHECK: dealloc_existential_box %1 : $any Error, $SomeError dealloc_existential_box %1 : $any Error, $SomeError return undef : $() } // CHECK-LABEL: sil public_external [transparent] @bridge_object : $@convention(thin) (@owned Class1, Builtin.Word) -> () { // CHECK: 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 [transparent] [serialized] @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 public_external [transparent] [reabstraction_thunk] @a_reabstraction_thunk : $@convention(thin) () -> () { sil [transparent] [serialized] [reabstraction_thunk] @a_reabstraction_thunk : $@convention(thin) () -> () { %1 = tuple() return %1 : $() } // CHECK-LABEL: sil public_external [transparent] [thunk] @a_regular_thunk : $@convention(thin) () -> () { sil [transparent] [serialized] [thunk] @a_regular_thunk : $@convention(thin) () -> () { %1 = tuple() return %1 : $() } public class WeakUnownedTest { @_hasStorage public unowned var unownedVal: @sil_unowned AnyObject { get set } @_hasStorage public weak var weakVal: @sil_weak AnyObject? { get set } public init(protoVal: AnyObject) deinit } // CHECK-LABEL: sil public_external [transparent] @weak_unowned : $@convention(thin) (@owned WeakUnownedTest, @owned AnyObject) -> () sil [transparent] [serialized] @weak_unowned : $@convention(thin) (@owned WeakUnownedTest, @owned AnyObject) -> () { bb0(%0 : $WeakUnownedTest, %1 : $AnyObject): %2 = ref_element_addr %0 : $WeakUnownedTest, #WeakUnownedTest.unownedVal // CHECK: store_unowned store_unowned %1 to %2 : $*@sil_unowned AnyObject %3 = enum $Optional, #Optional.some!enumelt, %1 : $AnyObject %4 = ref_element_addr %0 : $WeakUnownedTest, #WeakUnownedTest.weakVal // CHECK: store_weak store_weak %3 to %4 : $*@sil_weak AnyObject? %r = tuple () // CHECK: return return %r : $() } class A { @_hasStorage var property: Any { get set } deinit init() } // CHECK-LABEL: sil public_external [transparent] @test_access : $@convention(thin) (@guaranteed A) -> () { // CHECK: begin_access [read] [dynamic] // CHECK: end_access // CHECK: begin_access [read] [dynamic] [no_nested_conflict] // CHECK: end_access // CHECK: begin_unpaired_access [read] [dynamic] // CHECK: end_unpaired_access [dynamic] // CHECK: begin_unpaired_access [read] [dynamic] [no_nested_conflict] // CHECK-LABEL: } // end sil function 'test_access' sil [transparent] [serialized] @test_access : $@convention(thin) (@guaranteed A) -> () { bb0(%0 : $A): %1 = alloc_stack $Any %2 = ref_element_addr %0 : $A, #A.property %3 = begin_access [dynamic] [read] %2 : $*Any copy_addr %3 to [init] %1 : $*Any end_access %3 : $*Any %6 = begin_access [dynamic] [read] [no_nested_conflict] %2 : $*Any copy_addr %6 to %1 : $*Any end_access %6 : $*Any destroy_addr %1 : $*Any %9 = alloc_stack $Builtin.UnsafeValueBuffer begin_unpaired_access [read] [dynamic] %2 : $*Any, %9 : $*Builtin.UnsafeValueBuffer copy_addr %2 to %1 : $*Any end_unpaired_access [dynamic] %9 : $*Builtin.UnsafeValueBuffer begin_unpaired_access [read] [dynamic] [no_nested_conflict] %2 : $*Any, %9 : $*Builtin.UnsafeValueBuffer copy_addr %2 to %1 : $*Any destroy_addr %1 : $*Any dealloc_stack %9 : $*Builtin.UnsafeValueBuffer dealloc_stack %1 : $*Any %20 = tuple () return %20 : $() } // CHECK-LABEL: sil public_external [transparent] @test_builtin_access : $@convention(thin) (@guaranteed A) -> () { // CHECK: begin_access [read] [dynamic] [builtin] // CHECK: end_access // CHECK: begin_unpaired_access [read] [dynamic] [builtin] // CHECK: end_unpaired_access [dynamic] [builtin] // CHECK-LABEL: } // end sil function 'test_builtin_access' sil [transparent] [serialized] @test_builtin_access : $@convention(thin) (@guaranteed A) -> () { bb0(%0 : $A): %1 = alloc_stack $Any %2 = ref_element_addr %0 : $A, #A.property %6 = begin_access [dynamic] [read] [builtin] %2 : $*Any copy_addr %6 to %1 : $*Any end_access %6 : $*Any destroy_addr %1 : $*Any %9 = alloc_stack $Builtin.UnsafeValueBuffer begin_unpaired_access [read] [dynamic] [builtin] %2 : $*Any, %9 : $*Builtin.UnsafeValueBuffer copy_addr %2 to %1 : $*Any end_unpaired_access [dynamic] [builtin] %9 : $*Builtin.UnsafeValueBuffer destroy_addr %1 : $*Any dealloc_stack %9 : $*Builtin.UnsafeValueBuffer dealloc_stack %1 : $*Any %20 = tuple () return %20 : $() } public class Foo { subscript (x: Int, y: Int) -> Int32 { get set } var x: Int var y: Int init() } sil [transparent] [serialized] @$s3tmp3FooC9subscriptSiSi1x_Si1ytcfg : $@convention(method) (Int, Int, @guaranteed Foo) -> Int32 { 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 : $*Int store %1 to %5 : $*Int %8 = alloc_stack $Foo // var self // users: %15, %14, %9 store %2 to %8 : $*Foo %10 = metatype $@thin Int.Type %12 = integer_literal $Builtin.Int32, 0 // user: %13 %13 = struct $Int32 (%12 : $Builtin.Int32) // user: %18 destroy_addr %8 : $*Foo dealloc_stack %8 : $*Foo dealloc_stack %5 : $*Int dealloc_stack %4 : $*Int return %13 : $Int32 } sil [transparent] [serialized] @$s3tmp3FooC9subscriptSiSi1x_Si1ytcfs : $@convention(method) (Int32, Int, Int, @guaranteed Foo) -> () { bb0(%0 : $Int32, %1 : $Int, %2 : $Int, %3 : $Foo): %4 = alloc_stack $Int32 // var value // users: %16, %5 store %0 to %4 : $*Int32 %6 = alloc_stack $Int // var x // users: %15, %8 %7 = alloc_stack $Int // var y // users: %14, %9 store %1 to %6 : $*Int store %2 to %7 : $*Int %10 = alloc_stack $Foo // var self // users: %13, %12, %11 store %3 to %10 : $*Foo destroy_addr %10 : $*Foo dealloc_stack %10 : $*Foo dealloc_stack %7 : $*Int dealloc_stack %6 : $*Int dealloc_stack %4 : $*Int32 %17 = tuple () // user: %18 return %17 : $() } sil [transparent] [serialized] @assert_fail : $@convention(thin) (UnsafePointer, UnsafePointer, Int64) -> () sil shared [serialized] @closure_body : $@convention(thin) (UnsafePointer, UnsafePointer, Int64) -> () { bb0(%0 : $UnsafePointer, %1 : $UnsafePointer, %2 : $Int64): %3 = function_ref @assert_fail : $@convention(thin) (UnsafePointer, UnsafePointer, Int64) -> () %4 = apply %3(%0, %1, %2) : $@convention(thin) (UnsafePointer, UnsafePointer, Int64) -> () %5 = tuple () return %5 : $() } // CHECK-LABEL: @closure_body : $@convention(thin) (UnsafePointer, UnsafePointer, Int64) -> () { // CHECK: function_ref @assert_fail sil_vtable [serialized] Foo { #Foo.subscript!getter: @$s3tmp3FooC9subscriptSiSi1x_Si1ytcfg #Foo.subscript!setter: @$s3tmp3FooC9subscriptSiSi1x_Si1ytcfs } protocol AssocReqt { func requiredMethod() } struct ConformingAssoc : AssocReqt { func requiredMethod() } sil [transparent] [serialized] @$s14witness_tables15ConformingAssocV14requiredMethodyyycACF : $@convention(method) (@guaranteed ConformingAssoc) -> () { bb0(%0 : $ConformingAssoc): debug_value %0 : $ConformingAssoc %2 = tuple () return %2 : $() } sil [transparent] [serialized] @_TTWV14witness_tables15ConformingAssocS_9AssocReqtS_FS1_14requiredMethodU_fRQPS1_FT_T_ : $@convention(witness_method: AssocReqt) (@in_guaranteed ConformingAssoc) -> () { bb0(%0 : $*ConformingAssoc): %1 = load %0 : $*ConformingAssoc %2 = function_ref @$s14witness_tables15ConformingAssocV14requiredMethodyyycACF : $@convention(method) (@guaranteed ConformingAssoc) -> () %3 = apply %2(%1) : $@convention(method) (@guaranteed ConformingAssoc) -> () return %3 : $() } sil_witness_table [serialized] ConformingAssoc: AssocReqt module def_basic { method #AssocReqt.requiredMethod: @_TTWV14witness_tables15ConformingAssocS_9AssocReqtS_FS1_14requiredMethodU_fRQPS1_FT_T_ } protocol AnyProtocol { associatedtype AssocType associatedtype AssocWithReqt : AssocReqt func assocTypesMethod(_ x: AssocType, y: AssocWithReqt) static 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() } sil_witness_table [serialized] InheritedConformance: InheritedProtocol1 module witness_tables { base_protocol AnyProtocol: InheritedConformance: AnyProtocol module witness_tables } sil_witness_table [serialized] InheritedConformance: AnyProtocol module witness_tables { associated_type AssocType: SomeAssoc associated_conformance (AssocWithReqt: AssocReqt): ConformingAssoc: AssocReqt module witness_tables } sil [transparent] [serialized] @$s9def_basic13serialize_allyyF : $@convention(thin) () -> () { bb0: %0 = function_ref @_TV18lazy_global_access4Type10staticPropySia_public : $@convention(thin) () -> Builtin.RawPointer %1 = function_ref @_TV18lazy_global_access4Type10staticPropySia : $@convention(thin) () -> Builtin.RawPointer %2 = function_ref @test1 : $@convention(thin) () -> () %4 = function_ref @test2 : $@convention(thin) (Int) -> () %6 = function_ref @named_tuple : $@convention(thin) () -> (Builtin.Word, Builtin.Word) %9 = function_ref @return_int : $@convention(thin) (Int) -> Int %10 = function_ref @vector_base_addr : $@convention(thin) (@inout Builtin.FixedArray<10, Int>) -> Int %11 = function_ref @call_fn_pointer : $@convention(thin) (() -> Int) -> Int %13 = function_ref @return_constant : $@convention(thin) () -> Int %23 = function_ref @existentials : $@convention(thin) (@in P) -> () %25 = function_ref @classes : $@convention(thin) () -> () %27 = function_ref @$s4todo18erasure_from_proto1xAA8Runcible_pAaD_AA8Bendablep_tF : $@convention(thin) (@in Bendable & Runcible) -> @out Runcible %29 = function_ref @$s4todo18class_bound_method1xyAA10ClassBound_p_tF : $@convention(thin) (@owned ClassBound) -> () %31 = function_ref @$s6struct5AlephVyAcA3RefC1a_AA3ValV1btcACmcfC : $@convention(thin) (Ref, Val, @thin Aleph.Type) -> Aleph %33 = function_ref @$s6struct5AlephVyACycACmcfC : $@convention(thin) (@thin Aleph.Type) -> Aleph %35 = function_ref @test_union_empty_case : $@convention(thin) () -> Beth %37 = function_ref @test_union_data_case : $@convention(thin) (Int) -> Beth %39 = function_ref @test_union_addr_empty_case : $@convention(thin) () -> @out Gimel %41 = function_ref @test_union_addr_data_case : $@convention(thin) (@in Q) -> @out Gimel %43 = function_ref @$s5tuple5float1xySf_tF : $@convention(thin) (Float32) -> () %45 = function_ref @$s5tupleAASi_SftyF : $@convention(thin) () -> (Int, Float32) %47 = function_ref @$s5tuple0A8_element1xySi_Sft_tF : $@convention(thin) (Int, Float32) -> () %49 = function_ref @$s3ref1CC3fooyySi1x_tcACF : $@convention(method) (Int, @guaranteed M) -> () %51 = function_ref @$s4null3isa1bSbAA1BC_tF : $@convention(thin) (B) -> Builtin.Int1 %53 = function_ref @$sSd31_convertFromBuiltinFloatLiteralySdBf64_5value_tcSdmF : $@convention(thin) (Builtin.FPIEEE64, @thin Float64.Type) -> Float64 %55 = function_ref @$sSS32_convertFromBuiltinStringLiteralySSBp5value_Bi64_17utf8CodeUnitCountBi1_7isASCIItcSSmF : $@convention(thin) (Builtin.RawPointer, Builtin.Word, Builtin.Int1, @thin String.Type) -> String %57 = function_ref @$s7literal8literalsyyF : $@convention(thin) () -> () %59 = function_ref @$s5index5gep641p1iBpBp_Bi64_tF : $@convention(thin) (Builtin.RawPointer, Builtin.Word) -> Builtin.RawPointer %60 = function_ref @global_code : $@convention(thin) () -> () %61 = function_ref @base_addr : $@convention(thin) () -> () %62 = function_ref @global_object : $@convention(thin) () -> GlobalObject %63 = function_ref @test_class_metatype : $@convention(thin) (SomeClass, SomeSubclass) -> (@thick SomeClass.Type, @thick SomeClass.Type) %67 = function_ref @test_existential_metatype : $@convention(thin) (@in SomeProtocol) -> @thick SomeProtocol.Type %69 = function_ref @test_unreachable : $@convention(thin) () -> () %71 = function_ref @test_unowned_retain : $@convention(thin) (SomeClass) -> () %73 = function_ref @test_basic_block_arguments : $@convention(thin) (Builtin.Int1) -> Builtin.Word %75 = function_ref @test_cond_branch_basic_block_args : $@convention(thin) (Int, Builtin.Int1) -> Int %81 = function_ref @test_builtin_func_ref : $@convention(thin) (Builtin.Int1, Builtin.Int1) -> Builtin.Int1 %83 = function_ref @test_dealloc_ref : $@convention(thin) () -> () %84 = function_ref @test_dealloc_partial_ref : $@convention(thin) () -> () %85 = function_ref @test_dealloc_box : $@convention(thin) () -> () %86 = function_ref @test_stack_flag : $@convention(thin) () -> () %86b = function_ref @test_bare_flags : $@convention(thin) () -> () %86c = function_ref @test_stack_protection_flags : $@convention(thin) (@inout Builtin.Word) -> () %87 = function_ref @test_tail_elems : $@convention(thin) (Builtin.Word, Builtin.Word) -> () %88 = function_ref @test_tail_elems_dynamic : $@convention(thin) (Builtin.Word, Builtin.Word, @thick Class1.Type) -> () %89 = function_ref @test_tail_addr : $@convention(thin) (@owned Class1, Builtin.Word) -> @owned Class1 %90 = function_ref @test_cow_mutation : $@convention(thin) (@owned Class1) -> @owned Class1 %91 = function_ref @closure_test : $@convention(thin) () -> () %97 = function_ref @test_switch_union : $@convention(thin) (MaybePair) -> () %99 = function_ref @test_switch_union_addr : $@convention(thin) (@in MaybeAddressOnlyPair) -> () %101 = function_ref @test_switch_value : $@convention(thin) (Builtin.Word) -> () %103 = function_ref @test_init_existential : $@convention(thin) (Spoon) -> @out Bendable %105 = function_ref @test_existential_ref : $@convention(thin) (ConcreteClass) -> ClassP %107 = function_ref @test_store : $@convention(thin) (Int, @inout Int) -> () %109 = function_ref @test_transparent : $@convention(thin) () -> () %110 = function_ref @test_thunk : $@convention(thin) () -> () %130 = function_ref @noinline_callee : $@convention(thin) () -> Int %132 = function_ref @always_inline_callee : $@convention(thin) () -> Int %161 = function_ref @always_inline_callee2 : $@convention(thin) () -> Int %131 = function_ref @test_semantics : $@convention(thin) () -> () %136 = function_ref @test_onone : $@convention(thin) () -> () %137 = function_ref @test_ospeed : $@convention(thin) () -> () %138 = function_ref @test_osize : $@convention(thin) () -> () %111 = function_ref @test_partial_apply : $@convention(thin) (Float32) -> @callee_owned (Int) -> () %113 = function_ref @test_dynamic_lookup_br : $@convention(thin) (AnyObject) -> () %115 = function_ref @test_mark_fn_escape : $@convention(thin) () -> () %117 = function_ref @test_copy_release_value : $@convention(thin) (X) -> (X) %118 = function_ref @test_begin_end_ref : $@convention(thin) () -> (X) %119 = function_ref @test_pointer_to_address : $@convention(thin) (Builtin.RawPointer, X) -> () %120 = function_ref @test_bind_memory : $@convention(thin) (Builtin.RawPointer, Builtin.Word) -> () %121 = function_ref @cond_fail_test : $@convention(thin) (Builtin.Int1) -> () %122 = function_ref @test_dynamic_lifetime_flag : $@convention(thin) () -> () %124 = function_ref @block_storage_type : $@convention(thin) (Int) -> @convention(block) () -> () %127 = function_ref @bitcasts : $@convention(thin) (@owned Class1) -> @owned (Class2, Int) %133 = function_ref @test_try_apply : $@convention(thin) (@convention(thin) () -> @error Error) -> @error Error %135 = function_ref @test_try_nothrow : $@convention(thin) (@convention(thin) () -> @error Error) -> () %134 = function_ref @box_type : $@convention(thin) (<τ_0_0> { var τ_0_0 } , Int) -> () %140 = function_ref @test_forward_ref : $@convention(thin) (UInt8, UInt8) -> UInt8 %141 = function_ref @partial_apply : $@convention(thin) (@convention(thin) (Int) -> @out Int, Int) -> Int %142 = function_ref @partial_apply_with_closure : $@convention(thin) (@owned @callee_owned () -> Bool, @owned String, UnsafePointer, Int64) -> () %143 = function_ref @extract_generic_struct : $@convention(thin) (GenericStruct) -> Int64 %148 = function_ref @select_enum : $@convention(thin) (@in Beth) -> () %149 = function_ref @existential_box : $@convention(thin) (SomeError) -> () %150 = function_ref @bridge_object : $@convention(thin) (@owned Class1, Builtin.Word) -> () %151 = function_ref @a_reabstraction_thunk: $@convention(thin) () -> () %152 = function_ref @a_regular_thunk: $@convention(thin) () -> () %153 = function_ref @weak_unowned: $@convention(thin) (@owned WeakUnownedTest, @owned AnyObject) -> () %154 = function_ref @test_access : $@convention(thin) (@guaranteed A) -> () %155 = function_ref @test_builtin_access : $@convention(thin) (@guaranteed A) -> () %160 = global_addr @static_global_vector : $*Int32 %r = tuple () return %r : $() }