From 2d18f9fc9a48544aa456951a960ffe0c776bec3e Mon Sep 17 00:00:00 2001 From: Erik Eckstein Date: Tue, 19 Nov 2024 10:10:56 +0100 Subject: [PATCH] embedded: Don't emit SILProperties in embedded swift SILProperties are only needed for resilient builds. Fixes a crash in IRGen https://github.com/swiftlang/swift/issues/77682 --- lib/IRGen/GenDecl.cpp | 10 ++++++---- test/embedded/keypath-crash.swift | 10 ++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/IRGen/GenDecl.cpp b/lib/IRGen/GenDecl.cpp index 91c060a0edba8..c6875fd27cab9 100644 --- a/lib/IRGen/GenDecl.cpp +++ b/lib/IRGen/GenDecl.cpp @@ -1224,10 +1224,12 @@ void IRGenerator::emitGlobalTopLevel( } } - // Emit property descriptors. - for (auto &prop : PrimaryIGM->getSILModule().getPropertyList()) { - CurrentIGMPtr IGM = getGenModule(prop.getDecl()->getInnermostDeclContext()); - IGM->emitSILProperty(&prop); + if (!SIL.getASTContext().LangOpts.hasFeature(Feature::Embedded)) { + // Emit property descriptors. + for (auto &prop : PrimaryIGM->getSILModule().getPropertyList()) { + CurrentIGMPtr IGM = getGenModule(prop.getDecl()->getInnermostDeclContext()); + IGM->emitSILProperty(&prop); + } } // Emit differentiability witnesses. diff --git a/test/embedded/keypath-crash.swift b/test/embedded/keypath-crash.swift index 44e70b7b9329e..5ec31704d3dcf 100644 --- a/test/embedded/keypath-crash.swift +++ b/test/embedded/keypath-crash.swift @@ -42,4 +42,14 @@ public struct State { } } +public struct S { + public private(set) subscript(x: Int) -> Int { + get { + return 27 + } + mutating set { + } + } +} + // CHECK: define {{.*}}@main(