|
| 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 | +sil @returnInt : $@convention(thin) () -> Builtin.Int32 |
| 10 | + |
| 11 | +// CHECK-LABEL: sil @optimize_convert_escape_to_noescape : |
| 12 | +// CHECK: [[FN:%.*]] = function_ref @returnInt |
| 13 | +// CHECK: apply [[FN]]() |
| 14 | +// CHECK: } // end sil function 'optimize_convert_escape_to_noescape' |
| 15 | +sil @optimize_convert_escape_to_noescape : $@convention(thin) () -> Builtin.Int32 { |
| 16 | +bb0: |
| 17 | + %0 = function_ref @returnInt : $@convention(thin) () -> Builtin.Int32 |
| 18 | + %1 = thin_to_thick_function %0 : $@convention(thin) () -> Builtin.Int32 to $@callee_guaranteed () -> Builtin.Int32 |
| 19 | + %2 = convert_escape_to_noescape %1 : $@callee_guaranteed () -> Builtin.Int32 to $@noescape @callee_guaranteed () -> Builtin.Int32 |
| 20 | + %4 = apply %2() : $@noescape @callee_guaranteed () -> Builtin.Int32 |
| 21 | + return %4 : $Builtin.Int32 |
| 22 | +} |
| 23 | + |
| 24 | +// We have an extra thin_to_thick_function here since we do not yet have the |
| 25 | +// optimization for eliminating it enabled in OSSA yet. |
| 26 | +// |
| 27 | +// CHECK-LABEL: sil [ossa] @optimize_convert_escape_to_noescape_ossa : |
| 28 | +// CHECK: [[FN:%.*]] = function_ref @returnInt |
| 29 | +// CHECK: [[TTTFI:%.*]] = thin_to_thick_function [[FN]] |
| 30 | +// CHECK: apply [[TTTFI]]() |
| 31 | +// CHECK: } // end sil function 'optimize_convert_escape_to_noescape_ossa' |
| 32 | +sil [ossa] @optimize_convert_escape_to_noescape_ossa : $@convention(thin) () -> Builtin.Int32 { |
| 33 | +bb0: |
| 34 | + %0 = function_ref @returnInt : $@convention(thin) () -> Builtin.Int32 |
| 35 | + %1 = thin_to_thick_function %0 : $@convention(thin) () -> Builtin.Int32 to $@callee_guaranteed () -> Builtin.Int32 |
| 36 | + %2 = convert_escape_to_noescape %1 : $@callee_guaranteed () -> Builtin.Int32 to $@noescape @callee_guaranteed () -> Builtin.Int32 |
| 37 | + %4 = apply %2() : $@noescape @callee_guaranteed () -> Builtin.Int32 |
| 38 | + return %4 : $Builtin.Int32 |
| 39 | +} |
0 commit comments