[SILOptimizer] Don't apply CMO to key paths that reference inaccessible properties

rdar://145095088
This commit is contained in:
Dario Rexin
2025-02-19 17:12:18 -08:00
parent 63b7f05d74
commit bde7daa2f2
3 changed files with 28 additions and 1 deletions

View File

@@ -651,6 +651,21 @@ bool CrossModuleOptimization::canSerializeFieldsByInstructionKind(
canUse = methodScope.isPublicOrPackage();
}
});
auto pattern = KPI->getPattern();
for (auto &component : pattern->getComponents()) {
if (!canUse) {
break;
}
switch (component.getKind()) {
case KeyPathPatternComponent::Kind::StoredProperty: {
auto property = component.getStoredPropertyDecl();
canUse = isPackageOrPublic(property->getEffectiveAccess());
break;
}
default:
break;
}
}
return canUse;
}
if (auto *MI = dyn_cast<MethodInst>(inst)) {