Skip to content

Commit 80a22e3

Browse files
committed
cross-module-optimization: be more conservative with references to non-public functions
We need to make serializing shared functions more robust. Until then, be more conservative with non-public functions.
1 parent 8c52853 commit 80a22e3

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lib/SILOptimizer/IPO/CrossModuleOptimization.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,12 @@ bool CrossModuleOptimization::canSerializeInstruction(SILInstruction *inst,
248248
if (!callee)
249249
return false;
250250

251+
// In conservative mode we don't want to turn non-public functions into
252+
// public functions, because that can increase code size. E.g. if the
253+
// function is completely inlined afterwards.
254+
if (conservative && !hasPublicVisibility(callee->getLinkage()))
255+
return false;
256+
251257
// Recursivly walk down the call graph.
252258
if (canSerializeFunction(callee, canSerializeFlags, maxDepth - 1))
253259
return true;
@@ -260,12 +266,6 @@ bool CrossModuleOptimization::canSerializeInstruction(SILInstruction *inst,
260266
if (!canUseFromInline(callee))
261267
return false;
262268

263-
// In conservative mode we don't want to turn non-public functions into
264-
// public functions, because that can increase code size. E.g. if the
265-
// function is completely inlined afterwards.
266-
if (conservative && callee->getLinkage() != SILLinkage::Public)
267-
return false;
268-
269269
return true;
270270
}
271271
if (auto *GAI = dyn_cast<GlobalAddrInst>(inst)) {

0 commit comments

Comments
 (0)