|
| 1 | +// RUN: %target-sil-opt -enable-objc-interop -enforce-exclusivity=none -enable-sil-verify-all %s -sil-combine -sil-combine-disable-alloc-stack-opts | %FileCheck %s |
| 2 | + |
| 3 | +sil_stage canonical |
| 4 | + |
| 5 | +import Builtin |
| 6 | + |
| 7 | +class Klass {} |
| 8 | + |
| 9 | +// We test both the ossa and non-ossa variants. |
| 10 | +// |
| 11 | +// CHECK-LABEL: sil [ossa] @fix_lifetime_promotion_ossa : $@convention(thin) (@owned Klass) -> () { |
| 12 | +// CHECK: bb0([[ARG:%.*]] : |
| 13 | +// CHECK: [[STACK:%.*]] = alloc_stack $Klass |
| 14 | +// CHECK: store [[ARG]] to [init] [[STACK]] |
| 15 | +// CHECK: [[BORROW:%.*]] = load_borrow [[STACK]] |
| 16 | +// CHECK: fix_lifetime [[BORROW]] |
| 17 | +// CHECK: end_borrow [[BORROW]] |
| 18 | +// CHECK: destroy_addr [[STACK]] |
| 19 | +// CHECK: dealloc_stack [[STACK]] |
| 20 | +// CHECK: } // end sil function 'fix_lifetime_promotion_ossa' |
| 21 | +sil [ossa] @fix_lifetime_promotion_ossa : $@convention(thin) (@owned Klass) -> () { |
| 22 | +bb0(%0 : @owned $Klass): |
| 23 | + %1 = alloc_stack $Klass |
| 24 | + store %0 to [init] %1 : $*Klass |
| 25 | + fix_lifetime %1 : $*Klass |
| 26 | + destroy_addr %1 : $*Klass |
| 27 | + dealloc_stack %1 : $*Klass |
| 28 | + %9999 = tuple() |
| 29 | + return %9999 : $() |
| 30 | +} |
| 31 | + |
| 32 | +// CHECK-LABEL: sil @fix_lifetime_promotion : $@convention(thin) (@owned Klass) -> () { |
| 33 | +// CHECK: bb0([[ARG:%.*]] : |
| 34 | +// CHECK: [[STACK:%.*]] = alloc_stack $Klass |
| 35 | +// CHECK: store [[ARG]] to [[STACK]] |
| 36 | +// CHECK: [[BORROW:%.*]] = load [[STACK]] |
| 37 | +// CHECK: fix_lifetime [[BORROW]] |
| 38 | +// CHECK: destroy_addr [[STACK]] |
| 39 | +// CHECK: dealloc_stack [[STACK]] |
| 40 | +// CHECK: } // end sil function 'fix_lifetime_promotion' |
| 41 | +sil @fix_lifetime_promotion : $@convention(thin) (@owned Klass) -> () { |
| 42 | +bb0(%0 : $Klass): |
| 43 | + %1 = alloc_stack $Klass |
| 44 | + store %0 to %1 : $*Klass |
| 45 | + fix_lifetime %1 : $*Klass |
| 46 | + destroy_addr %1 : $*Klass |
| 47 | + dealloc_stack %1 : $*Klass |
| 48 | + %9999 = tuple() |
| 49 | + return %9999 : $() |
| 50 | +} |
0 commit comments