[embedded] Compile-time (literal) KeyPaths for Embedded Swift

Enable KeyPath/AnyKeyPath/PartialKeyPath/WritableKeyPath in Embedded Swift, but
for compile-time use only:

- Add keypath optimizations into the mandatory optimizations pipeline
- Allow keypath optimizations to look through begin_borrow, to make them work
  even in OSSA.
- If a use of a KeyPath doesn't optimize away, diagnose in PerformanceDiagnostics
- Make UnsafePointer.pointer(to:) transparent to allow the keypath optimization
  to happen in the callers of UnsafePointer.pointer(to:).
This commit is contained in:
Kuba Mracek
2024-03-20 15:35:43 -07:00
parent 4389ae2dc8
commit b642d771be
18 changed files with 272 additions and 119 deletions

View File

@@ -519,6 +519,10 @@ bool PerformanceDiagnostics::visitInst(SILInstruction *inst,
diagnose(loc, diag::embedded_swift_value_deinit, impactType.getASTType());
return true;
}
if (isa<KeyPathInst>(inst)) {
diagnose(loc, diag::embedded_swift_keypath);
return true;
}
if (!allowedMetadataUseInEmbeddedSwift(inst)) {
PrettyStackTracePerformanceDiagnostics stackTrace("metatype", inst);
if (impactType) {