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.
83 lines
3.7 KiB
Plaintext
83 lines
3.7 KiB
Plaintext
// First parse this and then emit a *.sib. Then read in the *.sib, then recreate
|
|
// RUN: %empty-directory(%t)
|
|
// RUN: %target-sil-opt -sil-print-types %s -emit-sib -o %t/tmp.sib -module-name borrow
|
|
// RUN: %target-sil-opt -sil-print-types %t/tmp.sib -o %t/tmp.2.sib -module-name borrow
|
|
// RUN: %target-sil-opt -sil-print-types %t/tmp.2.sib -module-name borrow | %FileCheck %s
|
|
|
|
sil_stage canonical
|
|
|
|
import Builtin
|
|
|
|
// CHECK-LABEL: sil [serialized] [ossa] @begin_borrow_test
|
|
// CHECK: begin_borrow [lexical] {{%[^,]+}}
|
|
// CHECK: begin_borrow {{%[^,]+}}
|
|
// CHECK: begin_borrow [var_decl] {{%[^,]+}}
|
|
// CHECK: } // end sil function 'begin_borrow_test'
|
|
sil [serialized] [ossa] @begin_borrow_test : $@convention(thin) () -> () {
|
|
%instance = alloc_ref $C
|
|
%guaranteed_c = begin_borrow [lexical] %instance : $C
|
|
end_borrow %guaranteed_c : $C
|
|
%guaranteed_c2 = begin_borrow %instance : $C
|
|
end_borrow %guaranteed_c2 : $C
|
|
%guaranteed_c3 = begin_borrow [var_decl] %instance : $C
|
|
end_borrow %guaranteed_c3 : $C
|
|
destroy_value %instance : $C
|
|
%res = tuple ()
|
|
return %res : $()
|
|
}
|
|
|
|
// CHECK-LABEL: sil [serialized] [ossa] @alloc_stack_test
|
|
// CHECK: alloc_stack $Builtin.NativeObject
|
|
// CHECK: alloc_stack [dynamic_lifetime]
|
|
// CHECK: alloc_stack [lexical]
|
|
// CHECK: alloc_stack [var_decl]
|
|
// CHECK: alloc_stack [dynamic_lifetime] [lexical]
|
|
// CHECK: alloc_stack [dynamic_lifetime] [var_decl]
|
|
// CHECK: alloc_stack [lexical] [var_decl]
|
|
// CHECK: alloc_stack [dynamic_lifetime] [lexical] [var_decl]
|
|
// CHECK: } // end sil function 'alloc_stack_test'
|
|
sil [serialized] [ossa] @alloc_stack_test : $@convention(thin) () -> () {
|
|
%instance = alloc_stack $Builtin.NativeObject
|
|
dealloc_stack %instance : $*Builtin.NativeObject
|
|
%instance2 = alloc_stack [dynamic_lifetime] $Builtin.NativeObject
|
|
dealloc_stack %instance2 : $*Builtin.NativeObject
|
|
%instance3 = alloc_stack [lexical] $Builtin.NativeObject
|
|
dealloc_stack %instance3 : $*Builtin.NativeObject
|
|
%instance5 = alloc_stack [var_decl] $Builtin.NativeObject
|
|
dealloc_stack %instance5 : $*Builtin.NativeObject
|
|
%instance4 = alloc_stack [lexical] [dynamic_lifetime] $Builtin.NativeObject
|
|
dealloc_stack %instance4 : $*Builtin.NativeObject
|
|
%instance6 = alloc_stack [dynamic_lifetime] [var_decl] $Builtin.NativeObject
|
|
dealloc_stack %instance6 : $*Builtin.NativeObject
|
|
%instance7 = alloc_stack [lexical] [var_decl] $Builtin.NativeObject
|
|
dealloc_stack %instance7 : $*Builtin.NativeObject
|
|
%instance8 = alloc_stack [lexical] [var_decl] [dynamic_lifetime] $Builtin.NativeObject
|
|
dealloc_stack %instance8 : $*Builtin.NativeObject
|
|
%res = tuple ()
|
|
return %res : $()
|
|
}
|
|
|
|
// We do not verify here, but just make sure that all of the combinations parse and print correctly.
|
|
// CHECK-LABEL: sil [serialized] [ossa] @borrow_test : $@convention(thin) (@in Builtin.NativeObject, @guaranteed Builtin.NativeObject) -> () {
|
|
// CHECK: bb0([[ARG1:%[0-9]+]] : $*Builtin.NativeObject, [[ARG2:%[0-9]+]] : @guaranteed $Builtin.NativeObject):
|
|
// CHECK: [[BORROWED_ARG2:%.*]] = begin_borrow [[ARG2]]
|
|
// CHECK: end_borrow [[BORROWED_ARG2]]
|
|
// CHECK: [[MEM:%.*]] = alloc_stack $Builtin.NativeObject
|
|
// CHECK: store_borrow [[ARG2]] to [[MEM]] : $*Builtin.NativeObject
|
|
// CHECK: } // end sil function 'borrow_test'
|
|
sil [serialized] [ossa] @borrow_test : $@convention(thin) (@in Builtin.NativeObject, @guaranteed Builtin.NativeObject) -> () {
|
|
bb0(%0 : $*Builtin.NativeObject, %1 : @guaranteed $Builtin.NativeObject):
|
|
%2 = begin_borrow %1 : $Builtin.NativeObject
|
|
end_borrow %2 : $Builtin.NativeObject
|
|
|
|
%3 = alloc_stack $Builtin.NativeObject
|
|
%sb = store_borrow %1 to %3 : $*Builtin.NativeObject
|
|
end_borrow %sb : $*Builtin.NativeObject
|
|
dealloc_stack %3 : $*Builtin.NativeObject
|
|
destroy_addr %0 : $*Builtin.NativeObject
|
|
%4 = tuple()
|
|
return %4 : $()
|
|
}
|
|
|
|
class C {}
|