Skip to content

Commit 5720d30

Browse files
committed
[sil-combine] Enable convert_escape_to_no_escape -> thin_to_thick_function for ossa.
Also begin a test file for casts specifically.
1 parent a4fd8d8 commit 5720d30

File tree

2 files changed

+39
-3
lines changed

2 files changed

+39
-3
lines changed

lib/SILOptimizer/SILCombiner/SILCombinerCastVisitors.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -630,9 +630,6 @@ visitCheckedCastAddrBranchInst(CheckedCastAddrBranchInst *CCABI) {
630630

631631
SILInstruction *SILCombiner::visitConvertEscapeToNoEscapeInst(
632632
ConvertEscapeToNoEscapeInst *Cvt) {
633-
if (Cvt->getFunction()->hasOwnership())
634-
return nullptr;
635-
636633
auto *OrigThinToThick =
637634
dyn_cast<ThinToThickFunctionInst>(Cvt->getConverted());
638635
if (!OrigThinToThick)
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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

Comments
 (0)