Skip to content

Commit db81552

Browse files
committed
GlobalOpt: Prevent calling a non-resilient (or not usable from inline) function from inlinable code.
This problem can show up with cross module optimization.
1 parent 213ccf8 commit db81552

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/SILOptimizer/IPO/GlobalOpt.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,10 @@ replaceLoadsByKnownValue(BuiltinInst *CallToOnce, SILFunction *AddrF,
667667
for (int i = 0, e = Calls.size(); i < e; ++i) {
668668
auto *Call = Calls[i];
669669

670+
if (Call->getFunction()->isSerialized() &&
671+
!GetterF->hasValidLinkageForFragileRef())
672+
continue;
673+
670674
// Make sure that we can go ahead and replace all uses of the
671675
// address with the value.
672676
bool isValid = true;
@@ -918,6 +922,10 @@ void SILGlobalOpt::optimizeGlobalAccess(SILGlobalVariable *SILG,
918922
// invocation should happen at the common dominator of all
919923
// loads inside this function.
920924
for (auto *Load : GlobalLoadMap[SILG]) {
925+
if (Load->getFunction()->isSerialized() &&
926+
!GetterF->hasValidLinkageForFragileRef())
927+
continue;
928+
921929
SILBuilderWithScope B(Load);
922930
auto *GetterRef = B.createFunctionRef(Load->getLoc(), GetterF);
923931
auto *Value = B.createApply(Load->getLoc(), GetterRef,

0 commit comments

Comments
 (0)