mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +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.
60 lines
3.1 KiB
Plaintext
60 lines
3.1 KiB
Plaintext
// RUN: %target-sil-opt -sil-print-types -enable-library-evolution -enable-sil-verify-all %s -capture-promotion | %FileCheck %s
|
|
|
|
sil_stage raw
|
|
|
|
import Swift
|
|
|
|
public struct ResilientStruct {
|
|
var x : Int64
|
|
}
|
|
|
|
sil [ossa] @closure0 : $@convention(thin) (@guaranteed <τ_0_0> { var τ_0_0 } <ResilientStruct>) -> () {
|
|
bb0(%0 : @guaranteed $<τ_0_0> { var τ_0_0 } <ResilientStruct>):
|
|
%1 = project_box %0 : $<τ_0_0> { var τ_0_0 } <ResilientStruct>, 0
|
|
%2 = tuple ()
|
|
return %2 : $()
|
|
}
|
|
|
|
// Primarily don't crash.
|
|
|
|
// CHECK-LABEL: sil [ossa] @$s8closure0Tf2i_n : $@convention(thin) (ResilientStruct) -> () {
|
|
// CHECK: bb0(%0 : $ResilientStruct):
|
|
// CHECK: return {{.*}} : $()
|
|
// CHECK: }
|
|
|
|
// CHECK: sil [ossa] @test_capture_promotion : $@convention(thin) (@in_guaranteed ResilientStruct) -> @owned @callee_guaranteed () -> () {
|
|
// CHECK: bb0([[ARG:%.*]] : $*ResilientStruct):
|
|
// CHECK: [[BOX:%.*]] = alloc_box $<τ_0_0> { var τ_0_0 } <ResilientStruct>
|
|
// CHECK: [[F1:%.*]] = project_box [[BOX]]
|
|
// CHECK: [[F2:%.*]] = project_box [[BOX]]
|
|
// CHECK: copy_addr [[ARG]] to [init] [[F2]] : $*ResilientStruct
|
|
// CHECK: [[F:%.*]] = function_ref @$s8closure0Tf2i_n : $@convention(thin) (ResilientStruct) -> () // user: %8
|
|
// CHECK: [[R:%.*]] = load [trivial] [[F1]] : $*ResilientStruct
|
|
// CHECK: [[C:%.*]] = partial_apply [callee_guaranteed] [[F]]([[R]])
|
|
// CHECK: return [[C]] : $@callee_guaranteed () -> ()
|
|
// CHECK: }
|
|
sil [ossa] @test_capture_promotion : $@convention(thin) (@in_guaranteed ResilientStruct) -> @owned @callee_guaranteed () -> () {
|
|
bb0(%0 : $*ResilientStruct):
|
|
%1 = alloc_box $<τ_0_0> { var τ_0_0 } <ResilientStruct>
|
|
%2 = project_box %1 : $<τ_0_0> { var τ_0_0 } <ResilientStruct>, 0
|
|
copy_addr %0 to [init] %2 : $*ResilientStruct
|
|
%4 = function_ref @closure0 : $@convention(thin) (@guaranteed <τ_0_0> { var τ_0_0 } <ResilientStruct>) -> ()
|
|
%5 = partial_apply [callee_guaranteed] %4(%1) : $@convention(thin) (@guaranteed <τ_0_0> { var τ_0_0 } <ResilientStruct>) -> ()
|
|
return %5 : $@callee_guaranteed () -> ()
|
|
}
|
|
|
|
// CHECK-LABEL: sil [serialized] [ossa] @test_capture_promotion_2 :
|
|
// CHECK: [[F:%.*]] = function_ref @closure0 : $@convention(thin) (@guaranteed <τ_0_0> { var τ_0_0 } <ResilientStruct>) -> ()
|
|
// CHECK: [[C:%.*]] = partial_apply [callee_guaranteed] [[F]]({{.*}}) : $@convention(thin) (@guaranteed <τ_0_0> { var τ_0_0 } <ResilientStruct>) -> ()
|
|
// CHECK: return [[C]]
|
|
// CHECK: } // end sil function 'test_capture_promotion_2'
|
|
sil [serialized] [ossa] @test_capture_promotion_2 : $@convention(thin) (@in_guaranteed ResilientStruct) -> @owned @callee_guaranteed () -> () {
|
|
bb0(%0 : $*ResilientStruct):
|
|
%1 = alloc_box $<τ_0_0> { var τ_0_0 } <ResilientStruct>
|
|
%2 = project_box %1 : $<τ_0_0> { var τ_0_0 } <ResilientStruct>, 0
|
|
copy_addr %0 to [init] %2 : $*ResilientStruct
|
|
%4 = function_ref @closure0 : $@convention(thin) (@guaranteed <τ_0_0> { var τ_0_0 } <ResilientStruct>) -> ()
|
|
%5 = partial_apply [callee_guaranteed] %4(%1) : $@convention(thin) (@guaranteed <τ_0_0> { var τ_0_0 } <ResilientStruct>) -> ()
|
|
return %5 : $@callee_guaranteed () -> ()
|
|
}
|