mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Type annotations for instruction operands are omitted, e.g. ``` %3 = struct $S(%1, %2) ``` Operand types are redundant anyway and were only used for sanity checking in the SIL parser. But: operand types _are_ printed if the definition of the operand value was not printed yet. This happens: * if the block with the definition appears after the block where the operand's instruction is located * if a block or instruction is printed in isolation, e.g. in a debugger The old behavior can be restored with `-Xllvm -sil-print-types`. This option is added to many existing test files which check for operand types in their check-lines.
104 lines
4.4 KiB
Plaintext
104 lines
4.4 KiB
Plaintext
// RUN: %target-sil-opt -sil-print-types -enable-sil-verify-all %s -onone-simplification -simplify-instruction=partial_apply | %FileCheck %s
|
|
|
|
// REQUIRES: swift_in_compiler
|
|
|
|
import Swift
|
|
import Builtin
|
|
|
|
sil @closure_with_args : $@convention(thin) (Int, Bool) -> ()
|
|
sil @closure2_with_args : $@convention(thin) (Int, String) -> ()
|
|
sil @closure3_with_args : $@convention(thin) (String, Bool) -> ()
|
|
sil @generic_callee_inguaranteed : $@convention(thin) <T, U> (@in_guaranteed T, @in_guaranteed U) -> ()
|
|
|
|
// CHECK-LABEL: sil @test_apply_of_partial_apply
|
|
// CHECK: [[F:%.*]] = function_ref @closure_with_args
|
|
// CHECK-NOT: partial_apply
|
|
// CHECK: apply [[F]](%0, %1)
|
|
// CHECK: } // end sil function 'test_apply_of_partial_apply'
|
|
sil @test_apply_of_partial_apply : $@convention(thin) (Int, Bool) -> () {
|
|
bb0(%0 : $Int, %1 : $Bool):
|
|
%2 = function_ref @closure_with_args : $@convention(thin) (Int, Bool) -> ()
|
|
%3 = partial_apply %2(%1) : $@convention(thin) (Int, Bool) -> ()
|
|
apply %3(%0) : $@callee_owned (Int) -> ()
|
|
%r = tuple()
|
|
return %r : $()
|
|
}
|
|
|
|
// CHECK-LABEL: sil @test_generic_partial_apply_apply_inguaranteed
|
|
// CHECK: [[F:%.*]] = function_ref @generic_callee_inguaranteed
|
|
// CHECK: [[S:%.*]] = alloc_stack $T
|
|
// CHECK: copy_addr [take] %1 to [init] [[S]]
|
|
// CHECK-NOT: partial_apply
|
|
// CHECK: apply [[F]]<T, T>(%0, [[S]])
|
|
// CHECK: destroy_addr [[S]]
|
|
// CHECK: destroy_addr %0
|
|
// CHECK: } // end sil function 'test_generic_partial_apply_apply_inguaranteed'
|
|
sil @test_generic_partial_apply_apply_inguaranteed : $@convention(thin) <T> (@in T, @in T) -> () {
|
|
bb0(%0 : $*T, %1 : $*T):
|
|
%f1 = function_ref @generic_callee_inguaranteed : $@convention(thin) <T, U> (@in_guaranteed T, @in_guaranteed U) -> ()
|
|
%pa = partial_apply %f1<T, T>(%1) : $@convention(thin) <T, U> (@in_guaranteed T, @in_guaranteed U) -> ()
|
|
%a1 = apply %pa(%0) : $@callee_owned (@in_guaranteed T) -> ()
|
|
destroy_addr %0 : $*T
|
|
%r = tuple ()
|
|
return %r : $()
|
|
}
|
|
|
|
// CHECK-LABEL: sil @test_non_trivial_pa_args
|
|
// CHECK: [[F:%.*]] = function_ref @closure2_with_args
|
|
// CHECK-NOT: partial_apply
|
|
// CHECK: apply [[F]](%0, %1)
|
|
// CHECK: release_value %1
|
|
// CHECK: } // end sil function 'test_non_trivial_pa_args'
|
|
sil @test_non_trivial_pa_args : $@convention(thin) (Int, String) -> () {
|
|
bb0(%0 : $Int, %1 : $String):
|
|
%2 = function_ref @closure2_with_args : $@convention(thin) (Int, String) -> ()
|
|
%3 = partial_apply %2(%1) : $@convention(thin) (Int, String) -> ()
|
|
apply %3(%0) : $@callee_owned (Int) -> ()
|
|
%r = tuple()
|
|
return %r : $()
|
|
}
|
|
|
|
// CHECK-LABEL: sil @test_non_trivial_apply_args
|
|
// CHECK: [[F:%.*]] = function_ref @closure3_with_args
|
|
// CHECK-NOT: partial_apply
|
|
// CHECK: apply [[F]](%0, %1)
|
|
// CHECK: } // end sil function 'test_non_trivial_apply_args'
|
|
sil @test_non_trivial_apply_args : $@convention(thin) (String, Bool) -> () {
|
|
bb0(%0 : $String, %1 : $Bool):
|
|
%2 = function_ref @closure3_with_args : $@convention(thin) (String, Bool) -> ()
|
|
%3 = partial_apply %2(%1) : $@convention(thin) (String, Bool) -> ()
|
|
apply %3(%0) : $@callee_owned (String) -> ()
|
|
%r = tuple()
|
|
return %r : $()
|
|
}
|
|
|
|
// CHECK-LABEL: sil @test_delete_dead_closure
|
|
// CHECK-NOT: function_ref
|
|
// CHECK-NOT: partial_apply
|
|
// CHECK: release_value %0 : $String
|
|
// CHECK: } // end sil function 'test_delete_dead_closure'
|
|
sil @test_delete_dead_closure : $@convention(thin) (@owned String, Bool) -> () {
|
|
bb0(%0 : $String, %1 : $Bool):
|
|
%2 = function_ref @closure3_with_args : $@convention(thin) (String, Bool) -> ()
|
|
%3 = partial_apply %2(%0, %1) : $@convention(thin) (String, Bool) -> ()
|
|
release_value %3 : $@callee_owned () -> ()
|
|
%r = tuple()
|
|
return %r : $()
|
|
}
|
|
|
|
// CHECK-LABEL: sil @test_dont_delete_dead_closure_with_debug_use
|
|
// CHECK: [[F:%.*]] = function_ref @closure3_with_args
|
|
// CHECK: [[C:%.*]] = partial_apply [[F]]
|
|
// CHECK: release_value [[C]]
|
|
// CHECK: } // end sil function 'test_dont_delete_dead_closure_with_debug_use'
|
|
sil @test_dont_delete_dead_closure_with_debug_use : $@convention(thin) (@owned String, Bool) -> () {
|
|
bb0(%0 : $String, %1 : $Bool):
|
|
%2 = function_ref @closure3_with_args : $@convention(thin) (String, Bool) -> ()
|
|
%3 = partial_apply %2(%0, %1) : $@convention(thin) (String, Bool) -> ()
|
|
debug_value %3 : $@callee_owned () -> (), let, name "x"
|
|
release_value %3 : $@callee_owned () -> ()
|
|
%r = tuple()
|
|
return %r : $()
|
|
}
|
|
|