Skip to content

Commit 1220ef8

Browse files
authored
Merge pull request #28607 from eeckstein/fix-cmo
2 parents fed5ff9 + 9b16a35 commit 1220ef8

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

lib/SILOptimizer/IPO/CrossModuleSerializationSetup.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,12 @@ makeSubstUsableFromInline(const SubstitutionMap &substs) {
191191
for (Type replType : substs.getReplacementTypes()) {
192192
makeTypeUsableFromInline(replType->getCanonicalType());
193193
}
194+
for (ProtocolConformanceRef pref : substs.getConformances()) {
195+
if (pref.isConcrete()) {
196+
ProtocolConformance *concrete = pref.getConcrete();
197+
makeDeclUsableFromInline(concrete->getProtocol(), M);
198+
}
199+
}
194200
}
195201

196202
/// Decide whether to serialize a function.

test/SILOptimizer/Inputs/cross-module.swift

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,29 @@ public func callFoo_gen<T>(_ t: T) {
152152
printFooGeneric(1234)
153153
}
154154

155+
fileprivate protocol PrivateProto {
156+
func foo()
157+
}
158+
159+
public class FooClass: PrivateProto {
160+
func foo() {
161+
print(321)
162+
}
163+
}
164+
165+
@inline(never)
166+
@_semantics("optimize.sil.specialize.generic.never")
167+
fileprivate func callProtocolFoo<T: PrivateProto>(_ t: T) {
168+
t.foo()
169+
}
170+
171+
@inline(never)
172+
@_semantics("optimize.sil.specialize.generic.never")
173+
public func callFooViaConformance<T>(_ t: T) {
174+
let c = FooClass()
175+
callProtocolFoo(c)
176+
}
177+
155178
@inline(never)
156179
public func callGenericSubmoduleFunc<T>(_ t: T) {
157180
genericSubmoduleFunc(t)

test/SILOptimizer/cross-module-optimization.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ func testProtocolsAndClasses() {
8383
callFoo_gen(27)
8484
// CHECK-OUTPUT: 55
8585
callClassMethod(55)
86+
// CHECK-OUTPUT: 321
87+
callFooViaConformance(0)
8688
}
8789

8890
func testSubModule() {

0 commit comments

Comments
 (0)