| // First parse this and then emit a *.sib. Then read in the *.sib, then recreate |
| // RUN: %empty-directory(%t) |
| // RUN: %target-sil-opt %s -emit-sib -o %t/tmp.sib -module-name borrow |
| // RUN: %target-sil-opt %t/tmp.sib -o %t/tmp.2.sib -module-name borrow |
| // RUN: %target-sil-opt %t/tmp.2.sib -module-name borrow | %FileCheck %s |
| |
| import Builtin |
| |
| // CHECK-LABEL: sil [serialized] [ossa] @test_unchecked_ownership_conversion : $@convention(thin) (@guaranteed Builtin.NativeObject) -> () { |
| // CHECK: unchecked_ownership_conversion {{%.*}} : $Builtin.NativeObject, @guaranteed to @owned |
| sil [serialized] [ossa] @test_unchecked_ownership_conversion : $@convention(thin) (@guaranteed Builtin.NativeObject) -> () { |
| bb0(%0 : @guaranteed $Builtin.NativeObject): |
| %1 = unchecked_ownership_conversion %0 : $Builtin.NativeObject, @guaranteed to @owned |
| destroy_value %1 : $Builtin.NativeObject |
| return undef : $() |
| } |
| |
| // CHECK-LABEL: sil [serialized] [ossa] @test_end_lifetime : $@convention(thin) (@owned Builtin.NativeObject) -> () { |
| // CHECK: end_lifetime {{%.*}} : $Builtin.NativeObject |
| sil [serialized] [ossa] @test_end_lifetime : $@convention(thin) (@owned Builtin.NativeObject) -> () { |
| bb0(%0 : @owned $Builtin.NativeObject): |
| end_lifetime %0 : $Builtin.NativeObject |
| return undef : $() |
| } |
| |
| class TestArrayStorage { |
| @_hasStorage var count: Int32 |
| init() |
| } |
| |
| struct TestArray2 { |
| var storage : TestArrayStorage |
| var someValue : Int32 |
| var storage2 : TestArrayStorage |
| } |
| |
| struct Int32 { |
| var x: Builtin.Int32 |
| } |
| |
| sil [ossa] @test_destructure_struct_tuple : $@convention(thin) (@owned (Builtin.NativeObject, Builtin.Int32), @owned TestArray2) -> @owned (Builtin.NativeObject, Builtin.Int32, TestArrayStorage, Int32, TestArrayStorage) { |
| bb0(%0 : @owned $(Builtin.NativeObject, Builtin.Int32), %1 : @owned $TestArray2): |
| (%2, %3) = destructure_tuple %0 : $(Builtin.NativeObject, Builtin.Int32) |
| (%4, %5, %6) = destructure_struct %1 : $TestArray2 |
| %7 = tuple(%2 : $Builtin.NativeObject, %3 : $Builtin.Int32, %4 : $TestArrayStorage, %5 : $Int32, %6 : $TestArrayStorage) |
| return %7 : $(Builtin.NativeObject, Builtin.Int32, TestArrayStorage, Int32, TestArrayStorage) |
| } |
| |
| struct EmptyStruct {} |
| |
| sil @test_empty_destructure : $@convention(thin) () -> () { |
| bb0: |
| %0 = struct $EmptyStruct() |
| () = destructure_struct %0 : $EmptyStruct |
| %1 = tuple() |
| () = destructure_tuple %1 : $() |
| return %1 : $() |
| } |