File tree Expand file tree Collapse file tree 3 files changed +53
-3
lines changed
lib/SILOptimizer/Transforms Expand file tree Collapse file tree 3 files changed +53
-3
lines changed Original file line number Diff line number Diff line change @@ -891,7 +891,16 @@ bool SILPerformanceInliner::inlineCallsIntoFunction(SILFunction *Caller) {
891
891
if (!Callee->shouldOptimize ()) {
892
892
continue ;
893
893
}
894
-
894
+
895
+ // If we have a callee that doesn't have ownership, but the caller does have
896
+ // ownership... do not inline. The two modes are incompatible. Today this
897
+ // should only happen with transparent functions.
898
+ if (!Callee->hasOwnership () && Caller->hasOwnership ()) {
899
+ assert (Caller->isTransparent () &&
900
+ " Should only happen with transparent functions" );
901
+ continue ;
902
+ }
903
+
895
904
SmallVector<SILValue, 8 > Args;
896
905
for (const auto &Arg : AI.getArguments ())
897
906
Args.push_back (Arg);
Original file line number Diff line number Diff line change @@ -13,8 +13,8 @@ class ABC {
13
13
14
14
15
15
// This is our c'tor.
16
- sil @_TFC4main3ABCcfMS0_FT1ySi_S0_ : $@convention(method) (Int64, @owned ABC) -> @owned ABC {
17
- bb0(%0 : $Int64, %1 : $ABC):
16
+ sil [ossa] @_TFC4main3ABCcfMS0_FT1ySi_S0_ : $@convention(method) (Int64, @owned ABC) -> @owned ABC {
17
+ bb0(%0 : $Int64, %1 : @owned $ABC):
18
18
return %1 : $ABC // id: %38
19
19
}
20
20
Original file line number Diff line number Diff line change
1
+ // RUN: %target-sil-opt -enable-sil-verify-all %s -inline | %FileCheck %s
2
+
3
+ sil_stage canonical
4
+
5
+ import Builtin
6
+ import Swift
7
+
8
+ // Make sure that we do not try to inline non-ossa functions into ossa
9
+ // functions. This can only occur with transparent functions today.
10
+
11
+ // We do not need a filecheck here since if we inline, the strong_release will
12
+ // hit assertions since strong_release is a non-ossa instruction that can never
13
+ // be in an ossa function.
14
+ sil [transparent] [ossa] @ossa_transparent_caller : $@convention(thin) (@owned Builtin.NativeObject) -> () {
15
+ bb0(%0 : @owned $Builtin.NativeObject):
16
+ %1 = function_ref @non_ossa_callee : $@convention(thin) (@owned Builtin.NativeObject) -> ()
17
+ apply %1(%0) : $@convention(thin) (@owned Builtin.NativeObject) -> ()
18
+ %9999 = tuple()
19
+ return %9999 : $()
20
+ }
21
+
22
+ // We put in this filecheck test to make sure that without the [ossa] bit, we
23
+ // /would/ inline.
24
+ //
25
+ // CHECK-LABEL: sil [transparent] @non_ossa_caller : $@convention(thin) (@owned Builtin.NativeObject) -> () {
26
+ // CHECK: strong_release
27
+ // CHECK: } // end sil function 'non_ossa_caller'
28
+ sil [transparent] @non_ossa_caller : $@convention(thin) (@owned Builtin.NativeObject) -> () {
29
+ bb0(%0 : $Builtin.NativeObject):
30
+ %1 = function_ref @non_ossa_callee : $@convention(thin) (@owned Builtin.NativeObject) -> ()
31
+ apply %1(%0) : $@convention(thin) (@owned Builtin.NativeObject) -> ()
32
+ %9999 = tuple()
33
+ return %9999 : $()
34
+ }
35
+
36
+ sil @non_ossa_callee : $@convention(thin) (@owned Builtin.NativeObject) -> () {
37
+ bb0(%0 : $Builtin.NativeObject):
38
+ strong_release %0 : $Builtin.NativeObject
39
+ %9999 = tuple()
40
+ return %9999 : $()
41
+ }
You can’t perform that action at this time.
0 commit comments