Skip to content

Commit edb7a5f

Browse files
committed
[IRGen] Enabled mangled inherited conformances for conditional conformances.
Now that the runtime fills in the private slots with conditional requirement information, we can always use mangled names for inherited conformances. Fixes rdar://problem/46282080. (cherry picked from commit e52a883)
1 parent 78c9cfa commit edb7a5f

File tree

3 files changed

+11
-37
lines changed

3 files changed

+11
-37
lines changed

lib/IRGen/GenProto.cpp

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,29 +1346,18 @@ class AccessorConformanceInfo : public ConformanceInfo {
13461346
return;
13471347
}
13481348

1349-
// If this isn't a conditional conformance, we can emit a mangled name.
1350-
// FIXME: Conditional conformances won't currently work because the
1351-
// witness tables for conditional requirements won't have been written
1352-
// into the private area yet.
1353-
if (SILConditionalConformances.empty()) {
1354-
if (isDependentConformance(astConf->getRootConformance(),
1355-
/*considerResilience=*/false))
1356-
RequiresSpecialization = true;
1357-
1358-
auto proto = Conformance.getProtocol();
1359-
CanType selfType = proto->getProtocolSelfType()->getCanonicalType();
1360-
AssociatedConformance requirement(proto, selfType, baseProto);
1361-
llvm::Constant *witnessEntry =
1362-
getAssociatedConformanceWitness(requirement, ConcreteType,
1363-
ProtocolConformanceRef(astConf));
1364-
Table.addBitCast(witnessEntry, IGM.Int8PtrTy);
1365-
return;
1366-
}
1349+
// Emit a mangled name.
1350+
if (isDependentConformance(astConf->getRootConformance(),
1351+
/*considerResilience=*/false))
1352+
RequiresSpecialization = true;
13671353

1368-
// Otherwise, we'll need to derive it at instantiation time.
1369-
RequiresSpecialization = true;
1370-
SpecializedBaseConformances.push_back({Table.size(), &conf});
1371-
Table.addNullPointer(IGM.Int8PtrTy);
1354+
auto proto = Conformance.getProtocol();
1355+
CanType selfType = proto->getProtocolSelfType()->getCanonicalType();
1356+
AssociatedConformance requirement(proto, selfType, baseProto);
1357+
llvm::Constant *witnessEntry =
1358+
getAssociatedConformanceWitness(requirement, ConcreteType,
1359+
ProtocolConformanceRef(astConf));
1360+
Table.addBitCast(witnessEntry, IGM.Int8PtrTy);
13721361
}
13731362

13741363
void addMethod(SILDeclRef requirement) {

test/Inputs/conditional_conformance_recursive.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@ protocol P3: P2 where A: P3 { }
1818

1919
extension Wrapper: P3 where T: P3 { }
2020

21-
// instantiation function for Wrapper<T>: P3
22-
// CHECK-LABEL: define internal void @"$s33conditional_conformance_recursive7WrapperVyxGAA2P3A2aERzrlWI"
23-
// CHECK-NOT: ret
24-
// CHECK: call i8** @swift_getWitnessTable
25-
2621
// associated type witness table accessor for A : P2 in Wrapper<T>: P2
2722
// CHECK-LABEL: define internal swiftcc i8** @"$s33conditional_conformance_recursive7WrapperVyxGAA2P2A2aERzrl1A_AaEPWT"
2823
// CHECK: [[CONDITIONAL_REQ_BUFFER:%.*]] = alloca [1 x i8**]

test/Inputs/conditional_conformance_with_assoc.swift

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -234,13 +234,3 @@ extension X: Base where T: Base { }
234234
extension X: Sub where T: Sub, T.S == T {
235235
typealias S = X<T>
236236
}
237-
238-
// Make sure we can recover the type metadata from X<T>.Type.
239-
// CHECK: define internal void @"$s34conditional_conformance_with_assoc1XVyxGAA3SubA2aERz1SQzRszlWI"(i8**, %swift.type* %"X<T>", i8**)
240-
// CHECK: entry:
241-
// CHECK: [[XT_TYPE:%.*]] = bitcast %swift.type* %"X<T>" to %swift.type**
242-
// CHECK: [[ADDR:%.*]] = getelementptr inbounds %swift.type*, %swift.type** [[XT_TYPE]], i64 2
243-
// CHECK: [[T:%.*]] = load %swift.type*, %swift.type** [[ADDR]]
244-
// CHECK: %T.Base = call swiftcc i8** @swift_getAssociatedConformanceWitness(i8** {{.*}}, %swift.type* %T, %swift.type* %T
245-
// CHECK: ret void
246-
// CHECK: }

0 commit comments

Comments
 (0)