mirror of
https://github.com/apple/swift.git
synced 2026-10-02 10:58:03 +02:00
* convert "method"s to "thin" functions: We are removing arguments from the original function. If the removed argument is the "self" argument, the specialized function cannot be a "method" anymore. * don't create `thin_to_thick_function` instructions for non-thin functions. Instead keep it a `partial_apply` Fixes a SIL verifier crash. rdar://172774069
1046 lines
54 KiB
Plaintext
1046 lines
54 KiB
Plaintext
// RUN: %target-sil-opt -sil-print-types -enable-sil-verify-all %s -constant-capture-propagation | %FileCheck %s
|
|
|
|
// Check the CapturePropagation specialized the reabstraction thunk.
|
|
|
|
sil_stage raw
|
|
|
|
import Builtin
|
|
import Swift
|
|
|
|
sil @capture_helper_2 : $@convention(thin) (Int32) -> ()
|
|
|
|
// CHECK-LABEL: test_capture_propagation
|
|
// CHECK: %[[FR:[0-9]+]] = function_ref @$sSiytIxyd_SiytIxid_TR22$s8capturep6helperySiFTf3npf_n : $@convention(thin) (@in Int32) -> ()
|
|
// CHECK: thin_to_thick_function %[[FR]] : $@convention(thin) (@in Int32) -> ()
|
|
sil private [ossa] @test_capture_propagation : $@convention(thin) () -> () {
|
|
bb0:
|
|
%0 = alloc_stack $Int32
|
|
%1 = integer_literal $Builtin.Int32, 3
|
|
%2 = struct $Int32 (%1 : $Builtin.Int32)
|
|
store %2 to [trivial] %0 : $*Int32
|
|
|
|
%4 = function_ref @$s8capturep6helperySiF : $@convention(thin) (Int32) -> ()
|
|
%5 = thin_to_thick_function %4 : $@convention(thin) (Int32) -> () to $@callee_guaranteed (Int32) -> ()
|
|
|
|
%6 = function_ref @$sSiytIxyd_SiytIxid_TR : $@convention(thin) (@in Int32, @guaranteed @callee_guaranteed (Int32) -> ()) -> ()
|
|
%7 = partial_apply %6(%5) : $@convention(thin) (@in Int32, @guaranteed @callee_guaranteed (Int32) -> ()) -> ()
|
|
|
|
%8 = function_ref @_TTSgSi___TF8capturep7genericU__FTQ_FQ_T__T_ : $@convention(thin) (@in Int32, @owned @callee_owned (@in Int32) -> ()) -> ()
|
|
%9 = apply %8(%0, %7) : $@convention(thin) (@in Int32, @owned @callee_owned (@in Int32) -> ()) -> ()
|
|
store %2 to [trivial] %0 : $*Int32
|
|
|
|
%11 = thin_to_thick_function %4 : $@convention(thin) (Int32) -> () to $@callee_owned (Int32) -> ()
|
|
%12 = function_ref @bad_thunk : $@convention(thin) (@in Int32, @guaranteed @callee_owned (Int32) -> ()) -> ()
|
|
%13 = partial_apply %12(%11) : $@convention(thin) (@in Int32, @guaranteed @callee_owned (Int32) -> ()) -> ()
|
|
%14 = apply %8(%0, %13) : $@convention(thin) (@in Int32, @owned @callee_owned (@in Int32) -> ()) -> ()
|
|
|
|
dealloc_stack %0 : $*Int32
|
|
%15 = tuple ()
|
|
return %15 : $()
|
|
}
|
|
|
|
// capturep.helper (Swift.Int32) -> ()
|
|
sil [ossa] @$s8capturep6helperySiF : $@convention(thin) (Int32) -> () {
|
|
bb0(%0 : $Int32):
|
|
%1 = tuple () // user: %2
|
|
return %1 : $() // id: %2
|
|
}
|
|
|
|
sil @bad_thunk : $@convention(thin) (@in Int32, @guaranteed @callee_owned (Int32) -> ()) -> ()
|
|
|
|
// reabstraction thunk helper from @callee_owned (@unowned Swift.Int32) -> (@unowned ()) to @callee_owned (@in Swift.Int32) -> (@unowned ())
|
|
sil shared [transparent] [ossa] @$sSiytIxyd_SiytIxid_TR : $@convention(thin) (@in Int32, @guaranteed @callee_guaranteed (Int32) -> ()) -> () {
|
|
bb0(%0 : $*Int32, %1 : @guaranteed $@callee_guaranteed (Int32) -> ()):
|
|
%2 = load [trivial] %0
|
|
%3 = apply %1(%2) : $@callee_guaranteed (Int32) -> ()
|
|
return %3 : $()
|
|
}
|
|
|
|
// specialization <Swift.Int32> of capturep.generic <A>(A, (A) -> ()) -> ()
|
|
sil shared [noinline] [ossa] @_TTSgSi___TF8capturep7genericU__FTQ_FQ_T__T_ : $@convention(thin) (@in Int32, @owned @callee_owned (@in Int32) -> ()) -> () {
|
|
bb0(%0 : $*Int32, %1 : @owned $@callee_owned (@in Int32) -> ()):
|
|
%2 = alloc_stack $Int32
|
|
%3 = load [trivial] %0
|
|
store %3 to [trivial] %2
|
|
%5 = apply %1(%2) : $@callee_owned (@in Int32) -> ()
|
|
dealloc_stack %2 : $*Int32
|
|
%7 = tuple ()
|
|
return %7 : $()
|
|
}
|
|
|
|
/*
|
|
// reabstraction thunk helper from @callee_owned (@unowned Swift.Int32) -> (@unowned ()) to @callee_owned (@in Swift.Int32) -> (@unowned ())
|
|
sil shared [transparent] @$sSiytIxyd_SiytIxid_TR : $@convention(thin) (@in Int32, @owned @callee_owned (Int32) -> ()) -> () {
|
|
bb0(%0 : $*Int32, %1 : $@callee_owned (Int32) -> ()):
|
|
%2 = load %0 : $*Int32
|
|
%3 = apply %1(%2) : $@callee_owned (Int32) -> ()
|
|
return %3 : $()
|
|
}
|
|
*/
|
|
|
|
sil [ossa] @_TFtest_capture_propagation2_closure : $@convention(thin) (Builtin.Int32, Builtin.FPIEEE32, Builtin.RawPointer, @in_guaranteed Builtin.Word) -> () {
|
|
bb0(%0 : $Builtin.Int32, %1 : $Builtin.FPIEEE32, %2 : $Builtin.RawPointer, %3 : $*Builtin.Word):
|
|
%9999 = tuple()
|
|
return %9999 : $()
|
|
}
|
|
|
|
sil_global [serialized] @globalinit_33_06E7F1D906492AE070936A9B58CBAE1C_token8 : $Builtin.Word
|
|
|
|
sil [ossa] @test_capture_propagation2_caller : $@convention(thin) () -> () {
|
|
%0 = integer_literal $Builtin.Int32, 0
|
|
%1 = float_literal $Builtin.FPIEEE32, 0
|
|
%2 = string_literal utf8 "123"
|
|
%3 = global_addr @globalinit_33_06E7F1D906492AE070936A9B58CBAE1C_token8 : $*Builtin.Word
|
|
%4 = function_ref @_TFtest_capture_propagation2_closure : $@convention(thin) (Builtin.Int32, Builtin.FPIEEE32, Builtin.RawPointer, @in_guaranteed Builtin.Word) -> ()
|
|
%5 = thin_to_thick_function %4 : $@convention(thin) (Builtin.Int32, Builtin.FPIEEE32, Builtin.RawPointer, @in_guaranteed Builtin.Word) -> () to $@callee_guaranteed (Builtin.Int32, Builtin.FPIEEE32, Builtin.RawPointer, @in_guaranteed Builtin.Word) -> ()
|
|
%6 = function_ref @test_capture_propagation2_callee : $@convention(thin) (@owned @callee_owned () -> ()) -> ()
|
|
%7 = function_ref @test_capture_propagation2_thunk : $@convention(thin) (Builtin.Int32, Builtin.FPIEEE32, Builtin.RawPointer, @in_guaranteed Builtin.Word, @guaranteed @callee_guaranteed (Builtin.Int32, Builtin.FPIEEE32, Builtin.RawPointer, @in_guaranteed Builtin.Word) -> ()) -> ()
|
|
%8 = partial_apply %7(%0, %1, %2, %3, %5) : $@convention(thin) (Builtin.Int32, Builtin.FPIEEE32, Builtin.RawPointer, @in_guaranteed Builtin.Word, @guaranteed @callee_guaranteed (Builtin.Int32, Builtin.FPIEEE32, Builtin.RawPointer, @in_guaranteed Builtin.Word) -> ()) -> ()
|
|
apply %6(%8) : $@convention(thin) (@owned @callee_owned () -> ()) -> ()
|
|
%9999 = tuple()
|
|
return %9999 : $()
|
|
}
|
|
|
|
sil shared [ossa] @test_capture_propagation2_thunk : $@convention(thin) (Builtin.Int32, Builtin.FPIEEE32, Builtin.RawPointer, @in_guaranteed Builtin.Word, @guaranteed @callee_guaranteed (Builtin.Int32, Builtin.FPIEEE32, Builtin.RawPointer, @in_guaranteed Builtin.Word) -> ()) -> () {
|
|
bb0(%0 : $Builtin.Int32, %1 : $Builtin.FPIEEE32, %2 : $Builtin.RawPointer, %3 : $*Builtin.Word, %4 : @guaranteed $@callee_guaranteed (Builtin.Int32, Builtin.FPIEEE32, Builtin.RawPointer, @in_guaranteed Builtin.Word) -> ()):
|
|
apply %4(%0, %1, %2, %3) : $@callee_guaranteed (Builtin.Int32, Builtin.FPIEEE32, Builtin.RawPointer, @in_guaranteed Builtin.Word) -> ()
|
|
%9999 = tuple()
|
|
return %9999 : $()
|
|
}
|
|
|
|
sil shared [ossa] @test_capture_propagation2_callee : $@convention(thin) (@owned @callee_owned () -> ()) -> () {
|
|
bb0(%0 : @owned $@callee_owned () -> ()):
|
|
apply %0() : $@callee_owned () -> ()
|
|
%9999 = tuple()
|
|
return %9999 : $()
|
|
}
|
|
|
|
// Test dead partial applied arguments
|
|
|
|
sil @specialized_nonthrowing_closure : $@convention(thin) (Int32, Int32) -> Bool
|
|
|
|
sil [ossa] @nonthrowing_closure : $@convention(method) (Int32, Int32, @thin Int32.Type) -> Bool {
|
|
bb0(%0 : $Int32, %1 : $Int32, %2 : $@thin Int32.Type):
|
|
%3 = function_ref @specialized_nonthrowing_closure : $@convention(thin) (Int32, Int32) -> Bool
|
|
%4 = apply %3(%0, %1) : $@convention(thin) (Int32, Int32) -> Bool
|
|
return %4 : $Bool
|
|
}
|
|
|
|
// CHECK-LABEL: sil [ossa] @return_nonthrowing_closure
|
|
// CHECK: [[F:%[0-9]+]] = function_ref @specialized_nonthrowing_closure
|
|
// CHECK: [[R:%[0-9]+]] = thin_to_thick_function [[F]]
|
|
// CHECK: return [[R]]
|
|
sil [ossa] @return_nonthrowing_closure : $@convention(thin) () -> @owned @callee_owned (Int32, Int32) -> Bool {
|
|
bb0:
|
|
%0 = metatype $@thin Int32.Type
|
|
%1 = function_ref @nonthrowing_closure : $@convention(method) (Int32, Int32, @thin Int32.Type) -> Bool
|
|
%2 = partial_apply %1(%0) : $@convention(method) (Int32, Int32, @thin Int32.Type) -> Bool
|
|
return %2 : $@callee_owned (Int32, Int32) -> Bool
|
|
}
|
|
|
|
sil @specialized_throwing_closure : $@convention(thin) (Int32, Int32) -> (Bool, @error any Error)
|
|
|
|
sil [ossa] @throwing_closure : $@convention(method) (Int32, Int32, @thin Int32.Type) -> (Bool, @error any Error) {
|
|
bb0(%0 : $Int32, %1 : $Int32, %2 : $@thin Int32.Type):
|
|
%3 = function_ref @specialized_throwing_closure : $@convention(thin) (Int32, Int32) -> (Bool, @error any Error)
|
|
try_apply %3(%0, %1) : $@convention(thin) (Int32, Int32) -> (Bool, @error any Error), normal bb1, error bb2
|
|
|
|
bb1(%5 : $Bool):
|
|
return %5 : $Bool
|
|
|
|
bb2(%7 : $Error):
|
|
throw %7 : $Error
|
|
}
|
|
|
|
// CHECK-LABEL: sil [ossa] @return_throwing_closure
|
|
// CHECK: [[F:%[0-9]+]] = function_ref @specialized_throwing_closure
|
|
// CHECK: [[R:%[0-9]+]] = thin_to_thick_function [[F]]
|
|
// CHECK: return [[R]]
|
|
sil [ossa] @return_throwing_closure : $@convention(thin) () -> @owned @callee_owned (Int32, Int32) -> (Bool, @error any Error) {
|
|
bb0:
|
|
%0 = metatype $@thin Int32.Type
|
|
%1 = function_ref @throwing_closure : $@convention(method) (Int32, Int32, @thin Int32.Type) -> (Bool, @error any Error)
|
|
%2 = partial_apply %1(%0) : $@convention(method) (Int32, Int32, @thin Int32.Type) -> (Bool, @error any Error)
|
|
return %2 : $@callee_owned (Int32, Int32) -> (Bool, @error any Error)
|
|
}
|
|
|
|
// Check if we can handle a non-throwing closure which is passed to a thunk accepting a throwing closure.
|
|
|
|
sil @simple_nonthrowing_closure : $@convention(thin) (Int32) -> Bool
|
|
|
|
// CHECK-LABEL: sil shared [ossa] @{{.*}}throwing_thunk{{.*}} : $@convention(thin) (Int32) -> (Bool, @error any Error) {
|
|
// CHECK: = function_ref @simple_nonthrowing_closure
|
|
// CHECK-NEXT: thin_to_thick_function
|
|
// CHECK-NEXT: convert_function
|
|
// CHECK-NEXT: try_apply
|
|
// CHECK: return
|
|
// CHECK: throw
|
|
sil [ossa] @throwing_thunk : $@convention(thin) (Int32, @owned @callee_owned (Int32) -> (Bool, @error any Error)) -> (Bool, @error any Error) {
|
|
bb0(%0 : $Int32, %1 : @owned $@callee_owned (Int32) -> (Bool, @error any Error)):
|
|
try_apply %1(%0) : $@callee_owned (Int32) -> (Bool, @error any Error), normal bb1, error bb2
|
|
|
|
bb1(%5 : $Bool):
|
|
return %5 : $Bool
|
|
|
|
bb2(%7 : $Error):
|
|
throw %7 : $Error
|
|
}
|
|
|
|
// CHECK-LABEL: sil [ossa] @return_throwing_thunk_closure
|
|
// CHECK: [[F:%[0-9]+]] = function_ref @{{.*}}throwing_thunk{{.*}} : $@convention(thin) (Int32) -> (Bool, @error any Error)
|
|
// CHECK: [[T:%[0-9]+]] = thin_to_thick_function [[F]]
|
|
// CHECK: return [[T]]
|
|
sil [ossa] @return_throwing_thunk_closure : $@convention(thin) () -> @owned @callee_owned (Int32) -> (Bool, @error any Error) {
|
|
bb0:
|
|
%c1 = function_ref @simple_nonthrowing_closure : $@convention(thin) (Int32) -> Bool
|
|
%c2 = thin_to_thick_function %c1 : $@convention(thin) (Int32) -> Bool to $@callee_owned (Int32) -> Bool
|
|
%c3 = convert_function %c2 : $@callee_owned (Int32) -> Bool to $@callee_owned (Int32) -> (Bool, @error any Error)
|
|
%t1 = function_ref @throwing_thunk : $@convention(thin) (Int32, @owned @callee_owned (Int32) -> (Bool, @error any Error)) -> (Bool, @error any Error)
|
|
%2 = partial_apply %t1(%c3) : $@convention(thin) (Int32, @owned @callee_owned (Int32) -> (Bool, @error any Error)) -> (Bool, @error any Error)
|
|
return %2 : $@callee_owned (Int32) -> (Bool, @error any Error)
|
|
}
|
|
|
|
// Negative tests
|
|
|
|
sil [ossa] @swapped_arguments : $@convention(method) (Int32, Int32, @thin Int32.Type) -> Bool {
|
|
bb0(%0 : $Int32, %1 : $Int32, %2 : $@thin Int32.Type):
|
|
%3 = function_ref @specialized_nonthrowing_closure : $@convention(thin) (Int32, Int32) -> Bool
|
|
%4 = apply %3(%1, %0) : $@convention(thin) (Int32, Int32) -> Bool
|
|
return %4 : $Bool
|
|
}
|
|
|
|
// CHECK-LABEL: sil [ossa] @return_swapped_arguments
|
|
// CHECK: [[M:%[0-9]+]] = metatype
|
|
// CHECK: [[F:%[0-9]+]] = function_ref @swapped_arguments
|
|
// CHECK: [[R:%[0-9]+]] = partial_apply [[F]]([[M]])
|
|
// CHECK: return [[R]]
|
|
sil [ossa] @return_swapped_arguments : $@convention(thin) () -> @owned @callee_owned (Int32, Int32) -> Bool {
|
|
bb0:
|
|
%0 = metatype $@thin Int32.Type
|
|
%1 = function_ref @swapped_arguments : $@convention(method) (Int32, Int32, @thin Int32.Type) -> Bool
|
|
%2 = partial_apply %1(%0) : $@convention(method) (Int32, Int32, @thin Int32.Type) -> Bool
|
|
return %2 : $@callee_owned (Int32, Int32) -> Bool
|
|
}
|
|
|
|
|
|
sil [ossa] @wrong_return1 : $@convention(method) (Int32, Int32, @thin Int32.Type) -> Bool {
|
|
bb0(%0 : $Int32, %1 : $Int32, %2 : $@thin Int32.Type):
|
|
%3 = function_ref @specialized_nonthrowing_closure : $@convention(thin) (Int32, Int32) -> Bool
|
|
%4 = apply %3(%0, %1) : $@convention(thin) (Int32, Int32) -> Bool
|
|
%i = integer_literal $Builtin.Int1, 0
|
|
%b = struct $Bool (%i : $Builtin.Int1)
|
|
return %b : $Bool
|
|
}
|
|
|
|
// CHECK-LABEL: sil [ossa] @return_wrong_return1
|
|
// CHECK: [[M:%[0-9]+]] = metatype
|
|
// CHECK: [[F:%[0-9]+]] = function_ref @wrong_return1
|
|
// CHECK: [[R:%[0-9]+]] = partial_apply [[F]]([[M]])
|
|
// CHECK: return [[R]]
|
|
sil [ossa] @return_wrong_return1 : $@convention(thin) () -> @owned @callee_owned (Int32, Int32) -> Bool {
|
|
bb0:
|
|
%0 = metatype $@thin Int32.Type
|
|
%1 = function_ref @wrong_return1 : $@convention(method) (Int32, Int32, @thin Int32.Type) -> Bool
|
|
%2 = partial_apply %1(%0) : $@convention(method) (Int32, Int32, @thin Int32.Type) -> Bool
|
|
return %2 : $@callee_owned (Int32, Int32) -> Bool
|
|
}
|
|
|
|
|
|
sil [ossa] @second_apply : $@convention(method) (Int32, Int32, @thin Int32.Type) -> Bool {
|
|
bb0(%0 : $Int32, %1 : $Int32, %2 : $@thin Int32.Type):
|
|
%3 = function_ref @specialized_nonthrowing_closure : $@convention(thin) (Int32, Int32) -> Bool
|
|
%u = apply %3(%0, %1) : $@convention(thin) (Int32, Int32) -> Bool
|
|
%4 = apply %3(%0, %1) : $@convention(thin) (Int32, Int32) -> Bool
|
|
return %4 : $Bool
|
|
}
|
|
|
|
// CHECK-LABEL: sil [ossa] @return_second_apply
|
|
// CHECK: [[M:%[0-9]+]] = metatype
|
|
// CHECK: [[F:%[0-9]+]] = function_ref @second_apply
|
|
// CHECK: [[R:%[0-9]+]] = partial_apply [[F]]([[M]])
|
|
// CHECK: return [[R]]
|
|
sil [ossa] @return_second_apply : $@convention(thin) () -> @owned @callee_owned (Int32, Int32) -> Bool {
|
|
bb0:
|
|
%0 = metatype $@thin Int32.Type
|
|
%1 = function_ref @second_apply : $@convention(method) (Int32, Int32, @thin Int32.Type) -> Bool
|
|
%2 = partial_apply %1(%0) : $@convention(method) (Int32, Int32, @thin Int32.Type) -> Bool
|
|
return %2 : $@callee_owned (Int32, Int32) -> Bool
|
|
}
|
|
|
|
|
|
class X { }
|
|
|
|
sil [ossa] @other_inst : $@convention(method) (Int32, Int32, @thin Int32.Type) -> Bool {
|
|
bb0(%0 : $Int32, %1 : $Int32, %2 : $@thin Int32.Type):
|
|
%3 = function_ref @specialized_nonthrowing_closure : $@convention(thin) (Int32, Int32) -> Bool
|
|
%4 = apply %3(%0, %1) : $@convention(thin) (Int32, Int32) -> Bool
|
|
%r = alloc_ref $X
|
|
destroy_value %r
|
|
return %4 : $Bool
|
|
}
|
|
|
|
// CHECK-LABEL: sil [ossa] @return_other_inst
|
|
// CHECK: [[M:%[0-9]+]] = metatype
|
|
// CHECK: [[F:%[0-9]+]] = function_ref @other_inst
|
|
// CHECK: [[R:%[0-9]+]] = partial_apply [[F]]([[M]])
|
|
// CHECK: return [[R]]
|
|
sil [ossa] @return_other_inst : $@convention(thin) () -> @owned @callee_owned (Int32, Int32) -> Bool {
|
|
bb0:
|
|
%0 = metatype $@thin Int32.Type
|
|
%1 = function_ref @other_inst : $@convention(method) (Int32, Int32, @thin Int32.Type) -> Bool
|
|
%2 = partial_apply %1(%0) : $@convention(method) (Int32, Int32, @thin Int32.Type) -> Bool
|
|
return %2 : $@callee_owned (Int32, Int32) -> Bool
|
|
}
|
|
|
|
|
|
sil [ossa] @other_inst_in_returnblock : $@convention(method) (Int32, Int32, @thin Int32.Type) -> (Bool, @error any Error) {
|
|
bb0(%0 : $Int32, %1 : $Int32, %2 : $@thin Int32.Type):
|
|
%3 = function_ref @specialized_throwing_closure : $@convention(thin) (Int32, Int32) -> (Bool, @error any Error)
|
|
try_apply %3(%0, %1) : $@convention(thin) (Int32, Int32) -> (Bool, @error any Error), normal bb1, error bb2
|
|
|
|
bb1(%5 : $Bool):
|
|
%r = alloc_ref $X
|
|
destroy_value %r : $X
|
|
return %5 : $Bool
|
|
|
|
bb2(%7 : $Error):
|
|
throw %7 : $Error
|
|
}
|
|
|
|
// CHECK-LABEL: sil [ossa] @return_other_inst_in_returnblock
|
|
// CHECK: [[M:%[0-9]+]] = metatype
|
|
// CHECK: [[F:%[0-9]+]] = function_ref @other_inst_in_returnblock
|
|
// CHECK: [[R:%[0-9]+]] = partial_apply [[F]]([[M]])
|
|
// CHECK: return [[R]]
|
|
sil [ossa] @return_other_inst_in_returnblock : $@convention(thin) () -> @owned @callee_owned (Int32, Int32) -> (Bool, @error any Error) {
|
|
bb0:
|
|
%0 = metatype $@thin Int32.Type
|
|
%1 = function_ref @other_inst_in_returnblock : $@convention(method) (Int32, Int32, @thin Int32.Type) -> (Bool, @error any Error)
|
|
%2 = partial_apply %1(%0) : $@convention(method) (Int32, Int32, @thin Int32.Type) -> (Bool, @error any Error)
|
|
return %2 : $@callee_owned (Int32, Int32) -> (Bool, @error any Error)
|
|
}
|
|
|
|
|
|
sil [ossa] @wrong_return2 : $@convention(method) (Int32, Int32, @thin Int32.Type) -> (Bool, @error any Error) {
|
|
bb0(%0 : $Int32, %1 : $Int32, %2 : $@thin Int32.Type):
|
|
%3 = function_ref @specialized_throwing_closure : $@convention(thin) (Int32, Int32) -> (Bool, @error any Error)
|
|
try_apply %3(%0, %1) : $@convention(thin) (Int32, Int32) -> (Bool, @error any Error), normal bb1, error bb2
|
|
|
|
bb1(%5 : $Bool):
|
|
%i = integer_literal $Builtin.Int1, 0
|
|
%b = struct $Bool (%i : $Builtin.Int1)
|
|
return %b : $Bool
|
|
|
|
bb2(%7 : $Error):
|
|
throw %7 : $Error
|
|
}
|
|
|
|
// CHECK-LABEL: sil [ossa] @return_wrong_return2
|
|
// CHECK: [[M:%[0-9]+]] = metatype
|
|
// CHECK: [[F:%[0-9]+]] = function_ref @wrong_return2
|
|
// CHECK: [[R:%[0-9]+]] = partial_apply [[F]]([[M]])
|
|
// CHECK: return [[R]]
|
|
sil [ossa] @return_wrong_return2 : $@convention(thin) () -> @owned @callee_owned (Int32, Int32) -> (Bool, @error any Error) {
|
|
bb0:
|
|
%0 = metatype $@thin Int32.Type
|
|
%1 = function_ref @wrong_return2 : $@convention(method) (Int32, Int32, @thin Int32.Type) -> (Bool, @error any Error)
|
|
%2 = partial_apply %1(%0) : $@convention(method) (Int32, Int32, @thin Int32.Type) -> (Bool, @error any Error)
|
|
return %2 : $@callee_owned (Int32, Int32) -> (Bool, @error any Error)
|
|
}
|
|
|
|
|
|
sil [ossa] @wrong_terminator : $@convention(method) (Int32, Int32, @thin Int32.Type) -> (Bool, @error any Error) {
|
|
bb0(%0 : $Int32, %1 : $Int32, %2 : $@thin Int32.Type):
|
|
%3 = function_ref @specialized_throwing_closure : $@convention(thin) (Int32, Int32) -> (Bool, @error any Error)
|
|
try_apply %3(%0, %1) : $@convention(thin) (Int32, Int32) -> (Bool, @error any Error), normal bb1, error bb2
|
|
|
|
bb1(%5 : $Bool):
|
|
return %5 : $Bool
|
|
|
|
bb2(%7 : $Error):
|
|
br bb3
|
|
|
|
bb3:
|
|
%i = integer_literal $Builtin.Int1, 1
|
|
cond_fail %i : $Builtin.Int1
|
|
unreachable
|
|
}
|
|
|
|
// CHECK-LABEL: sil [ossa] @return_wrong_terminator
|
|
// CHECK: [[M:%[0-9]+]] = metatype
|
|
// CHECK: [[F:%[0-9]+]] = function_ref @wrong_terminator
|
|
// CHECK: [[R:%[0-9]+]] = partial_apply [[F]]([[M]])
|
|
// CHECK: return [[R]]
|
|
sil [ossa] @return_wrong_terminator : $@convention(thin) () -> @owned @callee_owned (Int32, Int32) -> (Bool, @error any Error) {
|
|
bb0:
|
|
%0 = metatype $@thin Int32.Type
|
|
%1 = function_ref @wrong_terminator : $@convention(method) (Int32, Int32, @thin Int32.Type) -> (Bool, @error any Error)
|
|
%2 = partial_apply %1(%0) : $@convention(method) (Int32, Int32, @thin Int32.Type) -> (Bool, @error any Error)
|
|
return %2 : $@callee_owned (Int32, Int32) -> (Bool, @error any Error)
|
|
}
|
|
|
|
// Test generic capture propagation
|
|
|
|
sil [ossa] @_TFtest_generic_capture_propagation2_closure : $@convention(thin) <T> (Builtin.Int32, Builtin.FPIEEE32, Builtin.RawPointer, @in_guaranteed T) -> () {
|
|
bb0(%0 : $Builtin.Int32, %1 : $Builtin.FPIEEE32, %2 : $Builtin.RawPointer, %3 : $*T):
|
|
%9999 = tuple()
|
|
return %9999 : $()
|
|
}
|
|
|
|
// CHECK-LABEL: sil [ossa] @test_generic_capture_propagation2_caller
|
|
// CHECK: %[[CALLEE:[0-9]+]] = function_ref @test_generic_capture_propagation2_callee
|
|
// CHECK: %[[FR:[0-9]+]] = function_ref @{{.*}}test_generic_capture_propagation2_thunk{{.*}} : $@convention(thin) () -> ()
|
|
// CHECK: %[[CONVERTED:[0-9]+]] = thin_to_thick_function %[[FR]] : $@convention(thin) () -> () to $@callee_owned () -> ()
|
|
// CHECK-NOT: partial_apply
|
|
// CHECK: apply %[[CALLEE]](%[[CONVERTED]]) : $@convention(thin) (@owned @callee_owned () -> ()) -> ()
|
|
// CHECK-NOT: partial_apply
|
|
// CHECK: return
|
|
sil [ossa] @test_generic_capture_propagation2_caller : $@convention(thin) () -> () {
|
|
%0 = integer_literal $Builtin.Int32, 0
|
|
%1 = float_literal $Builtin.FPIEEE32, 0
|
|
%2 = string_literal utf8 "123"
|
|
%3 = global_addr @globalinit_33_06E7F1D906492AE070936A9B58CBAE1C_token8 : $*Builtin.Word
|
|
%4 = function_ref @_TFtest_generic_capture_propagation2_closure : $@convention(thin) <T> (Builtin.Int32, Builtin.FPIEEE32, Builtin.RawPointer, @in_guaranteed T) -> ()
|
|
%5 = thin_to_thick_function %4 : $@convention(thin) <T> (Builtin.Int32, Builtin.FPIEEE32, Builtin.RawPointer, @in_guaranteed T) -> () to $@callee_owned <T> (Builtin.Int32, Builtin.FPIEEE32, Builtin.RawPointer, @in_guaranteed T) -> ()
|
|
%6 = function_ref @test_generic_capture_propagation2_callee : $@convention(thin) (@owned @callee_owned () -> ()) -> ()
|
|
%7 = function_ref @test_generic_capture_propagation2_thunk : $@convention(thin) <T> (Builtin.Int32, Builtin.FPIEEE32, Builtin.RawPointer, @in_guaranteed T, @owned @callee_owned <T> (Builtin.Int32, Builtin.FPIEEE32, Builtin.RawPointer, @in_guaranteed T) -> ()) -> ()
|
|
%8 = partial_apply %7<Builtin.Word>(%0, %1, %2, %3, %5) : $@convention(thin) <T> (Builtin.Int32, Builtin.FPIEEE32, Builtin.RawPointer, @in_guaranteed T, @owned @callee_owned <T> (Builtin.Int32, Builtin.FPIEEE32, Builtin.RawPointer, @in_guaranteed T) -> ()) -> ()
|
|
apply %6(%8) : $@convention(thin) (@owned @callee_owned () -> ()) -> ()
|
|
%9999 = tuple()
|
|
return %9999 : $()
|
|
}
|
|
|
|
sil shared [ossa] @test_generic_capture_propagation2_thunk : $@convention(thin) <T> (Builtin.Int32, Builtin.FPIEEE32, Builtin.RawPointer, @in_guaranteed T, @owned @callee_owned <T> (Builtin.Int32, Builtin.FPIEEE32, Builtin.RawPointer, @in_guaranteed T) -> ()) -> () {
|
|
bb0(%0 : $Builtin.Int32, %1 : $Builtin.FPIEEE32, %2 : $Builtin.RawPointer, %3 : $*T, %4 : @owned $@callee_owned <T> (Builtin.Int32, Builtin.FPIEEE32, Builtin.RawPointer, @in_guaranteed T) -> ()):
|
|
apply %4<T>(%0, %1, %2, %3) : $@callee_owned <T> (Builtin.Int32, Builtin.FPIEEE32, Builtin.RawPointer, @in_guaranteed T) -> ()
|
|
%9999 = tuple()
|
|
return %9999 : $()
|
|
}
|
|
|
|
sil shared [ossa] @test_generic_capture_propagation2_callee : $@convention(thin) (@owned @callee_owned () -> ()) -> () {
|
|
bb0(%0 : @owned $@callee_owned () -> ()):
|
|
apply %0() : $@callee_owned () -> ()
|
|
%9999 = tuple()
|
|
return %9999 : $()
|
|
}
|
|
|
|
// Test dead partial applied arguments when using generics
|
|
|
|
sil [ossa] @specialized_generic_nonthrowing_closure : $@convention(thin) <T> (@in T, @in T) -> Bool {
|
|
bb0(%0 : $*T, %1 : $*T):
|
|
%10 = integer_literal $Builtin.Int1, -1
|
|
destroy_addr %0
|
|
destroy_addr %1
|
|
%9999 = struct $Bool (%10 : $Builtin.Int1)
|
|
return %9999 : $Bool
|
|
}
|
|
|
|
sil [ossa] @nonthrowing_generic_closure : $@convention(method) <T> (@in T, @in T, @thin T.Type) -> Bool {
|
|
bb0(%0 : $*T, %1 : $*T, %2 : $@thin T.Type):
|
|
%3 = function_ref @specialized_generic_nonthrowing_closure : $@convention(thin) <T> (@in T, @in T) -> Bool
|
|
%4 = apply %3<T>(%0, %1) : $@convention(thin) <T> (@in T, @in T) -> Bool
|
|
return %4 : $Bool
|
|
}
|
|
|
|
// CHECK-LABEL: sil [ossa] @return_generic_nonthrowing_closure
|
|
// CHECK: [[F:%[0-9]+]] = function_ref @$s39specialized_generic_nonthrowing_closures5Int32V_Tg5
|
|
// CHECK: [[R:%[0-9]+]] = thin_to_thick_function [[F]]
|
|
// CHECK: return [[R]]
|
|
sil [ossa] @return_generic_nonthrowing_closure : $@convention(thin) () -> @owned @callee_owned (@in Int32, @in Int32) -> Bool {
|
|
bb0:
|
|
%0 = metatype $@thin Int32.Type
|
|
%1 = function_ref @nonthrowing_generic_closure : $@convention(method) <T> (@in T, @in T, @thin T.Type) -> Bool
|
|
%2 = partial_apply %1<Int32>(%0) : $@convention(method) <T>(@in T, @in T, @thin T.Type) -> Bool
|
|
return %2 : $@callee_owned (@in Int32, @in Int32) -> Bool
|
|
}
|
|
|
|
sil @cfunc : $@convention(c) (Int32, Int32) -> Bool
|
|
|
|
sil [ossa] @call_cfunc : $@convention(method) (Int32, Int32, @thin Int32.Type) -> Bool {
|
|
bb0(%0 : $Int32, %1 : $Int32, %2 : $@thin Int32.Type):
|
|
%3 = function_ref @cfunc : $@convention(c) (Int32, Int32) -> Bool
|
|
%4 = apply %3(%0, %1) : $@convention(c) (Int32, Int32) -> Bool
|
|
return %4 : $Bool
|
|
}
|
|
// CHECK-LABEL: sil [ossa] @test_cfunc
|
|
// CHECK: function_ref
|
|
// CHECK: partial_apply
|
|
// CHECK: return
|
|
sil [ossa] @test_cfunc : $@convention(thin) () -> @owned @callee_owned (Int32, Int32) -> Bool {
|
|
bb0:
|
|
%0 = metatype $@thin Int32.Type
|
|
%1 = function_ref @call_cfunc : $@convention(method) (Int32, Int32, @thin Int32.Type) -> Bool
|
|
%2 = partial_apply %1(%0) : $@convention(method) (Int32, Int32, @thin Int32.Type) -> Bool
|
|
return %2 : $@callee_owned (Int32, Int32) -> Bool
|
|
}
|
|
|
|
sil shared [ossa] @test_capture_propagation2_callee_on_stack : $@convention(thin) (@guaranteed @noescape @callee_guaranteed () -> ()) -> () {
|
|
bb0(%0 : @guaranteed $@noescape @callee_guaranteed () -> ()):
|
|
apply %0() : $@noescape @callee_guaranteed () -> ()
|
|
%9999 = tuple()
|
|
return %9999 : $()
|
|
}
|
|
|
|
sil shared [ossa] @test_capture_propagation2_thunk_on_stack : $@convention(thin) (Builtin.Int32, Builtin.FPIEEE32, Builtin.RawPointer, @in_guaranteed Builtin.Word, @guaranteed @noescape @callee_guaranteed (Builtin.Int32, Builtin.FPIEEE32, Builtin.RawPointer, @in_guaranteed Builtin.Word) -> ()) -> () {
|
|
bb0(%0 : $Builtin.Int32, %1 : $Builtin.FPIEEE32, %2 : $Builtin.RawPointer, %3 : $*Builtin.Word, %4 : @guaranteed $@noescape @callee_guaranteed (Builtin.Int32, Builtin.FPIEEE32, Builtin.RawPointer, @in_guaranteed Builtin.Word) -> ()):
|
|
apply %4(%0, %1, %2, %3) : $@noescape @callee_guaranteed (Builtin.Int32, Builtin.FPIEEE32, Builtin.RawPointer, @in_guaranteed Builtin.Word) -> ()
|
|
%9999 = tuple()
|
|
return %9999 : $()
|
|
}
|
|
|
|
// CHECK: sil [ossa] @test_capture_propagation2_caller_on_stack
|
|
// CHECK: [[F:%.*]] = function_ref @test_capture_propagation2_callee_on_stack : $@convention(thin) (@guaranteed @noescape @callee_guaranteed () -> ()) -> ()
|
|
// CHECK: [[F2:%.*]] = function_ref @$s40test_capture_propagation2_thunk_on_stack4_12353globalinit_33_06E7F1D906492AE070936A9B58CBAE1C_token808_TFtest_b1_C8_closureTf3pi0pd0psbpgpf_n : $@convention(thin) () -> ()
|
|
// CHECK: [[CL:%.*]] = thin_to_thick_function [[F2]] : $@convention(thin) () -> () to $@noescape @callee_guaranteed () -> ()
|
|
// CHECK: apply [[F]]([[CL]]) : $@convention(thin) (@guaranteed @noescape @callee_guaranteed () -> ()) -> ()
|
|
// CHECK: return
|
|
|
|
sil [ossa] @test_capture_propagation2_caller_on_stack : $@convention(thin) () -> () {
|
|
%0 = integer_literal $Builtin.Int32, 0
|
|
%1 = float_literal $Builtin.FPIEEE32, 0
|
|
%2 = string_literal utf8 "123"
|
|
%3 = global_addr @globalinit_33_06E7F1D906492AE070936A9B58CBAE1C_token8 : $*Builtin.Word
|
|
%4 = function_ref @_TFtest_capture_propagation2_closure : $@convention(thin) (Builtin.Int32, Builtin.FPIEEE32, Builtin.RawPointer, @in_guaranteed Builtin.Word) -> ()
|
|
%5 = thin_to_thick_function %4 : $@convention(thin) (Builtin.Int32, Builtin.FPIEEE32, Builtin.RawPointer, @in_guaranteed Builtin.Word) -> () to $@noescape @callee_guaranteed (Builtin.Int32, Builtin.FPIEEE32, Builtin.RawPointer, @in_guaranteed Builtin.Word) -> ()
|
|
%6 = function_ref @test_capture_propagation2_callee_on_stack : $@convention(thin) (@guaranteed @noescape @callee_guaranteed () -> ()) -> ()
|
|
%7 = function_ref @test_capture_propagation2_thunk_on_stack : $@convention(thin) (Builtin.Int32, Builtin.FPIEEE32, Builtin.RawPointer, @in_guaranteed Builtin.Word, @guaranteed @noescape @callee_guaranteed (Builtin.Int32, Builtin.FPIEEE32, Builtin.RawPointer, @in_guaranteed Builtin.Word) -> ()) -> ()
|
|
%8 = partial_apply [callee_guaranteed] [on_stack] %7(%0, %1, %2, %3, %5) : $@convention(thin) (Builtin.Int32, Builtin.FPIEEE32, Builtin.RawPointer, @in_guaranteed Builtin.Word, @guaranteed @noescape @callee_guaranteed (Builtin.Int32, Builtin.FPIEEE32, Builtin.RawPointer, @in_guaranteed Builtin.Word) -> ()) -> ()
|
|
apply %6(%8) : $@convention(thin) (@guaranteed @noescape @callee_guaranteed () -> ()) -> ()
|
|
destroy_value %8
|
|
%9999 = tuple()
|
|
return %9999 : $()
|
|
}
|
|
|
|
struct Str {
|
|
@_hasStorage var a: Int { get set }
|
|
}
|
|
|
|
sil @calleeWithKeypath : $@convention(thin) (@noescape @callee_guaranteed (Str) -> Int) -> ()
|
|
|
|
// CHECK-LABEL: sil [ossa] @testKeypath
|
|
// CHECK: %0 = keypath
|
|
// CHECK: destroy_value %0
|
|
// CHECK: [[S:%.*]] = function_ref @$s18closureWithKeypath{{.*}}4main3StrVSiTf3npk_n : $@convention(thin) (Str) -> Int
|
|
// CHECK: [[T:%.*]] = thin_to_thick_function [[S]]
|
|
// CHECK: [[C:%.*]] = convert_escape_to_noescape [[T]]
|
|
// CHECK: apply {{%[0-9]+}}([[C]])
|
|
// CHECK: } // end sil function 'testKeypath'
|
|
sil [ossa] @testKeypath : $@convention(thin) () -> () {
|
|
bb0:
|
|
%0 = keypath $KeyPath<Str, Int>, (root $Str; stored_property #Str.a : $Int)
|
|
%1 = function_ref @closureWithKeypath : $@convention(thin) (Str, @guaranteed KeyPath<Str, Int>) -> Int
|
|
%2 = partial_apply [callee_guaranteed] %1(%0) : $@convention(thin) (Str, @guaranteed KeyPath<Str, Int>) -> Int
|
|
%3 = convert_escape_to_noescape %2 : $@callee_guaranteed (Str) -> Int to $@noescape @callee_guaranteed (Str) -> Int
|
|
%4 = function_ref @calleeWithKeypath : $@convention(thin) (@noescape @callee_guaranteed (Str) -> Int) -> ()
|
|
%5 = apply %4(%3) : $@convention(thin) (@noescape @callee_guaranteed (Str) -> Int) -> ()
|
|
destroy_value %2 : $@callee_guaranteed (Str) -> Int
|
|
destroy_value %3
|
|
%7 = tuple ()
|
|
return %7 : $()
|
|
}
|
|
|
|
// CHECK-LABEL: sil [ossa] @testCastKeypath :
|
|
// CHECK: %0 = keypath
|
|
// CHECK: [[U:%.*]] = upcast %0
|
|
// CHECK: destroy_value [[U]]
|
|
// CHECK: [[S:%.*]] = function_ref @$s18closureWithKeypath{{.*}}4main3StrVSiTf3npk_n : $@convention(thin) (Str) -> Int
|
|
// CHECK: [[T:%.*]] = thin_to_thick_function [[S]]
|
|
// CHECK: [[C:%.*]] = convert_escape_to_noescape [[T]]
|
|
// CHECK: apply {{%[0-9]+}}([[C]])
|
|
// CHECK: } // end sil function 'testCastKeypath'
|
|
sil [ossa] @testCastKeypath : $@convention(thin) () -> () {
|
|
bb0:
|
|
%0 = keypath $WritableKeyPath<Str, Int>, (root $Str; stored_property #Str.a : $Int)
|
|
%c = upcast %0 to $KeyPath<Str, Int>
|
|
%1 = function_ref @closureWithKeypath : $@convention(thin) (Str, @guaranteed KeyPath<Str, Int>) -> Int
|
|
%2 = partial_apply [callee_guaranteed] %1(%c) : $@convention(thin) (Str, @guaranteed KeyPath<Str, Int>) -> Int
|
|
%3 = convert_escape_to_noescape %2 : $@callee_guaranteed (Str) -> Int to $@noescape @callee_guaranteed (Str) -> Int
|
|
%4 = function_ref @calleeWithKeypath : $@convention(thin) (@noescape @callee_guaranteed (Str) -> Int) -> ()
|
|
%5 = apply %4(%3) : $@convention(thin) (@noescape @callee_guaranteed (Str) -> Int) -> ()
|
|
destroy_value %2 : $@callee_guaranteed (Str) -> Int
|
|
destroy_value %3
|
|
%7 = tuple ()
|
|
return %7 : $()
|
|
}
|
|
|
|
// CHECK-LABEL: sil [ossa] @multiUseKeypath :
|
|
// CHECK-NOT: partial_apply
|
|
// CHECK: } // end sil function 'multiUseKeypath'
|
|
sil [ossa] @multiUseKeypath : $@convention(thin) () -> () {
|
|
bb0:
|
|
%0 = keypath $WritableKeyPath<Str, Int>, (root $Str; stored_property #Str.a : $Int)
|
|
%c = upcast %0 to $KeyPath<Str, Int>
|
|
%1 = function_ref @closureWithKeypath : $@convention(thin) (Str, @guaranteed KeyPath<Str, Int>) -> Int
|
|
%2 = partial_apply [callee_guaranteed] %1(%c) : $@convention(thin) (Str, @guaranteed KeyPath<Str, Int>) -> Int
|
|
%3 = convert_escape_to_noescape %2 : $@callee_guaranteed (Str) -> Int to $@noescape @callee_guaranteed (Str) -> Int
|
|
%4 = function_ref @calleeWithKeypath : $@convention(thin) (@noescape @callee_guaranteed (Str) -> Int) -> ()
|
|
%5 = apply %4(%3) : $@convention(thin) (@noescape @callee_guaranteed (Str) -> Int) -> ()
|
|
destroy_value %2 : $@callee_guaranteed (Str) -> Int
|
|
destroy_value %3
|
|
%7 = tuple ()
|
|
return %7 : $()
|
|
}
|
|
|
|
|
|
// CHECK-LABEL: sil shared [ossa] @$s18closureWithKeypath{{.*}}main3StrVSiTf3npk_n : $@convention(thin) (Str) -> Int {
|
|
// CHECK: [[K:%[0-9]+]] = keypath
|
|
// CHECK: [[BB:%[0-9]+]] = begin_borrow [[K]]
|
|
// CHECK: [[F:%[0-9]+]] = function_ref @swift_getAtKeyPath
|
|
// CHECK: apply [[F]]<Str, Int>({{%[0-9]+, %[0-9]+}}, [[BB]]
|
|
// CHECK: } // end sil function '$s18closureWithKeypath{{.*}}main3StrVSiTf3npk_n'
|
|
sil [ossa] @closureWithKeypath : $@convention(thin) (Str, @guaranteed KeyPath<Str, Int>) -> Int {
|
|
bb0(%0 : $Str, %1 : @guaranteed $KeyPath<Str, Int>):
|
|
%4 = alloc_stack $Str
|
|
store %0 to [trivial] %4 : $*Str
|
|
%6 = function_ref @swift_getAtKeyPath : $@convention(thin) <τ_0_0, τ_0_1> (@in_guaranteed τ_0_0, @guaranteed KeyPath<τ_0_0, τ_0_1>) -> @out τ_0_1
|
|
%7 = alloc_stack $Int
|
|
%8 = apply %6<Str, Int>(%7, %4, %1) : $@convention(thin) <τ_0_0, τ_0_1> (@in_guaranteed τ_0_0, @guaranteed KeyPath<τ_0_0, τ_0_1>) -> @out τ_0_1
|
|
%9 = load [trivial] %7 : $*Int
|
|
dealloc_stack %7 : $*Int
|
|
dealloc_stack %4 : $*Str
|
|
return %9 : $Int
|
|
}
|
|
|
|
// CHECK-LABEL: sil [ossa] @testKeypathOSSA :
|
|
// CHECK: %0 = keypath
|
|
// CHECK: destroy_value %0
|
|
// CHECK: [[S:%.*]] = function_ref @$s22closureWithKeypathOSSA{{.*}}4main3StrVSiTf3npk_n : $@convention(thin) (Str) -> Int
|
|
// CHECK: [[T:%.*]] = thin_to_thick_function [[S]]
|
|
// CHECK: [[C:%.*]] = convert_escape_to_noescape [[T]]
|
|
// CHECK: apply {{%[0-9]+}}([[C]])
|
|
// CHECK: } // end sil function 'testKeypathOSSA'
|
|
sil [ossa] @testKeypathOSSA : $@convention(thin) () -> () {
|
|
bb0:
|
|
%0 = keypath $KeyPath<Str, Int>, (root $Str; stored_property #Str.a : $Int)
|
|
%1 = function_ref @closureWithKeypathOSSA : $@convention(thin) (Str, @guaranteed KeyPath<Str, Int>) -> Int
|
|
%2 = partial_apply [callee_guaranteed] %1(%0) : $@convention(thin) (Str, @guaranteed KeyPath<Str, Int>) -> Int
|
|
%3 = convert_escape_to_noescape %2 : $@callee_guaranteed (Str) -> Int to $@noescape @callee_guaranteed (Str) -> Int
|
|
%4 = function_ref @calleeWithKeypath : $@convention(thin) (@noescape @callee_guaranteed (Str) -> Int) -> ()
|
|
%5 = apply %4(%3) : $@convention(thin) (@noescape @callee_guaranteed (Str) -> Int) -> ()
|
|
destroy_value %3 : $@noescape @callee_guaranteed (Str) -> Int
|
|
destroy_value %2 : $@callee_guaranteed (Str) -> Int
|
|
%7 = tuple ()
|
|
return %7 : $()
|
|
}
|
|
|
|
// CHECK-LABEL: sil [ossa] @testCastKeypathOSSA :
|
|
// CHECK: %0 = keypath
|
|
// CHECK: [[U:%.*]] = upcast %0
|
|
// CHECK: destroy_value [[U]]
|
|
// CHECK: [[S:%.*]] = function_ref @$s22closureWithKeypathOSSA{{.*}}4main3StrVSiTf3npk_n : $@convention(thin) (Str) -> Int
|
|
// CHECK: [[T:%.*]] = thin_to_thick_function [[S]]
|
|
// CHECK: [[C:%.*]] = convert_escape_to_noescape [[T]]
|
|
// CHECK: apply {{%[0-9]+}}([[C]])
|
|
// CHECK: } // end sil function 'testCastKeypathOSSA'
|
|
sil [ossa] @testCastKeypathOSSA : $@convention(thin) () -> () {
|
|
bb0:
|
|
%0 = keypath $WritableKeyPath<Str, Int>, (root $Str; stored_property #Str.a : $Int)
|
|
%c = upcast %0 to $KeyPath<Str, Int>
|
|
%1 = function_ref @closureWithKeypathOSSA : $@convention(thin) (Str, @guaranteed KeyPath<Str, Int>) -> Int
|
|
%2 = partial_apply [callee_guaranteed] %1(%c) : $@convention(thin) (Str, @guaranteed KeyPath<Str, Int>) -> Int
|
|
%3 = convert_escape_to_noescape %2 : $@callee_guaranteed (Str) -> Int to $@noescape @callee_guaranteed (Str) -> Int
|
|
%4 = function_ref @calleeWithKeypath : $@convention(thin) (@noescape @callee_guaranteed (Str) -> Int) -> ()
|
|
%5 = apply %4(%3) : $@convention(thin) (@noescape @callee_guaranteed (Str) -> Int) -> ()
|
|
destroy_value %3 : $@noescape @callee_guaranteed (Str) -> Int
|
|
destroy_value %2 : $@callee_guaranteed (Str) -> Int
|
|
%7 = tuple ()
|
|
return %7 : $()
|
|
}
|
|
|
|
// CHECK-LABEL: sil [ossa] @testCastKeypathOSSA2 :
|
|
// CHECK: %0 = keypath
|
|
// CHECK: [[O:%.*]] = open_existential_ref %0
|
|
// CHECK: [[U:%.*]] = upcast [[O]]
|
|
// CHECK: destroy_value [[U]]
|
|
// CHECK: [[S:%.*]] = function_ref @$s22closureWithKeypathOSSA{{.*}}4main3StrVSiTf3npk_n : $@convention(thin) (Str) -> Int
|
|
// CHECK: [[T:%.*]] = thin_to_thick_function [[S]]
|
|
// CHECK: [[C:%.*]] = convert_escape_to_noescape [[T]]
|
|
// CHECK: apply {{%[0-9]+}}([[C]])
|
|
// CHECK: } // end sil function 'testCastKeypathOSSA2'
|
|
sil [ossa] @testCastKeypathOSSA2 : $@convention(thin) () -> () {
|
|
bb0:
|
|
%0 = keypath $any WritableKeyPath<Str, Int> & Sendable, (root $Str; stored_property #Str.a : $Int)
|
|
%o = open_existential_ref %0 to $@opened("E66BBE78-FA9E-11EF-B968-0EA13E3AABB4", any WritableKeyPath<Str, Int> & Sendable) Self
|
|
%c = upcast %o to $KeyPath<Str, Int>
|
|
%1 = function_ref @closureWithKeypathOSSA : $@convention(thin) (Str, @guaranteed KeyPath<Str, Int>) -> Int
|
|
%2 = partial_apply [callee_guaranteed] %1(%c) : $@convention(thin) (Str, @guaranteed KeyPath<Str, Int>) -> Int
|
|
%3 = convert_escape_to_noescape %2 : $@callee_guaranteed (Str) -> Int to $@noescape @callee_guaranteed (Str) -> Int
|
|
%4 = function_ref @calleeWithKeypath : $@convention(thin) (@noescape @callee_guaranteed (Str) -> Int) -> ()
|
|
%5 = apply %4(%3) : $@convention(thin) (@noescape @callee_guaranteed (Str) -> Int) -> ()
|
|
destroy_value %3 : $@noescape @callee_guaranteed (Str) -> Int
|
|
destroy_value %2 : $@callee_guaranteed (Str) -> Int
|
|
%7 = tuple ()
|
|
return %7 : $()
|
|
}
|
|
|
|
// CHECK-LABEL: sil [ossa] @testKeypathNoescapeOSSA
|
|
// CHECK: [[K:%[0-9]+]] = keypath
|
|
// CHECK: [[C:%[0-9]+]] = function_ref @$s22closureWithKeypathOSSA{{.*}}main3StrVSiTf3npk_n
|
|
// CHECK: [[T:%[0-9]+]] = thin_to_thick_function [[C]]
|
|
// CHECK: [[F:%[0-9]+]] = function_ref @calleeWithKeypath
|
|
// CHECK: apply [[F]]([[T]])
|
|
// CHECK: destroy_value [[K]]
|
|
// CHECK: } // end sil function 'testKeypathNoescapeOSSA'
|
|
sil [ossa] @testKeypathNoescapeOSSA : $@convention(thin) () -> () {
|
|
bb0:
|
|
%0 = keypath $KeyPath<Str, Int>, (root $Str; stored_property #Str.a : $Int)
|
|
%1 = function_ref @closureWithKeypathOSSA : $@convention(thin) (Str, @guaranteed KeyPath<Str, Int>) -> Int
|
|
%2 = partial_apply [callee_guaranteed] [on_stack] %1(%0) : $@convention(thin) (Str, @guaranteed KeyPath<Str, Int>) -> Int
|
|
%4 = function_ref @calleeWithKeypath : $@convention(thin) (@noescape @callee_guaranteed (Str) -> Int) -> ()
|
|
%5 = apply %4(%2) : $@convention(thin) (@noescape @callee_guaranteed (Str) -> Int) -> ()
|
|
destroy_value %2 : $@noescape @callee_guaranteed (Str) -> Int
|
|
destroy_value %0 : $KeyPath<Str, Int>
|
|
%7 = tuple ()
|
|
return %7 : $()
|
|
}
|
|
|
|
// CHECK-LABEL: sil shared [ossa] @$s22closureWithKeypathOSSA{{.*}}main3StrVSiTf3npk_n : $@convention(thin) (Str) -> Int {
|
|
// CHECK: [[K:%[0-9]+]] = keypath
|
|
// CHECK: [[BB:%[0-9]+]] = begin_borrow [[K]]
|
|
// CHECK: [[F:%[0-9]+]] = function_ref @swift_getAtKeyPath
|
|
// CHECK: apply [[F]]<Str, Int>({{%[0-9]+, %[0-9]+}}, [[BB]]
|
|
// CHECK: destroy_value [[K]]
|
|
// CHECK: } // end sil function '$s22closureWithKeypathOSSA{{.*}}main3StrVSiTf3npk_n'
|
|
sil [ossa] @closureWithKeypathOSSA : $@convention(thin) (Str, @guaranteed KeyPath<Str, Int>) -> Int {
|
|
bb0(%0 : $Str, %1 : @guaranteed $KeyPath<Str, Int>):
|
|
%4 = alloc_stack $Str
|
|
store %0 to [trivial] %4 : $*Str
|
|
%6 = function_ref @swift_getAtKeyPath : $@convention(thin) <τ_0_0, τ_0_1> (@in_guaranteed τ_0_0, @guaranteed KeyPath<τ_0_0, τ_0_1>) -> @out τ_0_1
|
|
%7 = alloc_stack $Int
|
|
%8 = apply %6<Str, Int>(%7, %4, %1) : $@convention(thin) <τ_0_0, τ_0_1> (@in_guaranteed τ_0_0, @guaranteed KeyPath<τ_0_0, τ_0_1>) -> @out τ_0_1
|
|
%9 = load [trivial] %7 : $*Int
|
|
dealloc_stack %7 : $*Int
|
|
dealloc_stack %4 : $*Str
|
|
return %9 : $Int
|
|
}
|
|
|
|
// CHECK-LABEL: sil [ossa] @testKeypathWithNonConst :
|
|
// CHECK: %1 = keypath
|
|
// CHECK: destroy_value %1
|
|
// CHECK: [[S:%.*]] = function_ref @$s24closureWithKeypathAndInt{{.*}}4main3StrVSiTf3npkn_n : $@convention(thin) (Str, Int) -> Int
|
|
// CHECK: [[P:%.*]] = partial_apply [callee_guaranteed] [[S]](%0) : $@convention(thin) (Str, Int) -> Int
|
|
// CHECK: [[C:%.*]] = convert_escape_to_noescape [[P]]
|
|
// CHECK: apply {{%[0-9]+}}([[C]])
|
|
// CHECK: } // end sil function 'testKeypathWithNonConst'
|
|
sil [ossa] @testKeypathWithNonConst : $@convention(thin) (Int) -> () {
|
|
bb0(%0 : $Int):
|
|
%1 = keypath $KeyPath<Str, Int>, (root $Str; stored_property #Str.a : $Int)
|
|
%2 = function_ref @closureWithKeypathAndInt : $@convention(thin) (Str, @guaranteed KeyPath<Str, Int>, Int) -> Int
|
|
%3 = partial_apply [callee_guaranteed] %2(%1, %0) : $@convention(thin) (Str, @guaranteed KeyPath<Str, Int>, Int) -> Int
|
|
%4 = convert_escape_to_noescape %3 : $@callee_guaranteed (Str) -> Int to $@noescape @callee_guaranteed (Str) -> Int
|
|
%5 = function_ref @calleeWithKeypath : $@convention(thin) (@noescape @callee_guaranteed (Str) -> Int) -> ()
|
|
%6 = apply %5(%4) : $@convention(thin) (@noescape @callee_guaranteed (Str) -> Int) -> ()
|
|
destroy_value %4 : $@noescape @callee_guaranteed (Str) -> Int
|
|
destroy_value %3 : $@callee_guaranteed (Str) -> Int
|
|
%8 = tuple ()
|
|
return %8 : $()
|
|
}
|
|
|
|
// CHECK-LABEL: sil shared [ossa] @$s24closureWithKeypathAndInt{{.*}}4main3StrVSiTf3npkn_n : $@convention(thin) (Str, Int) -> Int {
|
|
// CHECK: [[K:%[0-9]+]] = keypath
|
|
// CHECK: [[BB:%[0-9]+]] = begin_borrow [[K]]
|
|
// CHECK: [[F:%[0-9]+]] = function_ref @swift_getAtKeyPath
|
|
// CHECK: apply [[F]]<Str, Int>({{%[0-9]+, %[0-9]+}}, [[BB]]
|
|
// CHECK: destroy_value [[K]]
|
|
// CHECK: } // end sil function '$s24closureWithKeypathAndInt{{.*}}4main3StrVSiTf3npkn_n'
|
|
sil [ossa] @closureWithKeypathAndInt : $@convention(thin) (Str, @guaranteed KeyPath<Str, Int>, Int) -> Int {
|
|
bb0(%0 : $Str, %1 : @guaranteed $KeyPath<Str, Int>, %2 : $Int):
|
|
%4 = alloc_stack $Str
|
|
store %0 to [trivial] %4 : $*Str
|
|
%6 = function_ref @swift_getAtKeyPath : $@convention(thin) <τ_0_0, τ_0_1> (@in_guaranteed τ_0_0, @guaranteed KeyPath<τ_0_0, τ_0_1>) -> @out τ_0_1
|
|
%7 = alloc_stack $Int
|
|
%8 = apply %6<Str, Int>(%7, %4, %1) : $@convention(thin) <τ_0_0, τ_0_1> (@in_guaranteed τ_0_0, @guaranteed KeyPath<τ_0_0, τ_0_1>) -> @out τ_0_1
|
|
%9 = load [trivial] %7 : $*Int
|
|
dealloc_stack %7 : $*Int
|
|
dealloc_stack %4 : $*Str
|
|
return %9 : $Int
|
|
}
|
|
|
|
// CHECK-LABEL: sil [ossa] @testKeypathWithNonConstGeneric :
|
|
// CHECK: %1 = keypath
|
|
// CHECK: destroy_value %1
|
|
// CHECK: [[S:%.*]] = function_ref @$s22closureWithKeypathAndT{{.*}}4main3StrVSiTf3npkn_n : $@convention(thin) (Str, @in_guaranteed Int) -> Int
|
|
// CHECK: [[P:%.*]] = partial_apply [callee_guaranteed] [[S]](%0) : $@convention(thin) (Str, @in_guaranteed Int) -> Int
|
|
// CHECK: [[C:%.*]] = convert_escape_to_noescape [[P]]
|
|
// CHECK: apply {{%[0-9]+}}([[C]])
|
|
// CHECK: } // end sil function 'testKeypathWithNonConstGeneric'
|
|
sil [ossa] @testKeypathWithNonConstGeneric : $@convention(thin) (@in Int) -> () {
|
|
bb0(%0 : $*Int):
|
|
%1 = keypath $KeyPath<Str, Int>, (root $Str; stored_property #Str.a : $Int)
|
|
%2 = function_ref @closureWithKeypathAndT : $@convention(thin) <τ_0_0> (Str, @guaranteed KeyPath<Str, Int>, @in_guaranteed τ_0_0) -> Int
|
|
%3 = partial_apply [callee_guaranteed] %2<Int>(%1, %0) : $@convention(thin) <τ_0_0> (Str, @guaranteed KeyPath<Str, Int>, @in_guaranteed τ_0_0) -> Int
|
|
%4 = convert_escape_to_noescape %3 : $@callee_guaranteed (Str) -> Int to $@noescape @callee_guaranteed (Str) -> Int
|
|
%5 = function_ref @calleeWithKeypath : $@convention(thin) (@noescape @callee_guaranteed (Str) -> Int) -> ()
|
|
%6 = apply %5(%4) : $@convention(thin) (@noescape @callee_guaranteed (Str) -> Int) -> ()
|
|
destroy_value %4 : $@noescape @callee_guaranteed (Str) -> Int
|
|
destroy_value %3 : $@callee_guaranteed (Str) -> Int
|
|
%8 = tuple ()
|
|
return %8 : $()
|
|
}
|
|
|
|
// CHECK-LABEL: sil shared [ossa] @$s22closureWithKeypathAndT{{.*}}4main3StrVSiTf3npkn_n : $@convention(thin) (Str, @in_guaranteed Int) -> Int {
|
|
// CHECK: [[K:%[0-9]+]] = keypath
|
|
// CHECK: [[BB:%[0-9]+]] = begin_borrow [[K]]
|
|
// CHECK: [[F:%[0-9]+]] = function_ref @swift_getAtKeyPath
|
|
// CHECK: apply [[F]]<Str, Int>({{%[0-9]+, %[0-9]+}}, [[BB]]
|
|
// CHECK: destroy_value [[K]]
|
|
// CHECK: } // end sil function '$s22closureWithKeypathAndT{{.*}}4main3StrVSiTf3npkn_n'
|
|
sil [ossa] @closureWithKeypathAndT : $@convention(thin) <T> (Str, @guaranteed KeyPath<Str, Int>, @in_guaranteed T) -> Int {
|
|
bb0(%0 : $Str, %1 : @guaranteed $KeyPath<Str, Int>, %2 : $*T):
|
|
%4 = alloc_stack $Str
|
|
store %0 to [trivial] %4 : $*Str
|
|
%6 = function_ref @swift_getAtKeyPath : $@convention(thin) <τ_0_0, τ_0_1> (@in_guaranteed τ_0_0, @guaranteed KeyPath<τ_0_0, τ_0_1>) -> @out τ_0_1
|
|
%7 = alloc_stack $Int
|
|
%8 = apply %6<Str, Int>(%7, %4, %1) : $@convention(thin) <τ_0_0, τ_0_1> (@in_guaranteed τ_0_0, @guaranteed KeyPath<τ_0_0, τ_0_1>) -> @out τ_0_1
|
|
%9 = load [trivial] %7 : $*Int
|
|
dealloc_stack %7 : $*Int
|
|
dealloc_stack %4 : $*Str
|
|
return %9 : $Int
|
|
}
|
|
|
|
sil [ossa] @testUpcastInClosure : $@convention(thin) () -> () {
|
|
bb0:
|
|
%0 = keypath $WritableKeyPath<Str, Int>, (root $Str; stored_property #Str.a : $Int)
|
|
%1 = function_ref @closureWithWritableKeypath : $@convention(thin) (Str, @guaranteed WritableKeyPath<Str, Int>) -> Int
|
|
%2 = partial_apply [callee_guaranteed] %1(%0) : $@convention(thin) (Str, @guaranteed WritableKeyPath<Str, Int>) -> Int
|
|
%4 = function_ref @callee2WithKeypath : $@convention(thin) (@callee_guaranteed (Str) -> Int) -> ()
|
|
%5 = apply %4(%2) : $@convention(thin) (@callee_guaranteed (Str) -> Int) -> ()
|
|
destroy_value %2
|
|
%7 = tuple ()
|
|
return %7 : $()
|
|
}
|
|
|
|
// CHECK-LABEL: sil shared [ossa] @$s26closureWithWritableKeypath{{.*}}4main3StrVSiTf3npk_n : $@convention(thin) (Str) -> Int {
|
|
// CHECK: [[K:%[0-9]+]] = keypath
|
|
// CHECK: [[BB:%[0-9]+]] = begin_borrow [[K]]
|
|
// CHECK: [[UC:%[0-9]+]] = upcast [[BB]]
|
|
// CHECK: [[F:%[0-9]+]] = function_ref @swift_getAtKeyPath
|
|
// CHECK: apply [[F]]<Str, Int>({{%[0-9]+, %[0-9]+}}, [[UC]]
|
|
// CHECK: destroy_value [[K]]
|
|
// CHECK: } // end sil function '$s26closureWithWritableKeypath{{.*}}4main3StrVSiTf3npk_n'
|
|
sil [ossa] @closureWithWritableKeypath : $@convention(thin) (Str, @guaranteed WritableKeyPath<Str, Int>) -> Int {
|
|
bb0(%0 : $Str, %1 : @guaranteed $WritableKeyPath<Str, Int>):
|
|
%2 = upcast %1 to $KeyPath<Str, Int>
|
|
%4 = alloc_stack $Str
|
|
store %0 to [trivial] %4 : $*Str
|
|
%6 = function_ref @swift_getAtKeyPath : $@convention(thin) <τ_0_0, τ_0_1> (@in_guaranteed τ_0_0, @guaranteed KeyPath<τ_0_0, τ_0_1>) -> @out τ_0_1
|
|
%7 = alloc_stack $Int
|
|
%8 = apply %6<Str, Int>(%7, %4, %2) : $@convention(thin) <τ_0_0, τ_0_1> (@in_guaranteed τ_0_0, @guaranteed KeyPath<τ_0_0, τ_0_1>) -> @out τ_0_1
|
|
cond_br undef, bb1, bb2
|
|
|
|
bb1:
|
|
unreachable
|
|
|
|
bb2:
|
|
%9 = load [trivial] %7 : $*Int
|
|
dealloc_stack %7 : $*Int
|
|
dealloc_stack %4 : $*Str
|
|
return %9 : $Int
|
|
}
|
|
|
|
sil @callee2WithKeypath : $@convention(thin) (@callee_guaranteed (Str) -> Int) -> ()
|
|
|
|
sil @useIntClosure : $@convention(thin) (@noescape @callee_guaranteed (Str) -> Builtin.Int32) -> ()
|
|
|
|
// CHECK-LABEL: sil [ossa] @dontSpecializeConstAndNonConst :
|
|
// CHECK: %1 = integer_literal $Builtin.Int32, 3
|
|
// CHECK: %2 = function_ref @closureWithTwoInts :
|
|
// CHECK: %3 = partial_apply [callee_guaranteed] %2(%1, %0) :
|
|
// CHECK: } // end sil function 'dontSpecializeConstAndNonConst'
|
|
sil [ossa] @dontSpecializeConstAndNonConst : $@convention(thin) (Builtin.Int32) -> () {
|
|
bb0(%0 : $Builtin.Int32):
|
|
%1 = integer_literal $Builtin.Int32, 3
|
|
%2 = function_ref @closureWithTwoInts : $@convention(thin) (Str, Builtin.Int32, Builtin.Int32) -> Builtin.Int32
|
|
%3 = partial_apply [callee_guaranteed] %2(%1, %0) : $@convention(thin) (Str, Builtin.Int32, Builtin.Int32) -> Builtin.Int32
|
|
%4 = convert_escape_to_noescape %3 to $@noescape @callee_guaranteed (Str) -> Builtin.Int32
|
|
%5 = function_ref @useIntClosure : $@convention(thin) (@noescape @callee_guaranteed (Str) -> Builtin.Int32) -> ()
|
|
%6 = apply %5(%4) : $@convention(thin) (@noescape @callee_guaranteed (Str) -> Builtin.Int32) -> ()
|
|
destroy_value %4
|
|
destroy_value %3
|
|
%8 = tuple ()
|
|
return %8 : $()
|
|
}
|
|
|
|
sil [ossa] @closureWithTwoInts : $@convention(thin) (Str, Builtin.Int32, Builtin.Int32) -> Builtin.Int32 {
|
|
bb0(%0 : $Str, %1 : $Builtin.Int32, %2 : $Builtin.Int32):
|
|
return %1
|
|
}
|
|
|
|
struct S {
|
|
let i: Int32
|
|
let b: Bool
|
|
}
|
|
|
|
// CHECK-LABEL: sil [ossa] @testStruct :
|
|
// CHECK: [[C:%.*]] = function_ref @$s17closureWithStruct4main1SVs5Int32VSbTf3npSSi3Si0_n : $@convention(thin) (Str) -> Builtin.Int32
|
|
// CHECK: thin_to_thick_function [[C]] : $@convention(thin) (Str) -> Builtin.Int32 to $@callee_guaranteed (Str) -> Builtin.Int32
|
|
// CHECK: } // end sil function 'testStruct'
|
|
sil [ossa] @testStruct : $@convention(thin) () -> () {
|
|
bb0:
|
|
%0 = integer_literal $Builtin.Int32, 3
|
|
%1 = struct $Int32 (%0)
|
|
%2 = integer_literal $Builtin.Int1, 0
|
|
%3 = struct $Bool (%2)
|
|
%4 = struct $S (%1, %3)
|
|
%5 = function_ref @closureWithStruct : $@convention(thin) (Str, S) -> Builtin.Int32
|
|
%6 = partial_apply [callee_guaranteed] %5(%4) : $@convention(thin) (Str, S) -> Builtin.Int32
|
|
%7 = convert_escape_to_noescape %6 to $@noescape @callee_guaranteed (Str) -> Builtin.Int32
|
|
%8 = function_ref @useIntClosure : $@convention(thin) (@noescape @callee_guaranteed (Str) -> Builtin.Int32) -> ()
|
|
%9 = apply %8(%7) : $@convention(thin) (@noescape @callee_guaranteed (Str) -> Builtin.Int32) -> ()
|
|
destroy_value %7
|
|
destroy_value %6
|
|
%12 = tuple ()
|
|
return %12 : $()
|
|
}
|
|
|
|
// CHECK-LABEL: sil [ossa] @testNonConstStruct1 :
|
|
// CHECK: [[S:%.*]] = struct $S
|
|
// CHECK: partial_apply [callee_guaranteed] {{%[0-9]+}}([[S]])
|
|
// CHECK: } // end sil function 'testNonConstStruct1'
|
|
sil [ossa] @testNonConstStruct1 : $@convention(thin) (Int32) -> () {
|
|
bb0(%0 : $Int32):
|
|
%2 = integer_literal $Builtin.Int1, 0
|
|
%3 = struct $Bool (%2)
|
|
%4 = struct $S (%0, %3)
|
|
%5 = function_ref @closureWithStruct : $@convention(thin) (Str, S) -> Builtin.Int32
|
|
%6 = partial_apply [callee_guaranteed] %5(%4) : $@convention(thin) (Str, S) -> Builtin.Int32
|
|
%7 = convert_escape_to_noescape %6 to $@noescape @callee_guaranteed (Str) -> Builtin.Int32
|
|
%8 = function_ref @useIntClosure : $@convention(thin) (@noescape @callee_guaranteed (Str) -> Builtin.Int32) -> ()
|
|
%9 = apply %8(%7) : $@convention(thin) (@noescape @callee_guaranteed (Str) -> Builtin.Int32) -> ()
|
|
destroy_value %7
|
|
destroy_value %6
|
|
%12 = tuple ()
|
|
return %12 : $()
|
|
}
|
|
|
|
// CHECK-LABEL: sil [ossa] @testNonConstStruct2 :
|
|
// CHECK: [[S:%.*]] = struct $S
|
|
// CHECK: partial_apply [callee_guaranteed] {{%[0-9]+}}([[S]])
|
|
// CHECK: } // end sil function 'testNonConstStruct2'
|
|
sil [ossa] @testNonConstStruct2 : $@convention(thin) (Bool) -> () {
|
|
bb0(%0 : $Bool):
|
|
%1 = integer_literal $Builtin.Int32, 3
|
|
%2 = struct $Int32 (%1)
|
|
%4 = struct $S (%2, %0)
|
|
%5 = function_ref @closureWithStruct : $@convention(thin) (Str, S) -> Builtin.Int32
|
|
%6 = partial_apply [callee_guaranteed] %5(%4) : $@convention(thin) (Str, S) -> Builtin.Int32
|
|
%7 = convert_escape_to_noescape %6 to $@noescape @callee_guaranteed (Str) -> Builtin.Int32
|
|
%8 = function_ref @useIntClosure : $@convention(thin) (@noescape @callee_guaranteed (Str) -> Builtin.Int32) -> ()
|
|
%9 = apply %8(%7) : $@convention(thin) (@noescape @callee_guaranteed (Str) -> Builtin.Int32) -> ()
|
|
destroy_value %7
|
|
destroy_value %6
|
|
%12 = tuple ()
|
|
return %12 : $()
|
|
}
|
|
|
|
// CHECK-LABEL: sil shared [ossa] @$s17closureWithStruct4main1SVs5Int32VSbTf3npSSi3Si0_n : $@convention(thin) (Str) -> Builtin.Int32 {
|
|
// CHECK: bb0(%0 : $Str):
|
|
// CHECK: %1 = integer_literal $Builtin.Int32, 3
|
|
// CHECK: %2 = struct $Int32 (%1 : $Builtin.Int32)
|
|
// CHECK: %3 = integer_literal $Builtin.Int1, 0
|
|
// CHECK: %4 = struct $Bool (%3 : $Builtin.Int1)
|
|
// CHECK: %5 = struct $S (%2 : $Int32, %4 : $Bool)
|
|
// CHECK: %6 = struct_extract %5 : $S, #S.i
|
|
// CHECK: %7 = struct_extract %6 : $Int32, #Int32._value
|
|
// CHECK: return %7 : $Builtin.Int32
|
|
// CHECK: } // end sil function '$s17closureWithStruct4main1SVs5Int32VSbTf3npSSi3Si0_n'
|
|
sil [ossa] @closureWithStruct : $@convention(thin) (Str, S) -> Builtin.Int32 {
|
|
bb0(%0 : $Str, %1 : $S):
|
|
%2 = struct_extract %1, #S.i
|
|
%3 = struct_extract %2, #Int32._value
|
|
return %3
|
|
}
|
|
|
|
sil @swift_getAtKeyPath : $@convention(thin) <τ_0_0, τ_0_1> (@in_guaranteed τ_0_0, @guaranteed KeyPath<τ_0_0, τ_0_1>) -> @out τ_0_1
|
|
|
|
struct NonTrivialStruct {
|
|
var x: AnyObject
|
|
}
|
|
|
|
sil_global [serialized] @gNonTrivialStruct : $NonTrivialStruct
|
|
|
|
// CHECK-LABEL: sil [ossa] @test_global_addr :
|
|
// CHECK: [[C:%.*]] = function_ref @$s19global_addr_closure17gNonTrivialStructTf3pg_n : $@convention(thin) () -> ()
|
|
// CHECK: thin_to_thick_function %2 : $@convention(thin) () -> () to $@callee_owned () -> ()
|
|
// CHECK: } // end sil function 'test_global_addr'
|
|
sil [ossa] @test_global_addr : $@convention(thin) () -> () {
|
|
%3 = global_addr @gNonTrivialStruct : $*NonTrivialStruct
|
|
%7 = function_ref @global_addr_closure : $@convention(thin) <T> (@in_guaranteed T) -> ()
|
|
%8 = partial_apply %7<NonTrivialStruct>(%3) : $@convention(thin) <T> (@in_guaranteed T) -> ()
|
|
destroy_value %8
|
|
%r = tuple()
|
|
return %r
|
|
}
|
|
|
|
// CHECK-LABEL: sil shared [ossa] @$s19global_addr_closure17gNonTrivialStructTf3pg_n :
|
|
// CHECK: bb0:
|
|
// CHECK-NEXT: %0 = global_addr @gNonTrivialStruct : $*NonTrivialStruct
|
|
// CHECK-NEXT: %1 = tuple ()
|
|
// CHECK-NEXT: return %1
|
|
// CHECK: } // end sil function '$s19global_addr_closure17gNonTrivialStructTf3pg_n'
|
|
sil [ossa] @global_addr_closure : $@convention(thin) <T> (@in_guaranteed T) -> () {
|
|
bb0(%0 : $*T):
|
|
%r = tuple()
|
|
return %r : $()
|
|
}
|
|
|
|
sil @useClosure : $@convention(thin) (@noescape @callee_guaranteed () -> Builtin.Int32) -> ()
|
|
|
|
// CHECK-LABEL: sil [ossa] @testClosureWithNonThinConvention :
|
|
// CHECK: [[C:%.*]] = function_ref @$s18cClosureWithStruct4main1SVs5Int32VSbTf3pSSi3Si0_n : $@convention(c) () -> Builtin.Int32
|
|
// CHECK: = partial_apply [callee_guaranteed] [[C]]() : $@convention(c) () -> Builtin.Int32
|
|
// CHECK: } // end sil function 'testClosureWithNonThinConvention'
|
|
sil [ossa] @testClosureWithNonThinConvention : $@convention(thin) () -> () {
|
|
bb0:
|
|
%0 = integer_literal $Builtin.Int32, 3
|
|
%1 = struct $Int32 (%0)
|
|
%2 = integer_literal $Builtin.Int1, 0
|
|
%3 = struct $Bool (%2)
|
|
%4 = struct $S (%1, %3)
|
|
%5 = function_ref @cClosureWithStruct : $@convention(c) (S) -> Builtin.Int32
|
|
%6 = partial_apply [callee_guaranteed] %5(%4) : $@convention(c) (S) -> Builtin.Int32
|
|
%7 = convert_escape_to_noescape %6 to $@noescape @callee_guaranteed () -> Builtin.Int32
|
|
%8 = function_ref @useClosure : $@convention(thin) (@noescape @callee_guaranteed () -> Builtin.Int32) -> ()
|
|
%9 = apply %8(%7) : $@convention(thin) (@noescape @callee_guaranteed () -> Builtin.Int32) -> ()
|
|
destroy_value %7
|
|
destroy_value %6
|
|
%12 = tuple ()
|
|
return %12 : $()
|
|
}
|
|
|
|
sil [ossa] @cClosureWithStruct : $@convention(c) (S) -> Builtin.Int32 {
|
|
bb0(%1 : $S):
|
|
%2 = struct_extract %1, #S.i
|
|
%3 = struct_extract %2, #Int32._value
|
|
return %3
|
|
}
|
|
|
|
// CHECK-LABEL: sil [ossa] @testClosureWithMethodConvention :
|
|
// CHECK: [[C:%.*]] = function_ref @$s23methodClosureWithStruct4main1SVs5Int32VSbTf3pSSi3Si0_n : $@convention(thin) () -> Builtin.Int32
|
|
// CHECK: = thin_to_thick_function [[C]] : $@convention(thin) () -> Builtin.Int32 to $@callee_guaranteed () -> Builtin.Int32
|
|
// CHECK: } // end sil function 'testClosureWithMethodConvention'
|
|
sil [ossa] @testClosureWithMethodConvention : $@convention(thin) () -> () {
|
|
bb0:
|
|
%0 = integer_literal $Builtin.Int32, 3
|
|
%1 = struct $Int32 (%0)
|
|
%2 = integer_literal $Builtin.Int1, 0
|
|
%3 = struct $Bool (%2)
|
|
%4 = struct $S (%1, %3)
|
|
%5 = function_ref @methodClosureWithStruct : $@convention(method) (S) -> Builtin.Int32
|
|
%6 = partial_apply [callee_guaranteed] %5(%4) : $@convention(method) (S) -> Builtin.Int32
|
|
%7 = convert_escape_to_noescape %6 to $@noescape @callee_guaranteed () -> Builtin.Int32
|
|
%8 = function_ref @useClosure : $@convention(thin) (@noescape @callee_guaranteed () -> Builtin.Int32) -> ()
|
|
%9 = apply %8(%7) : $@convention(thin) (@noescape @callee_guaranteed () -> Builtin.Int32) -> ()
|
|
destroy_value %7
|
|
destroy_value %6
|
|
%12 = tuple ()
|
|
return %12 : $()
|
|
}
|
|
|
|
sil [ossa] @methodClosureWithStruct : $@convention(method) (S) -> Builtin.Int32 {
|
|
bb0(%1 : $S):
|
|
%2 = struct_extract %1, #S.i
|
|
%3 = struct_extract %2, #Int32._value
|
|
return %3
|
|
}
|