Skip to content

Commit b1399db

Browse files
committed
Merge remote-tracking branch 'origin/master' into master-next
2 parents eac3796 + b0ca53f commit b1399db

File tree

6 files changed

+51
-39
lines changed

6 files changed

+51
-39
lines changed

include/swift/AST/ASTMangler.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,9 @@ class ASTMangler : public Mangler {
370370

371371
void appendProtocolConformance(const ProtocolConformance *conformance);
372372
void appendProtocolConformanceRef(const RootProtocolConformance *conformance);
373+
void appendAnyProtocolConformance(CanGenericSignature genericSig,
374+
CanType conformingType,
375+
ProtocolConformanceRef conformance);
373376
void appendConcreteProtocolConformance(
374377
const ProtocolConformance *conformance);
375378
void appendDependentProtocolConformance(const ConformanceAccessPath &path);

lib/AST/ASTMangler.cpp

Lines changed: 36 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2801,6 +2801,35 @@ void ASTMangler::appendDependentProtocolConformance(
28012801
}
28022802
}
28032803

2804+
void ASTMangler::appendAnyProtocolConformance(
2805+
CanGenericSignature genericSig,
2806+
CanType conformingType,
2807+
ProtocolConformanceRef conformance) {
2808+
if (conformingType->isTypeParameter()) {
2809+
assert(genericSig && "Need a generic signature to resolve conformance");
2810+
auto path = genericSig->getConformanceAccessPath(conformingType,
2811+
conformance.getAbstract());
2812+
appendDependentProtocolConformance(path);
2813+
} else if (auto opaqueType = conformingType->getAs<OpaqueTypeArchetypeType>()) {
2814+
GenericSignature opaqueSignature = opaqueType->getBoundSignature();
2815+
GenericTypeParamType *opaqueTypeParam = opaqueSignature->getGenericParams().back();
2816+
ConformanceAccessPath conformanceAccessPath =
2817+
opaqueSignature->getConformanceAccessPath(opaqueTypeParam,
2818+
conformance.getAbstract());
2819+
2820+
// Append the conformance access path with the signature of the opaque type.
2821+
{
2822+
llvm::SaveAndRestore<CanGenericSignature> savedSignature(
2823+
CurGenericSignature, opaqueSignature.getCanonicalSignature());
2824+
appendDependentProtocolConformance(conformanceAccessPath);
2825+
}
2826+
appendType(conformingType);
2827+
appendOperator("HO");
2828+
} else {
2829+
appendConcreteProtocolConformance(conformance.getConcrete());
2830+
}
2831+
}
2832+
28042833
void ASTMangler::appendConcreteProtocolConformance(
28052834
const ProtocolConformance *conformance) {
28062835
auto module = conformance->getDeclContext()->getParentModule();
@@ -2841,30 +2870,15 @@ void ASTMangler::appendConcreteProtocolConformance(
28412870
CanType canType = type->getCanonicalType(CurGenericSignature);
28422871
auto proto =
28432872
conditionalReq.getSecondType()->castTo<ProtocolType>()->getDecl();
2844-
if (canType->isTypeParameter()) {
2845-
assert(CurGenericSignature &&
2846-
"Need a generic signature to resolve conformance");
2847-
auto conformanceAccessPath =
2848-
CurGenericSignature->getConformanceAccessPath(type, proto);
2849-
appendDependentProtocolConformance(conformanceAccessPath);
2850-
} else if (auto opaqueType = canType->getAs<OpaqueTypeArchetypeType>()) {
2851-
GenericSignature opaqueSignature = opaqueType->getBoundSignature();
2852-
GenericTypeParamType *opaqueTypeParam = opaqueSignature->getGenericParams().back();
2853-
ConformanceAccessPath conformanceAccessPath =
2854-
opaqueSignature->getConformanceAccessPath(opaqueTypeParam, proto);
2855-
2856-
// Append the conformance access path with the signature of the opaque type.
2857-
{
2858-
llvm::SaveAndRestore<CanGenericSignature> savedSignature(
2859-
CurGenericSignature, opaqueSignature.getCanonicalSignature());
2860-
appendDependentProtocolConformance(conformanceAccessPath);
2861-
}
2862-
appendType(canType);
2863-
appendOperator("HO");
2873+
2874+
ProtocolConformanceRef conformance;
2875+
2876+
if (canType->isTypeParameter() || canType->is<OpaqueTypeArchetypeType>()){
2877+
conformance = ProtocolConformanceRef(proto);
28642878
} else {
2865-
auto conditionalConf = module->lookupConformance(canType, proto);
2866-
appendConcreteProtocolConformance(conditionalConf.getConcrete());
2879+
conformance = module->lookupConformance(canType, proto);
28672880
}
2881+
appendAnyProtocolConformance(CurGenericSignature, canType, conformance);
28682882
appendListSeparator(firstRequirement);
28692883
break;
28702884
}

lib/AST/Availability.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,9 @@ AvailabilityContext ASTContext::getSwift52Availability() {
304304
AvailabilityContext ASTContext::getSwift53Availability() {
305305
auto target = LangOpts.Target;
306306

307+
if (target.getArchName() == "arm64e")
308+
return AvailabilityContext::alwaysAvailable();
309+
307310
if (target.isMacOSX() ) {
308311
return AvailabilityContext(
309312
VersionRange::allGTE(llvm::VersionTuple(10, 99, 0)));

lib/IRGen/IRGenMangler.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -308,15 +308,7 @@ std::string IRGenMangler::mangleSymbolNameForMangledConformanceAccessorString(
308308
if (genericSig)
309309
appendGenericSignature(genericSig);
310310

311-
if (type)
312-
appendType(type);
313-
314-
if (conformance.isConcrete())
315-
appendConcreteProtocolConformance(conformance.getConcrete());
316-
else if (conformance.isAbstract())
317-
appendProtocolName(conformance.getAbstract());
318-
else
319-
assert(conformance.isInvalid() && "Unknown protocol conformance");
311+
appendAnyProtocolConformance(genericSig, type, conformance);
320312
return finalize();
321313
}
322314

test/IRGen/opaque_result_type.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ extension String: P {
3737
// -- mangled underlying type
3838
// CHECK-SAME: @"symbolic Si"
3939
// -- conformance to O
40-
// CHECK-SAME: @"get_witness_table S2i18opaque_result_type1OHpyHC
40+
// CHECK-SAME: @"get_witness_table Si18opaque_result_type1OHpyHC
4141
// CHECK-SAME: }>
4242
func poo() -> some O {
4343
return 0
@@ -68,7 +68,7 @@ public class C: P, Q {
6868
// -- mangled underlying type
6969
// CHECK-SAME: @"symbolic Si"
7070
// -- conformance to O
71-
// CHECK-SAME: @"get_witness_table S2i18opaque_result_type1OHpyHC
71+
// CHECK-SAME: @"get_witness_table Si18opaque_result_type1OHpyHC
7272
// CHECK-SAME: }>
7373
func poo() -> some O {
7474
return 0
@@ -82,9 +82,9 @@ public class C: P, Q {
8282
// -- mangled underlying type
8383
// CHECK-SAME: @"symbolic Si"
8484
// -- conformance to O
85-
// CHECK-SAME: @"get_witness_table S2i18opaque_result_type1OHpyHC
85+
// CHECK-SAME: @"get_witness_table Si18opaque_result_type1OHpyHC
8686
// -- conformance to O2
87-
// CHECK-SAME: @"get_witness_table S2i18opaque_result_type2O2HpyHC
87+
// CHECK-SAME: @"get_witness_table Si18opaque_result_type2O2HpyHC
8888
// CHECK-SAME: }>
8989
func qoo() -> some O & O2 {
9090
return 0
@@ -99,7 +99,7 @@ public class C: P, Q {
9999
// -- mangled underlying type
100100
// CHECK-SAME: @"symbolic SS"
101101
// -- conformance to P
102-
// CHECK-SAME: @"get_witness_table S2S18opaque_result_type1PHpyHC
102+
// CHECK-SAME: @"get_witness_table SS18opaque_result_type1PHpyHC
103103
// CHECK-SAME: }>
104104
func foo(x: String) -> some P {
105105
return x
@@ -113,7 +113,7 @@ func foo(x: String) -> some P {
113113
// -- mangled underlying type
114114
// CHECK-SAME: @"symbolic _____ 18opaque_result_type1CC"
115115
// -- conformance to Q
116-
// CHECK-SAME: @"get_witness_table 18opaque_result_type1CCAcA1QHPyHC
116+
// CHECK-SAME: @"get_witness_table 18opaque_result_type1CCAA1QHPyHC
117117
// CHECK-SAME: }>
118118
func bar(y: C) -> some Q {
119119
return y

test/IRGen/opaque_result_type_metadata_peephole.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ func foo() -> some P {
1212
// The mangled underlying type in foo2 ought to look through foo()'s opaque type
1313
// CHECK-LABEL: @"$s36opaque_result_type_metadata_peephole4foo2QryFQOMQ" = {{.*}} constant
1414
// DEFAULT-SAME: @"symbolic Si"
15-
// DEFAULT-SAME: @"get_witness_table S2i36opaque_result_type_metadata_external1PHpyHC
15+
// DEFAULT-SAME: @"get_witness_table Si36opaque_result_type_metadata_external1PHpyHC
1616
// IMPLICIT-DYNAMIC-SAME: @"symbolic _____yQo_ 36opaque_result_type_metadata_peephole3fooQryFQO"
17-
// IMPLICIT-DYNAMIC-SAME: @"get_witness_table 36opaque_result_type_metadata_peephole3fooQryFQOyQo_0a1_b1_c1_D9_external1P
17+
// IMPLICIT-DYNAMIC-SAME: @"get_witness_table x36opaque_result_type_metadata_external1PHD1_0a1_b1_c1_D9_peephole3fooQryFQOyQo_HO
1818
func foo2() -> some P {
1919
return foo()
2020
}

0 commit comments

Comments
 (0)