Skip to content

Commit 2493dc9

Browse files
committed
Eliminate more ABI vestigates of marker protocols
1 parent cca2d28 commit 2493dc9

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

include/swift/AST/ASTMangler.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ class ASTMangler : public Mangler {
6868
std::function<bool (SymbolicReferent)> CanSymbolicReference;
6969

7070
bool canSymbolicReference(SymbolicReferent referent) {
71+
// Marker protocols cannot ever be symbolically referenced.
72+
if (auto nominal = referent.dyn_cast<const NominalTypeDecl *>()) {
73+
if (auto proto = dyn_cast<ProtocolDecl>(nominal)) {
74+
if (proto->isMarkerProtocol())
75+
return false;
76+
}
77+
}
78+
7179
return AllowSymbolicReferences
7280
&& (!CanSymbolicReference || CanSymbolicReference(referent));
7381
}

lib/IRGen/GenMeta.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5243,6 +5243,11 @@ GenericRequirementsMetadata irgen::addGenericRequirements(
52435243
case RequirementKind::Conformance: {
52445244
auto protocol = requirement.getSecondType()->castTo<ProtocolType>()
52455245
->getDecl();
5246+
5247+
// Marker protocols do not record generic requirements at all.
5248+
if (protocol->isMarkerProtocol())
5249+
break;
5250+
52465251
bool needsWitnessTable =
52475252
Lowering::TypeConverter::protocolRequiresWitnessTable(protocol);
52485253
auto flags = GenericRequirementFlags(GenericRequirementKind::Protocol,

lib/TBDGen/TBDGen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1037,7 +1037,7 @@ static bool isValidProtocolMemberForTBDGen(const Decl *D) {
10371037
#endif
10381038

10391039
void TBDGenVisitor::visitProtocolDecl(ProtocolDecl *PD) {
1040-
if (!PD->isObjC()) {
1040+
if (!PD->isObjC() && !PD->isMarkerProtocol()) {
10411041
addSymbol(LinkEntity::forProtocolDescriptor(PD));
10421042

10431043
struct WitnessVisitor : public SILWitnessVisitor<WitnessVisitor> {

test/IRGen/marker_protocol.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
// CHECK-NOT: $s15marker_protocol1PP
77
// CHECK-NOT: $s15marker_protocol1PMp
8-
// CHECK-NOT: "\01l_protocols"
98

109
@_marker public protocol P { }
1110

@@ -20,3 +19,5 @@ public func testGeneric(i: Int, array: [Int]) {
2019
generic(i)
2120
generic(array)
2221
}
22+
23+
public protocol Q: P { }

0 commit comments

Comments
 (0)