Skip to content

Commit 113fbb2

Browse files
committed
---
yaml --- r: 318335 b: refs/heads/master-rebranch c: eeefad1 h: refs/heads/master i: 318333: 2070708 318331: ef53c5f 318327: 075c698 318319: bfd6595 318303: 1ee4ee6 318271: 8a0ff51 318207: aaffd5a
1 parent 3b5b42f commit 113fbb2

File tree

4 files changed

+54
-4
lines changed

4 files changed

+54
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1457,4 +1457,4 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2019-08-02-a: ddd2b2976aa9bfde5f20fe37f6bd2
14571457
refs/tags/swift-DEVELOPMENT-SNAPSHOT-2019-08-03-a: 171cc166f2abeb5ca2a4003700a8a78a108bd300
14581458
refs/heads/benlangmuir-patch-1: baaebaf39d52f3bf36710d4fe40cf212e996b212
14591459
refs/heads/i-do-redeclare: 8c4e6d5de5c1e3f0a2cedccf319df713ea22c48e
1460-
refs/heads/master-rebranch: 99595a9c30c9b25d41f1888fc21bb918901b7ea1
1460+
refs/heads/master-rebranch: eeefad16d4dc379ae15950e28cf91a3db270be87

branches/master-rebranch/lib/SILOptimizer/Transforms/PerformanceInliner.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -891,7 +891,16 @@ bool SILPerformanceInliner::inlineCallsIntoFunction(SILFunction *Caller) {
891891
if (!Callee->shouldOptimize()) {
892892
continue;
893893
}
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+
895904
SmallVector<SILValue, 8> Args;
896905
for (const auto &Arg : AI.getArguments())
897906
Args.push_back(Arg);

branches/master-rebranch/test/SILOptimizer/devirt_ctors_ownership.sil

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ class ABC {
1313

1414

1515
// 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):
1818
return %1 : $ABC // id: %38
1919
}
2020

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
}

0 commit comments

Comments
 (0)