Skip to content

Commit c27ffd2

Browse files
committed
Merge pull request #832 from ezephir/linux-test-cse
[SILOptimizer]Refactor ObjC dependencies in CSE tests
2 parents cd71f51 + 36b89a9 commit c27ffd2

File tree

2 files changed

+126
-120
lines changed

2 files changed

+126
-120
lines changed

test/SILOptimizer/cse.sil

Lines changed: 0 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
// RUN: %target-sil-opt -enable-sil-verify-all %s -cse | FileCheck %s
22

3-
// XFAIL: linux
4-
53
import Builtin
64
import Swift
7-
import Foundation
85

96
//////////////////////
107
// Simple DCE Tests //
@@ -769,19 +766,6 @@ bb0(%0 : $B, %1 : $B):
769766
return %99 : $(@thick protocol<>.Type, @thick protocol<>.Type)
770767
}
771768

772-
// CHECK-LABEL: sil @cse_objc_protocol
773-
// CHECK: objc_protocol #XX : $Protocol
774-
// CHECK-NOT: objc_protocol
775-
// CHECK: tuple (%0 : $Protocol, %0 : $Protocol)
776-
// CHECK: return
777-
sil @cse_objc_protocol : $@convention(thin) () -> @owned (Protocol, Protocol) {
778-
bb0:
779-
%0 = objc_protocol #XX : $Protocol
780-
%1 = objc_protocol #XX : $Protocol
781-
%2 = tuple (%0: $Protocol, %1: $Protocol)
782-
return %2 : $(Protocol, Protocol)
783-
}
784-
785769

786770
// CHECK-LABEL: sil @cse_objc_metatype_to_object
787771
// CHECK: value_metatype $@objc_metatype
@@ -1246,107 +1230,3 @@ bb0(%0 : $*Flyable):
12461230
sil_witness_table hidden Airplane: Flyable module p2 {
12471231
method #Flyable.fly!1: @_TTWV2p28AirplaneS_7FlyableS_FS1_3flyuRq_S1__fq_FT_T_ // protocol witness for p2.Flyable.fly <A where A: p2.Flyable> (A)() -> () in conformance p2.Airplane : p2.Flyable in p2
12481232
}
1249-
1250-
@objc protocol Walkable {
1251-
func walk()
1252-
}
1253-
1254-
class Bar : NSObject, Walkable {
1255-
override init()
1256-
func walk()
1257-
deinit
1258-
}
1259-
1260-
func trytowalk(f: Walkable)
1261-
1262-
// test.Bar.init (test.Bar.Type)() -> test.Bar
1263-
sil hidden @_TFC4test3BarcfMS0_FT_S0_ : $@convention(method) (@owned Bar) -> @owned Bar {
1264-
bb0(%0 : $Bar):
1265-
%1 = alloc_stack $Bar, let, name "sf" // users: %2, %6, %9, %10
1266-
store %0 to %1#1 : $*Bar // id: %2
1267-
%3 = upcast %0 : $Bar to $NSObject // user: %7
1268-
%4 = super_method [volatile] %0 : $Bar, #NSObject.init!initializer.1.foreign : NSObject.Type -> () -> NSObject , $@convention(objc_method) (@owned NSObject) -> @owned NSObject // user: %7
1269-
%7 = apply %4(%3) : $@convention(objc_method) (@owned NSObject) -> @owned NSObject // user: %8
1270-
%8 = unchecked_ref_cast %7 : $NSObject to $Bar // users: %9, %11
1271-
store %8 to %1#1 : $*Bar // id: %9
1272-
dealloc_stack %1#0 : $*@local_storage Bar // id: %10
1273-
return %8 : $Bar // id: %11
1274-
}
1275-
1276-
// test.Bar.__allocating_init (test.Bar.Type)() -> test.Bar
1277-
sil hidden @_TFC4test3BarCfMS0_FT_S0_ : $@convention(thin) (@thick Bar.Type) -> @owned Bar {
1278-
bb0(%0 : $@thick Bar.Type):
1279-
%1 = alloc_ref [objc] $Bar // user: %3
1280-
// function_ref test.Bar.init (test.Bar.Type)() -> test.Bar
1281-
%2 = function_ref @_TFC4test3BarcfMS0_FT_S0_ : $@convention(method) (@owned Bar) -> @owned Bar // user: %3
1282-
%3 = apply %2(%1) : $@convention(method) (@owned Bar) -> @owned Bar // user: %4
1283-
return %3 : $Bar // id: %4
1284-
}
1285-
1286-
// @objc test.Bar.init (test.Bar.Type)() -> test.Bar
1287-
sil hidden @_TToFC4test3BarcfMS0_FT_S0_ : $@convention(objc_method) (@owned Bar) -> @owned Bar {
1288-
bb0(%0 : $Bar):
1289-
// function_ref test.Bar.init (test.Bar.Type)() -> test.Bar
1290-
%1 = function_ref @_TFC4test3BarcfMS0_FT_S0_ : $@convention(method) (@owned Bar) -> @owned Bar // user: %2
1291-
%2 = apply %1(%0) : $@convention(method) (@owned Bar) -> @owned Bar // user: %3
1292-
return %2 : $Bar // id: %3
1293-
}
1294-
1295-
// test.Bar.walk (test.Bar)() -> ()
1296-
sil hidden @_TFC4test3Bar4walkfS0_FT_T_ : $@convention(method) (@guaranteed Bar) -> () {
1297-
bb0(%0 : $Bar):
1298-
debug_value %0 : $Bar, let, name "self" // id: %1
1299-
%2 = tuple () // user: %3
1300-
return %2 : $() // id: %3
1301-
}
1302-
1303-
// @objc test.Bar.walk (test.Bar)() -> ()
1304-
sil hidden @_TToFC4test3Bar4walkfS0_FT_T_ : $@convention(objc_method) (Bar) -> () {
1305-
bb0(%0 : $Bar):
1306-
strong_retain %0 : $Bar // id: %1
1307-
// function_ref test.Bar.walk (test.Bar)() -> ()
1308-
%2 = function_ref @_TFC4test3Bar4walkfS0_FT_T_ : $@convention(method) (@guaranteed Bar) -> () // user: %3
1309-
%3 = apply %2(%0) : $@convention(method) (@guaranteed Bar) -> () // user: %5
1310-
strong_release %0 : $Bar // id: %4
1311-
return %3 : $() // id: %5
1312-
}
1313-
1314-
// test.Bar.__deallocating_deinit
1315-
sil hidden @_TFC4test3BarD : $@convention(method) (@owned Bar) -> () {
1316-
bb0(%0 : $Bar):
1317-
debug_value %0 : $Bar, let, name "self" // id: %1
1318-
%2 = super_method %0 : $Bar, #NSObject.deinit!deallocator.foreign : NSObject -> () , $@convention(objc_method) (NSObject) -> () // user: %4
1319-
%3 = upcast %0 : $Bar to $NSObject // user: %4
1320-
%4 = apply %2(%3) : $@convention(objc_method) (NSObject) -> ()
1321-
%5 = tuple () // user: %6
1322-
return %5 : $() // id: %6
1323-
}
1324-
1325-
// CHECK-LABEL: _TF4test9trytowalkFPS_8Walkable_T_
1326-
// CHECK: bb0(%0 : $Walkable):
1327-
// CHECK-NEXT: open_existential_ref
1328-
// CHECK-NEXT: witness_method
1329-
// CHECK-NEXT: apply
1330-
// CHECK-NEXT: witness_method
1331-
// CHECK-NEXT: apply
1332-
// CHECK-NEXT: strong_release
1333-
// CHECK-NEXT: tuple
1334-
// CHECK-NEXT: return
1335-
// test.trytowalk (test.Walkable) -> ()
1336-
sil hidden @_TF4test9trytowalkFPS_8Walkable_T_ : $@convention(thin) (@owned Walkable) -> () {
1337-
bb0(%0 : $Walkable):
1338-
%2 = open_existential_ref %0 : $Walkable to $@opened("7813D5BE-4C48-11E5-BD72-AC87A3294C0A") Walkable // users: %3, %4
1339-
%3 = witness_method [volatile] $@opened("7813D5BE-4C48-11E5-BD72-AC87A3294C0A") Walkable, #Walkable.walk!1.foreign, %2 : $@opened("7813D5BE-4C48-11E5-BD72-AC87A3294C0A") Walkable : $@convention(objc_method) <τ_0_0 where τ_0_0 : Walkable> (τ_0_0) -> () // user: %4
1340-
%4 = apply %3<@opened("7813D5BE-4C48-11E5-BD72-AC87A3294C0A") Walkable>(%2) : $@convention(objc_method) <τ_0_0 where τ_0_0 : Walkable> (τ_0_0) -> ()
1341-
%5 = witness_method [volatile] $@opened("7813D5BE-4C48-11E5-BD72-AC87A3294C0A") Walkable, #Walkable.walk!1.foreign, %2 : $@opened("7813D5BE-4C48-11E5-BD72-AC87A3294C0A") Walkable : $@convention(objc_method) <τ_0_0 where τ_0_0 : Walkable> (τ_0_0) -> () // user: %6
1342-
%6 = apply %5<@opened("7813D5BE-4C48-11E5-BD72-AC87A3294C0A") Walkable>(%2) : $@convention(objc_method) <τ_0_0 where τ_0_0 : Walkable> (τ_0_0) -> ()
1343-
strong_release %0 : $Walkable // id: %8
1344-
%9 = tuple () // user: %10
1345-
return %9 : $() // id: %10
1346-
}
1347-
1348-
sil_vtable Bar {
1349-
#Bar.init!initializer.1: _TFC4test3BarcfMS0_FT_S0_ // test.Bar.init (test.Bar.Type)() -> test.Bar
1350-
#Bar.walk!1: _TFC4test3Bar4walkfS0_FT_T_ // test.Bar.walk (test.Bar)() -> ()
1351-
#Bar.deinit!deallocator: _TFC4test3BarD // test.Bar.__deallocating_deinit
1352-
}

test/SILOptimizer/cse_objc.sil

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
// RUN: %target-sil-opt -enable-sil-verify-all %s -cse | FileCheck %s
2+
// REQUIRES: objc_interop
3+
4+
import Builtin
5+
import Swift
6+
import Foundation
7+
8+
@objc(XX) protocol XX {
9+
}
10+
11+
// CHECK-LABEL: sil @cse_objc_protocol
12+
// CHECK: objc_protocol #XX : $Protocol
13+
// CHECK-NOT: objc_protocol
14+
// CHECK: tuple (%0 : $Protocol, %0 : $Protocol)
15+
// CHECK: return
16+
sil @cse_objc_protocol : $@convention(thin) () -> @owned (Protocol, Protocol) {
17+
bb0:
18+
%0 = objc_protocol #XX : $Protocol
19+
%1 = objc_protocol #XX : $Protocol
20+
%2 = tuple (%0: $Protocol, %1: $Protocol)
21+
return %2 : $(Protocol, Protocol)
22+
}
23+
24+
@objc protocol Walkable {
25+
func walk()
26+
}
27+
28+
class Bar : NSObject, Walkable {
29+
override init()
30+
func walk()
31+
deinit
32+
}
33+
34+
func trytowalk(f: Walkable)
35+
36+
// test.Bar.init (test.Bar.Type)() -> test.Bar
37+
sil hidden @_TFC4test3BarcfMS0_FT_S0_ : $@convention(method) (@owned Bar) -> @owned Bar {
38+
bb0(%0 : $Bar):
39+
%1 = alloc_stack $Bar, let, name "sf" // users: %2, %6, %9, %10
40+
store %0 to %1#1 : $*Bar // id: %2
41+
%3 = upcast %0 : $Bar to $NSObject // user: %7
42+
%4 = super_method [volatile] %0 : $Bar, #NSObject.init!initializer.1.foreign : NSObject.Type -> () -> NSObject , $@convention(objc_method) (@owned NSObject) -> @owned NSObject // user: %7
43+
%7 = apply %4(%3) : $@convention(objc_method) (@owned NSObject) -> @owned NSObject // user: %8
44+
%8 = unchecked_ref_cast %7 : $NSObject to $Bar // users: %9, %11
45+
store %8 to %1#1 : $*Bar // id: %9
46+
dealloc_stack %1#0 : $*@local_storage Bar // id: %10
47+
return %8 : $Bar // id: %11
48+
}
49+
50+
// test.Bar.__allocating_init (test.Bar.Type)() -> test.Bar
51+
sil hidden @_TFC4test3BarCfMS0_FT_S0_ : $@convention(thin) (@thick Bar.Type) -> @owned Bar {
52+
bb0(%0 : $@thick Bar.Type):
53+
%1 = alloc_ref [objc] $Bar // user: %3
54+
// function_ref test.Bar.init (test.Bar.Type)() -> test.Bar
55+
%2 = function_ref @_TFC4test3BarcfMS0_FT_S0_ : $@convention(method) (@owned Bar) -> @owned Bar // user: %3
56+
%3 = apply %2(%1) : $@convention(method) (@owned Bar) -> @owned Bar // user: %4
57+
return %3 : $Bar // id: %4
58+
}
59+
60+
// @objc test.Bar.init (test.Bar.Type)() -> test.Bar
61+
sil hidden @_TToFC4test3BarcfMS0_FT_S0_ : $@convention(objc_method) (@owned Bar) -> @owned Bar {
62+
bb0(%0 : $Bar):
63+
// function_ref test.Bar.init (test.Bar.Type)() -> test.Bar
64+
%1 = function_ref @_TFC4test3BarcfMS0_FT_S0_ : $@convention(method) (@owned Bar) -> @owned Bar // user: %2
65+
%2 = apply %1(%0) : $@convention(method) (@owned Bar) -> @owned Bar // user: %3
66+
return %2 : $Bar // id: %3
67+
}
68+
69+
// test.Bar.walk (test.Bar)() -> ()
70+
sil hidden @_TFC4test3Bar4walkfS0_FT_T_ : $@convention(method) (@guaranteed Bar) -> () {
71+
bb0(%0 : $Bar):
72+
debug_value %0 : $Bar, let, name "self" // id: %1
73+
%2 = tuple () // user: %3
74+
return %2 : $() // id: %3
75+
}
76+
77+
// @objc test.Bar.walk (test.Bar)() -> ()
78+
sil hidden @_TToFC4test3Bar4walkfS0_FT_T_ : $@convention(objc_method) (Bar) -> () {
79+
bb0(%0 : $Bar):
80+
strong_retain %0 : $Bar // id: %1
81+
// function_ref test.Bar.walk (test.Bar)() -> ()
82+
%2 = function_ref @_TFC4test3Bar4walkfS0_FT_T_ : $@convention(method) (@guaranteed Bar) -> () // user: %3
83+
%3 = apply %2(%0) : $@convention(method) (@guaranteed Bar) -> () // user: %5
84+
strong_release %0 : $Bar // id: %4
85+
return %3 : $() // id: %5
86+
}
87+
88+
// test.Bar.__deallocating_deinit
89+
sil hidden @_TFC4test3BarD : $@convention(method) (@owned Bar) -> () {
90+
bb0(%0 : $Bar):
91+
debug_value %0 : $Bar, let, name "self" // id: %1
92+
%2 = super_method %0 : $Bar, #NSObject.deinit!deallocator.foreign : NSObject -> () , $@convention(objc_method) (NSObject) -> () // user: %4
93+
%3 = upcast %0 : $Bar to $NSObject // user: %4
94+
%4 = apply %2(%3) : $@convention(objc_method) (NSObject) -> ()
95+
%5 = tuple () // user: %6
96+
return %5 : $() // id: %6
97+
}
98+
99+
// CHECK-LABEL: _TF4test9trytowalkFPS_8Walkable_T_
100+
// CHECK: bb0(%0 : $Walkable):
101+
// CHECK-NEXT: open_existential_ref
102+
// CHECK-NEXT: witness_method
103+
// CHECK-NEXT: apply
104+
// CHECK-NEXT: witness_method
105+
// CHECK-NEXT: apply
106+
// CHECK-NEXT: strong_release
107+
// CHECK-NEXT: tuple
108+
// CHECK-NEXT: return
109+
// test.trytowalk (test.Walkable) -> ()
110+
sil hidden @_TF4test9trytowalkFPS_8Walkable_T_ : $@convention(thin) (@owned Walkable) -> () {
111+
bb0(%0 : $Walkable):
112+
%2 = open_existential_ref %0 : $Walkable to $@opened("7813D5BE-4C48-11E5-BD72-AC87A3294C0A") Walkable // users: %3, %4
113+
%3 = witness_method [volatile] $@opened("7813D5BE-4C48-11E5-BD72-AC87A3294C0A") Walkable, #Walkable.walk!1.foreign, %2 : $@opened("7813D5BE-4C48-11E5-BD72-AC87A3294C0A") Walkable : $@convention(objc_method) <τ_0_0 where τ_0_0 : Walkable> (τ_0_0) -> () // user: %4
114+
%4 = apply %3<@opened("7813D5BE-4C48-11E5-BD72-AC87A3294C0A") Walkable>(%2) : $@convention(objc_method) <τ_0_0 where τ_0_0 : Walkable> (τ_0_0) -> ()
115+
%5 = witness_method [volatile] $@opened("7813D5BE-4C48-11E5-BD72-AC87A3294C0A") Walkable, #Walkable.walk!1.foreign, %2 : $@opened("7813D5BE-4C48-11E5-BD72-AC87A3294C0A") Walkable : $@convention(objc_method) <τ_0_0 where τ_0_0 : Walkable> (τ_0_0) -> () // user: %6
116+
%6 = apply %5<@opened("7813D5BE-4C48-11E5-BD72-AC87A3294C0A") Walkable>(%2) : $@convention(objc_method) <τ_0_0 where τ_0_0 : Walkable> (τ_0_0) -> ()
117+
strong_release %0 : $Walkable // id: %8
118+
%9 = tuple () // user: %10
119+
return %9 : $() // id: %10
120+
}
121+
122+
sil_vtable Bar {
123+
#Bar.init!initializer.1: _TFC4test3BarcfMS0_FT_S0_ // test.Bar.init (test.Bar.Type)() -> test.Bar
124+
#Bar.walk!1: _TFC4test3Bar4walkfS0_FT_T_ // test.Bar.walk (test.Bar)() -> ()
125+
#Bar.deinit!deallocator: _TFC4test3BarD // test.Bar.__deallocating_deinit
126+
}

0 commit comments

Comments
 (0)