Skip to content

Commit 2f7289b

Browse files
committed
[SILOptimizer] Don't apply CMO to key paths that reference inaccessible properties
rdar://145095088
1 parent 63b7f05 commit 2f7289b

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

lib/SILOptimizer/IPO/CrossModuleOptimization.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,21 @@ bool CrossModuleOptimization::canSerializeFieldsByInstructionKind(
651651
canUse = methodScope.isPublicOrPackage();
652652
}
653653
});
654+
auto pattern = KPI->getPattern();
655+
for (auto &component : pattern->getComponents()) {
656+
if (!canUse) {
657+
break;
658+
}
659+
switch (component.getKind()) {
660+
case KeyPathPatternComponent::Kind::StoredProperty: {
661+
auto property = component.getStoredPropertyDecl();
662+
canUse = property->getEffectiveAccess() >= AccessLevel::Package;
663+
break;
664+
}
665+
default:
666+
break;
667+
}
668+
}
654669
return canUse;
655670
}
656671
if (auto *MI = dyn_cast<MethodInst>(inst)) {

0 commit comments

Comments
 (0)