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.
218 lines
11 KiB
Plaintext
218 lines
11 KiB
Plaintext
// RUN: %target-sil-opt -sil-print-types -enable-sil-verify-all %s -raw-sil-inst-lowering | %FileCheck %s
|
|
|
|
sil_stage raw
|
|
|
|
import Builtin
|
|
import Swift
|
|
|
|
class SomeClass {}
|
|
|
|
// CHECK-LABEL: sil [ossa] @non_box_assign_trivial
|
|
sil [ossa] @non_box_assign_trivial : $@convention(thin) (@inout Bool, Bool) -> () {
|
|
bb0(%0 : $*Bool, %1 : $Bool):
|
|
// This is parsed with having an unknown init kind which is lowered as
|
|
// assign [assign], but since this is trivial it's treated as assign [init].
|
|
//
|
|
// CHECK: store %1 to [trivial] %0 : $*Bool
|
|
assign %1 to %0 : $*Bool
|
|
|
|
%9 = tuple ()
|
|
// CHECK: return
|
|
return %9 : $()
|
|
}
|
|
|
|
// CHECK-LABEL: sil [ossa] @non_box_assign
|
|
sil [ossa] @non_box_assign : $@convention(thin) (@inout SomeClass, @owned SomeClass) -> () {
|
|
bb0(%0 : $*SomeClass, %1 : @owned $SomeClass):
|
|
// This is parsed with having an unknown init kind which is lowered as
|
|
// assign [assign].
|
|
//
|
|
// CHECK: store %1 to [assign] %0 : $*SomeClass
|
|
assign %1 to %0 : $*SomeClass
|
|
|
|
%9 = tuple ()
|
|
// CHECK: return
|
|
return %9 : $()
|
|
}
|
|
|
|
// CHECK-LABEL: sil [ossa] @non_box_assign_init
|
|
sil [ossa] @non_box_assign_init : $@convention(thin) (@owned SomeClass) -> @out SomeClass {
|
|
bb0(%0 : $*SomeClass, %1 : @owned $SomeClass):
|
|
// Explicitly check that assign [init] is treated as store [init]
|
|
//
|
|
// CHECK: store %1 to [init] %0 : $*SomeClass
|
|
assign %1 to [init] %0 : $*SomeClass
|
|
|
|
%9 = tuple ()
|
|
// CHECK: return
|
|
return %9 : $()
|
|
}
|
|
|
|
// CHECK-LABEL: sil [ossa] @non_box_assign_reassign
|
|
sil [ossa] @non_box_assign_reassign : $@convention(thin) (@inout SomeClass, @owned SomeClass) -> () {
|
|
bb0(%0 : $*SomeClass, %1 : @owned $SomeClass):
|
|
// Explicitly check that assign [reassign] is treated as store [assign]
|
|
//
|
|
// CHECK: store %1 to [assign] %0 : $*SomeClass
|
|
assign %1 to [reassign] %0 : $*SomeClass
|
|
|
|
%9 = tuple ()
|
|
// CHECK: return
|
|
return %9 : $()
|
|
}
|
|
|
|
// CHECK-LABEL: sil [ossa] @non_box_assign_reinit
|
|
sil [ossa] @non_box_assign_reinit : $@convention(thin) (@inout SomeClass, @owned SomeClass) -> () {
|
|
bb0(%0 : $*SomeClass, %1 : @owned $SomeClass):
|
|
// Explicitly check that assign [reinit] is treated as load [take], store [init],
|
|
// and dealloc_partial_ref
|
|
//
|
|
// CHECK: [[LOAD:%[0-9]+]] = load [take] %0 : $*SomeClass
|
|
// CHECK-NEXT: store %1 to [init] %0 : $*SomeClass
|
|
// CHECK-NEXT: [[METATYPE:%[0-9]+]] = value_metatype $@thick SomeClass.Type, [[LOAD]] : $SomeClass
|
|
// CHECK-NEXT: dealloc_partial_ref [[LOAD]] : $SomeClass, [[METATYPE]] : $@thick SomeClass.Type
|
|
assign %1 to [reinit] %0 : $*SomeClass
|
|
|
|
%9 = tuple ()
|
|
// CHECK: return
|
|
return %9 : $()
|
|
}
|
|
|
|
@propertyWrapper struct Wrapper<T> {
|
|
@_hasStorage var wrappedValue: T
|
|
init(wrappedValue initialValue: T)
|
|
}
|
|
|
|
struct RefStruct {
|
|
@_hasStorage var _wrapped: Wrapper<SomeClass>
|
|
}
|
|
|
|
|
|
sil @init_closure : $@convention(thin) (@owned SomeClass) -> @owned Wrapper<SomeClass>
|
|
sil @init_closure_indirect : $@convention(thin) (@owned SomeClass) -> @out Wrapper<SomeClass>
|
|
sil @set_closure : $@convention(method) (@owned SomeClass, @inout RefStruct) -> ()
|
|
|
|
// CHECK-LABEL: sil [ossa] @assign_by_wrapper_initialization_direct
|
|
// CHECK: [[E:%[0-9]+]] = struct_element_addr
|
|
// CHECK: [[C:%[0-9]+]] = function_ref @init_closure
|
|
// CHECK: [[P:%[0-9]+]] = partial_apply [callee_guaranteed] [[C]]()
|
|
// CHECK-NOT: partial_apply
|
|
// CHECK: [[R:%[0-9]+]] = apply [[P]](%0)
|
|
// CHECK: store [[R]] to [init] [[E]]
|
|
// CHECK: } // end sil function 'assign_by_wrapper_initialization_direct'
|
|
sil [ossa] @assign_by_wrapper_initialization_direct : $@convention(method) (@owned SomeClass) -> @owned RefStruct {
|
|
bb0(%0 : @owned $SomeClass):
|
|
%1 = alloc_stack $RefStruct
|
|
%7 = struct_element_addr %1 : $*RefStruct, #RefStruct._wrapped
|
|
%8 = function_ref @init_closure : $@convention(thin) (@owned SomeClass) -> @owned Wrapper<SomeClass>
|
|
%9 = partial_apply [callee_guaranteed] %8() : $@convention(thin) (@owned SomeClass) -> @owned Wrapper<SomeClass>
|
|
%10 = function_ref @set_closure : $@convention(method) (@owned SomeClass, @inout RefStruct) -> ()
|
|
%11 = partial_apply [callee_guaranteed] %10(%1) : $@convention(method) (@owned SomeClass, @inout RefStruct) -> ()
|
|
assign_by_wrapper %0 : $SomeClass to [init] %7 : $*Wrapper<SomeClass>, init %9 : $@callee_guaranteed (@owned SomeClass) -> @owned Wrapper<SomeClass>, set %11 : $@callee_guaranteed (@owned SomeClass) -> ()
|
|
destroy_value %11 : $@callee_guaranteed (@owned SomeClass) -> ()
|
|
destroy_value %9 : $@callee_guaranteed (@owned SomeClass) -> @owned Wrapper<SomeClass>
|
|
%16 = load [take] %1 : $*RefStruct
|
|
dealloc_stack %1 : $*RefStruct
|
|
return %16 : $RefStruct
|
|
}
|
|
|
|
// CHECK-LABEL: sil [ossa] @assign_by_wrapper_initialization_indirect
|
|
// CHECK: [[E:%[0-9]+]] = struct_element_addr
|
|
// CHECK: [[C:%[0-9]+]] = function_ref @init_closure_indirect
|
|
// CHECK: [[P:%[0-9]+]] = partial_apply [callee_guaranteed] [[C]]()
|
|
// CHECK-NOT: partial_apply
|
|
// CHECK-NOT: destroy_addr
|
|
// CHECK: [[R:%[0-9]+]] = apply [[P]]([[E]], %0)
|
|
// CHECK: } // end sil function 'assign_by_wrapper_initialization_indirect'
|
|
sil [ossa] @assign_by_wrapper_initialization_indirect : $@convention(method) (@owned SomeClass) -> @owned RefStruct {
|
|
bb0(%0 : @owned $SomeClass):
|
|
%1 = alloc_stack $RefStruct
|
|
%7 = struct_element_addr %1 : $*RefStruct, #RefStruct._wrapped
|
|
%8 = function_ref @init_closure_indirect : $@convention(thin) (@owned SomeClass) -> @out Wrapper<SomeClass>
|
|
%9 = partial_apply [callee_guaranteed] %8() : $@convention(thin) (@owned SomeClass) -> @out Wrapper<SomeClass>
|
|
%10 = function_ref @set_closure : $@convention(method) (@owned SomeClass, @inout RefStruct) -> ()
|
|
%11 = partial_apply [callee_guaranteed] %10(%1) : $@convention(method) (@owned SomeClass, @inout RefStruct) -> ()
|
|
assign_by_wrapper %0 : $SomeClass to [init] %7 : $*Wrapper<SomeClass>, init %9 : $@callee_guaranteed (@owned SomeClass) -> @out Wrapper<SomeClass>, set %11 : $@callee_guaranteed (@owned SomeClass) -> ()
|
|
destroy_value %11 : $@callee_guaranteed (@owned SomeClass) -> ()
|
|
destroy_value %9 : $@callee_guaranteed (@owned SomeClass) -> @out Wrapper<SomeClass>
|
|
%16 = load [take] %1 : $*RefStruct
|
|
dealloc_stack %1 : $*RefStruct
|
|
return %16 : $RefStruct
|
|
}
|
|
|
|
// CHECK-LABEL: sil [ossa] @assign_by_wrapper_assign_direct
|
|
// CHECK: [[E:%[0-9]+]] = struct_element_addr
|
|
// CHECK: [[C:%[0-9]+]] = function_ref @init_closure
|
|
// CHECK: [[P:%[0-9]+]] = partial_apply [callee_guaranteed] [[C]]()
|
|
// CHECK-NOT: partial_apply
|
|
// CHECK: [[R:%[0-9]+]] = apply [[P]](%0)
|
|
// CHECK: store [[R]] to [assign] [[E]]
|
|
// CHECK: } // end sil function 'assign_by_wrapper_assign_direct'
|
|
sil [ossa] @assign_by_wrapper_assign_direct : $@convention(method) (@owned SomeClass, @owned Wrapper<SomeClass>) -> @owned RefStruct {
|
|
bb0(%0 : @owned $SomeClass, %1 : @owned $Wrapper<SomeClass>):
|
|
%2 = alloc_stack $RefStruct
|
|
%7 = struct_element_addr %2 : $*RefStruct, #RefStruct._wrapped
|
|
store %1 to [init] %7 : $*Wrapper<SomeClass>
|
|
%8 = function_ref @init_closure : $@convention(thin) (@owned SomeClass) -> @owned Wrapper<SomeClass>
|
|
%9 = partial_apply [callee_guaranteed] %8() : $@convention(thin) (@owned SomeClass) -> @owned Wrapper<SomeClass>
|
|
%10 = function_ref @set_closure : $@convention(method) (@owned SomeClass, @inout RefStruct) -> ()
|
|
%11 = partial_apply [callee_guaranteed] %10(%2) : $@convention(method) (@owned SomeClass, @inout RefStruct) -> ()
|
|
assign_by_wrapper %0 : $SomeClass to [assign] %7 : $*Wrapper<SomeClass>, init %9 : $@callee_guaranteed (@owned SomeClass) -> @owned Wrapper<SomeClass>, set %11 : $@callee_guaranteed (@owned SomeClass) -> ()
|
|
destroy_value %11 : $@callee_guaranteed (@owned SomeClass) -> ()
|
|
destroy_value %9 : $@callee_guaranteed (@owned SomeClass) -> @owned Wrapper<SomeClass>
|
|
%16 = load [take] %2 : $*RefStruct
|
|
dealloc_stack %2 : $*RefStruct
|
|
return %16 : $RefStruct
|
|
}
|
|
|
|
// CHECK-LABEL: sil [ossa] @assign_by_wrapper_assign_indirect
|
|
// CHECK: [[E:%[0-9]+]] = struct_element_addr
|
|
// CHECK: [[C:%[0-9]+]] = function_ref @init_closure_indirect
|
|
// CHECK: [[P:%[0-9]+]] = partial_apply [callee_guaranteed] [[C]]()
|
|
// CHECK-NOT: partial_apply
|
|
// CHECK: destroy_addr [[E]]
|
|
// CHECK: [[R:%[0-9]+]] = apply [[P]]([[E]], %0)
|
|
// CHECK: } // end sil function 'assign_by_wrapper_assign_indirect'
|
|
sil [ossa] @assign_by_wrapper_assign_indirect : $@convention(method) (@owned SomeClass, @owned Wrapper<SomeClass>) -> @owned RefStruct {
|
|
bb0(%0 : @owned $SomeClass, %1 : @owned $Wrapper<SomeClass>):
|
|
%2 = alloc_stack $RefStruct
|
|
%7 = struct_element_addr %2 : $*RefStruct, #RefStruct._wrapped
|
|
store %1 to [init] %7 : $*Wrapper<SomeClass>
|
|
%8 = function_ref @init_closure_indirect : $@convention(thin) (@owned SomeClass) -> @out Wrapper<SomeClass>
|
|
%9 = partial_apply [callee_guaranteed] %8() : $@convention(thin) (@owned SomeClass) -> @out Wrapper<SomeClass>
|
|
%10 = function_ref @set_closure : $@convention(method) (@owned SomeClass, @inout RefStruct) -> ()
|
|
%11 = partial_apply [callee_guaranteed] %10(%2) : $@convention(method) (@owned SomeClass, @inout RefStruct) -> ()
|
|
assign_by_wrapper %0 : $SomeClass to [assign] %7 : $*Wrapper<SomeClass>, init %9 : $@callee_guaranteed (@owned SomeClass) -> @out Wrapper<SomeClass>, set %11 : $@callee_guaranteed (@owned SomeClass) -> ()
|
|
destroy_value %11 : $@callee_guaranteed (@owned SomeClass) -> ()
|
|
destroy_value %9 : $@callee_guaranteed (@owned SomeClass) -> @out Wrapper<SomeClass>
|
|
%16 = load [take] %2 : $*RefStruct
|
|
dealloc_stack %2 : $*RefStruct
|
|
return %16 : $RefStruct
|
|
}
|
|
|
|
// CHECK-LABEL: sil [ossa] @assign_by_wrapper_assign_wrapped_value
|
|
// CHECK: [[A:%[0-9]+]] = alloc_stack $RefStruct
|
|
// CHECK: [[E:%[0-9]+]] = struct_element_addr
|
|
// CHECK-NOT: partial_apply
|
|
// CHECK: [[C:%[0-9]+]] = function_ref @set_closure
|
|
// CHECK: [[P:%[0-9]+]] = partial_apply [callee_guaranteed] [[C]]([[A]])
|
|
// CHECK: apply [[P]](%0)
|
|
// CHECK: } // end sil function 'assign_by_wrapper_assign_wrapped_value'
|
|
sil [ossa] @assign_by_wrapper_assign_wrapped_value : $@convention(method) (@owned SomeClass, @owned RefStruct) -> @owned RefStruct {
|
|
bb0(%0 : @owned $SomeClass, %1 : @owned $RefStruct):
|
|
%2 = alloc_stack $RefStruct
|
|
store %1 to [init] %2 : $*RefStruct
|
|
%7 = struct_element_addr %2 : $*RefStruct, #RefStruct._wrapped
|
|
%8 = function_ref @init_closure : $@convention(thin) (@owned SomeClass) -> @owned Wrapper<SomeClass>
|
|
%9 = partial_apply [callee_guaranteed] %8() : $@convention(thin) (@owned SomeClass) -> @owned Wrapper<SomeClass>
|
|
%10 = function_ref @set_closure : $@convention(method) (@owned SomeClass, @inout RefStruct) -> ()
|
|
%11 = partial_apply [callee_guaranteed] %10(%2) : $@convention(method) (@owned SomeClass, @inout RefStruct) -> ()
|
|
assign_by_wrapper %0 : $SomeClass to [assign_wrapped_value] %7 : $*Wrapper<SomeClass>, init %9 : $@callee_guaranteed (@owned SomeClass) -> @owned Wrapper<SomeClass>, set %11 : $@callee_guaranteed (@owned SomeClass) -> ()
|
|
destroy_value %11 : $@callee_guaranteed (@owned SomeClass) -> ()
|
|
destroy_value %9 : $@callee_guaranteed (@owned SomeClass) -> @owned Wrapper<SomeClass>
|
|
%16 = load [take] %2 : $*RefStruct
|
|
dealloc_stack %2 : $*RefStruct
|
|
return %16 : $RefStruct
|
|
}
|
|
|