Skip to content

Commit ea1514b

Browse files
Merge pull request #58687 from aschwaighofer/cmo_dont_serialize_prespecialized_entry_points_only
CrossModuleOptimization: Don't serialize pre-specialized public entry points
2 parents c885dc6 + 6947170 commit ea1514b

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

lib/SILOptimizer/IPO/CrossModuleOptimization.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,9 @@ bool CrossModuleOptimization::canSerializeFunction(
207207
// Do the same check for the specializations of such functions.
208208
if (function->isSpecialization()) {
209209
const SILFunction *parent = function->getSpecializationInfo()->getParent();
210-
if (!parent->getSpecializeAttrs().empty())
210+
// Don't serialize exported (public) specializations.
211+
if (!parent->getSpecializeAttrs().empty() &&
212+
function->getLinkage() == SILLinkage::Public)
211213
return false;
212214
}
213215

test/SILOptimizer/Inputs/cross-module/cross-module.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public struct Container {
1717
var arr = Array<Base>()
1818
arr.append(Base())
1919
print(arr)
20+
dontBlockSerialization(arr)
2021
return t
2122
}
2223

test/SILOptimizer/Inputs/cross-module/cross-submodule.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,9 @@ public func genericSubmoduleFunc<T>(_ t: T) {
1010
printit(t)
1111
}
1212

13+
@_specialize(exported: true, where T == Int)
14+
@inlinable
15+
@inline(never)
16+
public func dontBlockSerialization<T>(_ t: T) {
17+
print(t)
18+
}

0 commit comments

Comments
 (0)