SILGen/stdlib: Remove _diagnoseUnavailableCodeReached_aeic().

It should no longer be necessary to provide an `@_alwaysEmitIntoClient` version
of `_diagnoseUnavailableCodeReached()`. This workaround was originally added to
provide compatibility with projects that were misconfigured to compile against
a newer stdlib but link against an older one.

Resolves rdar://119892482.
This commit is contained in:
Allan Shortlidge
2024-07-11 14:52:48 -07:00
parent a55beaa79d
commit 14200e412c
16 changed files with 25 additions and 55 deletions

View File

@@ -1499,10 +1499,6 @@ public:
/// The declared interface type of Builtin.TheTupleType.
BuiltinTupleType *getBuiltinTupleType();
/// The declaration for the `_diagnoseUnavailableCodeReached()` declaration
/// that ought to be used for the configured deployment target.
FuncDecl *getDiagnoseUnavailableCodeReachedDecl();
Type getNamedSwiftType(ModuleDecl *module, StringRef name);
/// Set the plugin loader.

View File

@@ -73,7 +73,6 @@ FUNC_DECL(DiagnoseUnexpectedNilOptional, "_diagnoseUnexpectedNilOptional")
FUNC_DECL(DiagnoseUnexpectedEnumCase, "_diagnoseUnexpectedEnumCase")
FUNC_DECL(DiagnoseUnexpectedEnumCaseValue, "_diagnoseUnexpectedEnumCaseValue")
FUNC_DECL(DiagnoseUnavailableCodeReached, "_diagnoseUnavailableCodeReached")
FUNC_DECL(DiagnoseUnavailableCodeReachedAEIC, "_diagnoseUnavailableCodeReached_aeic")
FUNC_DECL(GetErrorEmbeddedNSError, "_getErrorEmbeddedNSError")

View File

@@ -6591,14 +6591,6 @@ BuiltinTupleType *ASTContext::getBuiltinTupleType() {
return result;
}
FuncDecl *ASTContext::getDiagnoseUnavailableCodeReachedDecl() {
// FIXME: Remove this with rdar://119892482
if (AvailabilityContext::forDeploymentTarget(*this).isContainedIn(
getSwift59Availability()))
return getDiagnoseUnavailableCodeReached();
return getDiagnoseUnavailableCodeReachedAEIC();
}
void ASTContext::setPluginLoader(std::unique_ptr<PluginLoader> loader) {
getImpl().Plugins = std::move(loader);
}

View File

@@ -6397,7 +6397,7 @@ void SILGenFunction::emitApplyOfUnavailableCodeReached() {
return;
auto loc = RegularLocation::getAutoGeneratedLocation(F.getLocation());
FuncDecl *fd = getASTContext().getDiagnoseUnavailableCodeReachedDecl();
FuncDecl *fd = getASTContext().getDiagnoseUnavailableCodeReached();
if (!fd) {
// Broken stdlib?

View File

@@ -498,7 +498,7 @@ DerivedConformance::createBuiltinCall(ASTContext &ctx,
CallExpr *DerivedConformance::createDiagnoseUnavailableCodeReachedCallExpr(
ASTContext &ctx) {
FuncDecl *diagnoseDecl = ctx.getDiagnoseUnavailableCodeReachedDecl();
FuncDecl *diagnoseDecl = ctx.getDiagnoseUnavailableCodeReached();
assert(diagnoseDecl);
auto diagnoseDeclRefExpr =
new (ctx) DeclRefExpr(diagnoseDecl, DeclNameLoc(), true);
@@ -936,7 +936,7 @@ CaseStmt *DerivedConformance::unavailableEnumElementCaseStmt(
// If the stdlib isn't new enough to contain the helper function for
// diagnosing execution of unavailable code then just synthesize this case
// normally.
if (!C.getDiagnoseUnavailableCodeReachedDecl())
if (!C.getDiagnoseUnavailableCodeReached())
return nullptr;
auto createElementPattern = [&]() -> EnumElementPattern * {

View File

@@ -338,17 +338,6 @@ internal func _diagnoseUnexpectedEnumCase<SwitchedValue>(
@_semantics("unavailable_code_reached")
@usableFromInline // COMPILER_INTRINSIC
internal func _diagnoseUnavailableCodeReached() -> Never {
_diagnoseUnavailableCodeReached_aeic()
}
// FIXME: Remove this with rdar://119892482
/// An `@_alwaysEmitIntoClient` variant of `_diagnoseUnavailableCodeReached()`.
/// This is temporarily needed by the compiler to reference from back deployed
/// clients.
@_alwaysEmitIntoClient
@inline(never)
@_semantics("unavailable_code_reached")
internal func _diagnoseUnavailableCodeReached_aeic() -> Never {
_assertionFailure(
"Fatal error", "Unavailable code reached", flags: _fatalErrorFlags())
}

View File

@@ -3,7 +3,7 @@
public struct S {}
// CHECK-LABEL: sil{{.*}}@$s4Test15unavailableFuncAA1SVyF
// CHECK: [[FNREF:%.*]] = function_ref @$[[DIAGNOSEFN:(ss36_diagnoseUnavailableCodeReached_aeics5NeverOyF|ss31_diagnoseUnavailableCodeReacheds5NeverOyF|ss31_diagnoseUnavailableCodeReacheds5NeverOyFTwb)]] : $@convention(thin) () -> Never
// CHECK: [[FNREF:%.*]] = function_ref @$[[DIAGNOSEFN:(ss31_diagnoseUnavailableCodeReacheds5NeverOyF|ss31_diagnoseUnavailableCodeReacheds5NeverOyFTwb)]] : $@convention(thin) () -> Never
// CHECK-NEXT: [[APPLY:%.*]] = apply [[FNREF]]()
// CHECK: function_ref @$s4Test1SVACycfC
// CHECK: } // end sil function '$s4Test15unavailableFuncAA1SVyF'

View File

@@ -7,7 +7,7 @@ func foo() {}
public class ExplicitInitClass {
// ExplicitInitClass.s.getter
// CHECK-LABEL: sil{{.*}}@$s4Test17ExplicitInitClassC1sAA1SVvg
// CHECK: [[FNREF:%.*]] = function_ref @$[[DIAGNOSEFN:(ss36_diagnoseUnavailableCodeReached_aeics5NeverOyF|ss31_diagnoseUnavailableCodeReacheds5NeverOyF|ss31_diagnoseUnavailableCodeReacheds5NeverOyFTwb)]] : $@convention(thin) () -> Never
// CHECK: [[FNREF:%.*]] = function_ref @$[[DIAGNOSEFN:(ss31_diagnoseUnavailableCodeReacheds5NeverOyF|ss31_diagnoseUnavailableCodeReacheds5NeverOyFTwb)]] : $@convention(thin) () -> Never
// CHECK-NEXT: [[APPLY:%.*]] = apply [[FNREF]]()
// CHECK: load
// CHECK: } // end sil function '$s4Test17ExplicitInitClassC1sAA1SVvg'

View File

@@ -6,7 +6,7 @@
// REQUIRES: OS=macosx
// CHECK-LABEL: sil{{.*}}@$s4Test15unavailableFuncyyF
// CHECK-SWIFT5_8: [[FNREF:%.*]] = function_ref @$ss36_diagnoseUnavailableCodeReached_aeics5NeverOyF : $@convention(thin) () -> Never
// CHECK-SWIFT5_8: [[FNREF:%.*]] = function_ref @$ss31_diagnoseUnavailableCodeReacheds5NeverOyFTwb : $@convention(thin) () -> Never
// CHECK-SWIFT5_9: [[FNREF:%.*]] = function_ref @$ss31_diagnoseUnavailableCodeReacheds5NeverOyF : $@convention(thin) () -> Never
// CHECK-NEXT: [[APPLY:%.*]] = apply [[FNREF]]()
// CHECK: } // end sil function '$s4Test15unavailableFuncyyF'
@@ -14,7 +14,7 @@
public func unavailableFunc() {}
// CHECK-LABEL: sil{{.*}}@$s4Test24unavailableInlinableFuncyyF
// CHECK-SWIFT5_8: [[FNREF:%.*]] = function_ref @$ss36_diagnoseUnavailableCodeReached_aeics5NeverOyF : $@convention(thin) () -> Never
// CHECK-SWIFT5_8: [[FNREF:%.*]] = function_ref @$ss31_diagnoseUnavailableCodeReacheds5NeverOyFTwb : $@convention(thin) () -> Never
// CHECK-SWIFT5_9: [[FNREF:%.*]] = function_ref @$ss31_diagnoseUnavailableCodeReacheds5NeverOyFTwb : $@convention(thin) () -> Never
// CHECK-NEXT: [[APPLY:%.*]] = apply [[FNREF]]()
// CHECK: } // end sil function '$s4Test24unavailableInlinableFuncyyF'
@@ -22,7 +22,7 @@ public func unavailableFunc() {}
@inlinable public func unavailableInlinableFunc() {}
// CHECK-LABEL: sil{{.*}}@$s4Test22unavailableOnMacOSFuncyyF
// CHECK-SWIFT5_8: [[FNREF:%.*]] = function_ref @$ss36_diagnoseUnavailableCodeReached_aeics5NeverOyF : $@convention(thin) () -> Never
// CHECK-SWIFT5_8: [[FNREF:%.*]] = function_ref @$ss31_diagnoseUnavailableCodeReacheds5NeverOyFTwb : $@convention(thin) () -> Never
// CHECK-SWIFT5_9: [[FNREF:%.*]] = function_ref @$ss31_diagnoseUnavailableCodeReacheds5NeverOyF : $@convention(thin) () -> Never
// CHECK-NEXT: [[APPLY:%.*]] = apply [[FNREF]]()
// CHECK: } // end sil function '$s4Test22unavailableOnMacOSFuncyyF'
@@ -36,7 +36,7 @@ public func unavailableOnMacOSFunc() {}
public func unavailableOnMacOSExtensionFunc() {}
// CHECK-LABEL: sil{{.*}}@$s4Test021unavailableOnMacOSAndD15OSExtensionFuncyyF
// CHECK-SWIFT5_8: [[FNREF:%.*]] = function_ref @$ss36_diagnoseUnavailableCodeReached_aeics5NeverOyF : $@convention(thin) () -> Never
// CHECK-SWIFT5_8: [[FNREF:%.*]] = function_ref @$ss31_diagnoseUnavailableCodeReacheds5NeverOyFTwb : $@convention(thin) () -> Never
// CHECK-SWIFT5_9: [[FNREF:%.*]] = function_ref @$ss31_diagnoseUnavailableCodeReacheds5NeverOyF : $@convention(thin) () -> Never
// CHECK-NEXT: [[APPLY:%.*]] = apply [[FNREF]]()
// CHECK: } // end sil function '$s4Test021unavailableOnMacOSAndD15OSExtensionFuncyyF'

View File

@@ -3,7 +3,7 @@
// REQUIRES: OS=macosx
// CHECK-LABEL: sil{{.*}}@$s4Test15unavailableFuncyyF
// CHECK: [[FNREF:%.*]] = function_ref @$ss36_diagnoseUnavailableCodeReached_aeics5NeverOyF : $@convention(thin) () -> Never
// CHECK: [[FNREF:%.*]] = function_ref @$ss31_diagnoseUnavailableCodeReacheds5NeverOyFTwb : $@convention(thin) () -> Never
// CHECK-NEXT: [[APPLY:%.*]] = apply [[FNREF]]()
// CHECK: } // end sil function '$s4Test15unavailableFuncyyF'
@available(*, unavailable)

View File

@@ -10,7 +10,7 @@ func foo() {}
@objc public class C: NSObject {
// C.__allocating_init()
// CHECK-LABEL: sil{{.*}}@$s4Test1CCACycfC
// CHECK: [[FNREF:%.*]] = function_ref @$[[DIAGNOSEFN:(ss36_diagnoseUnavailableCodeReached_aeics5NeverOyF|ss31_diagnoseUnavailableCodeReacheds5NeverOyF|ss31_diagnoseUnavailableCodeReacheds5NeverOyFTwb)]] : $@convention(thin) () -> Never
// CHECK: [[FNREF:%.*]] = function_ref @$[[DIAGNOSEFN:(ss31_diagnoseUnavailableCodeReacheds5NeverOyF|ss31_diagnoseUnavailableCodeReacheds5NeverOyFTwb)]] : $@convention(thin) () -> Never
// CHECK-NEXT: [[APPLY:%.*]] = apply [[FNREF]]()
// CHECK: {{%.*}} = function_ref @$s4Test1CCACycfcTD
// CHECK: } // end sil function '$s4Test1CCACycfC'

View File

@@ -5,7 +5,7 @@ public struct S {}
extension S: P {}
// CHECK-LABEL: sil{{.*}}@$s4Test27unavailableOpaqueReturnFuncQryF
// CHECK: [[FNREF:%.*]] = function_ref @$[[DIAGNOSEFN:(ss36_diagnoseUnavailableCodeReached_aeics5NeverOyF|ss31_diagnoseUnavailableCodeReacheds5NeverOyF|ss31_diagnoseUnavailableCodeReacheds5NeverOyFTwb)]] : $@convention(thin) () -> Never
// CHECK: [[FNREF:%.*]] = function_ref @$[[DIAGNOSEFN:(ss31_diagnoseUnavailableCodeReacheds5NeverOyF|ss31_diagnoseUnavailableCodeReacheds5NeverOyFTwb)]] : $@convention(thin) () -> Never
// CHECK-NEXT: [[APPLY:%.*]] = apply [[FNREF]]()
// CHECK: function_ref @$s4Test1SVACycfC
// CHECK: } // end sil function '$s4Test27unavailableOpaqueReturnFuncQryF'

View File

@@ -17,7 +17,7 @@ extension EnumWithProtocolWitness: P {}
// protocol witness for static P.requirement(_:) in conformance EnumWithProtocolWitness
//
// CHECK-LABEL: sil{{.*}}@$s4Test23EnumWithProtocolWitnessOAA1PA2aDP11requirementyxAA1SVFZTW
// CHECK: [[FNREF:%.*]] = function_ref @$[[DIAGNOSEFN:(ss36_diagnoseUnavailableCodeReached_aeics5NeverOyF|ss31_diagnoseUnavailableCodeReacheds5NeverOyF|ss31_diagnoseUnavailableCodeReacheds5NeverOyFTwb)]] : $@convention(thin) () -> Never
// CHECK: [[FNREF:%.*]] = function_ref @$[[DIAGNOSEFN:(ss31_diagnoseUnavailableCodeReacheds5NeverOyF|ss31_diagnoseUnavailableCodeReacheds5NeverOyFTwb)]] : $@convention(thin) () -> Never
// CHECK-NEXT: [[APPLY:%.*]] = apply [[FNREF]]()
// CHECK: {{%.*}} = function_ref @$s4Test23EnumWithProtocolWitnessO11requirementyAcA1SVcACmF
// CHECK: } // end sil function '$s4Test23EnumWithProtocolWitnessOAA1PA2aDP11requirementyxAA1SVFZTW'

View File

@@ -5,7 +5,7 @@ public struct S {}
@available(*, unavailable)
public struct ImplicitInitStruct {
// CHECK-LABEL: sil hidden {{.*}} @$s4Test18ImplicitInitStructVACycfC
// CHECK: [[FNREF:%.*]] = function_ref @$[[DIAGNOSEFN:(ss36_diagnoseUnavailableCodeReached_aeics5NeverOyF|ss31_diagnoseUnavailableCodeReacheds5NeverOyF|ss31_diagnoseUnavailableCodeReacheds5NeverOyFTwb)]] : $@convention(thin) () -> Never
// CHECK: [[FNREF:%.*]] = function_ref @$[[DIAGNOSEFN:(ss31_diagnoseUnavailableCodeReacheds5NeverOyF|ss31_diagnoseUnavailableCodeReacheds5NeverOyFTwb)]] : $@convention(thin) () -> Never
// CHECK-NEXT: [[APPLY:%.*]] = apply [[FNREF]]()
// CHECK: return
// CHECK: } // end sil function '$s4Test18ImplicitInitStructVACycfC'

View File

@@ -3,7 +3,7 @@
public struct S {}
// CHECK-LABEL: sil{{.*}}@$s4Test15unavailableFuncAA1SVyF
// CHECK: [[FNREF:%.*]] = function_ref @$[[DIAGNOSEFN:(ss36_diagnoseUnavailableCodeReached_aeics5NeverOyF|ss31_diagnoseUnavailableCodeReacheds5NeverOyF|ss31_diagnoseUnavailableCodeReacheds5NeverOyFTwb)]] : $@convention(thin) () -> Never
// CHECK: [[FNREF:%.*]] = function_ref @$[[DIAGNOSEFN:(ss31_diagnoseUnavailableCodeReacheds5NeverOyF|ss31_diagnoseUnavailableCodeReacheds5NeverOyFTwb)]] : $@convention(thin) () -> Never
// CHECK-NEXT: [[APPLY:%.*]] = apply [[FNREF]]()
// CHECK-NEXT: unreachable
// CHECK-NEXT: } // end sil function '$s4Test15unavailableFuncAA1SVyF'

View File

@@ -1,7 +1,7 @@
// RUN: %target-swift-frontend -print-ast %s | %FileCheck %s --check-prefixes=CHECK,CHECK-PRE-SWIFT5_9
// RUN: %target-swift-frontend -application-extension -print-ast %s | %FileCheck %s --check-prefixes=CHECK,CHECK-PRE-SWIFT5_9
// RUN: %target-swift-frontend -target %target-cpu-apple-macosx10.51 -print-ast %s | %FileCheck %s --check-prefixes=CHECK,CHECK-PRE-SWIFT5_9
// RUN: %target-swift-frontend -target %target-cpu-apple-macosx14 -print-ast %s | %FileCheck %s --check-prefixes=CHECK,CHECK-SWIFT5_9
// RUN: %target-swift-frontend -print-ast %s | %FileCheck %s
// RUN: %target-swift-frontend -application-extension -print-ast %s | %FileCheck %s
// RUN: %target-swift-frontend -target %target-cpu-apple-macosx10.51 -print-ast %s | %FileCheck %s
// RUN: %target-swift-frontend -target %target-cpu-apple-macosx14 -print-ast %s | %FileCheck %s
// REQUIRES: OS=macosx
// CHECK-LABEL: internal enum HasElementsWithAvailability : Hashable
@@ -35,11 +35,9 @@ enum HasElementsWithAvailability: Hashable {
// CHECK-NEXT: case .alwaysAvailable:
// CHECK-NEXT: index_a = 0
// CHECK-NEXT: case .neverAvailable:
// CHECK-PRE-SWIFT5_9-NEXT: _diagnoseUnavailableCodeReached_aeic()
// CHECK-SWIFT5_9-NEXT: _diagnoseUnavailableCodeReached()
// CHECK-NEXT: _diagnoseUnavailableCodeReached()
// CHECK-NEXT: case .unavailableMacOS:
// CHECK-PRE-SWIFT5_9-NEXT: _diagnoseUnavailableCodeReached_aeic()
// CHECK-SWIFT5_9-NEXT: _diagnoseUnavailableCodeReached()
// CHECK-NEXT: _diagnoseUnavailableCodeReached()
// CHECK-NEXT: case .obsoleted10_50:
// CHECK-NEXT: index_a = 1
// CHECK-NEXT: case .introduced10_50:
@@ -52,11 +50,9 @@ enum HasElementsWithAvailability: Hashable {
// CHECK-NEXT: case .alwaysAvailable:
// CHECK-NEXT: index_b = 0
// CHECK-NEXT: case .neverAvailable:
// CHECK-PRE-SWIFT5_9-NEXT: _diagnoseUnavailableCodeReached_aeic()
// CHECK-SWIFT5_9-NEXT: _diagnoseUnavailableCodeReached()
// CHECK-NEXT: _diagnoseUnavailableCodeReached()
// CHECK-NEXT: case .unavailableMacOS:
// CHECK-PRE-SWIFT5_9-NEXT: _diagnoseUnavailableCodeReached_aeic()
// CHECK-SWIFT5_9-NEXT: _diagnoseUnavailableCodeReached()
// CHECK-NEXT: _diagnoseUnavailableCodeReached()
// CHECK-NEXT: case .obsoleted10_50:
// CHECK-NEXT: index_b = 1
// CHECK-NEXT: case .introduced10_50:
@@ -73,11 +69,9 @@ enum HasElementsWithAvailability: Hashable {
// CHECK-NEXT: case .alwaysAvailable:
// CHECK-NEXT: discriminator = 0
// CHECK-NEXT: case .neverAvailable:
// CHECK-PRE-SWIFT5_9-NEXT: _diagnoseUnavailableCodeReached_aeic()
// CHECK-SWIFT5_9-NEXT: _diagnoseUnavailableCodeReached()
// CHECK-NEXT: _diagnoseUnavailableCodeReached()
// CHECK-NEXT: case .unavailableMacOS:
// CHECK-PRE-SWIFT5_9-NEXT: _diagnoseUnavailableCodeReached_aeic()
// CHECK-SWIFT5_9-NEXT: _diagnoseUnavailableCodeReached()
// CHECK-NEXT: _diagnoseUnavailableCodeReached()
// CHECK-NEXT: case .obsoleted10_50:
// CHECK-NEXT: discriminator = 1
// CHECK-NEXT: case .introduced10_50: