Skip to content

CrossModuleOptimization: Don't serialize pre-specialized public entry points #58687

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/SILOptimizer/IPO/CrossModuleOptimization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,9 @@ bool CrossModuleOptimization::canSerializeFunction(
// Do the same check for the specializations of such functions.
if (function->isSpecialization()) {
const SILFunction *parent = function->getSpecializationInfo()->getParent();
if (!parent->getSpecializeAttrs().empty())
// Don't serialize exported (public) specializations.
if (!parent->getSpecializeAttrs().empty() &&
function->getLinkage() == SILLinkage::Public)
return false;
}

Expand Down
1 change: 1 addition & 0 deletions test/SILOptimizer/Inputs/cross-module/cross-module.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public struct Container {
var arr = Array<Base>()
arr.append(Base())
print(arr)
dontBlockSerialization(arr)
return t
}

Expand Down
6 changes: 6 additions & 0 deletions test/SILOptimizer/Inputs/cross-module/cross-submodule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,9 @@ public func genericSubmoduleFunc<T>(_ t: T) {
printit(t)
}

@_specialize(exported: true, where T == Int)
@inlinable
@inline(never)
public func dontBlockSerialization<T>(_ t: T) {
print(t)
}